From f883e5eb27c2738dd099a6b89b5c67fe7101f09c Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Fri, 30 Aug 2002 22:17:24 +0300 Subject: [PATCH] A nasty fix when all rows are deleted with a write lock --- myisam/mi_delete_all.c | 4 ++-- mysql-test/r/delete.result | 13 +++++++++++++ mysql-test/t/delete.test | 8 ++++++++ sql/mysqld.cc | 8 ++++---- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 58f885b63f0..0605c10e4fa 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; - info->state->records=info->state->del=state->split=0; + state->state.records=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; - info->state->data_file_length=0; + state->state.data_file_length=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 c2230722aa6..6fec36cebbe 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -24,3 +24,16 @@ 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/t/delete.test b/mysql-test/t/delete.test index 953e22cdd55..cd56d14921e 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -35,3 +35,11 @@ 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/sql/mysqld.cc b/sql/mysqld.cc index 7721939f491..be703c894f2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3004,10 +3004,10 @@ struct my_option my_long_options[] = {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE", 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL, - "Don't flush key buffers between writes for any MyISAM table (Depricated option, use --delay-key-write=all instead)", + "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"enable-locking", OPT_ENABLE_LOCK, - "Depricated option, use --external-locking instead", + "Deprecated option, use --external-locking instead", (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NT__ @@ -3244,7 +3244,7 @@ struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef TO_BE_DELETED {"safe-show-database", OPT_SAFE_SHOW_DB, - "Depricated option; One should use GRANT SHOW DATABASES instead...", + "Deprecated option; One should use GRANT SHOW DATABASES instead...", (gptr*) &opt_safe_show_db, (gptr*) &opt_safe_show_db, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -3274,7 +3274,7 @@ struct my_option my_long_options[] = {"skip-innodb", OPT_INNODB_SKIP, "Don't use Innodb (will save memory)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-locking", OPT_SKIP_LOCK, - "Depricated option, use --skip-external-locking instead", + "Deprecated option, use --skip-external-locking instead", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-external-locking", OPT_SKIP_LOCK, "Do not use system (external) locking", (gptr*) &opt_external_locking, (gptr*) &opt_external_locking,