diff options
author | unknown <monty@mysql.com> | 2005-06-07 16:34:10 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-06-07 16:34:10 +0300 |
commit | 270832b0a7deb73351f4ff9634118352155c24d4 (patch) | |
tree | 8b370763117959959030cca54a5de410ebbcd402 | |
parent | 01a5d650c01730286f3cade3ac506167671c3f07 (diff) | |
parent | 93722fded286965225f729a7ad84e16402d7b1bb (diff) | |
download | mariadb-git-270832b0a7deb73351f4ff9634118352155c24d4.tar.gz |
Merge mysql.com:/home/my/mysql-4.0 into mysql.com:/home/my/mysql-4.1
BitKeeper/etc/logging_ok:
auto-union
myisam/mi_check.c:
Auto merged
-rw-r--r-- | myisam/mi_check.c | 8 | ||||
-rw-r--r-- | mysql-test/r/analyze.result | 32 | ||||
-rw-r--r-- | mysql-test/t/analyze.test | 39 |
3 files changed, 79 insertions, 0 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index d59c9b9c697..60a2b664c70 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -3870,6 +3870,14 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update) if (!share->state.create_time) share->state.create_time=share->state.check_time; } + /* + When tables are locked we haven't synched the share state and the + real state for a while so we better do it here before synching + the share state to disk. Only when table is write locked is it + necessary to perform this synch. + */ + if (info->lock_type == F_WRLCK) + share->state.state= *info->state; if (mi_state_info_write(share->kfile,&share->state,1+2)) goto err; share->changed=0; diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result new file mode 100644 index 00000000000..0b44a502b13 --- /dev/null +++ b/mysql-test/r/analyze.result @@ -0,0 +1,32 @@ +create table t1 (a bigint); +lock tables t1 write; +insert into t1 values(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +unlock tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a bigint); +insert into t1 values(0); +lock tables t1 write; +delete from t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +unlock tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a bigint); +insert into t1 values(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test new file mode 100644 index 00000000000..faf30279c68 --- /dev/null +++ b/mysql-test/t/analyze.test @@ -0,0 +1,39 @@ +# +# Bug #10901 Analyze Table on new table destroys table +# This is minimal test case to get error +# The problem was that analyze table wrote the shared state to the file and this +# didn't include the inserts while locked. A check was needed to ensure that +# state information was not updated when executing analyze table for a locked table. +# The analyze table had to be within locks and check table had to be after unlocking +# since then it brings the wrong state from disk rather than from the currently +# correct internal state. The insert is needed since it changes the file state, +# number of records. +# The fix is to synchronise the state of the shared state and the current state before +# calling mi_state_info_write +# +create table t1 (a bigint); +lock tables t1 write; +insert into t1 values(0); +analyze table t1; +unlock tables; +check table t1; + +drop table t1; + +create table t1 (a bigint); +insert into t1 values(0); +lock tables t1 write; +delete from t1; +analyze table t1; +unlock tables; +check table t1; + +drop table t1; + +create table t1 (a bigint); +insert into t1 values(0); +analyze table t1; +check table t1; + +drop table t1; + |