Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT, UBSAN runtime error: member call on null pointer of type 'struct TABLE_LIST' in Item_param::save_in_field
#10 0x0000562f97afe73b in mysql_create_table_no_lock (thd=0x7f3268000b00, db=0x7f3268158690 "test", table_name=0x7f3268158048 "t1", create_info=0x7f327a8a7630, alter_info=0x7f327a8a7580, is_trans=0x7f327a8a728e, create_table_mode=0) at /data/src/10.2/sql/sql_table.cc:5012
#11 0x0000562f97afe9af in mysql_create_table (thd=0x7f3268000b00, create_table=0x7f3268158080, create_info=0x7f327a8a7630, alter_info=0x7f327a8a7580) at /data/src/10.2/sql/sql_table.cc:5075
#12 0x0000562f97a36e9b in mysql_execute_command (thd=0x7f3268000b00) at /data/src/10.2/sql/sql_parse.cc:3983
#13 0x0000562f97a60b18 in Prepared_statement::execute (this=0x7f32680066b0, expanded_query=0x7f327a8a83d0, open_cursor=false) at /data/src/10.2/sql/sql_prepare.cc:4774
#14 0x0000562f97a5ee73 in Prepared_statement::execute_loop (this=0x7f32680066b0, expanded_query=0x7f327a8a83d0, open_cursor=false, packet=0x0, packet_end=0x0) at /data/src/10.2/sql/sql_prepare.cc:4203
#15 0x0000562f97a6106e in Prepared_statement::execute_immediate (this=0x7f32680066b0, query=0x7f3268012750 "CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)", query_len=44) at /data/src/10.2/sql/sql_prepare.cc:4898
#16 0x0000562f97a5bc0f in mysql_sql_stmt_execute_immediate (thd=0x7f3268000b00) at /data/src/10.2/sql/sql_prepare.cc:2893
#17 0x0000562f97a35a04 in mysql_execute_command (thd=0x7f3268000b00) at /data/src/10.2/sql/sql_parse.cc:3485
#18 0x0000562f97a433a8 in mysql_parse (thd=0x7f3268000b00, rawbuf=0x7f3268012640 "EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT", length=78, parser_state=0x7f327a8a9200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7914
#19 0x0000562f97a31263 in dispatch_command (command=COM_QUERY, thd=0x7f3268000b00, packet=0x7f326816b521 "EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT", packet_length=78, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1815
#20 0x0000562f97a2fbc6 in do_command (thd=0x7f3268000b00) at /data/src/10.2/sql/sql_parse.cc:1369
#21 0x0000562f97b7e480 in do_handle_one_connection (connect=0x562f99f6c400) at /data/src/10.2/sql/sql_connect.cc:1335
#22 0x0000562f97b7e20d in handle_one_connection (arg=0x562f99f6c400) at /data/src/10.2/sql/sql_connect.cc:1241
#23 0x0000562f97f9e3de in pfs_spawn_thread (arg=0x562f99f46ec0) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#24 0x00007f32822a4494 in start_thread (arg=0x7f327a8aa700) at pthread_create.c:333
#25 0x00007f328068a93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
Note, the queries are incorrect. DEFAULT/IGNORE should not be allowed as bind parameters in this context.
The expected behaviour should be to return an error, e.g. like this query does:
MariaDB [test]> EXECUTE IMMEDIATE 'SELECT 1=?' USING DEFAULT;
ERROR 4032 (HY000): Default/ignore value isnot supported for such parameter usage
Attachments
Issue Links
relates to
MDEV-21028Server crashes in Query_arena::set_query_arena upon SELECT from view
[Current thread is 1 (Thread 0x15234b3c7700 (LWP 121254))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1 0x000056217ea96757 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:518
#2 0x000056217e45881a in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:329
#3 <signal handler called>
#4 TABLE_LIST::top_table (this=0x0) at /test/10.5_opt/sql/table.h:2535
#5 Item_param::save_in_field (this=0x15232810ee58, field=0x152328049e00, no_conversions=<optimized out>) at /test/10.5_opt/sql/item.cc:4274
#6 0x000056217e4372b3 in Field::sp_prepare_and_store_item (this=0x152328049e00, thd=0x152328012018, value=<optimized out>) at /test/10.5_opt/sql/field.cc:1430
#7 0x000056217e1c9097 in THD::sp_eval_expr (this=this@entry=0x152328012018, result_field=<optimized out>, expr_item_ptr=<optimized out>) at /test/10.5_opt/sql/sp_head.cc:431
#8 0x000056217e1d5c53 in sp_rcontext::set_variable (this=this@entry=0x152328048ac8, thd=thd@entry=0x152328012018, idx=idx@entry=0, value=<optimized out>) at /test/10.5_opt/sql/sp_rcontext.cc:639
#9 0x000056217e1cbb2d in sp_rcontext::set_parameter (value=<optimized out>, var_idx=<optimized out>, thd=<optimized out>, this=<optimized out>) at /test/10.5_opt/sql/sp_rcontext.h:191
#10 sp_head::execute_procedure (this=0x152328051030, thd=thd@entry=0x152328012018, args=0x15232810dfc0) at /test/10.5_opt/sql/sp_head.cc:2353
#11 0x000056217e260f55 in do_execute_sp (thd=thd@entry=0x152328012018, sp=sp@entry=0x152328051030) at /test/10.5_opt/sql/sql_parse.cc:3013
#12 0x000056217e2615e6 in Sql_cmd_call::execute (this=0x15232810ec60, thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:3258
#13 0x000056217e263010 in mysql_execute_command (thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:5912
#14 0x000056217e280975 in Prepared_statement::execute (this=this@entry=0x15232807c418, expanded_query=expanded_query@entry=0x15234b3c5d60, open_cursor=open_cursor@entry=false) at /test/10.5_opt/sql/sql_prepare.cc:4786
#15 0x000056217e280a72 in Prepared_statement::execute_loop (this=0x15232807c418, expanded_query=0x15234b3c5d60, open_cursor=<optimized out>, packet=<optimized out>, packet_end=<optimized out>) at /test/10.5_opt/sql/sql_prepare.cc:4275
#16 0x000056217e280f5b in Prepared_statement::execute_immediate (this=this@entry=0x15232807c418, query=<optimized out>, query_len=9) at /test/10.5_opt/sql/sql_prepare.cc:4914
#17 0x000056217e2811ae in mysql_sql_stmt_execute_immediate (thd=thd@entry=0x152328012018) at /test/10.5_opt/sql/sql_prepare.cc:2941
#18 0x000056217e263564 in mysql_execute_command (thd=thd@entry=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:3907
#19 0x000056217e26a27c in mysql_parse (thd=0x152328012018, rawbuf=<optimized out>, length=43, parser_state=0x15234b3c64d0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7957
#20 0x000056217e25f8a5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x152328012018, packet=packet@entry=0x15232803a019 "EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT", packet_length=packet_length@entry=43, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1839
#21 0x000056217e25db36 in do_command (thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:1358
#22 0x000056217e3522ee in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1523490329b8, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1422
#23 0x000056217e352494 in handle_one_connection (arg=arg@entry=0x1523490329b8) at /test/10.5_opt/sql/sql_connect.cc:1319
#24 0x000056217e6be5ea in pfs_spawn_thread (arg=0x15234904b018) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
#25 0x000015234a7ee6db in start_thread (arg=0x15234b3c7700) at pthread_create.c:463
#26 0x0000152349bec88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Roel Van de Paar
added a comment - - edited
CREATE PROCEDURE p(IN c INT) SET max_connections=100;
EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT;
The encapsulated SET is not important; it can be anything else.
Leads to:
10.5.3 64488a6f2dd6aa43462292b757e783cfba11a8c6
Core was generated by `/test/MD050520-mariadb-10.5.3-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x15234b3c7700 (LWP 121254))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1 0x000056217ea96757 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:518
#2 0x000056217e45881a in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:329
#3 <signal handler called>
#4 TABLE_LIST::top_table (this=0x0) at /test/10.5_opt/sql/table.h:2535
#5 Item_param::save_in_field (this=0x15232810ee58, field=0x152328049e00, no_conversions=<optimized out>) at /test/10.5_opt/sql/item.cc:4274
#6 0x000056217e4372b3 in Field::sp_prepare_and_store_item (this=0x152328049e00, thd=0x152328012018, value=<optimized out>) at /test/10.5_opt/sql/field.cc:1430
#7 0x000056217e1c9097 in THD::sp_eval_expr (this=this@entry=0x152328012018, result_field=<optimized out>, expr_item_ptr=<optimized out>) at /test/10.5_opt/sql/sp_head.cc:431
#8 0x000056217e1d5c53 in sp_rcontext::set_variable (this=this@entry=0x152328048ac8, thd=thd@entry=0x152328012018, idx=idx@entry=0, value=<optimized out>) at /test/10.5_opt/sql/sp_rcontext.cc:639
#9 0x000056217e1cbb2d in sp_rcontext::set_parameter (value=<optimized out>, var_idx=<optimized out>, thd=<optimized out>, this=<optimized out>) at /test/10.5_opt/sql/sp_rcontext.h:191
#10 sp_head::execute_procedure (this=0x152328051030, thd=thd@entry=0x152328012018, args=0x15232810dfc0) at /test/10.5_opt/sql/sp_head.cc:2353
#11 0x000056217e260f55 in do_execute_sp (thd=thd@entry=0x152328012018, sp=sp@entry=0x152328051030) at /test/10.5_opt/sql/sql_parse.cc:3013
#12 0x000056217e2615e6 in Sql_cmd_call::execute (this=0x15232810ec60, thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:3258
#13 0x000056217e263010 in mysql_execute_command (thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:5912
#14 0x000056217e280975 in Prepared_statement::execute (this=this@entry=0x15232807c418, expanded_query=expanded_query@entry=0x15234b3c5d60, open_cursor=open_cursor@entry=false) at /test/10.5_opt/sql/sql_prepare.cc:4786
#15 0x000056217e280a72 in Prepared_statement::execute_loop (this=0x15232807c418, expanded_query=0x15234b3c5d60, open_cursor=<optimized out>, packet=<optimized out>, packet_end=<optimized out>) at /test/10.5_opt/sql/sql_prepare.cc:4275
#16 0x000056217e280f5b in Prepared_statement::execute_immediate (this=this@entry=0x15232807c418, query=<optimized out>, query_len=9) at /test/10.5_opt/sql/sql_prepare.cc:4914
#17 0x000056217e2811ae in mysql_sql_stmt_execute_immediate (thd=thd@entry=0x152328012018) at /test/10.5_opt/sql/sql_prepare.cc:2941
#18 0x000056217e263564 in mysql_execute_command (thd=thd@entry=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:3907
#19 0x000056217e26a27c in mysql_parse (thd=0x152328012018, rawbuf=<optimized out>, length=43, parser_state=0x15234b3c64d0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7957
#20 0x000056217e25f8a5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x152328012018, packet=packet@entry=0x15232803a019 "EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT", packet_length=packet_length@entry=43, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1839
#21 0x000056217e25db36 in do_command (thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:1358
#22 0x000056217e3522ee in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1523490329b8, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1422
#23 0x000056217e352494 in handle_one_connection (arg=arg@entry=0x1523490329b8) at /test/10.5_opt/sql/sql_connect.cc:1319
#24 0x000056217e6be5ea in pfs_spawn_thread (arg=0x15234904b018) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
#25 0x000015234a7ee6db in start_thread (arg=0x15234b3c7700) at pthread_create.c:463
#26 0x0000152349bec88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Bug confirmed present in:
MariaDB: 10.2.32 (dbg), 10.2.32 (opt), 10.3.23 (dbg), 10.3.23 (opt), 10.4.13 (dbg), 10.4.13 (opt), 10.5.2 (dbg), 10.5.2 (opt), 10.5.3 (dbg), 10.5.3 (opt)
Bug confirmed not present in:
MariaDB: 10.1.45 (dbg), 10.1.45 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
10.4 version: check evaluablity on Field::make_empty_rec_store_default_value
10.2 version changed with ASSERTS.
Oleksandr Byelkin
added a comment - there are 2 version 10.2 and 10.4:
commit f9ee717c3440645b2b34857fe0297e7230332bcd (HEAD > bb-10.2 MDEV-15703 )
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 14:36:41 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Check usage of IGNORE out of allowed commands.
Check that table is opened for DEFAULT.
commit 4a499d8b2fca929db0f4f9080f360284f49c3e5a (HEAD > bb-10.4 MDEV-15703 , origin/bb-10.4- MDEV-15703 )
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 15:37:55 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
10.4 version: check evaluablity on Field::make_empty_rec_store_default_value
10.2 version changed with ASSERTS.
EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING DEFAULT;
EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING IGNORE;
Alexander Barkov
added a comment - - edited More similar crashes:
EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING DEFAULT ;
EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING IGNORE ;
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
Oleksandr Byelkin
added a comment - commit d476d9bc84b2267fb093e70563a15adaa874ae2b (HEAD > bb-10.2 MDEV-15703 , origin/bb-10.2- MDEV-15703 )
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Fri Jul 10 15:17:07 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
part 2: check that expressions are evaluable for
making empty row and assigning PS variable
(Item::is_evaluable_expression() bakported from 10.4).
commit 9d26f1d10a71732cf1d03906cfde809810058f98
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 14:36:41 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
Oleksandr Byelkin
added a comment - commit 70d1c6337c9d548d04f771c1762d8bfa08f415e9 (HEAD > bb-10.2 MDEV-15703 , origin/bb-10.2- MDEV-15703 )
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Fri Jul 10 15:17:07 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
part 2:
check that expressions are evaluable for
making empty row and assigning PS variable
Item::raise_error_not_evaluable() bakported from 10.4 and made vitrual
Item::is_evaluable_expression() bakported from 10.4
Item::check_is_evaluable_expression_or_error() bakported from 10.4
Item::Print bakported from 10.4
commit 9d26f1d10a71732cf1d03906cfde809810058f98
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 14:36:41 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
The other problem in default found due to asserts but repeatable on 10.2 vanilla:
CREATE TABLE t1 (a INT, b INT default a);
INSERT into t1 values (1,2),(2,3);
CREATE TABLE t2 (a INT, b INT default a);
INSERT into t2 values (1,10),(2,30);
UPDATE t1,t2 SET t1.b = DEFAULT, t2.b = DEFAULT WHERE t1.a=t2.a;
SELECT * from t1;
SELECT * from t2;
# Cleanup
DROP TABLE t1, t2;
Oleksandr Byelkin
added a comment - The other problem in default found due to asserts but repeatable on 10.2 vanilla:
CREATE TABLE t1 (a INT, b INT default a);
INSERT into t1 values (1,2),(2,3);
CREATE TABLE t2 (a INT, b INT default a);
INSERT into t2 values (1,10),(2,30);
UPDATE t1,t2 SET t1.b = DEFAULT, t2.b = DEFAULT WHERE t1.a=t2.a;
SELECT * from t1;
SELECT * from t2;
# Cleanup
DROP TABLE t1, t2;
The crash is the same as for https://jira.mariadb.org/browse/MDEV-21028 (because in both cases we try to apply complex default to a temporary table) but bugs are different.
Oleksandr Byelkin
added a comment - The crash is the same as for https://jira.mariadb.org/browse/MDEV-21028 (because in both cases we try to apply complex default to a temporary table) but bugs are different.
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
Oleksandr Byelkin
added a comment - commit bc73b455ba255d5fd6b277a3477ab47d368241a1
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Fri Jul 10 15:17:07 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
part 2:
check that expressions are evaluable for
making empty row and assigning PS variable
correctly handling writing to a temporary tabe during multi-update
by setting associated field
Item::raise_error_not_evaluable() bakported from 10.4 and made vitrual
Item::is_evaluable_expression() bakported from 10.4
Item::check_is_evaluable_expression_or_error() bakported from 10.4
Item::Print bakported from 10.4
commit 7311586ca259b619cac949da70e79ddd9f8f6da8
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 14:36:41 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
part 2:
- check that expressions are evaluable for
making empty row and assigning PS variable
- correctly handling writing to a temporary tabe during multi-update
by setting associated field
- Item::raise_error_not_evaluable() bakported from 10.4 and made vitrual
- Item::is_evaluable_expression() bakported from 10.4
- Item::check_is_evaluable_expression_or_error() bakported from 10.4
commit f584d567dbb499485b1d1122e4370db43cb27c4c
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 14:36:41 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
Oleksandr Byelkin
added a comment - - edited I fixed small issues, answered big one, but what to do with big ones I have no idea (partially because thay was requirements of first reviews)
commit 6d02ddda888dc85a91f5d5e6a92696a7d69a5b12 (HEAD -> bb-10.2-MDEV-15703, origin/bb-10.2-MDEV-15703)
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Tue Jul 14 10:12:22 2020 +0200
Fix of typo in the comment.
commit 62c35fe93e14ff469007dac2488f5c34a76ce9de
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Fri Jul 10 15:17:07 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
part 2:
- check that expressions are evaluable for
making empty row and assigning PS variable
- correctly handling writing to a temporary tabe during multi-update
by setting associated field
- Item::raise_error_not_evaluable() bakported from 10.4 and made vitrual
- Item::is_evaluable_expression() bakported from 10.4
- Item::check_is_evaluable_expression_or_error() bakported from 10.4
commit f584d567dbb499485b1d1122e4370db43cb27c4c
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Thu Jul 9 14:36:41 2020 +0200
MDEV-15703 Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
Part 1: make better asserts.
CREATEPROCEDURE p(IN c INT) SET max_connections=100;
EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT;
Roel Van de Paar
added a comment - Please also test any fixes with:
CREATE PROCEDURE p( IN c INT ) SET max_connections=100;
EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT ;
Roel Van de Paar
added a comment - Please also test any fixes with:
CREATE PROCEDURE p1( IN i INT ) EXECUTE s;
EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE ;
CREATE PROCEDURE p(IN c INT) SET max_connections=100;
EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT;
The encapsulated SET is not important; it can be anything else.
Leads to:
10.5.3 64488a6f2dd6aa43462292b757e783cfba11a8c6
Core was generated by `/test/MD050520-mariadb-10.5.3-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x15234b3c7700 (LWP 121254))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1 0x000056217ea96757 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:518
#2 0x000056217e45881a in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:329
#3 <signal handler called>
#4 TABLE_LIST::top_table (this=0x0) at /test/10.5_opt/sql/table.h:2535
#5 Item_param::save_in_field (this=0x15232810ee58, field=0x152328049e00, no_conversions=<optimized out>) at /test/10.5_opt/sql/item.cc:4274
#6 0x000056217e4372b3 in Field::sp_prepare_and_store_item (this=0x152328049e00, thd=0x152328012018, value=<optimized out>) at /test/10.5_opt/sql/field.cc:1430
#7 0x000056217e1c9097 in THD::sp_eval_expr (this=this@entry=0x152328012018, result_field=<optimized out>, expr_item_ptr=<optimized out>) at /test/10.5_opt/sql/sp_head.cc:431
#8 0x000056217e1d5c53 in sp_rcontext::set_variable (this=this@entry=0x152328048ac8, thd=thd@entry=0x152328012018, idx=idx@entry=0, value=<optimized out>) at /test/10.5_opt/sql/sp_rcontext.cc:639
#9 0x000056217e1cbb2d in sp_rcontext::set_parameter (value=<optimized out>, var_idx=<optimized out>, thd=<optimized out>, this=<optimized out>) at /test/10.5_opt/sql/sp_rcontext.h:191
#10 sp_head::execute_procedure (this=0x152328051030, thd=thd@entry=0x152328012018, args=0x15232810dfc0) at /test/10.5_opt/sql/sp_head.cc:2353
#11 0x000056217e260f55 in do_execute_sp (thd=thd@entry=0x152328012018, sp=sp@entry=0x152328051030) at /test/10.5_opt/sql/sql_parse.cc:3013
#12 0x000056217e2615e6 in Sql_cmd_call::execute (this=0x15232810ec60, thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:3258
#13 0x000056217e263010 in mysql_execute_command (thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:5912
#14 0x000056217e280975 in Prepared_statement::execute (this=this@entry=0x15232807c418, expanded_query=expanded_query@entry=0x15234b3c5d60, open_cursor=open_cursor@entry=false) at /test/10.5_opt/sql/sql_prepare.cc:4786
#15 0x000056217e280a72 in Prepared_statement::execute_loop (this=0x15232807c418, expanded_query=0x15234b3c5d60, open_cursor=<optimized out>, packet=<optimized out>, packet_end=<optimized out>) at /test/10.5_opt/sql/sql_prepare.cc:4275
#16 0x000056217e280f5b in Prepared_statement::execute_immediate (this=this@entry=0x15232807c418, query=<optimized out>, query_len=9) at /test/10.5_opt/sql/sql_prepare.cc:4914
#17 0x000056217e2811ae in mysql_sql_stmt_execute_immediate (thd=thd@entry=0x152328012018) at /test/10.5_opt/sql/sql_prepare.cc:2941
#18 0x000056217e263564 in mysql_execute_command (thd=thd@entry=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:3907
#19 0x000056217e26a27c in mysql_parse (thd=0x152328012018, rawbuf=<optimized out>, length=43, parser_state=0x15234b3c64d0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7957
#20 0x000056217e25f8a5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x152328012018, packet=packet@entry=0x15232803a019 "EXECUTE IMMEDIATE 'CALL p(?)' USING DEFAULT", packet_length=packet_length@entry=43, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1839
#21 0x000056217e25db36 in do_command (thd=0x152328012018) at /test/10.5_opt/sql/sql_parse.cc:1358
#22 0x000056217e3522ee in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1523490329b8, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1422
#23 0x000056217e352494 in handle_one_connection (arg=arg@entry=0x1523490329b8) at /test/10.5_opt/sql/sql_connect.cc:1319
#24 0x000056217e6be5ea in pfs_spawn_thread (arg=0x15234904b018) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
#25 0x000015234a7ee6db in start_thread (arg=0x15234b3c7700) at pthread_create.c:463
#26 0x0000152349bec88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Bug confirmed present in:
MariaDB: 10.2.32 (dbg), 10.2.32 (opt), 10.3.23 (dbg), 10.3.23 (opt), 10.4.13 (dbg), 10.4.13 (opt), 10.5.2 (dbg), 10.5.2 (opt), 10.5.3 (dbg), 10.5.3 (opt)
Bug confirmed not present in:
MariaDB: 10.1.45 (dbg), 10.1.45 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)