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

Wrong result for SELECT..WHERE varchar_column=' 1' AND (varchar_column XOR '1')

    XMLWordPrintable

Details

    Description

      This script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET cp1251 COLLATE cp1251_ukrainian_ci);
      INSERT INTO t1 VALUES (' 1'),('`1'); 
      SELECT * FROM t1 WHERE (a XOR '0');

      returns one row:

      +------+
      | a    |
      +------+
      |  1   |
      +------+

      Now if I make the WHERE condition even stricter:

      SELECT * FROM t1 WHERE a=' 1' AND (a XOR '0');

      it erroneously returns two rows:

      +------+
      | a    |
      +------+
      |  1   |
      | `1   |
      +------+

      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.