Commit f883e5eb authored by Sinisa@sinisa.nasamreza.org's avatar Sinisa@sinisa.nasamreza.org
Browse files

A nasty fix when all rows are deleted with a write lock

parent 5ec7991d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;

+13 −0
Original line number Diff line number Diff line
@@ -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;
+8 −0
Original line number Diff line number Diff line
@@ -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;
+4 −4
Original line number Diff line number Diff line
@@ -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,