Bug #38028 assert hit in function open_table_def in file table.cc:559
Submitted: 10 Jul 2008 19:16 Modified: 29 Sep 2011 13:05
Reporter: Zardosht Kasheff (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.1.23-rc, 5.1 bzr OS:Any
Assigned to: CPU Architecture:Any
Tags: open_table_def assert

[10 Jul 2008 19:16] Zardosht Kasheff
Description:
For a storage engine whose handlerton exposes the flag HTON_FLUSH_AFTER_RENAME, the following assert gets hit:

#0  0x00000035eec30065 in raise () from /lib64/libc.so.6
#1  0x00000035eec31b00 in abort () from /lib64/libc.so.6
#2  0x00000035eec29766 in __assert_fail () from /lib64/libc.so.6
#3  0x0000000000673520 in open_table_def (thd=0x186d118, share=0x18c8d58,
    db_flags=0) at table.cc:559
#4  0x00000000006629e9 in open_temporary_table (thd=0x186d118,
    path=0x45086da0 "./test/z1", db=<value optimized out>,
    table_name=0x450879a0 "#sql-342_1", link_in_list=false)
    at sql_base.cc:5358
#5  0x0000000000729f33 in mysql_alter_table (thd=0x186d118,
    new_db=0x18c9da8 "test", new_name=0x18c9db0 "z2", create_info=0x45087b70,
    table_list=0x18c9a80, alter_info=0x45088450, order_num=0, order=0x0,
    ignore=false) at sql_table.cc:6817
#6  0x000000000062ee55 in mysql_execute_command (thd=0x186d118)
    at sql_parse.cc:2612
#7  0x000000000062f82a in mysql_parse (thd=0x186d118,
    inBuf=0x18c9978 "ALTER TABLE z1 RENAME as z2, DROP longblob_col",
    length=46, found_semicolon=0x45089000) at sql_parse.cc:5565
#8  0x0000000000630405 in dispatch_command (command=COM_QUERY, thd=0x186d118,
    packet=<value optimized out>, packet_length=46) at sql_parse.cc:1090
#9  0x00000000006312ff in do_command (thd=0x186d118) at sql_parse.cc:764
#10 0x0000000000622540 in handle_one_connection (arg=<value optimized out>)
    at sql_connect.cc:1120
#11 0x0000003aaec062f7 in start_thread () from /lib64/libpthread.so.0
#12 0x00000035eecce86d in clone () from /lib64/libc.so.6
#13 0x0000000000000000 in ?? ()

The reason that this cannot be reproduced on InnoDB and MyISAM is that they do not expose the flag HTON_FLUSH_AFTER_RENAME. If one does, in sql_table.cc, at line 6807, the if-clause, "if (ha_check_storage_engine_flag(old_db_type,HTON_FLUSH_AFTER_RENAME))" will evaluate to true. Then, in line 6817, the function open_temporary_table will be called that will lead to the assert.

How to repeat:
For a storage engine that exposes the flag HTON_FLUSH_AFTER_RENAME, run the following test:

CREATE TABLE z1 (
  a int(5) unsigned NOT NULL,
  longblob_col longblob  not null
);

ALTER TABLE z1 RENAME as z2, DROP longblob_col;

The assert should hit on the alter table statement.

Suggested fix:
Do not know, because I do not understand what the problem is. I do not see how this flag being on or off should affect this test. I guess the test should succeed.
[13 Jul 2008 20:55] Sveta Smirnova
Thank you for the report.

Verified as described.

To repeat:

1. Apply patch to current BZR tree:

=== modified file 'storage/myisam/ha_myisam.cc'
--- storage/myisam/ha_myisam.cc 2008-03-28 10:14:27 +0000
+++ storage/myisam/ha_myisam.cc 2008-07-13 20:47:44 +0000
@@ -2047,7 +2047,7 @@
   myisam_hton->db_type= DB_TYPE_MYISAM;
   myisam_hton->create= myisam_create_handler;
   myisam_hton->panic= myisam_panic;
-  myisam_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
+  myisam_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES | HTON_FLUSH_AFTER_RENAME;
   return 0;
 }

2. $cat >mysql-test/t/bug38028.test 
CREATE TABLE z1 (
  a int(5) unsigned NOT NULL,
  longblob_col longblob  not null
);

ALTER TABLE z1 RENAME as z2, DROP longblob_col;
^C

3. $cd mysql-test
4. $./mysql-test-run.pl bug38028
[29 Sep 2011 13:05] Paul DuBois
Noted in 5.6.4 changelog.

For debug builds, an assertion could be raised for ALTER statements
that performed a RENAME operation. This occurred for storage engine
handlertons that exposed the HTON_FLUSH_AFTER_RENAME flag.