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

Wrong results from a MyISAM/HEAP/ARIA tables with a single record and an aggregate

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5
    • 10.5
    • None
    • None

    Description

      This query seems to return a correct result:

      CREATE OR REPLACE TABLE t1 (a int) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (NULL);
      SELECT 1,min(1) FROM t1 WHERE if(uuid_short(), a,1);
      +---+--------+
      | 1 | min(1) |
      +---+--------+
      | 1 |   NULL |
      +---+--------+
      

      Notice, the WHERE condition returns NULL in this statement and all statements below.

      This query on a table with a single record erroneously returns 0 instead of 1

      CREATE OR REPLACE TABLE t1 (a int) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (NULL);
      SELECT 1+0,min(1) FROM t1 WHERE if(uuid_short(), a,1);
      +-----+--------+
      | 1+0 | min(1) |
      +-----+--------+
      |   0 |   NULL |
      +-----+--------+
      

      But if the table if empty, the result is correct:

      CREATE OR REPLACE TABLE t1 (a int) ENGINE=MyISAM;
      SELECT 1+0,min(1) FROM t1 WHERE if(uuid_short(), a,1);
      +-----+--------+
      | 1+0 | min(1) |
      +-----+--------+
      |   1 |   NULL |
      +-----+--------+
      

      And if the table has more than one records, the result is also correct:

      CREATE OR REPLACE TABLE t1 (a int) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (NULL),(NULL);
      SELECT 1+0,min(1) FROM t1 WHERE if(uuid_short(), a,1);
      +-----+--------+
      | 1+0 | min(1) |
      +-----+--------+
      |   1 |   NULL |
      +-----+--------+
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.