From f89e6c442cea2d6f220afe55284520ce26362729 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 18 Sep 2013 17:25:10 +0200 Subject: [PATCH] MDEV-5029 Crash in MariaDB 5.5.33 with .frm from older MariaDB release Don't fail when an frm is inconsistent (legacy DB_TYPE_xxx code doesn't match the engine name), use the engine name, ignore the legacy code. --- mysql-test/r/bad_frm_crash_5029.result | 11 +++++++++++ .../std_data/{mdev5029.frm => mdev5029_1.frm} | Bin mysql-test/std_data/mdev5029_2.MAD | Bin 0 -> 8192 bytes mysql-test/std_data/mdev5029_2.MAI | Bin 0 -> 8192 bytes mysql-test/std_data/mdev5029_2.frm | Bin 0 -> 8602 bytes mysql-test/t/bad_frm_crash_5029.test | 11 ++++++++++- sql/table.cc | 5 ++++- 7 files changed, 25 insertions(+), 2 deletions(-) rename mysql-test/std_data/{mdev5029.frm => mdev5029_1.frm} (100%) create mode 100644 mysql-test/std_data/mdev5029_2.MAD create mode 100644 mysql-test/std_data/mdev5029_2.MAI create mode 100644 mysql-test/std_data/mdev5029_2.frm diff --git a/mysql-test/r/bad_frm_crash_5029.result b/mysql-test/r/bad_frm_crash_5029.result index 7a829c8f6ba..8aa0065f5ee 100644 --- a/mysql-test/r/bad_frm_crash_5029.result +++ b/mysql-test/r/bad_frm_crash_5029.result @@ -1,2 +1,13 @@ show create table t1; ERROR 42000: Unknown storage engine 'InnoDB' +call mtr.add_suppression("t1.frm is inconsistent: engine typecode 43, engine name Aria"); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) +) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 +drop table t1; diff --git a/mysql-test/std_data/mdev5029.frm b/mysql-test/std_data/mdev5029_1.frm similarity index 100% rename from mysql-test/std_data/mdev5029.frm rename to mysql-test/std_data/mdev5029_1.frm diff --git a/mysql-test/std_data/mdev5029_2.MAD b/mysql-test/std_data/mdev5029_2.MAD new file mode 100644 index 0000000000000000000000000000000000000000..3dcc005ec0d03681b402e75f595130e784a4a5d5 GIT binary patch literal 8192 zcmeIu0Sy2E3<4nghrZ_c1`$XwV8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b* J20jm5+W{%^1N;C0 literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mdev5029_2.MAI b/mysql-test/std_data/mdev5029_2.MAI new file mode 100644 index 0000000000000000000000000000000000000000..3533a1d705a05c79c5b916f4cd33952bc89de6a4 GIT binary patch literal 8192 zcmeH^KZ*h|6vn?~GB^VYYrRcCFJWV=jUd+EVJmB4i(L!B3s`svD+?PB;Q_pd`Xw`i z&LFbw!uOcu{rU3VgkP@LJZW3o#u>k+1q*%|k_0pZEP72BgjaSet*-ept$ba5m)%fJ zZ2GEeHaH#2I9~TDua5lLufHcl|JA*04!hNU`_nHP{fqwjlJ^-kgbwo$t`^rPR}b+< zjDk0TB;esv8$y1*I3LQ-W(>w2$dMv<86N|f!f|H{x0)KtrJ9D2X81c7&%?$JR?AOa#F0wN#+A|L`HAOa#F0wN#+A|L`HAOa#F0wN#+A|L`H MAOa#F0{@M`9i7EFNB{r; literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/mdev5029_2.frm b/mysql-test/std_data/mdev5029_2.frm new file mode 100644 index 0000000000000000000000000000000000000000..d7eb677fea780d987ffb29915b2b999306fb9e38 GIT binary patch literal 8602 zcmeI&O$x#=5C!0uNi1rqbRlls)TId48;CdX3bnX!>j`=e@8d;!5bLCWf>7vErP3Q&Lo z6rcbFC_sUq6c7OdoZz4x0GL9j>%#Sc6hRYIS#_y?@&w!z1t>5q@O5kTZr^X&@N#~k z00k&O0SZun0u-PC1^!mxVG#fA;YJ+Hz~YFFu8cmf9B{@;b6-a|E6Z&%vb2vPnZB8j li*{8chm$Zw-BZzjS^u2E2X#-S4FVs`eUqgP>P|~u;SFZO9y0&{ literal 0 HcmV?d00001 diff --git a/mysql-test/t/bad_frm_crash_5029.test b/mysql-test/t/bad_frm_crash_5029.test index b15c37fbc6d..858922886ab 100644 --- a/mysql-test/t/bad_frm_crash_5029.test +++ b/mysql-test/t/bad_frm_crash_5029.test @@ -4,8 +4,17 @@ # a.k.a. fail to open an frm with indexes: let $datadir=`select @@datadir`; -copy_file std_data/mdev5029.frm $datadir/test/t1.frm; + +# normal innodb table (but innodb is disabled here) +copy_file std_data/mdev5029_1.frm $datadir/test/t1.frm; --error ER_UNKNOWN_STORAGE_ENGINE show create table t1; remove_file $datadir/test/t1.frm; +# Aria table, incorrect typecode +call mtr.add_suppression("t1.frm is inconsistent: engine typecode 43, engine name Aria"); +copy_file std_data/mdev5029_2.frm $datadir/test/t1.frm; +copy_file std_data/mdev5029_2.MAI $datadir/test/t1.MAI; +copy_file std_data/mdev5029_2.MAD $datadir/test/t1.MAD; +show create table t1; +drop table t1; diff --git a/sql/table.cc b/sql/table.cc index 9e71680652a..15fbe867c15 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1093,7 +1093,10 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, plugin_data(tmp_plugin, handlerton *))) { /* bad file, legacy_db_type did not match the name */ - goto err; + sql_print_warning("%s.frm is inconsistent: engine typecode %d, engine name %s (%d)", + share->normalized_path.str, legacy_db_type, + plugin_name(tmp_plugin)->str, + ha_legacy_type(plugin_data(tmp_plugin, handlerton *))); } /* tmp_plugin is locked with a local lock.