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

Wrong result for SELECT..WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;

    Details

      Description

      This script:

      SET NAMES latin1;
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARCHAR(10));
      INSERT INTO t1 VALUES ('a'),('A'),('b'),('B'),('c'),('C');
      SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;

      returns 3 rows:

      +------+
      | a    |
      +------+
      | a    |
      | b    |
      | c    |
      +------+

      So far so good.
      If I make the condition stricter:

      SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin AND a='a';

      it returns 2 rows:

      +------+
      | a    |
      +------+
      | a    |
      | A    |
      +------+

      The above result is incorrect. It should return only one row, with 'a' (lower case).

        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: