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

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.1, 10.2, 10.0
    • Fix Version/s: 10.1.18, 10.2.2
    • Component/s: Optimizer
    • Labels:
      None
    • Sprint:
      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

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

                Dates

                Created:
                Updated:
                Resolved: