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

Wrong result (extra rows) on 2nd execution of PS with exists_to_in, MERGE view

    Details

    • Type: Bug
    • Status: Stalled
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.0.13
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      10.0.20

      Description

      CREATE TABLE t1 (a VARCHAR(3)) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('foo'),('bar');
      
      CREATE TABLE t2 (i INT, b VARCHAR(3)) ENGINE=MyISAM;
      CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
      INSERT INTO t2 VALUES (4,'foo'),(5,'baz');
      
      PREPARE stmt FROM "SELECT * FROM t1 WHERE NOT EXISTS ( SELECT i FROM v2 WHERE b = a )";
      EXECUTE stmt;
      EXECUTE stmt;
      

      Actual result:

      EXECUTE stmt;
      a
      bar
      EXECUTE stmt;
      a
      foo
      bar
      

      Expected result:

      EXECUTE stmt;
      a
      bar
      EXECUTE stmt;
      a
      bar
      
      revision-id: knielsen@knielsen-hq.org-20140902120701-txesdmkczel84qgf
      revno: 4369
      branch-nick: 10.0
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            sanja Oleksandr Byelkin added a comment - - edited

            Difference between 2 executions found:
            WHERE:(t1 final_pushdown_cond) 0x7fa04c1599c8 (not(((`test`.`t1`.`a` is not null) and <in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`v2` where (`test`.`t2`.`b` is not null))))))

            WHERE:(t1 final_pushdown_cond) 0x7fa04c1599c8 (not(((`test`.`t1`.`a` is not null) and <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in (select `test`.`t2`.`i` from `test`.`t2` where (`test`.`t2`.`b` is not null))))))

            Show
            sanja Oleksandr Byelkin added a comment - - edited Difference between 2 executions found: WHERE:(t1 final_pushdown_cond) 0x7fa04c1599c8 (not(((`test`.`t1`.`a` is not null) and <in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`v2` where (`test`.`t2`.`b` is not null)))))) WHERE:(t1 final_pushdown_cond) 0x7fa04c1599c8 (not(((`test`.`t1`.`a` is not null) and <in_optimizer>(`test`.`t1`.`a` ,`test`.`t1`.`a` in (select `test`.`t2`.`i` from `test`.`t2` where (`test`.`t2`.`b` is not null))))))
            Hide
            sanja Oleksandr Byelkin added a comment -

            Above is result about taking materialization strategy for IN subquery which was done later then printed first line but kept till next execution.

            Show
            sanja Oleksandr Byelkin added a comment - Above is result about taking materialization strategy for IN subquery which was done later then printed first line but kept till next execution.
            Hide
            sanja Oleksandr Byelkin added a comment -

            subselect_uniquesubquery_engine::exec() on the second execution looks for incorrect key:

            gdb) p (*key)@9
            $3 = "\000\000\000\000\000\000\000\000"

            against first execution key:

            (gdb) p (*key)@9
            $2 = "\000\003\000foo\000\000"

            Show
            sanja Oleksandr Byelkin added a comment - subselect_uniquesubquery_engine::exec() on the second execution looks for incorrect key: gdb) p (*key)@9 $3 = "\000\000\000\000\000\000\000\000" against first execution key: (gdb) p (*key)@9 $2 = "\000\003\000foo\000\000"
            Hide
            sanja Oleksandr Byelkin added a comment -

            Above happened because it trying to store in Field_long 'i' !!!

            Show
            sanja Oleksandr Byelkin added a comment - Above happened because it trying to store in Field_long 'i' !!!
            Hide
            sanja Oleksandr Byelkin added a comment -

            subselect_hash_sj_engine::make_unique_engine() creates subselect_uniquesubquery_engine for every execution, so probably works incorrectly on the second one picking up wrong field.

            Show
            sanja Oleksandr Byelkin added a comment - subselect_hash_sj_engine::make_unique_engine() creates subselect_uniquesubquery_engine for every execution, so probably works incorrectly on the second one picking up wrong field.
            Hide
            sanja Oleksandr Byelkin added a comment -

            tmp_key->key_part changed

            Show
            sanja Oleksandr Byelkin added a comment - tmp_key->key_part changed

              People

              • Assignee:
                sanja Oleksandr Byelkin
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Agile