From 3f363c7d4d04e9fda8fdf7b0ac99c369045e687c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 31 Aug 2002 20:42:41 +0000 Subject: [PATCH] LOCK+change+OPTIMIZE MyISAM bug myisam/mi_delete_all.c: reverting the wrong bugfix mysql-test/r/delete.result: moving the test case to where it belongs mysql-test/t/delete.test: moving the test case to where it belongs --- myisam/mi_delete_all.c | 4 ++-- mysql-test/r/delete.result | 13 ------------- mysql-test/r/myisam.result | 8 ++++++++ mysql-test/t/delete.test | 8 -------- mysql-test/t/myisam.test | 11 +++++++++++ sql/ha_myisam.cc | 3 ++- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 0605c10e4fa..58f885b63f0 100644 --- a/myisam/mi_delete_all.c +++ b/myisam/mi_delete_all.c @@ -35,11 +35,11 @@ int mi_delete_all_rows(MI_INFO *info) if (_mi_mark_file_changed(info)) goto err; - state->state.records=info->state->records=info->state->del=state->split=0; + info->state->records=info->state->del=state->split=0; state->dellink = HA_OFFSET_ERROR; state->sortkey= (ushort) ~0; info->state->key_file_length=share->base.keystart; - state->state.data_file_length=info->state->data_file_length=0; + info->state->data_file_length=0; info->state->empty=info->state->key_empty=0; state->checksum=0; diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 6fec36cebbe..c2230722aa6 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -24,16 +24,3 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (1), (2), (3); -LOCK TABLES t1 WRITE; -DELETE FROM t1; -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -SELECT * FROM t1; -a -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check status OK -drop table if exists t1; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 8750ea94125..1d66c4cc03d 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -100,3 +100,11 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES (1), (2), (3); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +DROP TABLE t1; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index cd56d14921e..953e22cdd55 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -35,11 +35,3 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (1), (2), (3); -LOCK TABLES t1 WRITE; -DELETE FROM t1; -OPTIMIZE TABLE t1; -SELECT * FROM t1; -CHECK TABLE t1; -drop table if exists t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index c607cb4d63e..dec53e92036 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -93,3 +93,14 @@ INSERT INTO t1 (post_text) VALUES ('ceci est un test'),('ceci est un test'),('ce REPAIR TABLE t1; CHECK TABLE t1; drop table t1; + +# +# Test of OPTIMIZE of locked and modified tables +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES (1), (2), (3); +OPTIMIZE TABLE t1; +DROP TABLE t1; + diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 6ff59babeb4..bae455cbb3c 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -566,11 +566,12 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) } if (!optimize || + memcmp(file->state, & share->state.state, sizeof(MI_STATUS_INFO)) || ((file->state->del || share->state.split != file->state->records) && (!(param.testflag & T_QUICK) || !(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) { - ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ? + ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ? ((ulonglong) 1L << share->base.keys)-1 : share->state.key_map); uint testflag=param.testflag;