diff options
author | unknown <sergefp@mysql.com> | 2004-09-22 16:29:15 +0400 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2004-09-22 16:29:15 +0400 |
commit | 4063fd2c726a71ed0c9fd7052650f6f0feaaaac7 (patch) | |
tree | e64aeb7d8d84ed6afb7086e9cc18ee52ee1a75fe /myisam | |
parent | 8bf8c8596873b534ad4a13eb73152c617c50c21b (diff) | |
download | mariadb-git-4063fd2c726a71ed0c9fd7052650f6f0feaaaac7.tar.gz |
Fix for BUG#4785:
* myisampack leaves key_file_length value from original table
* myisamchk uses this value when calculating key file pointer length
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_check.c | 2 | ||||
-rw-r--r-- | myisam/mi_create.c | 13 | ||||
-rw-r--r-- | myisam/myisampack.c | 6 |
3 files changed, 15 insertions, 6 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 078f7787dc3..e78d831fde7 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -3520,7 +3520,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) create_info.raid_chunksize= share.base.raid_chunksize; create_info.language = (param->language ? param->language : share.state.header.language); - + create_info.key_file_length= status_info.key_file_length; /* We don't have to handle symlinks here because we are using HA_DONT_TOUCH_DATA */ if (mi_create(filename, diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 328450c70db..99e9ca5ba5f 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -46,7 +46,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ulong reclength, real_reclength,min_pack_length; char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr; ulong pack_reclength; - ulonglong tot_length,max_rows; + ulonglong tot_length,max_rows, tmp; enum en_fieldtype type; MYISAM_SHARE share; MI_KEYDEF *keydef,tmp_keydef; @@ -442,10 +442,15 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.state.auto_increment=ci->auto_increment; share.options=options; share.base.rec_reflength=pointer; + /* Get estimate for index file length (this may be wrong for FT keys) */ + tmp= (tot_length + max_key_block_length * keys * + MI_INDEX_BLOCK_MARGIN) / MI_MIN_KEY_BLOCK_LENGTH; + /* + use maximum of key_file_length we calculated and key_file_length value we + got from MYI file header (see also myisampack.c:save_state) + */ share.base.key_reflength= - mi_get_pointer_length((tot_length + max_key_block_length * keys * - MI_INDEX_BLOCK_MARGIN) / MI_MIN_KEY_BLOCK_LENGTH, - 3); + mi_get_pointer_length(max(ci->key_file_length,tmp),3); share.base.keys= share.state.header.keys = keys; share.state.header.uniques= uniques; mi_int2store(share.state.header.key_parts,key_segs); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 872fcb49faf..4b784641266 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -2041,7 +2041,11 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, share->state.split=(ha_rows) mrg->records; share->state.version=(ulong) time((time_t*) 0); share->state.key_map=0; - share->state.state.key_file_length=share->base.keystart; + /* + Don't save key_file_length here, keep key_file_length of original file + so "myisamchk -rq" can use this value (this is necessary because index + size cannot be easily calculated for fulltext keys) + */ for (key=0 ; key < share->base.keys ; key++) share->state.key_root[key]= HA_OFFSET_ERROR; for (key=0 ; key < share->state.header.max_block_size ; key++) |