Bug #46256 drop table with unknown collation crashes innodb
Submitted: 17 Jul 2009 5:24 Modified: 18 Jun 2010 22:58
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S1 (Critical)
Version:5.1.37, 5.4.4 OS:Any
Assigned to: Satya B CPU Architecture:Any

[17 Jul 2009 5:24] Shane Bester
Description:
if you take your data from a server to another server which doesn't support the collation used, then try to drop the table, innodb crashes.

Version: '5.4.4-alpha-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
090629 23:38:09  InnoDB: Assertion failure in thread 3022673808 in file handler/ha_innodb.cc line 790
InnoDB: Failing assertion: cset == 0

mysql> show create table tbl_75; #expected
ERROR 1273 (HY000): Unknown collation '#254' in table 'tbl_75' definition
mysql> check table tbl_75; #expected
+-------------+-------------------------------------------------------+
| Table       | Msg_text                                              |
+-------------+-------------------------------------------------------+
| test.tbl_75 | Unknown collation '#254' in table 'tbl_75' definition |
| test.tbl_75 | Corrupt                                               |
+-------------+-------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> drop table tbl_75; #oops
ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
on a 5.1.37 server that has utf8_general_cs collation, create a table:

drop table if exists tbl_75;
create table tbl_75 (a varchar(1) character set utf8 collate utf8_general_cs,primary key(a))engine=innodb;

then start a server that doesn't support utf8_general_cs using this datadir and try drop the table.

check table tbl_75 extended;
drop table tbl_75

Suggested fix:
allow tables to be dropped if the collation is not supported.  myisam allows this.
[17 Jul 2009 5:31] MySQL Verification Team
creating a table in 5.1.37 and moving it to 5.1.37 without the collation also crashed:

mysqld.exe!innobase_get_cset_width()[ha_innodb.cc:817]
mysqld.exe!dtype_get_mblen()[data0type.ic:66]
mysqld.exe!dict_mem_table_add_col()[dict0mem.c:215]
mysqld.exe!dict_load_columns()[dict0load.c:427]
mysqld.exe!dict_load_table()[dict0load.c:859]
mysqld.exe!dict_table_get_low()[dict0dict.ic:606]
mysqld.exe!row_drop_table_for_mysql()[row0mysql.c:3045]
mysqld.exe!ha_innobase::delete_table()[ha_innodb.cc:5591]
mysqld.exe!handler::ha_delete_table()[handler.cc:3314]
mysqld.exe!ha_delete_table()[handler.cc:1957]
mysqld.exe!mysql_rm_table_part2()[sql_table.cc:1955]
mysqld.exe!mysql_rm_table()[sql_table.cc:1749]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3354]
mysqld.exe!mysql_parse()[sql_parse.cc:5933]
mysqld.exe!dispatch_command()[sql_parse.cc:1213]
mysqld.exe!do_command()[sql_parse.cc:854]
mysqld.exe!handle_one_connection()[sql_connect.cc:1127]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:293]
mysqld.exe!_threadstart()[thread.c:277]
kernel32.dll!FlsSetValue()
[27 Jul 2009 22:47] Calvin Sun
I can reproduce the crash with 5.1.36.
[5 Oct 2009 11:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/85740

3157 Satya B	2009-10-05
      Applying InnoDB snapshot 5.1-ss5921, part 3. Fixes BUG#46256
      
      1. BUG#46256 - drop table with unknown collation crashes innodb
      
      Note: No testcase attached and has to be verified manually
      
      Detailed revision comments:
      
      r5799 | calvin | 2009-09-09 20:47:31 +0300 (Wed, 09 Sep 2009) | 10 lines
      branches/5.1: fix bug#46256
      
      Allow tables to be dropped even if the collation is not found,
      but issue a warning.
      
      Could not find an easy way to add mysql-test since it requires
      changes to charsets and restarting the server. Tests were
      executed manually.
      
      Approved by: Heikki (on IM)
      r5805 | vasil | 2009-09-10 08:41:48 +0300 (Thu, 10 Sep 2009) | 7 lines
      branches/5.1:
      
      Fix a compilation warning caused by c5799:
      
      handler/ha_innodb.cc: In function 'void innobase_get_cset_width(ulint, ulint*, ulint*)':
      handler/ha_innodb.cc:830: warning: format '%d' expects type 'int', but argument 2 has type 'ulint'
[6 Oct 2009 8:58] Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:joro@sun.com-20091006071047-omas21geg3vdx043) (merge vers: 5.1.40) (pib:11)
[6 Oct 2009 9:28] Satya B
Patch queued to mysql-5.1-pe-stage. Bug still exists in 5.1 Innodb
plugin/ 5.4 Innobase
[14 Oct 2009 14:39] Bugs System
Pushed into 5.1.41 (revid:joro@sun.com-20091014143611-cphb0enjlx6lpat1) (version source revid:satya.bn@sun.com-20091009125218-w3xkjtkhtqret6l1) (merge vers: 5.1.40) (pib:13)
[14 Oct 2009 15:46] Paul DuBois
Noted in 5.1.40 changelog.

Dropping an InnoDB table that used an unknown collation (created on a 
different server, for example) caused a server crash.

Setting report to NDI pending push into 5.5.x+.
[22 Oct 2009 6:33] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091022063126-l0qzirh9xyhp0bpc) (version source revid:alik@sun.com-20091019135554-s1pvptt6i750lfhv) (merge vers: 6.0.14-alpha) (pib:13)
[22 Oct 2009 7:06] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091022060553-znkmxm0g0gm6ckvw) (version source revid:alik@sun.com-20091019131022-2o2ymjfjjoraq833) (merge vers: 5.5.0-beta) (pib:13)
[22 Oct 2009 20:05] Paul DuBois
Noted in 5.5.0, 6.0.14 changelogs.
[18 Dec 2009 10:29] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:44] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:00] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:14] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)
[5 May 2010 15:08] Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[6 May 2010 17:47] Paul DuBois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[28 May 2010 6:09] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
[28 May 2010 6:38] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[28 May 2010 7:05] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[29 May 2010 15:12] Paul DuBois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[15 Jun 2010 8:11] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100615080459-smuswd9ooeywcxuc) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (merge vers: 5.1.47) (pib:16)
[15 Jun 2010 8:27] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615080558-cw01bzdqr1bdmmec) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (pib:16)
[17 Jun 2010 12:14] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:01] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:42] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)