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

Function with EXECUTE IMMEDIATE crashes on INSERT with an InnoDB table

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 13.1
    • N/A
    • Stored routines
    • None
    • Can result in hang or crash
    • Q4/2026 Replic. Maintenance

    Description

      The this script scrashes in bb-13.1-bar-MDEV-39518:

      CREATE OR REPLACE TABLE t1 (a VARCHAR(30)) ENGINE=InnoDB;
       
      DELIMITER $$
      CREATE OR REPLACE FUNCTION f3() RETURNS INT
      BEGIN
        EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (''f3-immediate'')';
        RETURN 0;
      END;
      $$
       
      CREATE OR REPLACE FUNCTION f2() RETURNS INT
      BEGIN
        DECLARE v3 VARCHAR(10) DEFAULT f3();
        INSERT INTO t1 VALUES ('f2-direct');
        RETURN 0;
      END;
      $$
       
      CREATE OR REPLACE PROCEDURE p1()
      BEGIN
        DECLARE v2 VARCHAR(10) DEFAULT f2();
      END;
      $$
      DELIMITER ;
       
      CALL p1;
      SELECT * FROM t1 ORDER BY a DESC;
      DROP PROCEDURE p1;
      DROP FUNCTION f2;
      DROP FUNCTION f3;
      DROP TABLE t1;
      

      with the following stack trace:

      #0  0x00007ffff7082e7c in __pthread_kill_implementation ()
         from /lib64/libc.so.6
      #1  0x00007ffff7028f0e in raise () from /lib64/libc.so.6
      #2  0x00007ffff70106d0 in abort () from /lib64/libc.so.6
      #3  0x00007ffff7010639 in __assert_fail_base.cold () from /lib64/libc.so.6
      #4  0x00005555557c894d in Prepared_statement::prepare (this=0x77ffa80ed940, 
          packet=0x77ffa80d5890 "INSERT INTO t1 VALUES ('f3-immediate')", 
          packet_len=38)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_prepare.cc:4631
      #5  0x00005555557cc1c5 in Prepared_statement::execute_immediate (
          this=0x77ffa80ed940, 
          query=0x77ffa80d5890 "INSERT INTO t1 VALUES ('f3-immediate')", 
          query_len=38, dynamic_open_cursor=false, result_arg=0x77ffa80eda90, 
          cursor_arg=0x77ffa80edb00, instrs_set_placeholder=...)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_prepare.cc:5736
      #6  0x00005555557c463f in mysql_sql_stmt_execute_immediate (
          thd=0x77ffa8000dd0, dynamic_open_cursor=false, result_arg=0x0, 
          cursor_arg=0x0, instrs_set_placeholder=...)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_prepare.cc:3140
      #7  0x00005555557c4830 in mysql_sql_stmt_execute_immediate (thd=0x77ffa8000dd0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_prepare.cc:3163
      #8  0x0000555555775d3d in mysql_execute_command (thd=0x77ffa8000dd0, 
          is_called_from_prepared_stmt=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:4003
      #9  0x0000555555ad4b9b in sp_instr_stmt::exec_core (this=0x77ffa80d5a10, 
          thd=0x77ffa8000dd0, nextp=0x7fffe009ba7c)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:1281
      #10 0x0000555555ad2a25 in sp_lex_keeper::reset_lex_and_exec_core (
          this=0x77ffa80d5a50, thd=0x77ffa8000dd0, nextp=0x7fffe009ba7c, 
          open_tables=false, instr=0x77ffa80d5a10, rerun_the_same_instr=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:420
      #11 0x0000555555ad30ef in sp_lex_keeper::validate_lex_and_exec_core (
          this=0x77ffa80d5a50, thd=0x77ffa8000dd0, nextp=0x7fffe009ba7c, 
          open_tables=false, instr=0x77ffa80d5a10)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:599
      #12 0x0000555555ad46bd in sp_instr_stmt::execute (this=0x77ffa80d5a10, 
          thd=0x77ffa8000dd0, nextp=0x7fffe009ba7c)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:1183
      #13 0x0000555555628a3e in sp_head::execute (this=0x77ffa80d43b0, 
          thd=0x77ffa8000dd0, merge_da_on_success=true)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:1337
      #14 0x000055555562acf2 in sp_head::execute_function (this=0x77ffa80d43b0, 
          thd=0x77ffa8000dd0, argp=0x0, argcount=0, return_value_fld=0x77ffa80ce490, 
          func_ctx=0x77ffa80bf2b8, call_arena=0x77ffa80c4a20)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:2114
      #15 0x0000555555cd3ff2 in Item_sp::execute_impl (this=0x77ffa80bf250, 
          thd=0x77ffa8000dd0, args=0x0, arg_count=0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:3158
      #16 0x0000555555cd39dd in Item_sp::execute (this=0x77ffa80bf250, 
          thd=0x77ffa8000dd0, null_value=0x77ffa80bf206, args=0x0, arg_count=0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:3029
      #17 0x0000555555d66029 in Item_func_sp::execute (this=0x77ffa80bf190)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item_func.cc:6780
      #18 0x0000555555d6fc24 in Item_func_sp::val_int (this=0x77ffa80bf190)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item_func.h:4359
      #19 0x0000555555ce2e62 in Item::save_int_in_field (this=0x77ffa80bf190, 
          field=0x77ffa80e71e0, no_conversions=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:7539
      #20 0x0000555555af193c in Type_handler_int_result::Item_save_in_field (
          this=0x55555845eaa0 <type_handler_slong>, item=0x77ffa80bf190, 
          field=0x77ffa80e71e0, no_conversions=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_type.cc:4512
      #21 0x0000555555ce2faf in Item::save_in_field (this=0x77ffa80bf190, 
          field=0x77ffa80e71e0, no_conversions=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:7566
      #22 0x0000555555c5d2f4 in Field::sp_prepare_and_store_item (
          this=0x77ffa80e71e0, thd=0x77ffa8000dd0, value=0x77ffa80bf410)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/field.cc:1533
      #23 0x00005555556258fe in THD::sp_eval_expr (this=0x77ffa8000dd0, 
          result_field=0x77ffa80e71e0, expr_item_ptr=0x77ffa80bf410)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:452
      #24 0x00005555556401f5 in sp_rcontext::set_variable (this=0x77ffa80e65c0, 
          thd=0x77ffa8000dd0, idx=0, value=0x77ffa80bf410)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_rcontext.cc:676
      #25 0x0000555555ad4d21 in sp_instr_set::exec_core (this=0x77ffa80bf350, 
          thd=0x77ffa8000dd0, nextp=0x7fffe009ca1c)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:1314
      #26 0x0000555555ad2a25 in sp_lex_keeper::reset_lex_and_exec_core (
          this=0x77ffa80bf390, thd=0x77ffa8000dd0, nextp=0x7fffe009ca1c, 
          open_tables=true, instr=0x77ffa80bf350, rerun_the_same_instr=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:420
      #27 0x0000555555ad30ef in sp_lex_keeper::validate_lex_and_exec_core (
          this=0x77ffa80bf390, thd=0x77ffa8000dd0, nextp=0x7fffe009ca1c, 
          open_tables=true, instr=0x77ffa80bf350)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:599
      #28 0x0000555555ad4c5e in sp_instr_set::execute (this=0x77ffa80bf350, 
          thd=0x77ffa8000dd0, nextp=0x7fffe009ca1c)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:1301
      #29 0x0000555555628a3e in sp_head::execute (this=0x77ffa80bd920, 
          thd=0x77ffa8000dd0, merge_da_on_success=true)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:1337
      #30 0x000055555562acf2 in sp_head::execute_function (this=0x77ffa80bd920, 
          thd=0x77ffa8000dd0, argp=0x0, argcount=0, return_value_fld=0x77ffa8091aa0, 
          func_ctx=0x77ffa80915f8, call_arena=0x77ffa80b59e0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:2114
      #31 0x0000555555cd3ff2 in Item_sp::execute_impl (this=0x77ffa8091590, 
          thd=0x77ffa8000dd0, args=0x0, arg_count=0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:3158
      #32 0x0000555555cd39dd in Item_sp::execute (this=0x77ffa8091590, 
          thd=0x77ffa8000dd0, null_value=0x77ffa8091546, args=0x0, arg_count=0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:3029
      #33 0x0000555555d66029 in Item_func_sp::execute (this=0x77ffa80914d0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item_func.cc:6780
      #34 0x0000555555d6fc24 in Item_func_sp::val_int (this=0x77ffa80914d0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item_func.h:4359
      #35 0x0000555555ce2e62 in Item::save_int_in_field (this=0x77ffa80914d0, 
          field=0x77ffa8037490, no_conversions=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:7539
      #36 0x0000555555af193c in Type_handler_int_result::Item_save_in_field (
          this=0x55555845eaa0 <type_handler_slong>, item=0x77ffa80914d0, 
          field=0x77ffa8037490, no_conversions=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_type.cc:4512
      #37 0x0000555555ce2faf in Item::save_in_field (this=0x77ffa80914d0, 
          field=0x77ffa8037490, no_conversions=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/item.cc:7566
      #38 0x0000555555c5d2f4 in Field::sp_prepare_and_store_item (
          this=0x77ffa8037490, thd=0x77ffa8000dd0, value=0x77ffa8091750)
      #39 0x00005555556258fe in THD::sp_eval_expr (this=0x77ffa8000dd0, 
          result_field=0x77ffa8037490, expr_item_ptr=0x77ffa8091750)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:452
      #40 0x00005555556401f5 in sp_rcontext::set_variable (this=0x77ffa8036870, 
          thd=0x77ffa8000dd0, idx=0, value=0x77ffa8091750)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_rcontext.cc:676
      #41 0x0000555555ad4d21 in sp_instr_set::exec_core (this=0x77ffa8091690, 
          thd=0x77ffa8000dd0, nextp=0x7fffe009d9bc)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:1314
      #42 0x0000555555ad2a25 in sp_lex_keeper::reset_lex_and_exec_core (
          this=0x77ffa80916d0, thd=0x77ffa8000dd0, nextp=0x7fffe009d9bc, 
          open_tables=true, instr=0x77ffa8091690, rerun_the_same_instr=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:420
      #43 0x0000555555ad30ef in sp_lex_keeper::validate_lex_and_exec_core (
          this=0x77ffa80916d0, thd=0x77ffa8000dd0, nextp=0x7fffe009d9bc, 
          open_tables=true, instr=0x77ffa8091690)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:599
      #44 0x0000555555ad4c5e in sp_instr_set::execute (this=0x77ffa8091690, 
          thd=0x77ffa8000dd0, nextp=0x7fffe009d9bc)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_instr.cc:1301
      #45 0x0000555555628a3e in sp_head::execute (this=0x77ffa808fe00, 
          thd=0x77ffa8000dd0, merge_da_on_success=true)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:1337
      #46 0x000055555562bb0d in sp_head::execute_procedure (this=0x77ffa808fe00, 
          thd=0x77ffa8000dd0, args=0x77ffa8006558)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sp_head.cc:2382
      #47 0x0000555555771d1f in do_execute_sp (thd=0x77ffa8000dd0, sp=0x77ffa808fe00)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:3087
      #48 0x0000555555772a72 in Sql_cmd_call::execute (this=0x77ffa8035690, 
          thd=0x77ffa8000dd0)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:3325
      #49 0x000055555577d21b in mysql_execute_command (thd=0x77ffa8000dd0, 
          is_called_from_prepared_stmt=false)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:5911
      #50 0x0000555555783c19 in mysql_parse (thd=0x77ffa8000dd0, 
          rawbuf=0x77ffa80353f0 "CALL p1", length=7, parser_state=0x7fffe009ef30)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:7968
      #51 0x000055555576e3bc in dispatch_command (command=COM_QUERY,
          thd=0x77ffa8000dd0, packet=0x77ffa800c511 "CALL p1", packet_length=7, 
          blocking=true)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:1903
      #52 0x000055555576cacd in do_command (thd=0x77ffa8000dd0, blocking=true)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_parse.cc:1437
      #53 0x00005555559bf0cd in do_handle_one_connection (connect=0x55555982e360, 
          put_in_cache=true)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_connect.cc:1514
      #54 0x00005555559bee1a in handle_one_connection (arg=0x55555982e360)
          at /home/bar/maria-git/13.1.m39518.fnc5/sql/sql_connect.cc:1426
      #55 0x00005555560681f0 in pfs_spawn_thread (arg=0x555559809aa0)
          at /home/bar/maria-git/13.1.m39518.fnc5/storage/perfschema/pfs.cc:2198
      #56 0x00007ffff7080f34 in start_thread () from /lib64/libc.so.6
      #57 0x00007ffff710436c in __clone3 () from /lib64/libc.so.6
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Alexander Barkov Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 5h 2m
                  5h 2m
                  Remaining:
                  0d
                  Logged:
                  Time Not Required
                  Not Specified

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.