Description:
Run these queries:
CREATE TABLE x ( x INT ) ;
INSERT INTO x ( x ) VALUES ( 1 ) ;
UPDATE x SET x = 1 WHERE x = 1 ;
INSERT INTO x ( x ) VALUES ( 1 ) , ( 1 ) ;
WITH x ( x ) AS ( SELECT x FROM x ORDER BY x ASC ) SELECT 1 FROM x WHERE EXISTS ( SELECT * FROM x WHERE x = x ) GROUP BY x HAVING ( SELECT x GROUP BY 1 , 'x' , 1 , 1 HAVING ( SELECT ( SELECT x WHERE x < 1 * 1 GROUP BY NOT 1 > 'x' , 1 , 1 HAVING x = 1 ) ) > x ) IN ( SELECT x FROM ( SELECT x FROM x UNION SELECT x FROM x ) AS x ) ;
Will trigger assertion failure:
mysqld: /home/wx/mysql-8.0.34/sql/sql_base.cc:9133: bool setup_fields(THD*, ulong, bool, bool, bool, const mem_root_deque<Item*>*, mem_root_deque<Item*>*, Ref_item_array): Assertion `!thd->is_error()' failed.
GDB info:
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007ffff6af2859 in __GI_abort () at abort.c:79
#2 0x00007ffff6af2729 in __assert_fail_base (fmt=0x7ffff6c88588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555d4ef340 "!thd->is_error()", file=0x55555d4e8cc0 "/home/wx/mysql-8.0.34/sql/sql_base.cc", line=9133, function=<optimized out>) at assert.c:92
#3 0x00007ffff6b03fd6 in __GI___assert_fail (assertion=assertion@entry=0x55555d4ef340 "!thd->is_error()", file=file@entry=0x55555d4e8cc0 "/home/wx/mysql-8.0.34/sql/sql_base.cc", line=line@entry=9133, function=function@entry=0x55555d4eefa0 "bool setup_fields(THD*, ulong, bool, bool, bool, const mem_root_deque<Item*>*, mem_root_deque<Item*>*, Ref_item_array)") at assert.c:101
#4 0x00005555592cdfa0 in setup_fields (thd=thd@entry=0x6270002bf900, want_privilege=<optimized out>, allow_sum_func=allow_sum_func@entry=true, split_sum_funcs=split_sum_funcs@entry=true, column_update=column_update@entry=false, typed_items=typed_items@entry=0x0, fields=<optimized out>, ref_item_array=...) at /home/wx/mysql-8.0.34/sql/sql_base.cc:9133
#5 0x000055555958ccf7 in Query_block::prepare (this=this@entry=0x61900053edb0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:279
#6 0x000055555970ff37 in Query_expression::prepare (this=this@entry=0x6120003112f0, thd=thd@entry=0x6270002bf900, sel_result=<optimized out>, insert_field_list=insert_field_list@entry=0x0, added_options=added_options@entry=268435456, removed_options=removed_options@entry=0) at /home/wx/mysql-8.0.34/sql/sql_union.cc:753
#7 0x0000555559e1f1d8 in SubqueryWithResult::prepare (this=0x6080016af050, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2971
#8 0x0000555559e31605 in Item_subselect::fix_fields (this=0x6120003115f0, thd=0x6270002bf900, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:547
#9 0x00005555592cdd7d in setup_fields (thd=thd@entry=0x6270002bf900, want_privilege=<optimized out>, allow_sum_func=allow_sum_func@entry=true, split_sum_funcs=split_sum_funcs@entry=true, column_update=column_update@entry=false, typed_items=typed_items@entry=0x0, fields=<optimized out>, ref_item_array=...) at /home/wx/mysql-8.0.34/sql/sql_base.cc:9016
#10 0x000055555958ccf7 in Query_block::prepare (this=this@entry=0x61900053e3b0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:279
#11 0x000055555970ff37 in Query_expression::prepare (this=this@entry=0x612000311170, thd=thd@entry=0x6270002bf900, sel_result=<optimized out>, insert_field_list=insert_field_list@entry=0x0, added_options=added_options@entry=268435456, removed_options=removed_options@entry=0) at /home/wx/mysql-8.0.34/sql/sql_union.cc:753
#12 0x0000555559e1f1d8 in SubqueryWithResult::prepare (this=0x6080016af150, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2971
#13 0x0000555559e31605 in Item_subselect::fix_fields (this=0x6120003118f0, thd=0x6270002bf900, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:547
#14 0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x6150003adeb0, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x6150003adf58) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#15 0x0000555559d51c48 in Item_func::fix_fields (this=0x6150003adeb0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#16 0x000055555958d42f in Query_block::prepare (this=this@entry=0x61900053d4b0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:322
#17 0x000055555970ff37 in Query_expression::prepare (this=this@entry=0x612000310ff0, thd=thd@entry=0x6270002bf900, sel_result=<optimized out>, insert_field_list=insert_field_list@entry=0x0, added_options=added_options@entry=268435456, removed_options=removed_options@entry=0) at /home/wx/mysql-8.0.34/sql/sql_union.cc:753
#18 0x0000555559e1f1d8 in SubqueryWithResult::prepare (this=0x6080016af250, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2971
#19 0x0000555559e31605 in Item_subselect::fix_fields (this=0x612000311bf0, thd=0x6270002bf900, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:547
#20 0x0000555559e31c77 in Item_in_subselect::fix_fields (this=0x61400015d870, thd=0x6270002bf900, ref=0x619000531a20) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2519
#21 0x000055555958d42f in Query_block::prepare (this=this@entry=0x6190005316b0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:322
#22 0x00005555595b0c63 in Sql_cmd_select::prepare_inner (this=0x60b000156a90, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:650
#23 0x00005555595cd20b in Sql_cmd_dml::prepare (this=0x60b000156a90, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:566
#24 0x00005555595cda8d in Sql_cmd_dml::execute (this=0x60b000156a90, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:718
#25 0x00005555594bd568 in mysql_execute_command (thd=thd@entry=0x6270002bf900, first_level=first_level@entry=true) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:4719
#26 0x00005555594c0bfe in dispatch_sql_command (thd=0x6270002bf900, parser_state=parser_state@entry=0x7fffc706ec00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#27 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270002bf900, com_data=com_data@entry=0x7fffc7070200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#28 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#29 0x000055555989b7be in handle_connection (arg=arg@entry=0x6030001698a0) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#30 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042
#31 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#32 0x00007ffff6bef133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
How to repeat:
Run the queries above.