[MDEV-19185] Assertion `select_lex->select_number == (0x7fffffff * 2U + 1U) || select_lex->select_number == 0x7fffffff || !output || !output->get_select(select_lex->select_number) || output->get_select(select_lex->select_number)->select_lex == select_lex' failed Created: 2019-04-05  Updated: 2022-02-14  Resolved: 2019-04-05

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4
Fix Version/s: 10.4.4

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Allen Herrera
Resolution: Fixed Votes: 0
Labels: None


 Description   

set optimizer_switch="condition_pushdown_from_having=on";
 
create table t1 (pk int not null primary key, c1 varchar(64));
insert into t1 values (1,'bbb'),(2,'aaa'),(3,'ccc'),(4,	'ddd'),(5,'s'),(7,'c'),(6,'kkk'),(9,'ert'),(8,'s'),(12,'www');
create view v1 as select * from t1;
 
select pk from t1 group by  pk 
having (1 not in (select count(t1.c1) from (v1, t1)));

10.4 5da6944ea3a592efefd1adc33

mysqld: /10.4/sql/sql_select.cc:4102: bool JOIN::save_explain_data(Explain_query*, bool, bool, bool, bool): Assertion `select_lex->select_number == (0x7fffffff * 2U + 1U) || select_lex->select_number == 0x7fffffff || !output || !output->get_select(select_lex->select_number) || output->get_select(select_lex->select_number)->select_lex == select_lex' failed.
 
stdlib/abort.c:91(__GI_abort)[0x7f98fa40902a]
assert/assert.c:92(__assert_fail_base)[0x7f98fa3ffbd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f98fa3ffc82]
sql/sql_select.cc:4104(JOIN::save_explain_data(Explain_query*, bool, bool, bool, bool))[0x558197a99dd1]
sql/sql_select.cc:1514(JOIN::build_explain())[0x558197a809b4]
sql/sql_select.cc:1567(JOIN::optimize())[0x558197a81278]
sql/sql_lex.cc:4151(st_select_lex::optimize_unflattened_subqueries(bool))[0x5581979828ca]
sql/opt_subselect.cc:5382(JOIN::optimize_unflattened_subqueries())[0x558197e26015]
sql/sql_select.cc:2743(JOIN::optimize_stage2())[0x558197a8ca0f]
sql/sql_select.cc:2207(JOIN::optimize_inner())[0x558197a87154]
sql/sql_select.cc:1561(JOIN::optimize())[0x558197a811c9]
sql/sql_select.cc:4578(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x558197a9e0f5]
sql/sql_select.cc:424(handle_select(THD*, LEX*, select_result*, unsigned long))[0x558197a7525c]
sql/sql_parse.cc:6602(execute_sqlcom_select(THD*, TABLE_LIST*))[0x5581979fa653]
sql/sql_parse.cc:3891(mysql_execute_command(THD*))[0x5581979e7870]
sql/sql_parse.cc:8154(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x558197a02914]
sql/sql_parse.cc:1834(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x5581979db5c4]
sql/sql_parse.cc:1365(do_command(THD*))[0x5581979d8503]
sql/sql_connect.cc:1398(do_handle_one_connection(CONNECT*))[0x558197d4bf97]
sql/sql_connect.cc:1302(handle_one_connection)[0x558197d4b961]
perfschema/pfs.cc:1864(pfs_spawn_thread)[0x558199104f0f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f98fb2486ba]
x86_64/clone.S:111(clone)[0x7f98fa4d941d]



 Comments   
Comment by Elena Stepanova [ 2019-04-05 ]

Non-debug build crashes with SIGSEGV:

10.4 non-debug d2013e73

#2  <signal handler called>
#3  incr_loops (this=0x88) at /data/src/10.4/sql/sql_analyze_stmt.h:97
#4  JOIN::exec (this=0x7f7f14051ca0) at /data/src/10.4/sql/sql_select.cc:4159
#5  0x0000560520ac898d in subselect_single_select_engine::exec (this=0x7f7f14015510) at /data/src/10.4/sql/item_subselect.cc:3917
#6  0x0000560520ac733d in Item_subselect::exec (this=0x7f7f140152f0) at /data/src/10.4/sql/item_subselect.cc:738
#7  0x0000560520ac84df in Item_in_subselect::val_bool (this=0x7f7f140152f0) at /data/src/10.4/sql/item_subselect.cc:1789
#8  0x0000560520a6a7ad in Item_in_optimizer::val_int (this=0x7f7f14047e48) at /data/src/10.4/sql/item_cmpfunc.cc:1628
#9  0x0000560520966b10 in Type_handler_int_result::Item_val_bool (this=<optimized out>, item=<optimized out>) at /data/src/10.4/sql/sql_type.cc:4386
#10 0x0000560520a5f8b7 in Item_func_not::val_int (this=0x7f7f14015550) at /data/src/10.4/sql/item_cmpfunc.cc:200
#11 0x000056052094cbbd in and_new_conditions_to_optimized_cond (thd=0x7f7f140009a8, cond=<optimized out>, cond_eq=cond_eq@entry=0x7f7f14046b88, new_conds=..., cond_value=cond_value@entry=0x7f7f14046a60) at /data/src/10.4/sql/opt_subselect.cc:5828
#12 0x00005605208888d5 in JOIN::optimize_inner (this=this@entry=0x7f7f14046750) at /data/src/10.4/sql/sql_select.cc:1961
#13 0x000056052088aaa5 in JOIN::optimize (this=this@entry=0x7f7f14046750) at /data/src/10.4/sql/sql_select.cc:1561
#14 0x000056052088b960 in mysql_select (thd=thd@entry=0x7f7f140009a8, tables=0x7f7f14012638, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f7f14012e10, having=0x7f7f14015550, proc_param=0x0, select_options=2147748608, result=0x7f7f14046728, unit=0x7f7f14004718, select_lex=0x7f7f14012070) at /data/src/10.4/sql/sql_select.cc:4578
#15 0x000056052088c44e in handle_select (thd=thd@entry=0x7f7f140009a8, lex=lex@entry=0x7f7f14004650, result=result@entry=0x7f7f14046728, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/src/10.4/sql/sql_select.cc:424
#16 0x0000560520735d56 in execute_sqlcom_select (thd=thd@entry=0x7f7f140009a8, all_tables=0x7f7f14012638) at /data/src/10.4/sql/sql_parse.cc:6602
#17 0x000056052082d363 in mysql_execute_command (thd=thd@entry=0x7f7f140009a8) at /data/src/10.4/sql/sql_parse.cc:3891
#18 0x0000560520834c3b in mysql_parse (thd=thd@entry=0x7f7f140009a8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f7f302f4170, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.4/sql/sql_parse.cc:8154
#19 0x0000560520837d1e in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f7f140009a8, packet=packet@entry=0x7f7f14009bf9 "select pk from t1 group by  pk \nhaving (1 not in (select count(t1.c1) from (v1, t1)))", packet_length=packet_length@entry=85, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.4/sql/sql_parse.cc:1832
#20 0x00005605208393c9 in do_command (thd=0x7f7f140009a8) at /data/src/10.4/sql/sql_parse.cc:1365
#21 0x000056052091478c in do_handle_one_connection (connect=connect@entry=0x560522c6a888) at /data/src/10.4/sql/sql_connect.cc:1398
#22 0x00005605209148f4 in handle_one_connection (arg=arg@entry=0x560522c6a888) at /data/src/10.4/sql/sql_connect.cc:1301
#23 0x0000560520c31ac4 in pfs_spawn_thread (arg=0x560522c5e7d8) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#24 0x00007f7f3786a494 in start_thread (arg=0x7f7f302f5700) at pthread_create.c:333
#25 0x00007f7f35a3893f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Galina Shalygina (Inactive) [ 2019-04-05 ]

Pushed in 10.4

Generated at Thu Feb 08 08:49:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.