From 96252c1de935a4a4bf388dcde1df5a8394c32ff4 Mon Sep 17 00:00:00 2001 From: "mronstrom@mysql.com" <> Date: Fri, 3 Jun 2005 17:13:43 +0200 Subject: Bug #10901 Analyze table corrupts the state on data_file_length, records, index_file_length... by writing the shared state when there is an updated internal state due to inserts or deletes Fixed by synching the shared state with the internal state before writing it to disk Added test cases of 2 error cases and a normal case in new analyze test case --- myisam/mi_check.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'myisam') diff --git a/myisam/mi_check.c b/myisam/mi_check.c index e78d831fde7..16946adb3e8 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -3623,6 +3623,12 @@ 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. + */ + share->state.state= *info->state; if (mi_state_info_write(share->kfile,&share->state,1+2)) goto err; share->changed=0; -- cgit v1.2.1 From 1eaacaf194f314ac029c2cfa5ebaad3dcf764243 Mon Sep 17 00:00:00 2001 From: "mronstrom@mysql.com" <> Date: Fri, 3 Jun 2005 22:52:24 +0200 Subject: Bug #10901 After review fix Copy from internal state to share state only when in lock write mode (happens only when lock table x write has been performed since update_state_info is only called when holding a TL_READ_NO_INSERT lock normally. Previous patch would have failed in combination with delayed writes. --- myisam/mi_check.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'myisam') diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 16946adb3e8..a7c3d2a6f7e 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -3626,9 +3626,11 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update) /* 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. + the share state to disk. Only when table is write locked is it + necessary to perform this synch. */ - share->state.state= *info->state; + 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; -- cgit v1.2.1