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

LP:715738 - Wrong result with implicit grouping and empty result set

    XMLWordPrintable

Details

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

    Description

      When executing the following query with materialization, it returns a row, even though the WHERE clause must be false because the subquery in the NOT IN predicate returns ( NULL , NULL ) , which should make the NOT IN predicate FALSE. It seems this is only observed with queries that violate the ONLY_FULL_GROUP_BY SQL mode.

      Test case:

      SET SESSION optimizer_switch = 'in_to_exists=off,materialization=on,semijoin=off';
      CREATE TABLE t1 ( f10 varchar(1)) ;

      CREATE TABLE t2 ( f1 int(11), f3 int(11), PRIMARY KEY (f1)) ;

      CREATE TABLE t3 ( f4 date, f11 varchar(1)) ;
      INSERT IGNORE INTO t3 VALUES ('1900-01-01','f');

      SELECT f4 FROM t3
      WHERE ( 2 , 7 ) NOT IN (
      SELECT f1 , MIN( f3 ) FROM t2 WHERE ( 'j' ) IN ( SELECT t1.f10 FROM t1 ) );

      explain:

      -------------------------------------------------------------------------------------------------------------+

      id select_type table type possible_keys key key_len ref rows Extra

      -------------------------------------------------------------------------------------------------------------+

      1 PRIMARY t3 system NULL NULL NULL NULL 1  
      2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
      3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table

      -------------------------------------------------------------------------------------------------------------+

      Attachments

        Activity

          People

            timour Timour Katchaounov (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.