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

Wrong result for WHERE .. (f2=TO_BASE64('test') OR f2=TO_BASE64('TEST'))

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • 10.1.18, 10.2.2
    • Optimizer
    • None
    • 10.1.18

    Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (f1 VARCHAR(4), f2 VARCHAR(64), UNIQUE KEY k1 (f1,f2));
      INSERT INTO t1 VALUES ( 'test',to_base64('test')), ('TEST', to_base64('TEST'));
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (f1 VARCHAR(4), f2 VARCHAR(64), UNIQUE KEY k1 (f1,f2));
      INSERT INTO t1 VALUES ( 'test',to_base64('test')), ('test', to_base64('TEST'));
      SELECT * FROM t1 ignore index(k1) WHERE f1='test' AND (f2= to_base64("test") OR f2= to_base64("TEST"));
      SELECT * FROM t1                  WHERE f1='test' AND (f2= to_base64("test") OR f2= to_base64("TEST"));
      SELECT * FROM t1                  WHERE f1='test' AND (f2= to_base64("TEST") OR f2= to_base64("test"));
      

      The three SELECT queries return three different result sets.
      All three queries should return exactly the same result.

      The same problem is repeatable with password():

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (f1 VARCHAR(4), f2 VARCHAR(64), UNIQUE KEY k1 (f1,f2));
      INSERT INTO t1 VALUES ( 'test',password('test')), ('TEST', password('TEST'));
      SELECT * FROM t1 ignore index(k1) WHERE f1='test' AND (f2= password("test") OR f2= password("TEST"));
      SELECT * FROM t1                  WHERE f1='test' AND (f2= password("test") OR f2= password("TEST"));
      SELECT * FROM t1                  WHERE f1='test' AND (f2= password("TEST") OR f2= password("test"));
      

      The same problem is repeatable with hex():

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (f1 VARCHAR(4), f2 VARCHAR(64), UNIQUE KEY k1 (f1,f2));
      INSERT INTO t1 VALUES ( 'test',hex('test')), ('TEST',hex('TEST'));
      SELECT * FROM t1 ignore index(k1) WHERE f1='test' AND (f2= hex("test") OR f2= hex("TEST"));
      SELECT * FROM t1                  WHERE f1='test' AND (f2= hex("test") OR f2= hex("TEST"));
      SELECT * FROM t1                  WHERE f1='test' AND (f2= hex("TEST") OR f2= hex("test"));
      

      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.