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

Assertion `tl->jtbm_subselect' failed in JOIN::calc_allowed_top_level_tables on 2nd execution of PS

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (a INT);
      INSERT INTO t VALUES (1),(2); # Optional, fails either way
       
      PREPARE stmt FROM 'CREATE TABLE tmp AS 
      SELECT * 
      FROM (select t1.* from t t1 join t t2 on(t1.a = t2.a)) sq 
      WHERE "x"=0';
      --error ER_TRUNCATED_WRONG_VALUE
      EXECUTE stmt;
      --error ER_TRUNCATED_WRONG_VALUE
      EXECUTE stmt;
       
      # Cleanup
      DROP TABLE t;
      

      main 947de4b1db9782ed9fe9c07c9c7af03d0c369eb5

      mariadbd: /data/bld/main-asan/sql/sql_select.cc:20065: void JOIN::calc_allowed_top_level_tables(SELECT_LEX*): Assertion `tl->jtbm_subselect' failed.
      241102 21:29:11 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007f50f0e53e32 in __GI___assert_fail (assertion=0x5636ef664780 "tl->jtbm_subselect", file=0x5636ef6586c0 "/data/bld/main-asan/sql/sql_select.cc", line=20065, function=0x5636ef664720 "void JOIN::calc_allowed_top_level_tables(SELECT_LEX*)") at ./assert/assert.c:101
      #10 0x00005636ed44b69b in JOIN::calc_allowed_top_level_tables (this=0x6290000e6750, lex=0x62d00025aad8) at /data/bld/main-asan/sql/sql_select.cc:20065
      #11 0x00005636ed3c9015 in JOIN::optimize_inner (this=0x6290000e6750) at /data/bld/main-asan/sql/sql_select.cc:2344
      #12 0x00005636ed3c5f0b in JOIN::optimize (this=0x6290000e6750) at /data/bld/main-asan/sql/sql_select.cc:2004
      #13 0x00005636ed3e87fa in mysql_select (thd=0x62c0000c0218, tables=0x62d00025dcb0, fields=..., conds=0x62d00025e530, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201187781376, result=0x6290000e6608, unit=0x62d000258528, select_lex=0x62d00025aad8) at /data/bld/main-asan/sql/sql_select.cc:5346
      #14 0x00005636ed3b6fcd in handle_select (thd=0x62c0000c0218, lex=0x62d000258448, result=0x6290000e6608, setup_tables_done_option=0) at /data/bld/main-asan/sql/sql_select.cc:643
      #15 0x00005636ed600d49 in Sql_cmd_create_table_like::execute (this=0x62d00025a300, thd=0x62c0000c0218) at /data/bld/main-asan/sql/sql_table.cc:13201
      #16 0x00005636ed2d734b in mysql_execute_command (thd=0x62c0000c0218, is_called_from_prepared_stmt=true) at /data/bld/main-asan/sql/sql_parse.cc:5864
      #17 0x00005636ed378770 in Prepared_statement::execute (this=0x61900009a698, expanded_query=0x7f50e5c16590, open_cursor=false) at /data/bld/main-asan/sql/sql_prepare.cc:5050
      #18 0x00005636ed3736d3 in Prepared_statement::execute_loop (this=0x61900009a698, expanded_query=0x7f50e5c16590, open_cursor=false, packet=0x0, packet_end=0x0) at /data/bld/main-asan/sql/sql_prepare.cc:4427
      #19 0x00005636ed36cb8c in mysql_sql_stmt_execute (thd=0x62c0000c0218) at /data/bld/main-asan/sql/sql_prepare.cc:3446
      #20 0x00005636ed2c9653 in mysql_execute_command (thd=0x62c0000c0218, is_called_from_prepared_stmt=false) at /data/bld/main-asan/sql/sql_parse.cc:3972
      #21 0x00005636ed2e44a4 in mysql_parse (thd=0x62c0000c0218, rawbuf=0x6290000e6238 "EXECUTE stmt", length=12, parser_state=0x7f50e5c179d0) at /data/bld/main-asan/sql/sql_parse.cc:7891
      #22 0x00005636ed2bb428 in dispatch_command (command=COM_QUERY, thd=0x62c0000c0218, packet=0x629000253219 "EXECUTE stmt", packet_length=12, blocking=true) at /data/bld/main-asan/sql/sql_parse.cc:1892
      #23 0x00005636ed2b8130 in do_command (thd=0x62c0000c0218, blocking=true) at /data/bld/main-asan/sql/sql_parse.cc:1405
      #24 0x00005636ed7a8e54 in do_handle_one_connection (connect=0x608000003638, put_in_cache=true) at /data/bld/main-asan/sql/sql_connect.cc:1448
      #25 0x00005636ed7a8810 in handle_one_connection (arg=0x6080000035b8) at /data/bld/main-asan/sql/sql_connect.cc:1350
      #26 0x00005636ee441926 in pfs_spawn_thread (arg=0x617000005b98) at /data/bld/main-asan/storage/perfschema/pfs.cc:2198
      #27 0x00007f50f0ea8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #28 0x00007f50f0f2861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Also fails with a merge view instead of a sub-select.

      The failure started happening after this commit in main

      commit 4b6922a315fa5411665ac99c0b40fd7238093403 (HEAD)
      Author: Yuchen Pei
      Date:   Thu Aug 29 11:10:59 2024 +1000
       
          MDEV-25008: UPDATE/DELETE: Cost-based choice IN->EXISTS vs Materialization
      

      No obvious immediate effect on a non-debug build.

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.