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

Incorrect result interceptor passed to mysql_explain_union()

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1),(2);
      CREATE TABLE t2 (b INT);
      INSERT INTO t2 VALUES (3),(4);
       
      EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6);
       
      # Cleanup
      DROP TABLE t1, t2;
      

      10.5 f98d2ef5b4ab633d74fb245a8b6520fe86514de0

      #3  <signal handler called>
      #4  0x0000564753f06f06 in multi_delete::initialize_tables (this=0x62b00003b788, join=0x62900025d238) at /data/bld/10.5-asan/sql/sql_delete.cc:1242
      #5  0x00005647532f8b53 in JOIN::optimize_stage2 (this=0x62900025d238) at /data/bld/10.5-asan/sql/sql_select.cc:2457
      #6  0x00005647532f811e in JOIN::optimize_inner (this=0x62900025d238) at /data/bld/10.5-asan/sql/sql_select.cc:2409
      #7  0x00005647532f1279 in JOIN::optimize (this=0x62900025d238) at /data/bld/10.5-asan/sql/sql_select.cc:1741
      #8  0x0000564753311e36 in mysql_select (thd=0x62b000069218, tables=0x62b00003a120, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2199023255556, result=0x62b00003b788, unit=0x62b00003a0d8, select_lex=0x62b00003aec0) at /data/bld/10.5-asan/sql/sql_select.cc:4865
      #9  0x000056475353c8c8 in st_select_lex_unit::exec (this=0x62b00003a0d8) at /data/bld/10.5-asan/sql/sql_union.cc:2376
      #10 0x00005647533bb641 in mysql_explain_union (thd=0x62b000069218, unit=0x62b00003a0d8, result=0x62b00003b788) at /data/bld/10.5-asan/sql/sql_select.cc:28027
      #11 0x00005647533bafe1 in select_describe (join=0x62b00003b800, need_tmp_table=false, need_order=false, distinct=false, message=0x0) at /data/bld/10.5-asan/sql/sql_select.cc:27991
      #12 0x00005647533100b0 in JOIN::exec_inner (this=0x62b00003b800) at /data/bld/10.5-asan/sql/sql_select.cc:4584
      #13 0x000056475330dd14 in JOIN::exec (this=0x62b00003b800) at /data/bld/10.5-asan/sql/sql_select.cc:4402
      #14 0x000056475331202b in mysql_select (thd=0x62b000069218, tables=0x62b000038b00, fields=..., conds=0x62b00003b3a0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202244746116, result=0x62b00003b788, unit=0x62b00006d3c8, select_lex=0x62b00006dc00) at /data/bld/10.5-asan/sql/sql_select.cc:4879
      #15 0x000056475323fe14 in mysql_execute_command (thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_parse.cc:4951
      #16 0x0000564753255561 in mysql_parse (thd=0x62b000069218, rawbuf=0x62b000038238 "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)", length=69, parser_state=0x7ff40c69fc10, is_com_multi=false, is_next_command=false) at /data/bld/10.5-asan/sql/sql_parse.cc:8170
      #17 0x000056475322ac66 in dispatch_command (command=COM_QUERY, thd=0x62b000069218, packet=0x629000244219 "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)", packet_length=69, is_com_multi=false, is_next_command=false) at /data/bld/10.5-asan/sql/sql_parse.cc:1891
      #18 0x00005647532275f9 in do_command (thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_parse.cc:1375
      #19 0x000056475367acd0 in do_handle_one_connection (connect=0x608000002b38, put_in_cache=true) at /data/bld/10.5-asan/sql/sql_connect.cc:1415
      #20 0x000056475367a698 in handle_one_connection (arg=0x608000002ab8) at /data/bld/10.5-asan/sql/sql_connect.cc:1317
      #21 0x00005647542bd0ca in pfs_spawn_thread (arg=0x615000005318) at /data/bld/10.5-asan/storage/perfschema/pfs.cc:2201
      #22 0x00007ff4152a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #23 0x00007ff41532861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      The failure started happening after this commit in 10.5:

      commit c6a9fd79047b1ce5b0938a609978e63d9aa04b3a 89a5a8d234832ef9ed5ee814e4db42c636fcde1e
      Commit:     Rex Johnston
      CommitDate: Fri Dec 1 09:29:36 2023 +1200
       
          MDEV-32212 DELETE with ORDER BY and semijoin optimization causing crash
      

      Non-debug build crashes the same way.
      Reproducible with at least InnoDB and MyISAM.
      Not reproducible with the provided test case on 11.1 and higher.

      Attachments

        Issue Links

          Activity

            People

              Johnston Rex Johnston
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.