summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com/june.mysql.com>2007-04-13 12:38:27 +0500
committerunknown <svoj@mysql.com/june.mysql.com>2007-04-13 12:38:27 +0500
commitf4a5f3c6ffd09d574220dd3c20718e239d815341 (patch)
tree4e71fd10f53e58f29af50e0e05f819d7b8a8ae96 /myisam
parentddaeead8fc3bf96b87c1f755c226a251c0732bb9 (diff)
downloadmariadb-git-f4a5f3c6ffd09d574220dd3c20718e239d815341.tar.gz
BUG#27516 - divide by zero crash during optimize table
When a table status is requested by statement like SHOW TABLE STATUS and there is another statement (e.g. DELETE) sets number of records to 0 concurrently, we may get division by zero error, which crashes a server. This is fixed by using thread local variable x->records instead of shared info->state->records when we check if it is zero and divide by it. myisam/mi_info.c: Information schema does not lock a table when it requests table state info. If another thread sets info->state->records to 0 after we check if it is 0 and before we divide by it we may get division by zero error. Check and divide by local x->records variable instead of shared info->state->records.
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_info.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/myisam/mi_info.c b/myisam/mi_info.c
index 0435269ed6d..b7de8e7b37d 100644
--- a/myisam/mi_info.c
+++ b/myisam/mi_info.c
@@ -57,9 +57,9 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag)
x->keys = share->state.header.keys;
x->check_time = share->state.check_time;
- x->mean_reclength = info->state->records ?
- (ulong) ((info->state->data_file_length-info->state->empty)/
- info->state->records) : (ulong) share->min_pack_length;
+ x->mean_reclength= x->records ?
+ (ulong) ((x->data_file_length - x->delete_length) / x->records) :
+ (ulong) share->min_pack_length;
}
if (flag & HA_STATUS_ERRKEY)
{