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

LP:884175 - Wrong result with aggregate + varchar key

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      The following query:

      SELECT MAX(f2) FROM t1 where f2 = 'abc';

      returns rows even though f2 is defined as VARCHAR(1) and does not contain the value 'abc'. If the column does not have an index, no rows are returned.

      Explain: Select tables optimized away
      select max(`test`.`t1`.`f2`) AS `MAX(f2)` from `test`.`t1` where multiple equal('abc', `test`.`t1`.`f2`)

      repeatable in maria-5.2, mysql-5.5

      test case:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (f1 VARCHAR(1), f2 VARCHAR(1), KEY (f2));
      INSERT INTO t1 VALUES ('a','a');

      SELECT MAX(f1) FROM t1 where f1 = 'abc';
      SELECT MAX(f2) FROM t1 where f2 = 'abc';

      Attachments

        Activity

          People

            igor Igor Babaev (Inactive)
            philipstoev Philip Stoev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 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.