From b21997851493d2da85a34e8de669f55ae60a12f5 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Tue, 26 Aug 2008 18:48:50 +0500 Subject: [PATCH 1/2] Fix for bug #37310: 'on update CURRENT_TIMESTAMP' option crashes the table Problem: data consistency check (maximum record length) for a correct MyISAM table with CHECKSUM=1 and ROW_FORMAT=DYNAMIC option may fail due to wrong inner MyISAM parameter. In result we may have the table marked as 'corrupted'. Fix: properly set MyISAM maximum record length parameter. myisam/mi_create.c: Fix for bug #37310: 'on update CURRENT_TIMESTAMP' option crashes the table Use HA_OPTION_PACK_RECORD instead of HA_PACK_RECORD (typo?) calculating packed record length. --- myisam/mi_create.c | 2 +- mysql-test/r/myisam.result | 22 ++++++++++++++++++++++ mysql-test/t/myisam.test | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 75863ed976f..bb53393c345 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -192,7 +192,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, packed=(packed+7)/8; if (pack_reclength != INT_MAX32) pack_reclength+= reclength+packed + - test(test_all_bits(options, HA_OPTION_CHECKSUM | HA_PACK_RECORD)); + test(test_all_bits(options, HA_OPTION_CHECKSUM | HA_OPTION_PACK_RECORD)); min_pack_length+=packed; if (!ci->data_file_length && ci->max_rows) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 33f64d600bb..53bb022147e 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1861,4 +1861,26 @@ id ref 3 2 4 5 DROP TABLE t1, t2; +CREATE TABLE t1 (a INT) ENGINE=MyISAM CHECKSUM=1 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES (0); +UPDATE t1 SET a=1; +SELECT a FROM t1; +a +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES (0), (5), (4), (2); +UPDATE t1 SET a=2; +SELECT a FROM t1; +a +2 +2 +2 +2 +2 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 90d4fc01afb..254b0378aa8 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1210,4 +1210,19 @@ SELECT * FROM t1; DROP TABLE t1, t2; + +# +# Bug#37310: 'on update CURRENT_TIMESTAMP' option crashes the table +# +CREATE TABLE t1 (a INT) ENGINE=MyISAM CHECKSUM=1 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES (0); +UPDATE t1 SET a=1; +SELECT a FROM t1; +CHECK TABLE t1; +INSERT INTO t1 VALUES (0), (5), (4), (2); +UPDATE t1 SET a=2; +SELECT a FROM t1; +CHECK TABLE t1; +DROP TABLE t1; + --echo End of 5.0 tests From 42d0266afe88fb34877d5a33e38a356dd26b02e3 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Tue, 26 Aug 2008 18:51:06 +0500 Subject: [PATCH 2/2] Fix for bug#37277: Potential crash when a spatial index isn't the first key Typo fixed. No test case as we actually don't use rtree_get_first() and rtree_get_next() at present. --- myisam/rt_index.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myisam/rt_index.c b/myisam/rt_index.c index 8ecb3688ad5..df8964edc20 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -389,7 +389,7 @@ int rtree_get_first(MI_INFO *info, uint keynr, uint key_length) info->rtree_recursion_depth = -1; info->buff_used = 1; - return rtree_get_req(info, &keyinfo[keynr], key_length, root, 0); + return rtree_get_req(info, keyinfo, key_length, root, 0); } @@ -436,7 +436,7 @@ int rtree_get_next(MI_INFO *info, uint keynr, uint key_length) return -1; } - return rtree_get_req(info, &keyinfo[keynr], key_length, root, 0); + return rtree_get_req(info, keyinfo, key_length, root, 0); } }