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

Incorrect Result for IN Subquery on indexed CHAR Column

    XMLWordPrintable

Details

    Description

      An IN (subquery) expression returns an incorrect result if the column in the subquery is a CHAR or VARCHAR type with a UNIQUE index.The issue is also reproducible if the table is created with `CREATE TABLE t114 (c1 VARCHAR(10), UNIQUE (c1(1)));`. Removing the UNIQUE index produces the correct result.

      drop TABLE IF EXISTS t114;
      CREATE TABLE t114 (c1 CHAR, UNIQUE (c1));
      INSERT t114 () VALUES ('u');
      select ('uH' IN (SELECT t114.c1 FROM t114)) from t114;
      -- 1
       
      drop TABLE IF EXISTS t114;
      CREATE TABLE t114 (c1 CHAR);
      INSERT t114 () VALUES ('u');
      select ('uH' IN (SELECT t114.c1 FROM t114)) from t114;
      -- 0
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              zzz5248 zzz5248
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.