Crash in cp_buffer_from_ref with derived_with_keys and two views
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
Critical
|
Igor Babaev |
Bug Description
This query:
SELECT v1.a
FROM v1
JOIN v2 ON ( v2.b = v1.b )
ORDER BY 1;
crashes when executed with derived_
backtrace:
#4 <signal handler called>
#5 0x08346142 in cp_buffer_from_ref (thd=0xae746e0, table=0xae526208, ref=0xae531440) at sql_select.cc:18594
#6 0x083d2363 in get_quick_
#7 0x08344e81 in create_sort_index (thd=0xae746e0, join=0xae52b5e0, order=0xae513ac8, filesort_
select_
#8 0x08321a4a in JOIN::exec (this=0xae52b5e0) at sql_select.cc:2622
#9 0x0832252a in mysql_select (thd=0xae746e0, rref_pointer_
order=
at sql_select.cc:2900
#10 0x0831a2fb in handle_select (thd=0xae746e0, lex=0xae75de4, result=0xae514e88, setup_tables_
#11 0x082b4a88 in execute_
#12 0x082ab845 in mysql_execute_
#13 0x082b70b7 in mysql_parse (thd=0xae746e0, rawbuf=0xae512ec0 "SELECT v1.a\nFROM v1\nJOIN v2 ON ( v2.b = v1.b )\nORDER BY 1", length=57,
found_
#14 0x082a9494 in dispatch_command (command=COM_QUERY, thd=0xae746e0, packet=0xaecd321 "SELECT v1.a\nFROM v1\nJOIN v2 ON ( v2.b = v1.b )\nORDER BY 1",
packet_
#15 0x082a88ef in do_command (thd=0xae746e0) at sql_parse.cc:916
#16 0x082a58d3 in handle_
#17 0x00821919 in start_thread () from /lib/libpthread
#18 0x00453cce in clone () from /lib/libc.so.6
explain:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL key0 NULL NULL NULL 2 Using where; Using filesort
1 PRIMARY <derived3> ref key0 key0 5 v1.b 2
3 DERIVED t2 ALL NULL NULL NULL NULL 3
2 DERIVED t1 ALL NULL NULL NULL NULL 2
optimizer switch: derived_
full switch: index_merge=
bzr version-info:
revision-id: <email address hidden>
date: 2011-10-18 22:50:17 +0300
build-date: 2011-10-19 16:42:33 +0300
revno: 3241
branch-nick: maria-5.3
test case:
INSERT INTO t1 VALUES ('2005-03-24 07:33',
CREATE TABLE t2 ( b varchar(1)) ;
INSERT INTO t2 VALUES ('p'),('j'),('c');
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
SET SESSION optimizer_switch = 'derived_
SELECT v1.a
FROM v1
JOIN v2 ON ( v2.b = v1.b )
ORDER BY 1;
Changed in maria: | |
milestone: | none → 5.3 |
assignee: | nobody → Igor Babaev (igorb-seattle) |
Changed in maria: | |
status: | New → Confirmed |
importance: | Undecided → Critical |
Changed in maria: | |
status: | Confirmed → In Progress |
Changed in maria: | |
status: | In Progress → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
Complete test case:
CREATE TABLE t1 ( a datetime, b varchar(1)) ; 'j'),(' 2003-06- 13 23:19','c');
INSERT INTO t1 VALUES ('2005-03-24 07:33',
CREATE TABLE t2 ( b varchar(1)) ;
INSERT INTO t2 VALUES ('p'),('j'),('c');
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
SET SESSION optimizer_switch = 'derived_ with_keys= on';
SELECT v1.a
FROM v1
JOIN v2 ON ( v2.b = v1.b ) ORDER BY 1;