diff options
author | unknown <igor@rurik.mysql.com> | 2003-08-09 11:12:22 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2003-08-09 11:12:22 -0700 |
commit | cbd85f9deb0f407dcb50bd818b20e16aa77e6b2b (patch) | |
tree | ea16bf3e27f2e3cd5852920dd399f64853a919b7 /myisam | |
parent | af6d20830c3f192f1b617b610d1cc0def535f1fb (diff) | |
download | mariadb-git-cbd85f9deb0f407dcb50bd818b20e16aa77e6b2b.tar.gz |
set_var.cc, mysqld.cc, handler.cc, set_var.h, handler.h:
Added key cache parameters for midpoint insertion strategy
Many files:
Added midpoint insertion strategy for key cache
mi_test2.c:
Added a parameter to resize_key_cache
mysys/mf_keycache.c:
Added midpoint insertion strategy for key cache
myisam/mi_check.c:
Added midpoint insertion strategy for key cache
myisam/mi_page.c:
Added midpoint insertion strategy for key cache
myisam/mi_range.c:
Added midpoint insertion strategy for key cache
myisam/rt_index.c:
Added midpoint insertion strategy for key cache
myisam/rt_split.c:
Added midpoint insertion strategy for key cache
myisam/mi_delete.c:
Added midpoint insertion strategy for key cache
myisam/mi_preload.c:
Added midpoint insertion strategy for key cache
myisam/mi_search.c:
Added midpoint insertion strategy for key cache
myisam/mi_write.c:
Added midpoint insertion strategy for key cache
myisam/rt_key.c:
Added midpoint insertion strategy for key cache
myisam/mi_test2.c:
Added a parameter to resize_key_cache
isam/_page.c:
Added midpoint insertion strategy for key cache
include/my_sys.h:
Added midpoint insertion strategy for key cache
myisam/myisamdef.h:
Added midpoint insertion strategy for key cache
sql/handler.h:
Added key cache parameters for midpoint insertion strategy.
sql/set_var.h:
Added key cache parameters for midpoint insertion strategy.
sql/handler.cc:
Added key cache parameters for midpoint insertion strategy.
sql/mysqld.cc:
Added key cache parameters for midpoint insertion strategy.
sql/set_var.cc:
Added key cache parameters for midpoint insertion strategy.
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_check.c | 24 | ||||
-rw-r--r-- | myisam/mi_delete.c | 40 | ||||
-rw-r--r-- | myisam/mi_page.c | 18 | ||||
-rw-r--r-- | myisam/mi_preload.c | 6 | ||||
-rw-r--r-- | myisam/mi_range.c | 2 | ||||
-rw-r--r-- | myisam/mi_search.c | 10 | ||||
-rw-r--r-- | myisam/mi_test2.c | 2 | ||||
-rw-r--r-- | myisam/mi_write.c | 27 | ||||
-rw-r--r-- | myisam/myisamdef.h | 9 | ||||
-rw-r--r-- | myisam/rt_index.c | 49 | ||||
-rw-r--r-- | myisam/rt_key.c | 3 | ||||
-rw-r--r-- | myisam/rt_split.c | 6 |
12 files changed, 109 insertions, 87 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 1b29fd01272..e1b9c2597e7 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -231,7 +231,8 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) next_link & (info->s->blocksize-1)) DBUG_RETURN(1); if (!(buff=key_cache_read(*info->s->keycache, - info->s->kfile, next_link, (byte*) info->buff, + info->s->kfile, next_link, DFLT_INIT_HITS, + (byte*) info->buff, myisam_block_size, block_size, 1))) DBUG_RETURN(1); next_link=mi_sizekorr(buff); @@ -371,8 +372,8 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) if (share->state.key_root[key] == HA_OFFSET_ERROR && (info->state->records == 0 || keyinfo->flag & HA_FULLTEXT)) continue; - if (!_mi_fetch_keypage(info,keyinfo,share->state.key_root[key],info->buff, - 0)) + if (!_mi_fetch_keypage(info,keyinfo,share->state.key_root[key], + DFLT_INIT_HITS,info->buff,0)) { mi_check_print_error(param,"Can't read indexpage from filepos: %s", llstr(share->state.key_root[key],buff)); @@ -550,7 +551,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, info->state->key_file_length=(max_length & ~ (my_off_t) (info->s->blocksize-1)); } - if (!_mi_fetch_keypage(info,keyinfo,next_page,temp_buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,next_page, + DFLT_INIT_HITS,temp_buff,0)) { mi_check_print_error(param,"Can't read key from filepos: %s",llstr(next_page,llbuff)); goto err; @@ -1443,7 +1445,8 @@ int movepoint(register MI_INFO *info, byte *record, my_off_t oldpos, nod_flag=mi_test_if_nod(info->buff); _mi_dpointer(info,info->int_keypos-nod_flag- info->s->rec_reflength,newpos); - if (_mi_write_keypage(info,keyinfo,info->last_keypage,info->buff)) + if (_mi_write_keypage(info,keyinfo,info->last_keypage, + DFLT_INIT_HITS,info->buff)) DBUG_RETURN(-1); } else @@ -1600,7 +1603,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, mi_check_print_error(param,"Not Enough memory"); DBUG_RETURN(-1); } - if (!_mi_fetch_keypage(info,keyinfo,pagepos,buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,pagepos,DFLT_INIT_HITS,buff,0)) { mi_check_print_error(param,"Can't read key block from filepos: %s", llstr(pagepos,llbuff)); @@ -3334,13 +3337,13 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, bzero((byte*) anc_buff+key_block->last_length, keyinfo->block_length- key_block->last_length); key_file_length=info->state->key_file_length; - if ((filepos=_mi_new(info,keyinfo)) == HA_OFFSET_ERROR) + if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) DBUG_RETURN(1); /* If we read the page from the key cache, we have to write it back to it */ if (key_file_length == info->state->key_file_length) { - if (_mi_write_keypage(info, keyinfo, filepos, anc_buff)) + if (_mi_write_keypage(info, keyinfo, filepos, DFLT_INIT_HITS, anc_buff)) DBUG_RETURN(1); } else if (my_pwrite(info->s->kfile,(byte*) anc_buff, @@ -3438,13 +3441,14 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) _mi_kpointer(info,key_block->end_pos,filepos); key_file_length=info->state->key_file_length; bzero((byte*) key_block->buff+length, keyinfo->block_length-length); - if ((filepos=_mi_new(info,keyinfo)) == HA_OFFSET_ERROR) + if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) DBUG_RETURN(1); /* If we read the page from the key cache, we have to write it back */ if (key_file_length == info->state->key_file_length) { - if (_mi_write_keypage(info, keyinfo, filepos, key_block->buff)) + if (_mi_write_keypage(info, keyinfo, filepos, + DFLT_INIT_HITS, key_block->buff)) DBUG_RETURN(1); } else if (my_pwrite(info->s->kfile,(byte*) key_block->buff, diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index 2ab5c5d0319..5635e0a2139 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -155,7 +155,7 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_RETURN(my_errno=ENOMEM); } DBUG_PRINT("info",("root_page: %ld",old_root)); - if (!_mi_fetch_keypage(info,keyinfo,old_root,root_buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,old_root,DFLT_INIT_HITS,root_buff,0)) { error= -1; goto err; @@ -179,11 +179,12 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, *root=_mi_kpos(nod_flag,root_buff+2+nod_flag); else *root=HA_OFFSET_ERROR; - if (_mi_dispose(info,keyinfo,old_root)) + if (_mi_dispose(info,keyinfo,old_root,DFLT_INIT_HITS)) error= -1; } else - error=_mi_write_keypage(info,keyinfo,old_root,root_buff); + error=_mi_write_keypage(info,keyinfo,old_root, + DFLT_INIT_HITS,root_buff); } } err: @@ -253,7 +254,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, { /* the last entry in sub-tree */ DBUG_PRINT("info",("FT2: the last entry")); - _mi_dispose(info, keyinfo, root); + _mi_dispose(info, keyinfo, root,DFLT_INIT_HITS); /* fall through to normal delete */ } else @@ -268,7 +269,8 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, subkeys++; ft_intXstore(kpos, subkeys); if (!ret_value) - ret_value=_mi_write_keypage(info,keyinfo,page,anc_buff); + ret_value=_mi_write_keypage(info,keyinfo,page, + DFLT_INIT_HITS,anc_buff); DBUG_PRINT("exit",("Return: %d",ret_value)); DBUG_RETURN(ret_value); } @@ -287,7 +289,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_PRINT("exit",("Return: %d",-1)); DBUG_RETURN(-1); } - if (!_mi_fetch_keypage(info,keyinfo,leaf_page,leaf_buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff,0)) goto err; } @@ -319,7 +321,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, mi_putint(anc_buff,length,nod_flag); if (!nod_flag) { /* On leaf page */ - if (_mi_write_keypage(info,keyinfo,page,anc_buff)) + if (_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff)) { DBUG_PRINT("exit",("Return: %d",-1)); DBUG_RETURN(-1); @@ -354,7 +356,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, ret_value=_mi_split_page(info,keyinfo,key,anc_buff,lastkey,0) | 2; } if (save_flag && ret_value != 1) - ret_value|=_mi_write_keypage(info,keyinfo,page,anc_buff); + ret_value|=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff); else { DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff)); @@ -398,7 +400,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, if (!(next_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ MI_MAX_KEY_BUFF*2))) DBUG_RETURN(-1); - if (!_mi_fetch_keypage(info,keyinfo,next_page,next_buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,next_buff,0)) ret_value= -1; else { @@ -426,7 +428,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, (uchar*) 0,(uchar*) 0,(my_off_t) 0,0); } } - if (_mi_write_keypage(info,keyinfo,leaf_page,leaf_buff)) + if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff)) goto err; } my_afree((byte*) next_buff); @@ -436,7 +438,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, /* Remove last key from leaf page */ mi_putint(leaf_buff,key_start-leaf_buff,nod_flag); - if (_mi_write_keypage(info,keyinfo,leaf_page,leaf_buff)) + if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff)) goto err; /* Place last key in ancestor page on deleted key position */ @@ -524,7 +526,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, goto err; } next_page= _mi_kpos(key_reflength,next_keypos); - if (!_mi_fetch_keypage(info,keyinfo,next_page,buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) goto err; buff_length=mi_getint(buff); DBUG_DUMP("next",(byte*) buff,buff_length); @@ -563,7 +565,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (buff_length <= keyinfo->block_length) { /* Keys in one page */ memcpy((byte*) leaf_buff,(byte*) buff,(size_t) buff_length); - if (_mi_dispose(info,keyinfo,next_page)) + if (_mi_dispose(info,keyinfo,next_page,DFLT_INIT_HITS)) goto err; } else @@ -612,10 +614,10 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, (*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp); mi_putint(buff,length+t_length+p_length,nod_flag); - if (_mi_write_keypage(info,keyinfo,next_page,buff)) + if (_mi_write_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff)) goto err; } - if (_mi_write_keypage(info,keyinfo,leaf_page,leaf_buff)) + if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff)) goto err; DBUG_RETURN(anc_length <= ((info->quick_mode ? MI_MIN_BLOCK_LENGTH : (uint) keyinfo->underflow_block_length))); @@ -627,7 +629,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!keypos) goto err; next_page= _mi_kpos(key_reflength,keypos); - if (!_mi_fetch_keypage(info,keyinfo,next_page,buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) goto err; buff_length=mi_getint(buff); endpos=buff+buff_length; @@ -671,7 +673,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (buff_length <= keyinfo->block_length) { /* Keys in one page */ - if (_mi_dispose(info,keyinfo,leaf_page)) + if (_mi_dispose(info,keyinfo,leaf_page,DFLT_INIT_HITS)) goto err; } else @@ -718,11 +720,11 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, (size_t) length); (*keyinfo->store_key)(keyinfo,leaf_buff+p_length,&s_temp); mi_putint(leaf_buff,length+t_length+p_length,nod_flag); - if (_mi_write_keypage(info,keyinfo,leaf_page,leaf_buff)) + if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff)) goto err; mi_putint(buff,endpos-buff,nod_flag); } - if (_mi_write_keypage(info,keyinfo,next_page,buff)) + if (_mi_write_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff)) goto err; DBUG_RETURN(anc_length <= (uint) keyinfo->block_length/2); err: diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 61a0c98233c..72aaac5d381 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -24,7 +24,8 @@ /* Fetch a key-page in memory */ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, - my_off_t page, uchar *buff, int return_buffer) + my_off_t page, int level, + uchar *buff, int return_buffer) { uchar *tmp; uint page_size; @@ -32,7 +33,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("enter",("page: %ld",page)); tmp=(uchar*) key_cache_read(*info->s->keycache, - info->s->kfile,page,(byte*) buff, + info->s->kfile, page, level, (byte*) buff, (uint) keyinfo->block_length, (uint) keyinfo->block_length, return_buffer); @@ -62,7 +63,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, /* Write a key-page on disk */ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, - my_off_t page, uchar *buff) + my_off_t page, int level, uchar *buff) { reg3 uint length; DBUG_ENTER("_mi_write_keypage"); @@ -94,7 +95,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, } #endif DBUG_RETURN((key_cache_write(*info->s->keycache, - info->s->kfile,page,(byte*) buff,length, + info->s->kfile,page, level, (byte*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || info->s->delay_key_write)))); @@ -103,7 +104,8 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, /* Remove page from disk */ -int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos) +int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, + int level) { my_off_t old_link; char buff[8]; @@ -115,7 +117,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos) mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; DBUG_RETURN(key_cache_write(*info->s->keycache, - info->s->kfile,pos,buff, + info->s->kfile, pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, (int) (info->lock_type != F_UNLCK))); @@ -124,7 +126,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos) /* Make new page on disk */ -my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo) +my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level) { my_off_t pos; char buff[8]; @@ -144,7 +146,7 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo) else { if (!key_cache_read(*info->s->keycache, - info->s->kfile,pos, + info->s->kfile, pos, level, buff, (uint) sizeof(buff), (uint) keyinfo->block_length,0)) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 02d5229bd4d..dc4fff5700a 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -88,7 +88,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (mi_test_if_nod(buff)) { if (key_cache_insert(*share->keycache, - share->kfile, pos, (byte*) buff, block_length)) + share->kfile, pos, DFLT_INIT_HITS, + (byte*) buff, block_length)) goto err; } pos+= block_length; @@ -99,7 +100,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) else { if (key_cache_insert(*share->keycache, - share->kfile, pos, (byte*) buff, length)) + share->kfile, pos, DFLT_INIT_HITS, + (byte*) buff, length)) goto err; pos+= length; } diff --git a/myisam/mi_range.c b/myisam/mi_range.c index 379ffba135a..caa57ce6187 100644 --- a/myisam/mi_range.c +++ b/myisam/mi_range.c @@ -142,7 +142,7 @@ static double _mi_search_pos(register MI_INFO *info, if (pos == HA_OFFSET_ERROR) DBUG_RETURN(0.5); - if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,info->buff,1))) + if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff,1))) goto err; flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag, &keypos,info->lastkey, &after_key); diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 7e8577c0656..c2168d97cfe 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -76,7 +76,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_RETURN(1); /* Search at upper levels */ } - if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,info->buff, + if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff, test(!(nextflag & SEARCH_SAVE_BUFF))))) goto err; DBUG_DUMP("page",(byte*) buff,mi_getint(buff)); @@ -119,7 +119,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (pos != info->last_keypage) { uchar *old_buff=buff; - if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,info->buff, + if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff, test(!(nextflag & SEARCH_SAVE_BUFF))))) goto err; keypos=buff+(keypos-old_buff); @@ -1105,7 +1105,7 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (info->buff_used) { if (!_mi_fetch_keypage(info,keyinfo,info->last_search_keypage, - info->buff,0)) + DFLT_INIT_HITS,info->buff,0)) DBUG_RETURN(-1); info->buff_used=0; } @@ -1174,7 +1174,7 @@ int _mi_search_first(register MI_INFO *info, register MI_KEYDEF *keyinfo, do { - if (!_mi_fetch_keypage(info,keyinfo,pos,info->buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff,0)) { info->lastpos= HA_OFFSET_ERROR; DBUG_RETURN(-1); @@ -1217,7 +1217,7 @@ int _mi_search_last(register MI_INFO *info, register MI_KEYDEF *keyinfo, buff=info->buff; do { - if (!_mi_fetch_keypage(info,keyinfo,pos,buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,buff,0)) { info->lastpos= HA_OFFSET_ERROR; DBUG_RETURN(-1); diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 11a8e12a7e5..61a14adf1ce 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) goto end; } if (key_cacheing) - resize_key_cache(dflt_keycache,key_cache_size*2); + resize_key_cache(dflt_keycache,key_cache_block_size,key_cache_size*2); } if (!silent) diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 6985dac7832..8c08d6f179e 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -290,8 +290,8 @@ int _mi_enlarge_root(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, mi_putint(info->buff,t_length+2+nod_flag,nod_flag); (*keyinfo->store_key)(keyinfo,info->buff+2+nod_flag,&s_temp); info->buff_used=info->page_changed=1; /* info->buff is used */ - if ((*root= _mi_new(info,keyinfo)) == HA_OFFSET_ERROR || - _mi_write_keypage(info,keyinfo,*root,info->buff)) + if ((*root= _mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR || + _mi_write_keypage(info,keyinfo,*root,DFLT_INIT_HITS,info->buff)) DBUG_RETURN(-1); DBUG_RETURN(0); } /* _mi_enlarge_root */ @@ -322,7 +322,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ MI_MAX_KEY_BUFF*2))) DBUG_RETURN(-1); - if (!_mi_fetch_keypage(info,keyinfo,page,temp_buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff,0)) goto err; flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,search_key_length, @@ -368,7 +368,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, subkeys--; /* should there be underflow protection ? */ ft_intXstore(keypos, subkeys); if (!error) - error=_mi_write_keypage(info,keyinfo,page,temp_buff); + error=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff); my_afree((byte*) temp_buff); DBUG_RETURN(error); } @@ -391,7 +391,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, { error=_mi_insert(info,keyinfo,key,temp_buff,keypos,keybuff,father_buff, father_keypos,father_page, insert_last); - if (_mi_write_keypage(info,keyinfo,page,temp_buff)) + if (_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff)) goto err; } my_afree((byte*) temp_buff); @@ -515,7 +515,7 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, } /* Move middle item to key and pointer to new page */ - if ((new_pos=_mi_new(info,keyinfo)) == HA_OFFSET_ERROR) + if ((new_pos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) DBUG_RETURN(-1); _mi_kpointer(info,_mi_move_key(keyinfo,key,key_buff),new_pos); @@ -531,7 +531,7 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, (*keyinfo->store_key)(keyinfo,info->buff+key_ref_length,&s_temp); mi_putint(info->buff,length+t_length+key_ref_length,nod_flag); - if (_mi_write_keypage(info,keyinfo,new_pos,info->buff)) + if (_mi_write_keypage(info,keyinfo,new_pos,DFLT_INIT_HITS,info->buff)) DBUG_RETURN(-1); DBUG_DUMP("key",(byte*) key,_mi_keylength(keyinfo,key)); DBUG_RETURN(2); /* Middle key up */ @@ -682,7 +682,7 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("test",("use left page: %lu",next_page)); } /* father_key_pos ptr to parting key */ - if (!_mi_fetch_keypage(info,keyinfo,next_page,info->buff,0)) + if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0)) goto err; DBUG_DUMP("next",(byte*) info->buff,mi_getint(info->buff)); @@ -722,8 +722,8 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, memcpy((byte*) buff+2,(byte*) pos+k_length,(size_t) length); } - if (_mi_write_keypage(info,keyinfo,next_page,info->buff) || - _mi_write_keypage(info,keyinfo,father_page,father_buff)) + if (_mi_write_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff) || + _mi_write_keypage(info,keyinfo,father_page,DFLT_INIT_HITS,father_buff)) goto err; DBUG_RETURN(0); } @@ -763,12 +763,13 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, memcpy((byte*) (right ? key : father_key_pos),pos,(size_t) k_length); memcpy((byte*) (right ? father_key_pos : key),tmp_part_key, k_length); - if ((new_pos=_mi_new(info,keyinfo)) == HA_OFFSET_ERROR) + if ((new_pos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) goto err; _mi_kpointer(info,key+k_length,new_pos); if (_mi_write_keypage(info,keyinfo,(right ? new_pos : next_page), - info->buff) || - _mi_write_keypage(info,keyinfo,(right ? next_page : new_pos),extra_buff)) + DFLT_INIT_HITS,info->buff) || + _mi_write_keypage(info,keyinfo,(right ? next_page : new_pos), + DFLT_INIT_HITS,extra_buff)) goto err; DBUG_RETURN(1); /* Middle key up */ diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index e02858453d2..9ed0e3ca3a2 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -548,11 +548,12 @@ extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, extern int _mi_search_first(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); extern int _mi_search_last(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); extern uchar *_mi_fetch_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page, - uchar *buff,int return_buffer); + int level,uchar *buff,int return_buffer); extern int _mi_write_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page, - uchar *buff); -extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); -extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo); + int level, uchar *buff); +extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos, + int level); +extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level); extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key, const byte *record,my_off_t filepos); extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old, diff --git a/myisam/rt_index.c b/myisam/rt_index.c index f02d6121eb5..8b877d2e65c 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -60,7 +60,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u my_errno = HA_ERR_OUT_OF_MEM; return -1; } - if (!_mi_fetch_keypage(info, keyinfo, page, page_buf, 0)) + if (!_mi_fetch_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf, 0)) goto err1; nod_flag = mi_test_if_nod(page_buf); @@ -257,7 +257,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length, if (!(page_buf = (uchar*)my_alloca((uint)keyinfo->block_length))) return -1; - if (!_mi_fetch_keypage(info, keyinfo, page, page_buf, 0)) + if (!_mi_fetch_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf, 0)) goto err1; nod_flag = mi_test_if_nod(page_buf); @@ -429,7 +429,7 @@ static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, my_errno = HA_ERR_OUT_OF_MEM; return -1; } - if (!_mi_fetch_keypage(info, keyinfo, page, page_buf, 0)) + if (!_mi_fetch_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf, 0)) goto err1; nod_flag = mi_test_if_nod(page_buf); @@ -445,7 +445,7 @@ static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, case 0: /* child was not split */ { rtree_combine_rect(keyinfo->seg, k, key, k, key_length); - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf)) goto err1; goto ok; } @@ -462,7 +462,7 @@ static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, goto err1; res = rtree_add_key(info, keyinfo, new_key, key_length, page_buf, new_page); - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf)) goto err1; goto ok; } @@ -476,7 +476,7 @@ static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, else { res = rtree_add_key(info, keyinfo, key, key_length, page_buf, new_page); - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf)) goto err1; goto ok; } @@ -509,12 +509,12 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key, { int res; - if ((old_root = _mi_new(info, keyinfo)) == HA_OFFSET_ERROR) + if ((old_root = _mi_new(info, keyinfo, DFLT_INIT_HITS)) == HA_OFFSET_ERROR) return -1; info->buff_used = 1; mi_putint(info->buff, 2, 0); res = rtree_add_key(info, keyinfo, key, key_length, info->buff, NULL); - if (_mi_write_keypage(info, keyinfo, old_root, info->buff)) + if (_mi_write_keypage(info, keyinfo, old_root, DFLT_INIT_HITS, info->buff)) return 1; info->s->state.key_root[keynr] = old_root; return res; @@ -542,7 +542,8 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key, } mi_putint(new_root_buf, 2, nod_flag); - if ((new_root = _mi_new(info, keyinfo)) == HA_OFFSET_ERROR) + if ((new_root = _mi_new(info, keyinfo, DFLT_INIT_HITS)) == + HA_OFFSET_ERROR) goto err1; new_key = new_root_buf + keyinfo->block_length + nod_flag; @@ -559,7 +560,8 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key, if (rtree_add_key(info, keyinfo, new_key, key_length, new_root_buf, NULL) == -1) goto err1; - if (_mi_write_keypage(info, keyinfo, new_root, new_root_buf)) + if (_mi_write_keypage(info, keyinfo, new_root, + DFLT_INIT_HITS, new_root_buf)) goto err1; info->s->state.key_root[keynr] = new_root; @@ -636,7 +638,7 @@ static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, my_errno = HA_ERR_OUT_OF_MEM; return -1; } - if (!_mi_fetch_keypage(info, keyinfo, page, page_buf, 0)) + if (!_mi_fetch_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf, 0)) goto err1; nod_flag = mi_test_if_nod(page_buf); @@ -662,7 +664,8 @@ static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, if (rtree_set_key_mbr(info, keyinfo, k, key_length, _mi_kpos(nod_flag, k))) goto err1; - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, + DFLT_INIT_HITS, page_buf)) goto err1; } else @@ -672,7 +675,8 @@ static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, level + 1)) goto err1; rtree_delete_key(info, page_buf, k, key_length, nod_flag); - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, + DFLT_INIT_HITS, page_buf)) goto err1; *page_size = mi_getint(page_buf); } @@ -686,7 +690,8 @@ static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, case 2: /* vacuous case: last key in the leaf */ { rtree_delete_key(info, page_buf, k, key_length, nod_flag); - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, + DFLT_INIT_HITS, page_buf)) goto err1; *page_size = mi_getint(page_buf); res = 0; @@ -711,13 +716,13 @@ static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, { /* last key in the leaf */ res = 2; - if (_mi_dispose(info, keyinfo, page)) + if (_mi_dispose(info, keyinfo, page, DFLT_INIT_HITS)) goto err1; } else { res = 0; - if (_mi_write_keypage(info, keyinfo, page, page_buf)) + if (_mi_write_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf)) goto err1; } goto ok; @@ -783,7 +788,7 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) goto err1; } if (!_mi_fetch_keypage(info, keyinfo, ReinsertList.pages[i].offs, - page_buf, 0)) + DFLT_INIT_HITS, page_buf, 0)) goto err1; nod_flag = mi_test_if_nod(page_buf); k = rt_PAGE_FIRST_KEY(page_buf, nod_flag); @@ -798,7 +803,8 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) } } my_afree((byte*)page_buf); - if (_mi_dispose(info, keyinfo, ReinsertList.pages[i].offs)) + if (_mi_dispose(info, keyinfo, ReinsertList.pages[i].offs, + DFLT_INIT_HITS)) goto err1; } if (ReinsertList.pages) @@ -807,7 +813,8 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) /* check for redundant root (not leaf, 1 child) and eliminate */ if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) goto err1; - if (!_mi_fetch_keypage(info, keyinfo, old_root, info->buff, 0)) + if (!_mi_fetch_keypage(info, keyinfo, old_root, DFLT_INIT_HITS, + info->buff, 0)) goto err1; nod_flag = mi_test_if_nod(info->buff); page_size = mi_getint(info->buff); @@ -816,7 +823,7 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) { my_off_t new_root = _mi_kpos(nod_flag, rt_PAGE_FIRST_KEY(info->buff, nod_flag)); - if (_mi_dispose(info, keyinfo, old_root)) + if (_mi_dispose(info, keyinfo, old_root, DFLT_INIT_HITS)) goto err1; info->s->state.key_root[keynr] = new_root; } @@ -863,7 +870,7 @@ ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key, return HA_POS_ERROR; if (!(page_buf = (uchar*)my_alloca((uint)keyinfo->block_length))) return HA_POS_ERROR; - if (!_mi_fetch_keypage(info, keyinfo, root, page_buf, 0)) + if (!_mi_fetch_keypage(info, keyinfo, root, DFLT_INIT_HITS, page_buf, 0)) goto err1; nod_flag = mi_test_if_nod(page_buf); diff --git a/myisam/rt_key.c b/myisam/rt_key.c index dfabf7624d2..f18d13af8d8 100644 --- a/myisam/rt_key.c +++ b/myisam/rt_key.c @@ -88,7 +88,8 @@ int rtree_delete_key(MI_INFO *info, uchar *page_buf, uchar *key, int rtree_set_key_mbr(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, uint key_length, my_off_t child_page) { - if (!_mi_fetch_keypage(info, keyinfo, child_page, info->buff, 0)) + if (!_mi_fetch_keypage(info, keyinfo, child_page, + DFLT_INIT_HITS, info->buff, 0)) return -1; return rtree_page_mbr(info, keyinfo->seg, info->buff, key, key_length); diff --git a/myisam/rt_split.c b/myisam/rt_split.c index 72a3c4887ab..41d6f8f8ccd 100644 --- a/myisam/rt_split.c +++ b/myisam/rt_split.c @@ -332,10 +332,12 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, mi_putint(page, 2 + n1 * full_length, nod_flag); mi_putint(new_page, 2 + n2 * full_length, nod_flag); - if ((*new_page_offs= _mi_new(info, keyinfo)) == HA_OFFSET_ERROR) + if ((*new_page_offs= _mi_new(info, keyinfo, DFLT_INIT_HITS)) == + HA_OFFSET_ERROR) err_code= -1; else - err_code= _mi_write_keypage(info, keyinfo, *new_page_offs, new_page); + err_code= _mi_write_keypage(info, keyinfo, *new_page_offs, + DFLT_INIT_HITS, new_page); my_afree((byte*)new_page); |