[MDEV-3189] LP:878199 - Crash in cp_buffer_from_ref with derived_with_keys and two views Created: 2011-10-19  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Philip Stoev (Inactive) Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug878199.xml    

 Description   

This query:

SELECT v1.a
FROM v1
JOIN v2 ON ( v2.b = v1.b )
ORDER BY 1;

crashes when executed with derived_with_keys=on

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_select_for_ref (thd=0xae746e0, table=0xae526208, ref=0xae531440, records=2) at opt_range.cc:10301
#7 0x08344e81 in create_sort_index (thd=0xae746e0, join=0xae52b5e0, order=0xae513ac8, filesort_limit=18446744073709551615,
select_limit=18446744073709551615, is_order_by=false) at sql_select.cc:18098
#8 0x08321a4a in JOIN::exec (this=0xae52b5e0) at sql_select.cc:2622
#9 0x0832252a in mysql_select (thd=0xae746e0, rref_pointer_array=0xae7625c, tables=0xae513060, wild_num=0, fields=..., conds=0x0, og_num=1,
order=0xae513ac8, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xae514e88, unit=0xae75e40, select_lex=0xae76120)
at sql_select.cc:2900
#10 0x0831a2fb in handle_select (thd=0xae746e0, lex=0xae75de4, result=0xae514e88, setup_tables_done_option=0) at sql_select.cc:283
#11 0x082b4a88 in execute_sqlcom_select (thd=0xae746e0, all_tables=0xae513060) at sql_parse.cc:5112
#12 0x082ab845 in mysql_execute_command (thd=0xae746e0) at sql_parse.cc:2250
#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_semicolon=0xae8a0228) at sql_parse.cc:6112
#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_length=57) at sql_parse.cc:1221
#15 0x082a88ef in do_command (thd=0xae746e0) at sql_parse.cc:916
#16 0x082a58d3 in handle_one_connection (arg=0xae746e0) at sql_connect.cc:1191
#17 0x00821919 in start_thread () from /lib/libpthread.so.0
#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_with_keys=on

full switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=on,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on

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','j'),('2003-06-13 23:19','c');

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;



 Comments   
Comment by Philip Stoev (Inactive) [ 2011-10-20 ]

Re: Crash in cp_buffer_from_ref with derived_with_keys and two views
Complete test case:

CREATE TABLE t1 ( a datetime, b varchar(1)) ;
INSERT INTO t1 VALUES ('2005-03-24 07:33','j'),('2003-06-13 23:19','c');

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;

Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ]

Launchpad bug id: 878199

Generated at Thu Feb 08 06:46:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.