diff options
author | unknown <monty@hundin.mysql.fi> | 2001-10-02 05:53:00 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-10-02 05:53:00 +0300 |
commit | 9e72e1ef534384ab53a0c5943399c946856bef76 (patch) | |
tree | b029d516fe4b48e540f64b01492d64cf5d68ad2f /myisam | |
parent | 003ed4cfaecf0c80dc2ced8593e869076cd8c34d (diff) | |
download | mariadb-git-9e72e1ef534384ab53a0c5943399c946856bef76.tar.gz |
Cleaned up SSL documentation
Fixes for embedded server
Made key_cache more configurable
Fixed that one can change key blocksize in MyISAM
A lot of optimizations to make MyISAM slightly faster
Docs/manual.texi:
Cleaned up SSL documentation
client/mysql.cc:
Fixes for embedded server
client/mysqltest.c:
Fixes for embedded server
Removed memory and file leaks
include/my_global.h:
Added C_MODE_START / C_MODE_END macros
include/my_sys.h:
Made key_cache more configurable
include/myisam.h:
Fixed that one can change MyISAM key block size
include/mysql.h:
Fixes for embedded server
libmysql/libmysql.c:
Cleanup
libmysqld/Makefile.am:
Cleanup
libmysqld/examples/test-run:
Added --debug
libmysqld/lib_sql.cc:
Cleanup
libmysqld/libmysqld.c:
Cleanup
myisam/ft_boolean_search.c:
Optimized mi_key_cmp to be faster
myisam/ft_nlq_search.c:
Optimized mi_key_cmp to be faster
myisam/ft_search.c:
Optimized mi_key_cmp to be faster
myisam/mi_changed.c:
Optimized mi_key_cmp to be faster
myisam/mi_check.c:
Optimized mi_key_cmp to be faster
myisam/mi_create.c:
Fixed that one can change blocksize by changing myisam_block_size
myisam/mi_delete.c:
Optimized mi_key_cmp to be faster
myisam/mi_delete_all.c:
Optimized mi_key_cmp to be faster
myisam/mi_dynrec.c:
Speed optimizations
myisam/mi_info.c:
Speed optimizations
myisam/mi_key.c:
Speed optimizations
myisam/mi_locking.c:
Speed optimizations
myisam/mi_open.c:
Fixed that one can change blocksize by changing myisam_block_size
myisam/mi_page.c:
Fixed that one can change blocksize by changing myisam_block_size
myisam/mi_range.c:
Speed optimizations
myisam/mi_rkey.c:
Speed optimizations
myisam/mi_rnext.c:
Speed optimizations
myisam/mi_rnext_same.c:
Speed optimizations
myisam/mi_rprev.c:
Speed optimizations
myisam/mi_rsame.c:
Speed optimizations
myisam/mi_search.c:
Speed optimizations
myisam/mi_static.c:
Fixed that one can change blocksize by changing myisam_block_size
myisam/mi_statrec.c:
Speed optimizations
myisam/mi_test2.c:
Added more test options
myisam/mi_test_all.res:
Added more test options
myisam/mi_test_all.sh:
Added more test options
myisam/mi_write.c:
Speed optimizations
myisam/myisamchk.c:
Added options to change block size and repair checksums
myisam/myisamdef.h:
Speed optimizations
mysys/Makefile.am:
Added bit handling functions
mysys/mf_keycache.c:
Made key_cache more configurable
mysys/my_init.c:
made my_init_done global
scripts/mysql_fix_privilege_tables.sh:
Fixes for SSL
scripts/mysql_install_db.sh:
Fixes for SSL
sql/derror.cc:
Don't call exit, call unireg_abort()
sql/item_cmpfunc.cc:
Speed optimizations
sql/item_cmpfunc.h:
Speed optimizations
sql/mysql_priv.h:
Fixes for embedded server
sql/mysqld.cc:
Fixes for embedded server
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/ft_boolean_search.c | 2 | ||||
-rw-r--r-- | myisam/ft_nlq_search.c | 2 | ||||
-rw-r--r-- | myisam/ft_search.c | 2 | ||||
-rw-r--r-- | myisam/mi_changed.c | 2 | ||||
-rw-r--r-- | myisam/mi_check.c | 27 | ||||
-rw-r--r-- | myisam/mi_create.c | 17 | ||||
-rw-r--r-- | myisam/mi_delete.c | 3 | ||||
-rw-r--r-- | myisam/mi_delete_all.c | 2 | ||||
-rw-r--r-- | myisam/mi_dynrec.c | 7 | ||||
-rw-r--r-- | myisam/mi_info.c | 2 | ||||
-rw-r--r-- | myisam/mi_key.c | 2 | ||||
-rw-r--r-- | myisam/mi_locking.c | 10 | ||||
-rw-r--r-- | myisam/mi_open.c | 4 | ||||
-rw-r--r-- | myisam/mi_page.c | 4 | ||||
-rw-r--r-- | myisam/mi_range.c | 16 | ||||
-rw-r--r-- | myisam/mi_rkey.c | 12 | ||||
-rw-r--r-- | myisam/mi_rnext.c | 4 | ||||
-rw-r--r-- | myisam/mi_rnext_same.c | 2 | ||||
-rw-r--r-- | myisam/mi_rprev.c | 4 | ||||
-rw-r--r-- | myisam/mi_rsame.c | 5 | ||||
-rw-r--r-- | myisam/mi_search.c | 40 | ||||
-rw-r--r-- | myisam/mi_static.c | 2 | ||||
-rw-r--r-- | myisam/mi_statrec.c | 7 | ||||
-rw-r--r-- | myisam/mi_test2.c | 142 | ||||
-rw-r--r-- | myisam/mi_test_all.res | 90 | ||||
-rwxr-xr-x | myisam/mi_test_all.sh | 20 | ||||
-rw-r--r-- | myisam/mi_write.c | 10 | ||||
-rw-r--r-- | myisam/myisamchk.c | 28 | ||||
-rw-r--r-- | myisam/myisamdef.h | 11 |
29 files changed, 282 insertions, 197 deletions
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index ef248b5d62b..8f3138af989 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -173,7 +173,7 @@ int do_boolean(ALL_IN_ONE *aio, uint nested __attribute__((unused)), aio->key_root); else r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey, - aio->info->lastkey_length, SEARCH_BIGGER, + USE_WHOLE_KEY, SEARCH_BIGGER, aio->key_root); } break; diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c index 350a60708f6..644becb27ab 100644 --- a/myisam/ft_nlq_search.c +++ b/myisam/ft_nlq_search.c @@ -126,7 +126,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) aio->key_root); else r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey, - aio->info->lastkey_length, SEARCH_BIGGER, + USE_WHOLE_KEY, SEARCH_BIGGER, aio->key_root); } if(doc_cnt) { diff --git a/myisam/ft_search.c b/myisam/ft_search.c index c5a43734d9a..6970fa2835d 100644 --- a/myisam/ft_search.c +++ b/myisam/ft_search.c @@ -34,7 +34,7 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query, /* black magic ON */ if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0) return NULL; - if (_mi_readinfo((MI_INFO *)info,F_RDLCK,1)) + if (fast_mi_readinfo((MI_INFO *) info)) return NULL; /* black magic OFF */ diff --git a/myisam/mi_changed.c b/myisam/mi_changed.c index bd6b14b0c6c..5b9003798b0 100644 --- a/myisam/mi_changed.c +++ b/myisam/mi_changed.c @@ -24,7 +24,7 @@ int mi_is_changed(MI_INFO *info) { int result; DBUG_ENTER("mi_is_changed"); - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) DBUG_RETURN(-1); VOID(_mi_writeinfo(info,0)); result=(int) info->data_changed; diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 4ea52c1b565..656e6aa995f 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -231,7 +231,7 @@ wrong: static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) { my_off_t next_link; - uint block_size=(nr+1)*MI_KEY_BLOCK_LENGTH; + uint block_size=(nr+1)*MI_MIN_KEY_BLOCK_LENGTH; ha_rows records; char llbuff[21],*buff; DBUG_ENTER("check_k_link"); @@ -1205,8 +1205,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, param->glob_crc=0; if (param->testflag & T_CALC_CHECKSUM) param->calc_checksum=1; - if (!rep_quick) - share->state.checksum=0; info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); for (i=0 ; i < info->s->base.keys ; i++) @@ -1301,9 +1299,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, else { info->state->data_file_length=sort_info->max_pos; - if (param->testflag & T_CALC_CHECKSUM) - share->state.checksum=param->glob_crc; } + if (param->testflag & T_CALC_CHECKSUM) + share->state.checksum=param->glob_crc; if (!(param->testflag & T_SILENT)) { @@ -1886,8 +1884,6 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, param->glob_crc=0; if (param->testflag & T_CALC_CHECKSUM) param->calc_checksum=1; - if (! rep_quick) - share->state.checksum=0; rec_per_key_part= param->rec_per_key_part; for (sort_info->key=0 ; sort_info->key < share->base.keys ; @@ -2018,7 +2014,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, "Can't change size of datafile, error: %d", my_errno); } - else if (param->testflag & T_CALC_CHECKSUM) + if (param->testflag & T_CALC_CHECKSUM) share->state.checksum=param->glob_crc; if (my_chsize(share->kfile,info->state->key_file_length,MYF(0))) @@ -2115,6 +2111,7 @@ static int sort_key_read(SORT_INFO *sort_info, void *key) DBUG_RETURN(sort_write_record(sort_info)); } /* sort_key_read */ + static int sort_ft_key_read(SORT_INFO *sort_info, void *key) { int error; @@ -2540,7 +2537,7 @@ int sort_write_record(SORT_INFO *sort_info) DBUG_RETURN(1); } sort_info->filepos+=share->base.pack_reclength; - info->s->state.checksum+=mi_static_checksum(info, sort_info->record); + /* sort_info->param->glob_crc+=mi_static_checksum(info, sort_info->record); */ break; case DYNAMIC_RECORD: if (! info->blobs) @@ -2564,7 +2561,7 @@ int sort_write_record(SORT_INFO *sort_info) } info->checksum=mi_checksum(info,sort_info->record); reclength=_mi_rec_pack(info,from,sort_info->record); - info->s->state.checksum+=info->checksum; + /* sort_info->param->glob_crc+=info->checksum; */ block_length=reclength+ 3 + test(reclength >= (65520-3)); if (block_length < share->base.min_block_length) block_length=share->base.min_block_length; @@ -2578,7 +2575,7 @@ int sort_write_record(SORT_INFO *sort_info) DBUG_RETURN(1); } sort_info->filepos+=block_length; - info->s->state.checksum+=info->checksum; + /* sort_info->param->glob_crc+=info->checksum; */ break; case COMPRESSED_RECORD: reclength=info->packed_length; @@ -2591,7 +2588,7 @@ int sort_write_record(SORT_INFO *sort_info) mi_check_print_error(param,"%d when writing to datafile",my_errno); DBUG_RETURN(1); } - info->s->state.checksum+=info->checksum; + /* sort_info->param->glob_crc+=info->checksum; */ sort_info->filepos+=reclength+length; break; } @@ -2808,9 +2805,9 @@ static int sort_delete_record(MI_CHECK *param) DBUG_RETURN(1); } } - if (info->s->calc_checksum) - info->s->state.checksum-=(*info->s->calc_checksum)(info, - sort_info->record); + if (param->calc_checksum) + param->glob_crc-=(*info->s->calc_checksum)(info, + sort_info->record); } error=flush_io_cache(&info->rec_cache) || (*info->s->delete_record)(info); info->dfile=old_file; /* restore actual value */ diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 7033cd59639..aad0300c978 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -227,8 +227,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.state.key_del=key_del; if (uniques) { - max_key_block_length= MI_KEY_BLOCK_LENGTH; - max_key_length= MI_UNIQUE_HASH_LENGTH; + max_key_block_length= myisam_block_size; + max_key_length= MI_UNIQUE_HASH_LENGTH; } for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++) @@ -370,7 +370,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.state.rec_per_key_part[key_segs-1]=1L; length+=key_length; keydef->block_length= MI_BLOCK_SIZE(length,pointer,MI_MAX_KEYPTR_SIZE); - if (keydef->block_length/MI_KEY_BLOCK_LENGTH > MI_MAX_KEY_BLOCK_SIZE) + if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH) { my_errno=HA_WRONG_CREATE_OPTION; goto err; @@ -386,7 +386,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, (length*2)))* (ulong) keydef->block_length; } - for (i=max_key_block_length/MI_KEY_BLOCK_LENGTH ; i-- ; ) + for (i=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH ; i-- ; ) key_del[i]=HA_OFFSET_ERROR; unique_key_parts=0; @@ -401,7 +401,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, key_segs+=uniques; /* Each unique has 1 key seg */ base_pos=(MI_STATE_INFO_SIZE + keys * MI_STATE_KEY_SIZE + - max_key_block_length/MI_KEY_BLOCK_LENGTH*MI_STATE_KEYBLOCK_SIZE+ + max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH* + MI_STATE_KEYBLOCK_SIZE+ key_segs*MI_STATE_KEYSEG_SIZE); info_length=base_pos+(uint) (MI_BASE_INFO_SIZE+ keys * MI_KEYDEF_SIZE+ @@ -420,7 +421,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, mi_int2store(share.state.header.base_pos,base_pos); share.state.header.language= (ci->language ? ci->language : MY_CHARSET_CURRENT); - share.state.header.max_block_size=max_key_block_length/MI_KEY_BLOCK_LENGTH; + share.state.header.max_block_size=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH; share.state.dellink = HA_OFFSET_ERROR; share.state.process= (ulong) getpid(); @@ -433,7 +434,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.base.rec_reflength=pointer; share.base.key_reflength= mi_get_pointer_length((tot_length + max_key_block_length * keys * - MI_INDEX_BLOCK_MARGIN) / MI_KEY_BLOCK_LENGTH, + MI_INDEX_BLOCK_MARGIN) / MI_MIN_KEY_BLOCK_LENGTH, 3); share.base.keys= share.state.header.keys = keys; share.state.header.uniques= uniques; @@ -575,7 +576,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, { tmp_keydef.keysegs=1; tmp_keydef.flag= HA_UNIQUE_CHECK; - tmp_keydef.block_length= MI_KEY_BLOCK_LENGTH; + tmp_keydef.block_length= myisam_block_size; tmp_keydef.keylength= MI_UNIQUE_HASH_LENGTH + pointer; tmp_keydef.minlength=tmp_keydef.maxlength=tmp_keydef.keylength; tmp_keyseg.type= MI_UNIQUE_HASH_TYPE; diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index 445e745b07d..65d245e64f9 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -196,7 +196,8 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_ENTER("d_search"); DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff)); - flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key,key_length,SEARCH_SAME, + flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, USE_WHOLE_KEY, + SEARCH_SAME, &keypos, lastkey, &last_key); if (flag == MI_FOUND_WRONG_KEY) { diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 2c506da865f..6467246e779 100644 --- a/myisam/mi_delete_all.c +++ b/myisam/mi_delete_all.c @@ -43,7 +43,7 @@ int mi_delete_all_rows(MI_INFO *info) info->state->empty=info->state->key_empty=0; state->checksum=0; - for (i=share->base.max_key_block_length/MI_KEY_BLOCK_LENGTH ; i-- ; ) + for (i=share->base.max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH ; i-- ; ) state->key_del[i]= HA_OFFSET_ERROR; for (i=0 ; i < share->base.keys ; i++) state->key_root[i]= HA_OFFSET_ERROR; diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index c9fe493744d..c07fa5aa080 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -1059,11 +1059,11 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf) } while (left_length); info->update|= HA_STATE_AKTIV; /* We have a aktive record */ - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); DBUG_RETURN(_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) != MY_FILE_ERROR ? 0 : -1); } - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); DBUG_RETURN(-1); /* Wrong data to read */ panic: @@ -1393,8 +1393,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf, } while (left_len); info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED; - if (share->r_locks == 0 && share->w_locks == 0) - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); if (_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) != MY_FILE_ERROR) DBUG_RETURN(0); diff --git a/myisam/mi_info.c b/myisam/mi_info.c index 867718de326..c55707ea00c 100644 --- a/myisam/mi_info.c +++ b/myisam/mi_info.c @@ -45,7 +45,7 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag) { pthread_mutex_lock(&share->intern_lock); VOID(_mi_readinfo(info,F_RDLCK,0)); - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); pthread_mutex_unlock(&share->intern_lock); } if (flag & HA_STATUS_VARIABLE) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 9f4e2cb1524..67772c250ac 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -346,7 +346,7 @@ err: int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf) { - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); if (filepos != HA_OFFSET_ERROR) { if (info->lastinx >= 0) diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 8ef5db1d344..b8ffc300fa9 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -50,6 +50,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) count= --share->r_locks; else count= --share->w_locks; + --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && !share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP)) { @@ -153,6 +154,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) } VOID(_mi_test_if_changed(info)); share->r_locks++; + share->tot_locks++; info->lock_type=lock_type; break; case F_WRLCK: @@ -200,6 +202,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) VOID(_mi_test_if_changed(info)); info->lock_type=lock_type; share->w_locks++; + share->tot_locks++; break; default: break; /* Impossible */ @@ -295,13 +298,12 @@ my_bool mi_check_status(void* param) int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer) { - MYISAM_SHARE *share; DBUG_ENTER("_mi_readinfo"); - share=info->s; if (info->lock_type == F_UNLCK) { - if (!share->r_locks && !share->w_locks) + MYISAM_SHARE *share=info->s; + if (!share->tot_locks) { if ((info->tmp_lock_type=lock_type) != F_RDLCK) if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, @@ -339,7 +341,7 @@ int _mi_writeinfo(register MI_INFO *info, uint operation) DBUG_ENTER("_mi_writeinfo"); error=0; - if (share->r_locks == 0 && share->w_locks == 0) + if (share->tot_locks == 0) { olderror=my_errno; /* Remember last error */ if (operation) diff --git a/myisam/mi_open.c b/myisam/mi_open.c index c34f2aa43f4..675dac38d41 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -217,7 +217,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (mi_safe_mul(share->base.reclength, (ulonglong) 1 << (share->base.rec_reflength*8))-1); max_key_file_length= - mi_safe_mul(MI_KEY_BLOCK_LENGTH, + mi_safe_mul(MI_MIN_KEY_BLOCK_LENGTH, ((ulonglong) 1 << (share->base.key_reflength*8))-1); #if SIZEOF_OFF_T == 4 set_if_smaller(max_data_file_length, INT_MAX32); @@ -913,7 +913,7 @@ char *mi_keydef_read(char *ptr, MI_KEYDEF *keydef) keydef->keylength = mi_uint2korr(ptr); ptr +=2; keydef->minlength = mi_uint2korr(ptr); ptr +=2; keydef->maxlength = mi_uint2korr(ptr); ptr +=2; - keydef->block_size = keydef->block_length/MI_KEY_BLOCK_LENGTH-1; + keydef->block_size = keydef->block_length/MI_MIN_KEY_BLOCK_LENGTH-1; keydef->underflow_block_length=keydef->block_length/3; keydef->version = 0; /* Not saved */ return ptr; diff --git a/myisam/mi_page.c b/myisam/mi_page.c index f8e2a977754..d62970c7d98 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -64,9 +64,9 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, #ifndef FAST /* Safety check */ if (page < info->s->base.keystart || page+keyinfo->block_length > info->state->key_file_length || - page & (myisam_block_size-1)) + (page & (MI_MIN_KEY_BLOCK_LENGTH-1))) { - DBUG_PRINT("error",("Trying to write outside key region: %lu", + DBUG_PRINT("error",("Trying to write inside key status region: %lu", (long) page)); my_errno=EINVAL; return(-1); diff --git a/myisam/mi_range.c b/myisam/mi_range.c index 038f9abc3a6..6bf3356e449 100644 --- a/myisam/mi_range.c +++ b/myisam/mi_range.c @@ -45,7 +45,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key, if ((inx = _mi_check_index(info,inx)) < 0) DBUG_RETURN(HA_POS_ERROR); - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) DBUG_RETURN(HA_POS_ERROR); info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED); if (info->s->concurrent_insert) @@ -58,7 +58,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key, info->state->records+ (ha_rows) 1); if (info->s->concurrent_insert) rw_unlock(&info->s->key_root_lock[inx]); - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR) DBUG_RETURN(HA_POS_ERROR); DBUG_PRINT("info",("records: %ld",(ulong) (end_pos-start_pos))); @@ -72,7 +72,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key, static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len, enum ha_rkey_function search_flag) { - uint inx=(uint) info->lastinx; + uint inx=(uint) info->lastinx, nextflag; MI_KEYDEF *keyinfo=info->s->keyinfo+inx; uchar *key_buff; double pos; @@ -86,8 +86,12 @@ static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len, key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len); DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg, (uchar*) key_buff,key_len);); + nextflag=myisam_read_vec[search_flag]; + if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST))) + key_len=USE_WHOLE_KEY; + pos=_mi_search_pos(info,keyinfo,key_buff,key_len, - myisam_read_vec[search_flag] | SEARCH_SAVE_BUFF, + nextflag | SEARCH_SAVE_BUFF, info->s->state.key_root[inx]); if (pos >= 0.0) { @@ -145,9 +149,9 @@ static double _mi_search_pos(register MI_INFO *info, ** Matches keynr+1 */ offset=1.0; /* Matches keynr+1 */ - if (nextflag & SEARCH_FIND && + if ((nextflag & SEARCH_FIND) && nod_flag && ((keyinfo->flag & (HA_NOSAME | HA_NULL_PART)) != HA_NOSAME || - key_len) && nod_flag) + key_len != USE_WHOLE_KEY)) { /* ** There may be identical keys in the tree. Try to match on of those. diff --git a/myisam/mi_rkey.c b/myisam/mi_rkey.c index 0df390412b9..86547d3ef04 100644 --- a/myisam/mi_rkey.c +++ b/myisam/mi_rkey.c @@ -27,7 +27,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, { uchar *key_buff; MYISAM_SHARE *share=info->s; - uint pack_key_length; + uint pack_key_length, use_key_length, nextflag; DBUG_ENTER("mi_rkey"); DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d", info,inx,search_flag)); @@ -55,11 +55,17 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, bmove(key_buff,key,key_len); } - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) goto err; if (share->concurrent_insert) rw_rdlock(&share->key_root_lock[inx]); - if (!_mi_search(info,info->s->keyinfo+inx,key_buff,pack_key_length, + + nextflag=myisam_read_vec[search_flag]; + use_key_length=pack_key_length; + if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST))) + use_key_length=USE_WHOLE_KEY; + + if (!_mi_search(info,info->s->keyinfo+inx,key_buff,use_key_length, myisam_read_vec[search_flag],info->s->state.key_root[inx])) { while (info->lastpos >= info->state->data_file_length) diff --git a/myisam/mi_rnext.c b/myisam/mi_rnext.c index f297740af60..6d135462f96 100644 --- a/myisam/mi_rnext.c +++ b/myisam/mi_rnext.c @@ -35,7 +35,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx) if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_PREV_FOUND) flag=0; /* Read first */ - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) DBUG_RETURN(my_errno); if (info->s->concurrent_insert) rw_rdlock(&info->s->key_root_lock[inx]); @@ -51,7 +51,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx) info->s->state.key_root[inx]); else error=_mi_search(info,info->s->keyinfo+inx,info->lastkey, - info->lastkey_length,flag, info->s->state.key_root[inx]); + USE_WHOLE_KEY,flag, info->s->state.key_root[inx]); if (!error) { diff --git a/myisam/mi_rnext_same.c b/myisam/mi_rnext_same.c index 0e172894cdf..44943ea9137 100644 --- a/myisam/mi_rnext_same.c +++ b/myisam/mi_rnext_same.c @@ -35,7 +35,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf) DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); keyinfo=info->s->keyinfo+inx; flag=SEARCH_BIGGER; /* Read next */ - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) DBUG_RETURN(my_errno); memcpy(info->lastkey2,info->lastkey,info->last_rkey_length); diff --git a/myisam/mi_rprev.c b/myisam/mi_rprev.c index fff2d2257b6..4807e636252 100644 --- a/myisam/mi_rprev.c +++ b/myisam/mi_rprev.c @@ -36,7 +36,7 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx) if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_NEXT_FOUND) flag=0; /* Read last */ - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) DBUG_RETURN(my_errno); changed=_mi_test_if_changed(info); if (share->concurrent_insert) @@ -50,7 +50,7 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx) share->state.key_root[inx]); else error=_mi_search(info,share->keyinfo+inx,info->lastkey, - info->lastkey_length, flag, share->state.key_root[inx]); + USE_WHOLE_KEY, flag, share->state.key_root[inx]); if (!error) { diff --git a/myisam/mi_rsame.c b/myisam/mi_rsame.c index a4092b53c0b..511c247760e 100644 --- a/myisam/mi_rsame.c +++ b/myisam/mi_rsame.c @@ -41,7 +41,7 @@ int mi_rsame(MI_INFO *info, byte *record, int inx) info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); /* Read row from data file */ - if (_mi_readinfo(info,F_RDLCK,1)) + if (fast_mi_readinfo(info)) DBUG_RETURN(my_errno); if (inx >= 0) @@ -51,7 +51,8 @@ int mi_rsame(MI_INFO *info, byte *record, int inx) info->lastpos); if (info->s->concurrent_insert) rw_rdlock(&info->s->key_root_lock[inx]); - VOID(_mi_search(info,info->s->keyinfo+inx,info->lastkey,0,SEARCH_SAME, + VOID(_mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY, + SEARCH_SAME, info->s->state.key_root[inx])); if (info->s->concurrent_insert) rw_unlock(&info->s->key_root_lock[inx]); diff --git a/myisam/mi_search.c b/myisam/mi_search.c index b9895e9d6cd..96ddd9d789d 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -107,14 +107,15 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, } else { - if (nextflag & SEARCH_FIND && (!(keyinfo->flag & HA_NOSAME) - || key_len) && nod_flag) + if ((nextflag & SEARCH_FIND) && nod_flag && + ((keyinfo->flag & (HA_NOSAME | HA_NULL_PART)) != HA_NOSAME || + key_len != USE_WHOLE_KEY)) { if ((error=_mi_search(info,keyinfo,key,key_len,SEARCH_FIND, _mi_kpos(nod_flag,keypos))) >= 0 || my_errno != HA_ERR_KEY_NOT_FOUND) DBUG_RETURN(error); - info->last_keypage= HA_OFFSET_ERROR; /* Buffer not in memory */ + info->last_keypage= HA_OFFSET_ERROR; /* Buffer not in mem */ } } if (pos != info->last_keypage) @@ -283,8 +284,6 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, LINT_INIT(saved_vseg); t_buff[0]=0; /* Avoid bugs */ - if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST))) - key_len=USE_WHOLE_KEY; end= page+mi_getint(page); nod_flag=mi_test_if_nod(page); page+=2+nod_flag; @@ -477,11 +476,11 @@ my_off_t _mi_kpos(uint nod_flag, uchar *after_key) switch (nod_flag) { #if SIZEOF_OFF_T > 4 case 7: - return mi_uint7korr(after_key)*MI_KEY_BLOCK_LENGTH; + return mi_uint7korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH; case 6: - return mi_uint6korr(after_key)*MI_KEY_BLOCK_LENGTH; + return mi_uint6korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH; case 5: - return mi_uint5korr(after_key)*MI_KEY_BLOCK_LENGTH; + return mi_uint5korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH; #else case 7: after_key++; @@ -491,13 +490,13 @@ my_off_t _mi_kpos(uint nod_flag, uchar *after_key) after_key++; #endif case 4: - return ((my_off_t) mi_uint4korr(after_key))*MI_KEY_BLOCK_LENGTH; + return ((my_off_t) mi_uint4korr(after_key))*MI_MIN_KEY_BLOCK_LENGTH; case 3: - return ((my_off_t) mi_uint3korr(after_key))*MI_KEY_BLOCK_LENGTH; + return ((my_off_t) mi_uint3korr(after_key))*MI_MIN_KEY_BLOCK_LENGTH; case 2: - return (my_off_t) (mi_uint2korr(after_key)*MI_KEY_BLOCK_LENGTH); + return (my_off_t) (mi_uint2korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH); case 1: - return (uint) (*after_key)*MI_KEY_BLOCK_LENGTH; + return (uint) (*after_key)*MI_MIN_KEY_BLOCK_LENGTH; case 0: /* At leaf page */ default: /* Impossible */ return(HA_OFFSET_ERROR); @@ -509,7 +508,7 @@ my_off_t _mi_kpos(uint nod_flag, uchar *after_key) void _mi_kpointer(register MI_INFO *info, register uchar *buff, my_off_t pos) { - pos/=MI_KEY_BLOCK_LENGTH; + pos/=MI_MIN_KEY_BLOCK_LENGTH; switch (info->s->base.key_reflength) { #if SIZEOF_OFF_T > 4 case 7: mi_int7store(buff,pos); break; @@ -719,10 +718,7 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, double d_1,d_2; uint next_key_length; - if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST))) - key_length=USE_WHOLE_KEY; *diff_pos=0; - for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++) { uchar *end; @@ -1446,7 +1442,7 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, info->page_changed || (info->int_keytree_version != keyinfo->version && (info->int_nod_flag || info->buff_used))) - DBUG_RETURN(_mi_search(info,keyinfo,key,key_length, + DBUG_RETURN(_mi_search(info,keyinfo,key, USE_WHOLE_KEY, nextflag | SEARCH_SAVE_BUFF, pos)); if (info->buff_used) @@ -1459,17 +1455,17 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, /* Last used buffer is in info->buff */ nod_flag=mi_test_if_nod(info->buff); - memcpy(lastkey,key,key_length); if (nextflag & SEARCH_BIGGER) /* Next key */ { my_off_t tmp_pos=_mi_kpos(nod_flag,info->int_keypos); if (tmp_pos != HA_OFFSET_ERROR) { - if ((error=_mi_search(info,keyinfo,key,key_length, + if ((error=_mi_search(info,keyinfo,key, USE_WHOLE_KEY, nextflag | SEARCH_SAVE_BUFF, tmp_pos)) <=0) DBUG_RETURN(error); } + memcpy(lastkey,key,key_length); if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag, &info->int_keypos,lastkey))) DBUG_RETURN(-1); @@ -1483,12 +1479,14 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!info->int_keypos) DBUG_RETURN(-1); if (info->int_keypos == info->buff+2) - DBUG_RETURN(_mi_search(info,keyinfo,key,key_length, + DBUG_RETURN(_mi_search(info,keyinfo,key, USE_WHOLE_KEY, nextflag | SEARCH_SAVE_BUFF, pos)); - if ((error=_mi_search(info,keyinfo,key,0,nextflag | SEARCH_SAVE_BUFF, + if ((error=_mi_search(info,keyinfo,key, USE_WHOLE_KEY, + nextflag | SEARCH_SAVE_BUFF, _mi_kpos(nod_flag,info->int_keypos))) <= 0) DBUG_RETURN(error); + /* QQ: We should be able to optimize away the following call */ if (! _mi_get_last_key(info,keyinfo,info->buff,lastkey, info->int_keypos,&info->lastkey_length)) DBUG_RETURN(-1); diff --git a/myisam/mi_static.c b/myisam/mi_static.c index 389aac3142a..43e21340f5f 100644 --- a/myisam/mi_static.c +++ b/myisam/mi_static.c @@ -40,7 +40,7 @@ my_bool myisam_concurrent_insert=0; #endif my_off_t myisam_max_extra_temp_length= MI_MAX_TEMP_LENGTH; my_off_t myisam_max_temp_length= MAX_FILE_SIZE; -uint myisam_bulk_insert_tree_size=8192*1024; +ulong myisam_bulk_insert_tree_size=8192*1024; /* read_vec[] is used for converting between P_READ_KEY.. and SEARCH_ */ /* Position is , == , >= , <= , > , < */ diff --git a/myisam/mi_statrec.c b/myisam/mi_statrec.c index e0fce6d3e1c..2712c125f4e 100644 --- a/myisam/mi_statrec.c +++ b/myisam/mi_statrec.c @@ -181,8 +181,7 @@ int _mi_read_static_record(register MI_INFO *info, register my_off_t pos, error=my_pread(info->dfile,(char*) record,info->s->base.reclength, pos,MYF(MY_NABP)) != 0; - if (info->s->r_locks == 0 && info->s->w_locks == 0) - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); if (! error) { if (!*record) @@ -195,7 +194,7 @@ int _mi_read_static_record(register MI_INFO *info, register my_off_t pos, } return(-1); /* Error on read */ } - VOID(_mi_writeinfo(info,0)); /* No such record */ + fast_mi_writeinfo(info); /* No such record */ return(-1); } @@ -257,7 +256,7 @@ int _mi_read_rnd_static_record(MI_INFO *info, byte *buf, DBUG_PRINT("test",("filepos: %ld (%ld) records: %ld del: %ld", filepos/share->base.reclength,filepos, info->state->records, info->state->del)); - VOID(_mi_writeinfo(info,0)); + fast_mi_writeinfo(info); DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE); } info->lastpos= filepos; diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index b66b02afdf9..cb60aeb8618 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -343,68 +343,72 @@ int main(int argc, char *argv[]) } if (testflag==3) goto end; - if (!silent) - printf("- Same key: first - next -> last - prev -> first\n"); - DBUG_PRINT("progpos",("first - next -> last - prev -> first")); for (i=999, dupp_keys=j=0 ; i>0 ; i--) { - if (key1[i] >dupp_keys) { dupp_keys=key1[i]; j=i; } + if (key1[i] > dupp_keys) { dupp_keys=key1[i]; j=i; } } sprintf(key,"%6d",j); - if (verbose) printf(" Using key: \"%s\" Keys: %d\n",key,dupp_keys); - if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err; - if (mi_rsame(file,read_record2,-1)) goto err; - if (memcmp(read_record,read_record2,reclength) != 0) - { - printf("mi_rsame didn't find same record\n"); - goto end; - } - info.recpos=mi_position(file); - if (mi_rfirst(file,read_record2,0) || - mi_rsame_with_pos(file,read_record2,0,info.recpos) || - memcmp(read_record,read_record2,reclength) != 0) + if (dupp_keys) { - printf("mi_rsame_with_pos didn't find same record\n"); - goto end; - } - { - int skr=mi_rnext(file,read_record2,0); - if ((skr && my_errno != HA_ERR_END_OF_FILE) || - mi_rprev(file,read_record2,-1) || + if (!silent) + printf("- Same key: first - next -> last - prev -> first\n"); + DBUG_PRINT("progpos",("first - next -> last - prev -> first")); + if (verbose) printf(" Using key: \"%s\" Keys: %d\n",key,dupp_keys); + + if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err; + if (mi_rsame(file,read_record2,-1)) goto err; + if (memcmp(read_record,read_record2,reclength) != 0) + { + printf("mi_rsame didn't find same record\n"); + goto end; + } + info.recpos=mi_position(file); + if (mi_rfirst(file,read_record2,0) || + mi_rsame_with_pos(file,read_record2,0,info.recpos) || memcmp(read_record,read_record2,reclength) != 0) { - printf("mi_rsame_with_pos lost position\n"); + printf("mi_rsame_with_pos didn't find same record\n"); + goto end; + } + { + int skr=mi_rnext(file,read_record2,0); + if ((skr && my_errno != HA_ERR_END_OF_FILE) || + mi_rprev(file,read_record2,-1) || + memcmp(read_record,read_record2,reclength) != 0) + { + printf("mi_rsame_with_pos lost position\n"); + goto end; + } + } + ant=1; + start=keyinfo[0].seg[0].start; length=keyinfo[0].seg[0].length; + while (mi_rnext(file,read_record2,0) == 0 && + memcmp(read_record2+start,key,length) == 0) ant++; + if (ant != dupp_keys) + { + printf("next: Found: %d keys of %d\n",ant,dupp_keys); + goto end; + } + ant=0; + while (mi_rprev(file,read_record3,0) == 0 && + bcmp(read_record3+start,key,length) == 0) ant++; + if (ant != dupp_keys) + { + printf("prev: Found: %d records of %d\n",ant,dupp_keys); goto end; } - } - ant=1; - start=keyinfo[0].seg[0].start; length=keyinfo[0].seg[0].length; - while (mi_rnext(file,read_record2,0) == 0 && - memcmp(read_record2+start,key,length) == 0) ant++; - if (ant != dupp_keys) - { - printf("next: Found: %d keys of %d\n",ant,dupp_keys); - goto end; - } - ant=0; - while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; - if (ant != dupp_keys) - { - printf("prev: Found: %d records of %d\n",ant,dupp_keys); - goto end; - } - /* Check of mi_rnext_same */ - if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) - goto err; - ant=1; - while (!mi_rnext_same(file,read_record3) && ant < dupp_keys+10) - ant++; - if (ant != dupp_keys || my_errno != HA_ERR_END_OF_FILE) - { - printf("mi_rnext_same: Found: %d records of %d\n",ant,dupp_keys); - goto end; + /* Check of mi_rnext_same */ + if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) + goto err; + ant=1; + while (!mi_rnext_same(file,read_record3) && ant < dupp_keys+10) + ant++; + if (ant != dupp_keys || my_errno != HA_ERR_END_OF_FILE) + { + printf("mi_rnext_same: Found: %d records of %d\n",ant,dupp_keys); + goto end; + } } if (!silent) @@ -776,9 +780,13 @@ end: printf("\nFollowing test have been made:\n"); printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete); if (rec_pointer_size) - printf("Record pointer size: %d\n",rec_pointer_size); + printf("Record pointer size: %d\n",rec_pointer_size); + printf("myisam_block_size: %u\n", myisam_block_size); if (key_cacheing) + { puts("Key cacheing used"); + printf("key_cache_block_size: %u\n", key_cache_block_size); + } if (write_cacheing) puts("Write cacheing used"); if (write_cacheing) @@ -801,7 +809,7 @@ reads: %10lu\n", end_key_cache(); if (blob_buffer) my_free(blob_buffer,MYF(0)); - my_end(MY_CHECK_ERROR | MY_GIVE_INFO); + my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); return(0); err: printf("got error: %d when using MyISAM-database\n",my_errno); @@ -861,7 +869,29 @@ static void get_options(int argc, char **argv) verbose=1; break; case 'm': /* records */ - recant=atoi(++pos); + if ((recant=atoi(++pos)) < 10) + { + fprintf(stderr,"record count must be >= 10\n"); + exit(1); + } + break; + case 'e': /* myisam_block_length */ + if ((myisam_block_size=atoi(++pos)) < MI_MIN_KEY_BLOCK_LENGTH || + myisam_block_size > MI_MAX_KEY_BLOCK_LENGTH) + { + fprintf(stderr,"Wrong myisam_block_length\n"); + exit(1); + } + myisam_block_size=1 << my_bit_log2(myisam_block_size); + break; + case 'E': /* myisam_block_length */ + if ((key_cache_block_size=atoi(++pos)) < MI_MIN_KEY_BLOCK_LENGTH || + key_cache_block_size > MI_MAX_KEY_BLOCK_LENGTH) + { + fprintf(stderr,"Wrong key_cache_block_size\n"); + exit(1); + } + key_cache_block_size=1 << my_bit_log2(key_cache_block_size); break; case 'f': if ((first_key=atoi(++pos)) < 0 || first_key >= MYISAM_KEYS) @@ -904,7 +934,7 @@ static void get_options(int argc, char **argv) case 'V': printf("%s Ver 1.2 for %s at %s\n",progname,SYSTEM_TYPE,MACHINE_TYPE); puts("By Monty, for your professional use\n"); - printf("Usage: %s [-?AbBcDIKLPRqSsVWltv] [-k#] [-f#] [-m#] [-t#]\n", + printf("Usage: %s [-?AbBcDIKLPRqSsVWltv] [-k#] [-f#] [-m#] [-e#] [-E#] [-t#]\n", progname); exit(0); case '#': diff --git a/myisam/mi_test_all.res b/myisam/mi_test_all.res index d6b4703d702..94355bf1aa2 100644 --- a/myisam/mi_test_all.res +++ b/myisam/mi_test_all.res @@ -1,48 +1,50 @@ -Maximum memory usage: 545477 bytes (533k) -Maximum memory usage: 545477 bytes (533k) -Maximum memory usage: 545369 bytes (533k) -mi_test2-i686 -s -L -K -R1 -m2000 ; Should give error 135 +mi_test2 -s -L -K -R1 -m2000 ; Should give error 135 Error: 135 in write at record: 1105 got error: 135 when using MyISAM-database -Maximum memory usage: 29439 bytes (29k) -Maximum memory usage: 66541 bytes (65k) -Maximum memory usage: 5101 bytes (5k) -Maximum memory usage: 545488 bytes (533k) +myisamchk: MyISAM file test2 +myisamchk: warning: Datafile is almost full, 65532 of 65534 used +MyISAM-table 'test2' is usable but should be fixed Commands Used count Errors Recover errors -open 1 0 0 -write 50 0 0 -update 5 0 0 -delete 50 0 0 -close 1 0 0 -extra 6 0 0 -Total 113 0 0 -Maximum memory usage: 545744 bytes (533k) +open 17 0 0 +write 850 0 0 +update 85 0 0 +delete 850 0 0 +close 17 0 0 +extra 102 0 0 +Total 1921 0 0 Commands Used count Errors Recover errors -open 2 0 0 -write 100 0 0 -update 10 0 0 -delete 100 0 0 -close 2 0 0 -extra 12 0 0 -Total 226 0 0 -Maximum memory usage: 5101 bytes (5k) -1.12user 0.52system 0:01.71elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (214major+25minor)pagefaults 0swaps -Maximum memory usage: 21189 bytes (21k) -1.29user 0.55system 0:01.82elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (215major+29minor)pagefaults 0swaps -Maximum memory usage: 66541 bytes (65k) -1.10user 0.51system 0:01.66elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (216major+40minor)pagefaults 0swaps -Maximum memory usage: 82629 bytes (81k) -1.33user 0.24system 0:01.54elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (216major+44minor)pagefaults 0swaps -Maximum memory usage: 545477 bytes (533k) -1.31user 0.24system 0:01.55elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (216major+173minor)pagefaults 0swaps -Maximum memory usage: 545389 bytes (533k) -1.37user 0.18system 0:01.57elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (218major+180minor)pagefaults 0swaps -Maximum memory usage: 109165 bytes (107k) -1.42user 0.38system 0:01.78elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k -0inputs+0outputs (218major+51minor)pagefaults 0swaps +open 18 0 0 +write 900 0 0 +update 90 0 0 +delete 900 0 0 +close 18 0 0 +extra 108 0 0 +Total 2034 0 0 + +real 0m1.054s +user 0m0.410s +sys 0m0.640s + +real 0m1.077s +user 0m0.550s +sys 0m0.530s + +real 0m1.100s +user 0m0.420s +sys 0m0.680s + +real 0m0.783s +user 0m0.590s +sys 0m0.200s + +real 0m0.764s +user 0m0.560s +sys 0m0.210s + +real 0m0.699s +user 0m0.570s +sys 0m0.130s + +real 0m0.991s +user 0m0.630s +sys 0m0.350s diff --git a/myisam/mi_test_all.sh b/myisam/mi_test_all.sh index ccc9c39c64e..a2d57ea1a83 100755 --- a/myisam/mi_test_all.sh +++ b/myisam/mi_test_all.sh @@ -66,6 +66,14 @@ myisamchk$suffix -rs test1 myisamchk$suffix -se test1 myisamchk$suffix -rqs test1 myisamchk$suffix -se test1 +myisamchk$suffix -rs --correct-checksum test1 +myisamchk$suffix -se test1 +myisamchk$suffix -rqs --correct-checksum test1 +myisamchk$suffix -se test1 +myisamchk$suffix -ros --correct-checksum test1 +myisamchk$suffix -se test1 +myisamchk$suffix -rqos --correct-checksum test1 +myisamchk$suffix -se test1 # check of myisampack / myisamchk myisampack$suffix --force -s test1 @@ -105,13 +113,25 @@ mi_test1$suffix $silent --key_multiple -P -S myisamchk$suffix -sm test1 mi_test2$suffix $silent -L -K -W -P +myisamchk$suffix -sm test2 mi_test2$suffix $silent -L -K -W -P -A +myisamchk$suffix -sm test2 mi_test2$suffix $silent -L -K -W -P -S -R1 -m500 echo "mi_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135" +myisamchk$suffix -sm test2 mi_test2$suffix $silent -L -K -R1 -m2000 +myisamchk$suffix -sm test2 mi_test2$suffix $silent -L -K -P -S -R3 -m50 -b1000000 +myisamchk$suffix -sm test2 mi_test2$suffix $silent -L -B +myisamchk$suffix -sm test2 mi_test2$suffix $silent -D -B -c +myisamchk$suffix -sm test2 +mi_test2$suffix $silent -m10000 -e8192 -K +myisamchk$suffix -sm test2 +mi_test2$suffix $silent -m10000 -e16384 -E16384 -K -L +myisamchk$suffix -sm test2 + mi_test2$suffix $silent -L -K -W -P -m50 -l myisamlog$suffix mi_test2$suffix $silent -L -K -W -P -m50 -l -b100 diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 096d5829fed..e3de13d2d9a 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -291,7 +291,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_bool insert_last) { int error,flag; - uint comp_flag,nod_flag; + uint comp_flag,nod_flag, search_key_length; uchar *temp_buff,*keypos; uchar keybuff[MI_MAX_KEY_BUFF]; my_bool was_last_key; @@ -299,10 +299,14 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_ENTER("w_search"); DBUG_PRINT("enter",("page: %ld",page)); + search_key_length=USE_WHOLE_KEY; if (keyinfo->flag & HA_SORT_ALLOWS_SAME) comp_flag=SEARCH_BIGGER; /* Put after same key */ else if (keyinfo->flag & HA_NOSAME) + { comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No dupplicates */ + search_key_length= key_length; + } else comp_flag=SEARCH_SAME; /* Keys in rec-pos order */ @@ -312,8 +316,8 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!_mi_fetch_keypage(info,keyinfo,page,temp_buff,0)) goto err; - flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,key_length,comp_flag, - &keypos, keybuff, &was_last_key); + flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,search_key_length, + comp_flag, &keypos, keybuff, &was_last_key); nod_flag=mi_test_if_nod(temp_buff); if (flag == 0) { diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 319539b44d4..b4c9e2f0fd6 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -40,6 +40,7 @@ static char **default_argv; static const char *load_default_groups[]= { "myisamchk", 0 }; static const char *set_charset_name; static CHARSET_INFO *set_charset; +static long opt_myisam_block_size; static const char *type_names[]= { "?","char","binary", "short", "long", "float", @@ -141,6 +142,9 @@ int main(int argc, char **argv) static CHANGEABLE_VAR changeable_vars[] = { { "key_buffer_size",(long*) &check_param.use_buffers,(long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) ~0L,(long) MALLOC_OVERHEAD,(long) IO_SIZE }, + { "myisam_block_size", (long*) &opt_myisam_block_size, + MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, + 0, MI_MIN_KEY_BLOCK_LENGTH }, { "read_buffer_size", (long*) &check_param.read_buffer_length,(long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,(long) ~0L,(long) MALLOC_OVERHEAD,(long) 1L }, { "write_buffer_size", (long*) &check_param.write_buffer_length,(long) READ_BUFFER_INIT, @@ -159,7 +163,10 @@ static CHANGEABLE_VAR changeable_vars[] = { 20, 4, HA_FT_MAXLEN, 0, 1 }, { NullS,(long*) 0,0L,0L,0L,0L,0L,} }; -enum options {OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS}; +enum options { + OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS, + OPT_CORRECT_CHECKSUM +}; static struct option long_options[] = @@ -167,9 +174,10 @@ static struct option long_options[] = {"analyze", no_argument, 0, 'a'}, {"block-search", required_argument,0, 'b'}, {"backup", no_argument, 0, 'B'}, - {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, + {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, {"check", no_argument, 0, 'c'}, {"check-only-changed",no_argument, 0, 'C'}, + {"correct-checksum", no_argument, 0, OPT_CORRECT_CHECKSUM}, #ifndef DBUG_OFF {"debug", optional_argument, 0, '#'}, #endif @@ -205,7 +213,7 @@ static struct option long_options[] = static void print_version(void) { - printf("%s Ver 1.51 for %s at %s\n",my_progname,SYSTEM_TYPE, + printf("%s Ver 1.52 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); } @@ -248,6 +256,7 @@ static void usage(void) puts("Repair options (When using -r or -o) \n\ -B, --backup Make a backup of the .MYD file as 'filename-time.BAK'\n\ + --correct-checksum Correct checksum information for table. \n\ -D, --data-file-length=# Max length of data file (when recreating data\n\ file when it's full)\n\ -e, --extend-check Try to recover every possible row from the data file\n\ @@ -433,6 +442,9 @@ static void get_options(register int *argc,register char ***argv) case 'V': print_version(); exit(0); + case OPT_CORRECT_CHECKSUM: + check_param.testflag|=T_CALC_CHECKSUM; + break; case OPT_CHARSETS_DIR: charsets_dir = optarg; break; @@ -449,6 +461,11 @@ static void get_options(register int *argc,register char ***argv) exit(0); } } + /* If using repair, then update checksum if one uses --update-state */ + if ((check_param.testflag & T_UPDATE_STATE) && + (check_param.testflag & (T_REP | T_REP_BY_SORT))) + check_param.testflag|= T_CALC_CHECKSUM; + (*argc)-=optind; (*argv)+=optind; if (*argc == 0) @@ -456,6 +473,7 @@ static void get_options(register int *argc,register char ***argv) usage(); exit(-1); } + if ((check_param.testflag & T_UNPACK) && (check_param.opt_rep_quick || (check_param.testflag & T_SORT_RECORDS))) { @@ -479,6 +497,7 @@ static void get_options(register int *argc,register char ***argv) if (!(set_charset=get_charset_by_name(set_charset_name, MYF(MY_WME)))) exit(1); + myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size); return; } /* get options */ @@ -605,7 +624,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) (((ulonglong) 1L << share->base.keys)-1)) || test_if_almost_full(info) || info->s->state.header.file_version[3] != myisam_file_magic[3] || - (set_charset && set_charset->number != share->state.header.language))) + (set_charset && set_charset->number != share->state.header.language) || + myisam_block_size != MI_KEY_BLOCK_LENGTH)) { if (set_charset) check_param.language=set_charset->number; diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index a2a30ae50ce..33837dfda00 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -173,7 +173,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */ File data_file; /* Shared data file */ int mode; /* mode of file on open */ uint reopen; /* How many times reopened */ - uint w_locks,r_locks; /* Number of read/write locks */ + uint w_locks,r_locks,tot_locks; /* Number of read/write locks */ uint blocksize; /* blocksize of keyfile */ ulong min_pack_length; /* Theese are used by packed data */ ulong max_pack_length; @@ -365,10 +365,8 @@ struct st_myisam_info { #define PACK_TYPE_ZERO_FILL 4 #define MI_FOUND_WRONG_KEY 32738 /* Impossible value from _mi_key_cmp */ -#define MI_KEY_BLOCK_LENGTH 1024 /* Min key block length */ -#define MI_MAX_KEY_BLOCK_LENGTH 8192 -#define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_KEY_BLOCK_LENGTH) -#define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer) ((((key_length+data_pointer+key_pointer)*4+key_pointer+2)/MI_KEY_BLOCK_LENGTH+1)*MI_KEY_BLOCK_LENGTH) +#define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH) +#define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer) ((((key_length+data_pointer+key_pointer)*4+key_pointer+2)/myisam_block_size+1)*myisam_block_size) #define MI_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ #define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */ @@ -589,6 +587,9 @@ enum myisam_log_commands { #define myisam_log_command(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_command(a,b,c,d,e) #define myisam_log_record(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_record(a,b,c,d,e) +#define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0) +#define fast_mi_readinfo(INFO) (!(INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1) + #ifdef __cplusplus extern "C" { #endif |