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

Assertion failure or unexpected outcome upon 2nd execution of parameterized PS

Details

    Description

      CREATE TABLE t (a INT);
      INSERT INTO t VALUES (1),(2);
       
      PREPARE stmt FROM 'UPDATE t SET a = 3 WHERE a IN (SELECT ? UNION SELECT ?)';
       
      --error ER_TRUNCATED_WRONG_VALUE
      EXECUTE stmt USING '',4;
      --error ER_TRUNCATED_WRONG_VALUE
      EXECUTE stmt USING '',4;
       
      DROP TABLE t;
      

      11.7 44d0f5864e8dc04464524c42dd916be20e9f152e

      mariadbd: /data/bld/11.7-asan/sql/item.cc:4715: bool Item_param::can_return_value() const: Assertion `0' failed.
      250210 16:41:13 [ERROR] /share8t/bld/11.7-asan/sql/mariadbd got signal 6 ;
       
      #9  0x00007f2693253e32 in __GI___assert_fail (assertion=0x5584d85b5260 "0", file=0x5584d85b7c80 "/data/bld/11.7-asan/sql/item.cc", line=4715, function=0x5584d85bb7e0 "bool Item_param::can_return_value() const") at ./assert/assert.c:101
      #10 0x00005584d6670706 in Item_param::can_return_value (this=0x62d0005852e0) at /data/bld/11.7-asan/sql/item.cc:4715
      #11 0x00005584d66ac1b0 in Item_param::val_decimal (this=0x62d0005852e0, dec=0x7f26835bed48) at /data/bld/11.7-asan/sql/item.h:4327
      #12 0x00005584d588f743 in Item::val_decimal_result (this=0x62d0005852e0, val=0x7f26835bed48) at /data/bld/11.7-asan/sql/item.h:1820
      #13 0x00005584d6675b38 in Item_ref_null_helper::val_decimal (this=0x62d0003437c8, decimal_value=0x7f26835bed48) at /data/bld/11.7-asan/sql/item.cc:5428
      #14 0x00005584d6369c32 in VDec::VDec (this=0x7f26835bed40, item=0x62d0003437c8) at /data/bld/11.7-asan/sql/sql_type.cc:357
      #15 0x00005584d66cab83 in Arg_comparator::compare_decimal (this=0x62d000343998) at /data/bld/11.7-asan/sql/item_cmpfunc.cc:952
      #16 0x00005584d670c93a in Arg_comparator::compare (this=0x62d000343998) at /data/bld/11.7-asan/sql/item_cmpfunc.h:114
      #17 0x00005584d66d5e18 in Item_func_eq::val_bool (this=0x62d0003438e0) at /data/bld/11.7-asan/sql/item_cmpfunc.cc:1881
      #18 0x00005584d5d7969d in JOIN::exec_inner (this=0x62d000341708) at /data/bld/11.7-asan/sql/sql_select.cc:4912
      #19 0x00005584d5d78432 in JOIN::exec (this=0x62d000341708) at /data/bld/11.7-asan/sql/sql_select.cc:4829
      #20 0x00005584d5fdb5dd in st_select_lex_unit::exec_inner (this=0x62d0005854d8) at /data/bld/11.7-asan/sql/sql_union.cc:2437
      #21 0x00005584d5fd9fa0 in st_select_lex_unit::exec (this=0x62d0005854d8) at /data/bld/11.7-asan/sql/sql_union.cc:2342
      #22 0x00005584d68c7ac2 in subselect_union_engine::exec (this=0x62d000586b08) at /data/bld/11.7-asan/sql/item_subselect.cc:4227
      #23 0x00005584d68a1cca in Item_subselect::exec (this=0x62d0005868c0) at /data/bld/11.7-asan/sql/item_subselect.cc:813
      #24 0x00005584d68a3252 in Item_in_subselect::exec (this=0x62d0005868c0) at /data/bld/11.7-asan/sql/item_subselect.cc:995
      #25 0x00005584d68ae5e1 in Item_in_subselect::val_bool (this=0x62d0005868c0) at /data/bld/11.7-asan/sql/item_subselect.cc:2011
      #26 0x00005584d588f7ac in Item::val_bool_result (this=0x62d0005868c0) at /data/bld/11.7-asan/sql/item.h:1821
      #27 0x00005584d66d4171 in Item_in_optimizer::val_bool (this=0x62d000586d08) at /data/bld/11.7-asan/sql/item_cmpfunc.cc:1765
      #28 0x00005584d5b689f1 in SQL_SELECT::skip_record (this=0x62d0003435a8, thd=0x62c0000c0218) at /data/bld/11.7-asan/sql/opt_range.h:1922
      #29 0x00005584d600618a in Sql_cmd_update::update_single_table (this=0x62d000584c68, thd=0x62c0000c0218) at /data/bld/11.7-asan/sql/sql_update.cc:971
      #30 0x00005584d601b339 in Sql_cmd_update::execute_inner (this=0x62d000584c68, thd=0x62c0000c0218) at /data/bld/11.7-asan/sql/sql_update.cc:3163
      #31 0x00005584d5e4af40 in Sql_cmd_dml::execute (this=0x62d000584c68, thd=0x62c0000c0218) at /data/bld/11.7-asan/sql/sql_select.cc:34325
      #32 0x00005584d5c5e5c6 in mysql_execute_command (thd=0x62c0000c0218, is_called_from_prepared_stmt=true) at /data/bld/11.7-asan/sql/sql_parse.cc:4428
      #33 0x00005584d5d0b906 in Prepared_statement::execute (this=0x61900005aa98, expanded_query=0x7f26835c15a0, open_cursor=false) at /data/bld/11.7-asan/sql/sql_prepare.cc:5069
      #34 0x00005584d5d0686a in Prepared_statement::execute_loop (this=0x61900005aa98, expanded_query=0x7f26835c15a0, open_cursor=false, packet=0x0, packet_end=0x0) at /data/bld/11.7-asan/sql/sql_prepare.cc:4445
      #35 0x00005584d5cffc4f in mysql_sql_stmt_execute (thd=0x62c0000c0218) at /data/bld/11.7-asan/sql/sql_prepare.cc:3460
      #36 0x00005584d5c5bc4f in mysql_execute_command (thd=0x62c0000c0218, is_called_from_prepared_stmt=false) at /data/bld/11.7-asan/sql/sql_parse.cc:3995
      #37 0x00005584d5c76a5a in mysql_parse (thd=0x62c0000c0218, rawbuf=0x62d00033e438 "EXECUTE stmt USING '',4", length=23, parser_state=0x7f26835c2a30) at /data/bld/11.7-asan/sql/sql_parse.cc:7915
      #38 0x00005584d5c4d8ab in dispatch_command (command=COM_QUERY, thd=0x62c0000c0218, packet=0x629000253219 "EXECUTE stmt USING '',4", packet_length=23, blocking=true) at /data/bld/11.7-asan/sql/sql_parse.cc:1902
      #39 0x00005584d5c4a5b3 in do_command (thd=0x62c0000c0218, blocking=true) at /data/bld/11.7-asan/sql/sql_parse.cc:1415
      #40 0x00005584d6145481 in do_handle_one_connection (connect=0x6080000037b8, put_in_cache=true) at /data/bld/11.7-asan/sql/sql_connect.cc:1415
      #41 0x00005584d6144fe0 in handle_one_connection (arg=0x608000003738) at /data/bld/11.7-asan/sql/sql_connect.cc:1327
      #42 0x00005584d6e0516c in pfs_spawn_thread (arg=0x617000005b98) at /data/bld/11.7-asan/storage/perfschema/pfs.cc:2198
      #43 0x00007f26932a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #44 0x00007f269332861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      On a non-debug build there is no assertion failure of course, but the 2nd execution does not produce an error like the 1st one, and doesn't update anything either:

      CREATE TABLE t (a INT);
      INSERT INTO t VALUES (1),(2);
       
      PREPARE stmt FROM 'UPDATE t SET a = 3 WHERE a IN (SELECT ? UNION SELECT ?)';
       
      --error ER_TRUNCATED_WRONG_VALUE
      EXECUTE stmt USING '',4;
      #--error ER_TRUNCATED_WRONG_VALUE
      EXECUTE stmt USING '',4;
      SELECT * FROM t;
       
      DROP TABLE t;
      

      11.7 44d0f5864e8dc04464524c42dd916be20e9f152e

      CREATE TABLE t (a INT);
      INSERT INTO t VALUES (1),(2);
      PREPARE stmt FROM 'UPDATE t SET a = 3 WHERE a IN (SELECT ? UNION SELECT ?)';
      EXECUTE stmt USING '',4;
      ERROR 22007: Truncated incorrect DECIMAL value: ''
      EXECUTE stmt USING '',4;
      SELECT * FROM t;
      a
      1
      2
      DROP TABLE t;
      

      The failure started happening after this commit in 11.7 and bb-11.7-release:

      commit 0e21ff8ca47ab637564b4c120322215caa70835d (HEAD)
      Commit:     Sergei Petrunia
      CommitDate: Tue Feb 4 18:27:24 2025 +0200
       
          MDEV-35318 Assertion `tl->jtbm_subselect' failed in JOIN::calc_allowed_top_level_tables
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              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.