Bug #56777 RENAME TABLE of upper case table hits DBUG_ASSERT under lower_case_table_names=2
Submitted: 14 Sep 2010 16:23 Modified: 23 Sep 2010 11:51
Reporter: Mattias Jonsson Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DDL Severity:S2 (Serious)
Version:5.5 OS:Any (Windows, Mac OS X)
Assigned to: Assigned Account CPU Architecture:Any
Tags: regression

[14 Sep 2010 16:23] Mattias Jonsson
Description:
parts.partition_mgm_lc2* tests all fail on windows in a DBUG_ASSERT in RENAME TABLE.

Assertion failed: thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, old_table, MDL_EXCLUSIVE), file ..\..\sql\sql_trigger.cc, line 1911

stack trace:
00710DF3    mysqld.exe!my_sigabrt_handler()[my_thr_init.c:521]
007DA6EB    mysqld.exe!raise()[winsig.c:590]
007E32A5    mysqld.exe!abort()[abort.c:71]
007DC9A7    mysqld.exe!_wassert()[assert.c:346]
00417B3C    mysqld.exe!Table_triggers_list::change_table_name()[sql_trigger.cc:1911]
004FEEE2    mysqld.exe!do_rename()[sql_rename.cc:289]
004FF113    mysqld.exe!rename_tables()[sql_rename.cc:365]
004FEB06    mysqld.exe!mysql_rename_tables()[sql_rename.cc:159]
003CAF29    mysqld.exe!mysql_execute_command()[sql_parse.cc:2706]
003D2177    mysqld.exe!mysql_parse()[sql_parse.cc:5594]
003C7FBA    mysqld.exe!dispatch_command()[sql_parse.cc:1139]
003C77C9    mysqld.exe!do_command()[sql_parse.cc:811]
002E38EF    mysqld.exe!do_handle_one_connection()[sql_connect.cc:1192]
002E369C    mysqld.exe!handle_one_connection()[sql_connect.cc:1131]
006EEB6B    mysqld.exe!pfs_spawn_thread()[pfs.cc:1015]
0070FD58    mysqld.exe!pthread_start()[my_winthread.c:61]
007EA093    mysqld.exe!_callthreadstartex()[threadex.c:348]
007EA034    mysqld.exe!_threadstartex()[threadex.c:331]
7752ECCB    kernel32.dll!BaseThreadInitThunk()
77D6D24D    ntdll.dll!RtlCreateUserProcess()
77D6D45F    ntdll.dll!RtlCreateProcessParameters()
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 052D1338=RENAME TABLE TableA to TableB

How to repeat:
./mtr parts.partition_mgm_lc2_myisam on a debug build on windows. (only tested mysql-5.5-bugfixing).
[14 Sep 2010 16:52] Valeriy Kravchuk
Verified with current mysql-5.5 tree on Mac OS X 10.5.x also:

...
Version: '5.5.7-m3-debug-log'  socket: '/Users/openxs/dbs/5.5/mysql-test/var/tmp/mysqld.1.sock'  port: 13000  Source distribution
Assertion failed: (thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, old_table, MDL_EXCLUSIVE)), function change_table_name, file sql_trigger.cc, line 1911.
100914 19:48:31 - mysqld got signal 6 ;
[23 Sep 2010 11:45] Mattias Jonsson
main.lowercase_table2 test also hits this bug -> not related to partitioning.

The problem is Table_triggers_list::change_table_name() which have an assertion
that uses the table->alias (not folded to lower case) instead of table->table_name (folded according to lower_case_table_names) which makes the lookup in thd->mdl_context.is_lock_owner() fail since it cannot find any EXCLUSIVE lock with the uppercase name (since it is locked with lower case name, according to lower_case_table_names).

Fix is probably to include both table_name and alias in change_table_name (just like do_rename) and use the table_name for the lock assertion.
[23 Sep 2010 11:51] Mattias Jonsson
Duplicate of bug#56595.