Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23658

Wrong result of WHERE with SUB-SELECT and CONCAT and character set conversion

    XMLWordPrintable

    Details

      Description

      This script demonstrates the problem:

      SET NAMES latin1;
      CREATE OR REPLACE TABLE t1(a INT) ENGINE=MYISAM;
      INSERT INTO t1 VALUES (1);
      CREATE OR REPLACE TABLE t2(a VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci) ENGINE=MYISAM;
      INSERT INTO t2 VALUES ('1');
       
      -- These queries returns one row as expected
      SELECT * FROM t1 WHERE (SELECT CONCAT(a) FROM t1) = (SELECT CONCAT(a) FROM t2);
      SELECT * FROM t1 WHERE (SELECT 1,CONCAT(a) FROM t1) = (SELECT 1,CONCAT(a) FROM t2);
       
      -- This returns TRUE as expected (Unicode Character 'NO-BREAK SPACE' (U+00A0) is on the both sides)
      SELECT _latin1 0xA0 = _utf8 0xC2A0;
       
      -- This returns one row as expected
      SELECT * FROM t1 WHERE (SELECT CONCAT(a, _latin1 0xA0) FROM t1) = (SELECT CONCAT(a,_utf8 0xC2A0) FROM t2);
       
      -- This returns no rows. One row is expected!
      SELECT * FROM t1 WHERE (SELECT 1,CONCAT(a, _latin1 0xA0) FROM t1) = (SELECT 1,CONCAT(a,_utf8 0xC2A0) FROM t2);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.