Bug #78408 Assertion in DROP TRIGGER when table has virtual generated column
Submitted: 11 Sep 2015 12:55 Modified: 2 Oct 2015 14:42
Reporter: Knut Anders Hatlen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.7.9 OS:Any
Assigned to: CPU Architecture:Any

[11 Sep 2015 12:55] Knut Anders Hatlen
Description:
DROP TRIGGER fails with an assertion in some cases when there is a virtual generated column in the table on which the trigger is defined.

How to repeat:
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL);
CREATE TRIGGER tr BEFORE INSERT ON t FOR EACH ROW BEGIN END;
SELECT * FROM t;
DROP TRIGGER tr;  <-- hits a DBUG_ASSERT in TABLE_LIST::map()
[11 Sep 2015 13:00] Knut Anders Hatlen
Posted by developer:
 
Backtrace for the assert failure:

Thread 1 (Thread 0x7f677dec5700 (LWP 29456)):
#0  0x00007f6797d24771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000017bf744 in my_write_core (sig=6) at /code/mysql/5.7/mysys/stacktrace.c:247
#2  0x0000000000e1c6ac in handle_fatal_signal (sig=6) at /code/mysql/5.7/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007f679671e5d7 in raise () from /lib64/libc.so.6
#5  0x00007f679671fcc8 in abort () from /lib64/libc.so.6
#6  0x00007f6796717546 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f67967175f2 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000ec563b in TABLE_LIST::map (this=0x7f672c1f58b0) at /code/mysql/5.7/sql/table.h:2506
#9  0x0000000000eaee3c in Item_field::used_tables (this=0x7f672c1cb4d0) at /code/mysql/5.7/sql/item.cc:3126
#10 0x0000000001585daa in validate_generated_expr (field=0x7f672c3ddb00) at /code/mysql/5.7/sql/table.cc:2642
#11 0x000000000158629a in fix_fields_gcol_func (thd=0x7f672cfcf910, field=0x7f672c3ddb00) at /code/mysql/5.7/sql/table.cc:2752
#12 0x000000000158b282 in TABLE::refix_gc_items (this=0x7f672c0f0fd0, thd=0x7f672cfcf910) at /code/mysql/5.7/sql/table.cc:4636
#13 0x000000000158b18c in TABLE::init (this=0x7f672c0f0fd0, thd=0x7f672cfcf910, tl=0x7f672c1f58b0) at /code/mysql/5.7/sql/table.cc:4613
#14 0x0000000001412dd8 in open_table (thd=0x7f672cfcf910, table_list=0x7f672c1f58b0, ot_ctx=0x7f677dec3180) at /code/mysql/5.7/sql/sql_base.cc:3537
#15 0x0000000001415356 in open_and_process_table (thd=0x7f672cfcf910, lex=0x7f672cfd1bf8, tables=0x7f672c1f58b0, counter=0x7f677dec3284, flags=0, prelocking_strategy=0x7f677dec3320, has_prelocking_list=false, ot_ctx=0x7f677dec3180) at /code/mysql/5.7/sql/sql_base.cc:5024
#16 0x00000000014163f4 in open_tables (thd=0x7f672cfcf910, start=0x7f677dec3240, counter=0x7f677dec3284, flags=0, prelocking_strategy=0x7f677dec3320) at /code/mysql/5.7/sql/sql_base.cc:5633
#17 0x00000000014174a0 in open_and_lock_tables (thd=0x7f672cfcf910, tables=0x7f672c1f58b0, flags=0, prelocking_strategy=0x7f677dec3320) at /code/mysql/5.7/sql/sql_base.cc:6318
#18 0x0000000001416fce in open_n_lock_single_table (thd=0x7f672cfcf910, table_l=0x7f672c1f58b0, lock_type=TL_READ_NO_INSERT, flags=0, prelocking_strategy=0x7f677dec3320) at /code/mysql/5.7/sql/sql_base.cc:6163
#19 0x000000000154654e in open_n_lock_single_table (thd=0x7f672cfcf910, table_l=0x7f672c1f58b0, lock_type=TL_READ_NO_INSERT, flags=0) at /code/mysql/5.7/sql/sql_base.h:468
#20 0x0000000001545ad8 in mysql_create_or_drop_trigger (thd=0x7f672cfcf910, tables=0x7f672c1f58b0, create=false) at /code/mysql/5.7/sql/sql_trigger.cc:215
#21 0x000000000149dc82 in mysql_execute_command (thd=0x7f672cfcf910, first_level=true) at /code/mysql/5.7/sql/sql_parse.cc:4593
#22 0x000000000149fd79 in mysql_parse (thd=0x7f672cfcf910, parser_state=0x7f677dec46b0) at /code/mysql/5.7/sql/sql_parse.cc:5357
#23 0x0000000001495526 in dispatch_command (thd=0x7f672cfcf910, com_data=0x7f677dec4e00, command=COM_QUERY) at /code/mysql/5.7/sql/sql_parse.cc:1284
#24 0x00000000014943f2 in do_command (thd=0x7f672cfcf910) at /code/mysql/5.7/sql/sql_parse.cc:852
#25 0x00000000015c58e7 in handle_connection (arg=0x515ba30) at /code/mysql/5.7/sql/conn_handler/connection_handler_per_thread.cc:294
#26 0x00000000018076a3 in pfs_spawn_thread (arg=0x531f360) at /code/mysql/5.7/storage/perfschema/pfs.cc:2191
#27 0x00007f6797d1fdf5 in start_thread () from /lib64/libpthread.so.0
#28 0x00007f67967df60d in clone () from /lib64/libc.so.6
[11 Sep 2015 13:03] Knut Anders Hatlen
Posted by developer:
 
The assert failure is only seen after the fix for:

Bug#21491442 variant::forced_return() [with t = json_scalar*]: assertion `false' failed.
[2 Oct 2015 14:42] Paul DuBois
Noted in 5.7.9, 5.8.0 changelogs.

For debug builds, a DROP TRIGGER statement could raise an assertion
if the trigger was defined on a table that contained a generated
column.