Bug #111722 Create view assertion error
Submitted: 11 Jul 2023 14:31 Modified: 12 Jul 2023 5:22
Reporter: Pedro Ferreira Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Prepared statements Severity:S6 (Debug Builds)
Version:8.0.33 OS:Ubuntu (22.04)
Assigned to: CPU Architecture:x86 (x86_64)

[11 Jul 2023 14:31] Pedro Ferreira
Description:
This may be related to Bug #111310.
Run these statements:

PREPARE p0 FROM 'CREATE VIEW x(x) AS (WITH y(y) AS (SELECT 1 WHERE ? = 1) SELECT 1)';
SET @a0 = TIME '15:19:32';
EXECUTE p0 USING @a0;

The execute will trigger an assertion error at sql/sql_view.cc:453
assert(!lex->result && !lex->param_list.elements);

The compilation parameters are the same as issue 108148:

-DWITH_DEBUG=1 -DWITH_ASAN=ON -DWITH_UBSAN=ON and boost library version 1.77

How to repeat:
Run the statements above.
[12 Jul 2023 5:22] MySQL Verification Team
Hello Pedro Ferreira,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[12 Jul 2023 5:23] MySQL Verification Team
-- release build not affected

 ./mtr bug111722 --nocheck-testcases
Logging: ./mtr  bug111722 --nocheck-testcases
MySQL Version 8.0.33
Checking supported features
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
 - WARNING: Using the 'mysql-test/var' symlink
Creating var directory '/export/home/tmp/ushastry/mysql-8.0.33/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
PREPARE p0 FROM 'CREATE VIEW x(x) AS (WITH y(y) AS (SELECT 1 WHERE ? = 1) SELECT 1)';
SET @a0 = TIME '15:19:32';
EXECUTE p0 USING @a0;
[ 50%] main.bug111722                            [ pass ]      2
[100%] shutdown_report                           [ pass ]

-- debug build affected

./mtr bug111722 --nocheck-testcases --debug-server
Logging: ./mtr  bug111722 --nocheck-testcases --debug-server
MySQL Version 8.0.33
Checking supported features
 - Binaries are debug compiled
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
 - WARNING: Using the 'mysql-test/var' symlink
Creating var directory '/export/home/tmp/ushastry/mysql-8.0.33/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
PREPARE p0 FROM 'CREATE VIEW x(x) AS (WITH y(y) AS (SELECT 1 WHERE ? = 1) SELECT 1)';
SET @a0 = TIME '15:19:32';
EXECUTE p0 USING @a0;
[ 50%] main.bug111722                            [ fail ]
        Test ended at 2023-07-12 07:22:13

CURRENT_TEST: main.bug111722
mysqltest: At line 3: Query 'EXECUTE p0 USING @a0' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query

--bt

#0  0x00007f0f2a201aa1 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000003f9296e in my_write_core(int) ()
#2  0x00000000032365f5 in handle_fatal_signal ()
#3  <signal handler called>
#4  0x00007f0f2843b387 in raise () from /lib64/libc.so.6
#5  0x00007f0f2843ca78 in abort () from /lib64/libc.so.6
#6  0x00007f0f284341a6 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f0f28434252 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000031a07f1 in mysql_create_view(THD*, Table_ref*, enum_view_create_mode) ()
#9  0x00000000030c4880 in mysql_execute_command(THD*, bool) ()
#10 0x00000000030f16b6 in Prepared_statement::execute(THD*, String*, bool) ()
#11 0x00000000030f47ca in Prepared_statement::execute_loop(THD*, String*, bool) ()
#12 0x00000000030f4ef1 in mysql_sql_stmt_execute(THD*) ()
#13 0x00000000030c1947 in mysql_execute_command(THD*, bool) ()
#14 0x00000000030c5dc9 in dispatch_sql_command(THD*, Parser_state*) ()
#15 0x00000000030c752b in dispatch_command(THD*, COM_DATA const*, enum_server_command) ()
#16 0x00000000030c926e in do_command(THD*) ()
#17 0x0000000003227bb7 in handle_connection ()
#18 0x0000000004743af9 in pfs_spawn_thread ()
#19 0x00007f0f2a1fcea5 in start_thread () from /lib64/libpthread.so.0
#20 0x00007f0f28503b2d in clone () from /lib64/libc.so.6