[MDEV-3906] Exists2In: Server crashes in Dependency_marker::visit_field on 2nd execution of PS with exists_to_in and NOT EXISTS subquery Created: 2012-12-01  Updated: 2023-11-02  Resolved: 2012-12-10

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

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-38 NOT EXISTS to IN (part of exists2in t... Closed

 Description   

#3  <signal handler called>
#4  0x000000000080449f in Dependency_marker::visit_field (this=0x7f768a719510, item=0x305bd58) at 10.0-exists2in/sql/item.cc:6601
#5  0x00000000007ebc38 in Item_field::enumerate_field_refs_processor (this=0x305bd58, arg=0x7f768a719510 "\260S@\001") at 10.0-exists2in/sql/item.cc:2381
#6  0x0000000000579611 in Item::walk (this=0x305bd58, processor=&virtual table offset 688, walk_subquery=false, arg=0x7f768a719510 "\260S@\001") at 10.0-exists2in/sql/item.h:1108
#7  0x00000000007f8023 in Item_ref::fix_fields (this=0x307a418, thd=0x304b8a0, reference=0x307a5b8) at 10.0-exists2in/sql/item.cc:6896
#8  0x0000000000831c62 in Item_func::fix_fields (this=0x307a528, thd=0x304b8a0, ref=0x307a758) at 10.0-exists2in/sql/item_func.cc:203
#9  0x000000000081477c in Item_cond::fix_fields (this=0x307a608, thd=0x304b8a0, ref=0x3054948) at 10.0-exists2in/sql/item_cmpfunc.cc:4337
#10 0x0000000000831c62 in Item_func::fix_fields (this=0x30548b8, thd=0x304b8a0, ref=0x30793e8) at 10.0-exists2in/sql/item_func.cc:203
#11 0x0000000000817e5c in Item_func_not::fix_fields (this=0x30548b8, thd=0x304b8a0, ref=0x30793e8) at 10.0-exists2in/sql/item_cmpfunc.cc:5412
#12 0x00000000005bfe36 in setup_conds (thd=0x304b8a0, tables=0x3053a88, leaves=..., conds=0x30793e8) at 10.0-exists2in/sql/sql_base.cc:8774
#13 0x0000000000683f4e in setup_without_group (thd=0x304b8a0, ref_pointer_array=0x3054998, tables=0x3053a88, leaves=..., fields=..., all_fields=..., conds=0x30793e8, order=0x0, group=0x0, hidden_group_fields=0x307929f, reserved=0x3075fbc) at 10.0-exists2in/sql/sql_select.cc:614
#14 0x000000000064452e in JOIN::prepare (this=0x3078f78, rref_pointer_array=0x3075fa0, tables_init=0x3053a88, wild_num=0, conds_init=0x30548b8, og_num=0, order_init=0x0, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x3075cf0, unit_arg=0x30755f8) at 10.0-exists2in/sql/sql_select.cc:769
#15 0x000000000064d0d2 in mysql_select (thd=0x304b8a0, rref_pointer_array=0x3075fa0, tables=0x3053a88, wild_num=0, fields=..., conds=0x30548b8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x2f8d748, unit=0x30755f8, select_lex=0x3075cf0) at 10.0-exists2in/sql/sql_select.cc:3187
#16 0x000000000064387e in handle_select (thd=0x304b8a0, lex=0x3075548, result=0x2f8d748, setup_tables_done_option=0) at 10.0-exists2in/sql/sql_select.cc:362
#17 0x000000000061b13b in execute_sqlcom_select (thd=0x304b8a0, all_tables=0x3053a88) at 10.0-exists2in/sql/sql_parse.cc:4937
#18 0x00000000006137a8 in mysql_execute_command (thd=0x304b8a0) at 10.0-exists2in/sql/sql_parse.cc:2421
#19 0x0000000000635b95 in Prepared_statement::execute (this=0x3097ba0, expanded_query=0x7f768a71ac30, open_cursor=false) at 10.0-exists2in/sql/sql_prepare.cc:3914
#20 0x0000000000634c2c in Prepared_statement::execute_loop (this=0x3097ba0, expanded_query=0x7f768a71ac30, open_cursor=false, packet=0x0, packet_end=0x0) at 10.0-exists2in/sql/sql_prepare.cc:3570
#21 0x0000000000632ce3 in mysql_sql_stmt_execute (thd=0x304b8a0) at 10.0-exists2in/sql/sql_prepare.cc:2732
#22 0x00000000006137d9 in mysql_execute_command (thd=0x304b8a0) at 10.0-exists2in/sql/sql_parse.cc:2431
#23 0x000000000061d9f6 in mysql_parse (thd=0x304b8a0, rawbuf=0x3096248 "EXECUTE stmt", length=12, parser_state=0x7f768a71b4e0) at 10.0-exists2in/sql/sql_parse.cc:6056
#24 0x000000000061099a in dispatch_command (command=COM_QUERY, thd=0x304b8a0, packet=0x3055ab1 "EXECUTE stmt", packet_length=12) at 10.0-exists2in/sql/sql_parse.cc:1216
#25 0x000000000060fb93 in do_command (thd=0x304b8a0) at 10.0-exists2in/sql/sql_parse.cc:945
#26 0x000000000071a57a in do_handle_one_connection (thd_arg=0x304b8a0) at 10.0-exists2in/sql/sql_connect.cc:1254

branch: 10.0-exists2in
revision-id: sanja@montyprogram.com-20121129184233-zxp9qe77tfcupomh
date: 2012-11-29 20:42:33 +0200
revno: 3486

Minimal optimizer_switch: in_to_exists=on,exists_to_in=on or materialization=on,exists_to_in=on
Full optimizer_switch (default + exists_to_in=on):

index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=off,exists_to_in=on

Test case:

SET optimizer_switch='exists_to_in=on';
 
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(7);
 
PREPARE stmt FROM ' 
SELECT * FROM t1 AS alias 
WHERE NOT EXISTS ( SELECT * FROM t1 WHERE a = alias.a ) 
';
 
EXECUTE stmt;
EXECUTE stmt;



 Comments   
Comment by Oleksandr Byelkin [ 2012-12-07 ]

The problem is that in case of NOT we put IS NOT NULL befoe Item_in_optimizer with reference on its left expression. On the first execution the left expression is already "fixed". But on the second IS NOT NULL fix_field() called before and so it is not fix fielded.

Comment by Oleksandr Byelkin [ 2012-12-10 ]

Fix is to allow direct references to call fixfields of its arguments.

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