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;

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL)
    • 10.1.7
    • Optimizer

    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

              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.