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

Wrong result for SELECT..WHERE COLLATION(a)='binary' AND a='a'

    XMLWordPrintable

Details

    Description

      In this script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARBINARY(10));
      INSERT INTO t1 VALUES ('a');
      SELECT * FROM t1 WHERE COLLATION(a)='binary';
      SELECT * FROM t1 WHERE a='a'; 

      the two SELECT queries return one row.

      Now if I join both conditions using AND in the same query:

      SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';

      It returns empty set.

      A similar script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARBINARY(10));
      INSERT INTO t1 VALUES ('a');
      SELECT * FROM t1 WHERE CHARSET(a)='binary';
      SELECT * FROM t1 WHERE a='a'; 
      SELECT * FROM t1 WHERE CHARSET(a)='binary' AND a='a';

      A similar script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARBINARY(10));
      INSERT INTO t1 VALUES ('a');
      SELECT * FROM t1 WHERE COERCIBILITY(a)=2;
      SELECT * FROM t1 WHERE a='a'; 
      SELECT * FROM t1 WHERE COERCIBILITY(a)=2 AND a='a';

      A similar script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARBINARY(10));
      INSERT INTO t1 VALUES ('a');
      SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a';
      SELECT * FROM t1 WHERE a='a'; 
      SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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