Crash in do_copy_not_null with prepared statement, outer join , join_cache_level > 3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Igor Babaev |
Bug Description
If this query
SELECT *
FROM ( t2 LEFT JOIN t1 ON t1.b = t2.b )
JOIN t3 ON t1.b = t3.b
is executed twice as a prepared statement with join_cache_level>3 , the server crashes as follows:
#4 <signal handler called>
#5 0x08424c0a in do_copy_not_null (copy=0xae514304) at field_conv.cc:253
#6 0x0834ccc8 in store_key_
#7 0x082528f8 in store_key::copy (this=0xae5142f0) at sql_select.h:1269
#8 0x083439f9 in cp_buffer_from_ref (thd=0x9f126b8, table=0xae631e48, ref=0xae5140fc) at sql_select.cc:18550
#9 0x082f1ff6 in JOIN_CACHE_
#10 0x0833b10c in sub_select_cache (join=0xae52b668, join_tab=
#11 0x082f13d0 in JOIN_CACHE:
#12 0x082f118a in JOIN_CACHE:
#13 0x082f0cec in JOIN_CACHE:
#14 0x0833b042 in sub_select_cache (join=0xae52b668, join_tab=
#15 0x0833b25a in sub_select (join=0xae52b668, join_tab=
#16 0x0833ad49 in do_select (join=0xae52b668, fields=0xae529a10, table=0x0, procedure=0x0) at sql_select.cc:14735
#17 0x0831f7cb in JOIN::exec (this=0xae52b668) at sql_select.cc:2680
#18 0x0831fff8 in mysql_select (thd=0x9f126b8, rref_pointer_
order=0x0, group=0x0, having=0x0, proc_param=0x0, select_
at sql_select.cc:2901
#19 0x08317deb in handle_select (thd=0x9f126b8, lex=0xae529640, result=0xae52b5c0, setup_tables_
#20 0x082b31b9 in execute_
#21 0x082a9fbd in mysql_execute_
#22 0x08362468 in Prepared_
#23 0x08361983 in Prepared_
at sql_prepare.cc:3417
#24 0x08360253 in mysql_sql_
#25 0x082a9fe6 in mysql_execute_
#26 0x082b57f5 in mysql_parse (thd=0x9f126b8, rawbuf=0xae512ec0 "EXECUTE st1", length=11, found_semicolon
#27 0x082a7c3a in dispatch_command (command=COM_QUERY, thd=0x9f126b8, packet=0x9f6b549 "", packet_length=11) at sql_parse.cc:1211
#28 0x082a7095 in do_command (thd=0x9f126b8) at sql_parse.cc:906
#29 0x082a40fd in handle_
#30 0x00821919 in start_thread () from /lib/libpthread
#31 0x0076acce in clone () from /lib/libc.so.6
or:
#4 <signal handler called>
#5 0x08424c0a in do_copy_not_null (copy=0xae713a64) at field_conv.cc:253
#6 0x0834ccc8 in store_key_
#7 0x082528f8 in store_key::copy (this=0xae713a50) at sql_select.h:1269
#8 0x083439f9 in cp_buffer_from_ref (thd=0xa09b6b8, table=0xae721be0, ref=0xae71385c) at sql_select.cc:18550
#9 0x0834394c in cmp_buffer_with_ref (thd=0xa09b6b8, table=0xae721be0, tab_ref=0xae71385c) at sql_select.cc:18532
#10 0x0833c898 in join_read_key2 (thd=0xa09b6b8, tab=0xae7136f8, table=0xae721be0, table_ref=
#11 0x0833c82e in join_read_key (tab=0xae7136f8) at sql_select.cc:15628
#12 0x0833b477 in sub_select (join=0xae72b6f0, join_tab=
#13 0x0833bb67 in evaluate_
#14 0x0833b4ca in sub_select (join=0xae72b6f0, join_tab=
#15 0x0833bb67 in evaluate_
#16 0x0833b4ca in sub_select (join=0xae72b6f0, join_tab=
#17 0x0833ad1d in do_select (join=0xae72b6f0, fields=0xae729a98, table=0x0, procedure=0x0) at sql_select.cc:14733
#18 0x0831f7cb in JOIN::exec (this=0xae72b6f0) at sql_select.cc:2680
#19 0x0831fff8 in mysql_select (thd=0xa09b6b8, rref_pointer_
order=0x0, group=0x0, having=0x0, proc_param=0x0, select_
at sql_select.cc:2901
#20 0x08317deb in handle_select (thd=0xa09b6b8, lex=0xae7296c8, result=0xae72b428, setup_tables_
#21 0x082b31b9 in execute_
#22 0x082a9fbd in mysql_execute_
#23 0x08362468 in Prepared_
#24 0x08361983 in Prepared_
at sql_prepare.cc:3417
#25 0x08360253 in mysql_sql_
#26 0x082a9fe6 in mysql_execute_
#27 0x082b57f5 in mysql_parse (thd=0xa09b6b8, rawbuf=0xae7125f0 "EXECUTE st1", length=11, found_semicolon
#28 0x082a7c3a in dispatch_command (command=COM_QUERY, thd=0xa09b6b8, packet=0xa0f4549 "", packet_length=11) at sql_parse.cc:1211
#29 0x082a7095 in do_command (thd=0xa09b6b8) at sql_parse.cc:906
#30 0x082a40fd in handle_
#31 0x00821919 in start_thread () from /lib/libpthread
#32 0x00453cce in clone () from /lib/libc.so.6
explain:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t3 hash_ALL PRIMARY #hash#PRIMARY 4 test.t1.b 10 Using join buffer (flat, BNLH join)
1 SIMPLE t2 hash_index PRIMARY #hash#PRIMARY:
minimal switches: join_cache_level=4
full optimizer_switch: index_merge=
bzr version-info:
revision-id: <email address hidden>
date: 2011-08-29 18:16:18 +0300
build-date: 2011-09-01 10:50:00 +0300
revno: 3169
branch-nick: maria-5.3
test case:
SET SESSION join_cache_level=4;
CREATE TABLE t1 ( b int NOT NULL ) ;
INSERT INTO t1 VALUES (9),(10);
CREATE TABLE t2 ( b int NOT NULL, PRIMARY KEY (b)) ;
INSERT INTO t2 VALUES (75),(76)
CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ;
INSERT INTO t3 VALUES (0,6),(
PREPARE st1 FROM '
SELECT *
FROM ( t2 LEFT JOIN t1 ON t1.b = t2.b )
JOIN t3 ON t1.b = t3.b
';
EXECUTE st1;
EXECUTE st1;
Changed in maria: | |
milestone: | none → 5.3 |
Changed in maria: | |
status: | New → Confirmed |
importance: | Undecided → High |
assignee: | nobody → Igor Babaev (igorb-seattle) |
Changed in maria: | |
status: | Fix Committed → Fix Released |
Igor has pushed fix for this today