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

LP:844997 - Wrong query result with SELECT const_table_column, aggregate_func, implict grouping and empty resultset

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Trivial
    • Resolution: Unresolved
    • 5.1.67, 5.2.14, 5.3.12, 5.5.36, 10.0.9, 10.3(EOL), 10.4(EOL), 10.5(EOL), 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL)
    • 5.5(EOL), 10.3(EOL)
    • None

    Description

      Consider the below: it shows how changing const table to non-const will change the resultset. This is a bug.

      create table t11 (a int primary key, b int);
      insert into t11 values (1,1),(2,2);
       
      create table t10 (a int, b int, c int);
      insert into t10 values (10, NULL, NULL), (10, NULL, NULL);
       
      MariaDB [j12]> explain select t11.b, max(t10.b) from t10, t11 where t10.c<1 and t11.a=2;
      +----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
      | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
      +----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
      | 1 | SIMPLE | t11 | const | PRIMARY | PRIMARY | 4 | const | 1 | |
      | 1 | SIMPLE | t10 | ALL | NULL | NULL | NULL | NULL | 2 | Using where |
      +----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
      2 rows in set (2.63 sec)
       
      MariaDB [j12]> select t11.b, max(t10.b) from t10, t11 where t10.c<1 and t11.a=2;
      +------+------------+
      | b | max(t10.b) |
      +------+------------+
      | 2 | NULL |
      +------+------------+
      1 row in set (3.31 sec)

      MariaDB [j12]> alter table t11 drop primary key;
      Query OK, 2 rows affected (0.01 sec)
      Records: 2 Duplicates: 0 Warnings: 0
       
      MariaDB [j12]> select t11.b, max(t10.b) from t10, t11 where t10.c<1 and t11.a=2;
      +------+------------+
      | b | max(t10.b) |
      +------+------------+
      | NULL | NULL |
      +------+------------+
      1 row in set (3.66 sec)

      The bug can be repeated on current mysql-5.1

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            psergei Sergei Petrunia
            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.