Description:
Run these queries:
CREATE TABLE t0 ( c60 INT , c54 INT ) ;
INSERT INTO t0 VALUES ( DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT ) ;
ALTER TABLE t0 ADD COLUMN c27 INT AFTER c54 ;
INSERT INTO t0 VALUES ( DEFAULT , DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT , DEFAULT ) ;
SELECT t1 . c37 AS c54 , IF ( t2 . c6 , t1 . c37 , 34 ) AS c7 FROM ( SELECT c27 AS c37 FROM t0 ) AS t1 CROSS JOIN ( SELECT c60 AS c6 FROM t0 ) AS t2 ON t1 . c37 IN ( SELECT c27 AS c40 FROM t0 ) IS NOT FALSE HAVING FIND_IN_SET ( 14 , '\\ngL}x!ma0lQGBY1 1]s`9]o' ) IN ( SELECT t2 . c6 = t1 . c37 IN ( RAND ( ) NOT IN ( '.N1WD5d' = -63 ) ) IS NOT UNKNOWN AS c56 ) ORDER BY c7 LIMIT 26 ;
Will trigger assertion failure:
/home/wx/mysql-8.0.34/sql/sql_select.cc:4222: bool JOIN::add_having_as_tmp_table_cond(uint): Assertion `having_cond->has_subquery() || !(having_cond->used_tables() & ~(1 | PSEUDO_TABLE_BITS))' 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=0x55555dd88620 "having_cond->has_subquery() || !(having_cond->used_tables() & ~(1 | PSEUDO_TABLE_BITS))", file=0x55555dd856c0 "/home/wx/mysql-8.0.34/sql/sql_select.cc", line=4222, function=<optimized out>) at assert.c:92
#3 0x00007ffff6b03fd6 in __GI___assert_fail ( assertion=assertion@entry=0x55555dd88620 "having_cond->has_subquery() || !(having_cond->used_tables() & ~(1 | PSEUDO_TABLE_BITS))", file=file@entry=0x55555dd856c0 "/home/wx/mysql-8.0.34/sql/sql_select.cc", line=line@entry=4222, function=function@entry=0x55555dd885c0 "bool JOIN::add_having_as_tmp_table_cond(uint)") at assert.c:101
#4 0x00005555595b6206 in JOIN::add_having_as_tmp_table_cond (this=this@entry=0x6190005479b0, curr_tmp_table=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_select.cc:4222
#5 0x00005555595ca733 in JOIN::make_tmp_tables_info (this=this@entry=0x6190005479b0) at /home/wx/mysql-8.0.34/sql/sql_select.cc:4734
#6 0x0000555559495da4 in JOIN::optimize (this=0x6190005479b0, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_optimizer.cc:1021
#7 0x00005555595b28b0 in Query_block::optimize (this=this@entry=0x619000536bb0, thd=thd@entry=0x6270002bf900, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_select.cc:2013
#8 0x0000555559714de9 in Query_expression::optimize (this=this@entry=0x612000318f70, thd=thd@entry=0x6270002bf900, materialize_destination=materialize_destination@entry=0x0, create_iterators=create_iterators@entry=true, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1006
#9 0x00005555595b1ee9 in Sql_cmd_dml::execute_inner (this=0x60b000157e80, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:1007
#10 0x00005555595ce209 in Sql_cmd_dml::execute (this=0x60b000157e80, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:793
#11 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
#12 0x00005555594c0bfe in dispatch_sql_command (thd=0x6270002bf900, parser_state=parser_state@entry=0x7fffc707ec00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#13 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270002bf900, com_data=com_data@entry=0x7fffc7080200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#14 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#15 0x000055555989b7be in handle_connection (arg=arg@entry=0x60300016f9f0) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#16 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042
#17 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#18 0x00007ffff6bef133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
How to repeat:
Run the queries above.