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

Assertion `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed on 2nd execution of PS with derived_merge

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.3.12, 5.5.36, 10.0.8
    • 5.5.37, 10.0.10, 5.3.13
    • None
    • None

    Description

      SET optimizer_switch = 'derived_merge=on';
       
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1),(2);
      CREATE TABLE t2 (b INT);
      INSERT INTO t2 VALUES (1),(2);
       
      PREPARE stmt FROM '
        INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM (SELECT * FROM t1) AS sq  
      ';
      EXECUTE stmt;
      EXECUTE stmt;

      mysqld: table.cc:4438: void TABLE_LIST::set_check_merged(): Assertion `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed.

      #6  0x00007fb0847f0621 in *__GI___assert_fail (assertion=0xd36e28 "!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test", file=<optimized out>, line=4438, function=0xd386a0 "void TABLE_LIST::set_check_merged()") at assert.c:81
      #7  0x00000000007207c3 in TABLE_LIST::set_check_merged (this=0x1f5b3d0) at table.cc:4436
      #8  0x00000000007249b1 in TABLE_LIST::set_merged_derived (this=0x1f5b3d0) at table.h:1796
      #9  0x00000000007241c9 in TABLE_LIST::init_derived (this=0x1f5b3d0, thd=0x1ea0b88, init_view=true) at table.cc:6034
      #10 0x00000000008b28d6 in mysql_derived_init (thd=0x1ea0b88, lex=0x1f57958, derived=0x1f5b3d0) at sql_derived.cc:542
      #11 0x00000000008b1f24 in mysql_handle_derived (lex=0x1f57958, phases=1) at sql_derived.cc:112
      #12 0x00000000007086b4 in open_and_lock_tables_derived (thd=0x1ea0b88, tables=0x1f58b80, derived=true) at sql_base.cc:5262
      #13 0x00000000006bbd14 in open_and_lock_tables (thd=0x1ea0b88, tables=0x1f58b80) at mysql_priv.h:1826
      #14 0x00000000006ae385 in mysql_execute_command (thd=0x1ea0b88) at sql_parse.cc:3305
      #15 0x0000000000786882 in Prepared_statement::execute (this=0x1f57588, expanded_query=0x7fb07bd0ccb0, open_cursor=false) at sql_prepare.cc:3764
      #16 0x0000000000785acf in Prepared_statement::execute_loop (this=0x1f57588, expanded_query=0x7fb07bd0ccb0, open_cursor=false, packet=0x0, packet_end=0x0) at sql_prepare.cc:3445
      #17 0x0000000000783f26 in mysql_sql_stmt_execute (thd=0x1ea0b88) at sql_prepare.cc:2670
      #18 0x00000000006ab6f6 in mysql_execute_command (thd=0x1ea0b88) at sql_parse.cc:2314
      #19 0x00000000006b6e93 in mysql_parse (thd=0x1ea0b88, rawbuf=0x1f248c0 "EXECUTE stmt", length=12, found_semicolon=0x7fb07bd0dcb8) at sql_parse.cc:6173
      #20 0x00000000006a8ea8 in dispatch_command (command=COM_QUERY, thd=0x1ea0b88, packet=0x1f1b459 "EXECUTE stmt", packet_length=12) at sql_parse.cc:1243
      #21 0x00000000006a8194 in do_command (thd=0x1ea0b88) at sql_parse.cc:923
      #22 0x00000000006a5025 in handle_one_connection (arg=0x1ea0b88) at sql_connect.cc:1231
      #23 0x00007fb0854fcb50 in start_thread (arg=<optimized out>) at pthread_create.c:304
      #24 0x00007fb08489fa7d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Stack trace from:

      revision-id: igor@askmonty.org-20140221052733-ypg4dpfcmy5l0b3q
      date: 2014-02-20 21:27:33 -0800
      build-date: 2014-02-26 03:02:19 +0400
      revno: 3765
      branch-nick: 5.3
      BUILD/compile-pentium-debug-max-no-ndb

      Attachments

        Activity

          elenst Elena Stepanova created issue -
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          elenst Elena Stepanova made changes -
          igor Igor Babaev (Inactive) made changes -
          Assignee Igor Babaev [ igor ] Oleksandr Byelkin [ sanja ]
          sanja Oleksandr Byelkin made changes -
          Status Open [ 1 ] In Progress [ 3 ]

          probably exclude_from_table_unique_test is not reset.

          sanja Oleksandr Byelkin added a comment - probably exclude_from_table_unique_test is not reset.

          Above is not reset because mysql_derived_fill was never called despite switching to materialized derived.

          sanja Oleksandr Byelkin added a comment - Above is not reset because mysql_derived_fill was never called despite switching to materialized derived.

          The problem is that after set_materialized_derived() call the table still merged

          sanja Oleksandr Byelkin added a comment - The problem is that after set_materialized_derived() call the table still merged

          set_materialized_derived() run in one execution, then nothing was done to execute, the derived, reinitialization do not call unit->cleanup() so exclude_from_table_unique_test is not reset which was detected by set_merged_derived() on the next execution.

          Adding unit->cleanup() to mysql_derived_reinit() leads to crash (there is even unit->unclean() call in mysql_derived_reinit()).

          sanja Oleksandr Byelkin added a comment - set_materialized_derived() run in one execution, then nothing was done to execute, the derived, reinitialization do not call unit->cleanup() so exclude_from_table_unique_test is not reset which was detected by set_merged_derived() on the next execution. Adding unit->cleanup() to mysql_derived_reinit() leads to crash (there is even unit->unclean() call in mysql_derived_reinit()).
          sanja Oleksandr Byelkin made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]

          Decision to materialize derived appeared when UNION already executed during "fake select" execution.
          Checking of underlying tables on this stage is wrong, because fake select works on temporary tables.

          sanja Oleksandr Byelkin added a comment - Decision to materialize derived appeared when UNION already executed during "fake select" execution. Checking of underlying tables on this stage is wrong, because fake select works on temporary tables.

          Sent for review...

          sanja Oleksandr Byelkin added a comment - Sent for review...
          sanja Oleksandr Byelkin made changes -
          Status Stalled [ 10000 ] In Progress [ 3 ]
          sanja Oleksandr Byelkin made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.10 [ 14500 ]
          Fix Version/s 10.0.9 [ 14400 ]
          sanja Oleksandr Byelkin made changes -
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 34923 ] MariaDB v2 [ 43325 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 43325 ] MariaDB v3 [ 63097 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 63097 ] MariaDB v4 [ 147550 ]

          People

            sanja Oleksandr Byelkin
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.