[MDEV-29697] Assertion failure in Diagnostics_area::set_ok_status upon CREATE OR REPLACE causing ER_UPDATE_TABLE_USED Created: 2022-10-04  Updated: 2022-10-07  Resolved: 2022-10-05

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.3.37, 10.4.27, 10.5.18, 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-29698 Server crash or assertion failure upo... Closed
Relates
relates to MDEV-29698 Server crash or assertion failure upo... Closed

 Description   

CREATE TABLE t (a INT) ENGINE=MyISAM;
CREATE TABLE tm (a INT) ENGINE=MERGE UNION(t);
--error ER_UPDATE_TABLE_USED
CREATE OR REPLACE TABLE t LIKE tm;
 
# Cleanup
DROP TABLE IF EXISTS tm, t;

10.3 dd8833bf

mysqld: /data/src/10.3/sql/sql_error.cc:335: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
221004 13:48:30 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f5d8889f662 in __GI___assert_fail (assertion=0x561e2135ab60 "!is_set() || (m_status == DA_OK_BULK && is_bulk_op())", file=0x561e2135a7e0 "/data/src/10.3/sql/sql_error.cc", line=335, function=0x561e2135abc0 "void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*)") at assert.c:101
#8  0x0000561e1f688ea8 in Diagnostics_area::set_ok_status (this=0x62a0000657e8, affected_rows=0, last_insert_id=0, message=0x0) at /data/src/10.3/sql/sql_error.cc:335
#9  0x0000561e1f5b7963 in my_ok (thd=0x62a000060208, affected_rows_arg=0, id=0, message=0x0) at /data/src/10.3/sql/sql_class.h:4955
#10 0x0000561e1f9a48e7 in Sql_cmd_create_table_like::execute (this=0x62b000000330, thd=0x62a000060208) at /data/src/10.3/sql/sql_table.cc:11464
#11 0x0000561e1f74f7d6 in mysql_execute_command (thd=0x62a000060208) at /data/src/10.3/sql/sql_parse.cc:6076
#12 0x0000561e1f75b608 in mysql_parse (thd=0x62a000060208, rawbuf=0x62b000000228 "CREATE OR REPLACE TABLE t LIKE tm", length=33, parser_state=0x7f5d7df139d0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7855
#13 0x0000561e1f732c56 in dispatch_command (command=COM_QUERY, thd=0x62a000060208, packet=0x6290000eb209 "CREATE OR REPLACE TABLE t LIKE tm", packet_length=33, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
#14 0x0000561e1f72f80e in do_command (thd=0x62a000060208) at /data/src/10.3/sql/sql_parse.cc:1398
#15 0x0000561e1faf2336 in do_handle_one_connection (connect=0x608000000ea8) at /data/src/10.3/sql/sql_connect.cc:1403
#16 0x0000561e1faf1c32 in handle_one_connection (arg=0x608000000ea8) at /data/src/10.3/sql/sql_connect.cc:1308
#17 0x0000561e2109d29f in pfs_spawn_thread (arg=0x615000004408) at /data/src/10.3/storage/perfschema/pfs.cc:1869
#18 0x00007f5d88a4aea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#19 0x00007f5d8896aaef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.3-10.10.
Non-debug build throws ER_UPDATE_TABLE_USED which is probably expected:

CREATE OR REPLACE TABLE t LIKE tm;
ERROR HY000: Table 'tm' is specified twice, both as a target for 'CREATE' and as a separate source for data

In 10.11 MDEV-25292 introduced atomic create or replace, and it fails in a different way, see MDEV-29698.



 Comments   
Comment by Aleksey Midenkov [ 2022-10-04 ]

Please review bb-10.3-midenok

Comment by Rucha Deodhar [ 2022-10-05 ]

midenok Looks ok to push.

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