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

Wrong result for SELECT..WHERE HEX(enum_column)='61' AND enum_column='a '

    XMLWordPrintable

    Details

      Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a ENUM('a','A') COLLATE latin1_bin);
      INSERT INTO t1 VALUES ('a'),('A');
      SELECT * FROM t1 WHERE a='a ';
      SELECT * FROM t1 WHERE HEX(a)='61';
      SELECT * FROM t1 WHERE HEX(a)='61' AND a='a ';

      The first and the second query correctly return one row.
      The third query erroneously returns empty set.
      Notice, trailing space in the constant 'a '.

      The same problem is repeatable with SET:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a SET('a','A') COLLATE latin1_bin);
      INSERT INTO t1 VALUES ('a'),('A');
      SELECT * FROM t1 WHERE a='a ';
      SELECT * FROM t1 WHERE HEX(a)='61';
      SELECT * FROM t1 WHERE HEX(a)='61' AND a='a ';

        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: