diff options
author | unknown <monty@mashka.mysql.fi> | 2002-07-23 20:39:36 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-07-23 20:39:36 +0300 |
commit | 10bd14dee8488b59798e9b24db1c50759e9242ae (patch) | |
tree | dd3586b209432966efbbf77cd272760438711106 /myisam | |
parent | b42ca98d34a2e834dfc454338493fa26553c8d20 (diff) | |
parent | a8caad316a89d6eeb8c22e70bc7a5fd4cf6ce904 (diff) | |
download | mariadb-git-10bd14dee8488b59798e9b24db1c50759e9242ae.tar.gz |
merge
include/my_sys.h:
Auto merged
include/myisam.h:
Auto merged
myisam/mi_check.c:
Auto merged
sql/Makefile.am:
Auto merged
sql/ha_myisam.h:
Auto merged
sql/ha_myisammrg.cc:
Auto merged
sql/ha_myisammrg.h:
Auto merged
sql/handler.cc:
Auto merged
sql/item.h:
Auto merged
sql/lex.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_union.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/structs.h:
Auto merged
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_check.c | 12 | ||||
-rw-r--r-- | myisam/mi_extra.c | 41 | ||||
-rw-r--r-- | myisam/mi_open.c | 2 | ||||
-rw-r--r-- | myisam/mi_test1.c | 2 | ||||
-rw-r--r-- | myisam/mi_test2.c | 22 | ||||
-rw-r--r-- | myisam/mi_test3.c | 10 | ||||
-rw-r--r-- | myisam/mi_write.c | 9 | ||||
-rw-r--r-- | myisam/myisamchk.c | 4 | ||||
-rw-r--r-- | myisam/myisamdef.h | 2 | ||||
-rw-r--r-- | myisam/myisamlog.c | 4 | ||||
-rw-r--r-- | myisam/myisampack.c | 12 |
11 files changed, 72 insertions, 48 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 52ad02a3c1a..4727a3ab303 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -455,7 +455,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) info->s->state.auto_increment=save_auto_value; /* Check that there isn't a row with auto_increment = 0 in the table */ - mi_extra(info,HA_EXTRA_KEYREAD); + mi_extra(info,HA_EXTRA_KEYREAD,0); bzero(info->lastkey,keyinfo->seg->length); if (!mi_rkey(info, info->rec_buff, key, (const byte*) info->lastkey, keyinfo->seg->length, HA_READ_KEY_EXACT)) @@ -466,7 +466,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) "Found row where the auto_increment column has the value 0"); param->warning_printed=save; } - mi_extra(info,HA_EXTRA_NO_KEYREAD); + mi_extra(info,HA_EXTRA_NO_KEYREAD,0); } length=(my_off_t) isam_key_length(info,keyinfo)*keys + param->key_blocks*2; @@ -1128,7 +1128,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, param->testflag|=T_REP; /* for easy checking */ if (!param->using_global_keycache) - VOID(init_key_cache(param->use_buffers,NEED_MEM)); + VOID(init_key_cache(param->use_buffers)); if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, @@ -3601,12 +3601,12 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, !(param->testflag & T_REP)) printf("Updating MyISAM file: %s\n", param->isam_file_name); /* We have to use keyread here as a normal read uses info->rec_buff */ - mi_extra(info,HA_EXTRA_KEYREAD); + mi_extra(info,HA_EXTRA_KEYREAD,0); if (mi_rlast(info,info->rec_buff, info->s->base.auto_key-1)) { if (my_errno != HA_ERR_END_OF_FILE) { - mi_extra(info,HA_EXTRA_NO_KEYREAD); + mi_extra(info,HA_EXTRA_NO_KEYREAD,0); mi_check_print_error(param,"%d when reading last record",my_errno); return; } @@ -3621,7 +3621,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, update_auto_increment(info,info->rec_buff); set_if_bigger(info->s->state.auto_increment,auto_increment); } - mi_extra(info,HA_EXTRA_NO_KEYREAD); + mi_extra(info,HA_EXTRA_NO_KEYREAD,0); update_state_info(param, info, UPDATE_AUTO_INC); return; } diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 9e514a6c055..6c658a33dda 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -14,11 +14,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Extra functions we want to do with a database */ -/* - Set flags for quicker databasehandler */ -/* - Set databasehandler to normal */ -/* - Reset recordpointers as after open database */ - #include "myisamdef.h" #ifdef HAVE_MMAP #include <sys/mman.h> @@ -27,11 +22,28 @@ #include <errno.h> #endif - /* set extra flags for database */ +/* + Set options and buffers to optimize table handling + + SYNOPSIS + mi_extra() + info open table + function operation + extra_arg Pointer to extra argument (normally pointer to ulong) + Used when function is one of: + HA_EXTRA_WRITE_CACHE + HA_EXTRA_CACHE + HA_EXTRA_BULK_INSERT_BEGIN + If extra_arg is 0, then the default cache size is used. + RETURN VALUES + 0 ok +*/ -int mi_extra(MI_INFO *info, enum ha_extra_function function) + +int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { int error=0; + ulong cache_size; MYISAM_SHARE *share=info->s; DBUG_ENTER("mi_extra"); DBUG_PRINT("enter",("function: %d",(int) function)); @@ -103,11 +115,13 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) if (!(info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED | MEMMAP_USED))) { + cache_size= (extra_arg ? *(ulong*) extra_arg : + my_default_record_cache_size); if (!(init_io_cache(&info->rec_cache,info->dfile, (uint) min(info->state->data_file_length+1, - my_default_record_cache_size), - READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK), - MYF(share->write_flag & MY_WAIT_IF_FULL)))) + cache_size), + READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK), + MYF(share->write_flag & MY_WAIT_IF_FULL)))) { info->opt_flag|=READ_CACHE_USED; info->update&= ~HA_STATE_ROW_CHANGED; @@ -133,10 +147,12 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) error=1; /* Not possibly if not locked */ break; } + cache_size= (extra_arg ? *(ulong*) extra_arg : + my_default_record_cache_size); if (!(info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) && !share->state.header.uniques) - if (!(init_io_cache(&info->rec_cache,info->dfile,0, + if (!(init_io_cache(&info->rec_cache,info->dfile, cache_size, WRITE_CACHE,info->state->data_file_length, (pbool) (info->lock_type != F_UNLCK), MYF(share->write_flag & MY_WAIT_IF_FULL)))) @@ -337,7 +353,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) info->quick_mode=1; break; case HA_EXTRA_BULK_INSERT_BEGIN: - error=_mi_init_bulk_insert(info); + error=_mi_init_bulk_insert(info, (extra_arg ? *(ulong*) extra_arg : + myisam_bulk_insert_tree_size)); break; case HA_EXTRA_BULK_INSERT_END: if (info->bulk_insert) diff --git a/myisam/mi_open.c b/myisam/mi_open.c index c9ecdaab47f..e10d931e6d3 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -66,7 +66,7 @@ static MI_INFO *test_if_reopen(char *filename) MI_INFO *mi_open(const char *name, int mode, uint open_flags) { int lock_error,kfile,open_mode,save_errno; - uint i,j,len,errpos,head_length,base_pos,offset,info_length,extra,keys, + uint i,j,len,errpos,head_length,base_pos,offset,info_length,keys, key_parts,unique_key_parts,tmp_length,uniques; char name_buff[FN_REFLEN], org_name [FN_REFLEN], index_name[FN_REFLEN], data_name[FN_REFLEN]; diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index d0ce3ea966e..bcb9cd172ec 100644 --- a/myisam/mi_test1.c +++ b/myisam/mi_test1.c @@ -50,7 +50,7 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); my_init(); if (key_cacheing) - init_key_cache(IO_SIZE*16,(uint) IO_SIZE*4*10); + init_key_cache(IO_SIZE*16); get_options(argc,argv); exit(run_test("test1")); diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 75129ac7667..93538e3ead7 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -208,13 +208,13 @@ int main(int argc, char *argv[]) if (!silent) printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(key_cache_size,(uint) IO_SIZE*4*10); /* Use a small cache */ + init_key_cache(key_cache_size); /* Use a small cache */ if (locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) - mi_extra(file,HA_EXTRA_WRITE_CACHE); + mi_extra(file,HA_EXTRA_WRITE_CACHE,0); if (opt_quick_mode) - mi_extra(file,HA_EXTRA_QUICK); + mi_extra(file,HA_EXTRA_QUICK,0); for (i=0 ; i < recant ; i++) { @@ -261,11 +261,15 @@ int main(int argc, char *argv[]) if (testflag==1) goto end; if (write_cacheing) - if (mi_extra(file,HA_EXTRA_NO_CACHE)) + { + if (mi_extra(file,HA_EXTRA_NO_CACHE,0)) { puts("got error from mi_extra(HA_EXTRA_NO_CACHE)"); goto end; } + if (key_cacheing) + resize_key_cache(key_cache_size*2); + } if (!silent) printf("- Delete\n"); @@ -677,7 +681,7 @@ int main(int argc, char *argv[]) if (!silent) printf("- mi_extra(CACHE) + mi_rrnd.... + mi_extra(NO_CACHE)\n"); - if (mi_extra(file,HA_EXTRA_RESET) || mi_extra(file,HA_EXTRA_CACHE)) + if (mi_extra(file,HA_EXTRA_RESET,0) || mi_extra(file,HA_EXTRA_CACHE,0)) { if (locking || (!use_blob && !pack_fields)) { @@ -695,7 +699,7 @@ int main(int argc, char *argv[]) ant,write_count-opt_delete); goto end; } - if (mi_extra(file,HA_EXTRA_NO_CACHE)) + if (mi_extra(file,HA_EXTRA_NO_CACHE,0)) { puts("got error from mi_extra(HA_EXTRA_NO_CACHE)"); goto end; @@ -720,7 +724,7 @@ int main(int argc, char *argv[]) DBUG_PRINT("progpos",("Removing keys")); lastpos = HA_OFFSET_ERROR; /* DBUG_POP(); */ - mi_extra(file,HA_EXTRA_RESET); + mi_extra(file,HA_EXTRA_RESET,0); found_parts=0; while ((error=mi_rrnd(file,read_record,HA_OFFSET_ERROR)) != HA_ERR_END_OF_FILE) @@ -791,8 +795,10 @@ end: printf("myisam_block_size: %u\n", myisam_block_size); if (key_cacheing) { - puts("Key cacheing used"); + puts("Key cache used"); printf("key_cache_block_size: %u\n", key_cache_block_size); + if (write_cacheing) + puts("Key cache resized"); } if (write_cacheing) puts("Write cacheing used"); diff --git a/myisam/mi_test3.c b/myisam/mi_test3.c index 36222c3edbc..ac36f55a181 100644 --- a/myisam/mi_test3.c +++ b/myisam/mi_test3.c @@ -173,7 +173,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(65536L,(uint) IO_SIZE*4*10); + init_key_cache(65536L); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) @@ -302,7 +302,7 @@ int test_rrnd(MI_INFO *file,int id) return 1; } if (rnd(2) == 0) - mi_extra(file,HA_EXTRA_CACHE); + mi_extra(file,HA_EXTRA_CACHE,0); } count=0; @@ -323,7 +323,7 @@ int test_rrnd(MI_INFO *file,int id) end: if (lock) { - mi_extra(file,HA_EXTRA_NO_CACHE); + mi_extra(file,HA_EXTRA_NO_CACHE,0); if (mi_lock_database(file,F_UNLCK)) { fprintf(stderr,"%2d: Can't unlock table\n",id); @@ -355,7 +355,7 @@ int test_write(MI_INFO *file,int id,int lock_type) return 1; } if (rnd(2) == 0) - mi_extra(file,HA_EXTRA_WRITE_CACHE); + mi_extra(file,HA_EXTRA_WRITE_CACHE,0); } sprintf(record.id,"%7d",getpid()); @@ -380,7 +380,7 @@ int test_write(MI_INFO *file,int id,int lock_type) } if (lock) { - mi_extra(file,HA_EXTRA_NO_CACHE); + mi_extra(file,HA_EXTRA_NO_CACHE,0); if (mi_lock_database(file,F_UNLCK)) { fprintf(stderr,"%2d: Can't unlock table\n",id); diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 9998a25a96a..cfacd0bc4d5 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -801,7 +801,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) } -int _mi_init_bulk_insert(MI_INFO *info) +int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size) { MYISAM_SHARE *share=info->s; MI_KEYDEF *key=share->keyinfo; @@ -809,6 +809,7 @@ int _mi_init_bulk_insert(MI_INFO *info) uint i, num_keys; ulonglong key_map=0; DBUG_ENTER("_mi_init_bulk_insert"); + DBUG_PRINT("enter",("cache_size: %lu", cache_size)); if (info->bulk_insert) DBUG_RETURN(0); @@ -824,7 +825,7 @@ int _mi_init_bulk_insert(MI_INFO *info) } if (num_keys==0 || - num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > myisam_bulk_insert_tree_size) + num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > cache_size) DBUG_RETURN(0); info->bulk_insert=(TREE *) @@ -842,8 +843,8 @@ int _mi_init_bulk_insert(MI_INFO *info) params->info=info; params->keynr=i; init_tree(&info->bulk_insert[i], - myisam_bulk_insert_tree_size / num_keys / 4 + 10, - myisam_bulk_insert_tree_size / num_keys, 0, + cache_size / num_keys / 4 + 10, + cache_size / num_keys, 0, (qsort_cmp2)keys_compare, 0, (tree_element_free) keys_free, (void *)params++); } diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index e91181ff420..ff8c47f93cc 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -1003,7 +1003,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) !(param->testflag & (T_FAST | T_FORCE_CREATE))) { if (param->testflag & (T_EXTEND | T_MEDIUM)) - VOID(init_key_cache(param->use_buffers,(uint) NEED_MEM)); + VOID(init_key_cache(param->use_buffers)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1413,7 +1413,7 @@ static int mi_sort_records(MI_CHECK *param, if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(param->use_buffers,NEED_MEM); + init_key_cache(param->use_buffers); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 5790ae6f475..8c1ca393a3c 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -656,7 +656,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup); int mi_open_keyfile(MYISAM_SHARE *share); void mi_setup_functions(register MYISAM_SHARE *share); -int _mi_init_bulk_insert(MI_INFO *info); +int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size); /* Functions needed by mi_check */ void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...)); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index 2d4c7570956..ceca8d2a0e3 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -333,7 +333,7 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(KEY_CACHE_SIZE,(uint) (10*4*(IO_SIZE+MALLOC_OVERHEAD)))); + VOID(init_key_cache(KEY_CACHE_SIZE)); files_open=0; access_time=0; while (access_time++ != number_of_commands && @@ -484,7 +484,7 @@ static int examine_log(my_string file_name, char **table_names) command_name[command], (int) extra_command,result); if (update && curr_file_info && !curr_file_info->closed) { - if (mi_extra(curr_file_info->isam, extra_command) != (int) result) + if (mi_extra(curr_file_info->isam, extra_command, 0) != (int) result) { fflush(stdout); VOID(fprintf(stderr, diff --git a/myisam/myisampack.c b/myisam/myisampack.c index b7dd788821a..14fde9aa8b3 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -2088,7 +2088,7 @@ static void mrg_reset(PACK_MRG_INFO *mrg) { if (mrg->current) { - mi_extra(*mrg->current,HA_EXTRA_NO_CACHE); + mi_extra(*mrg->current, HA_EXTRA_NO_CACHE, 0); mrg->current=0; } } @@ -2103,8 +2103,8 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) { isam_info= *(info->current=info->file); info->end=info->current+info->count; - mi_extra(isam_info,HA_EXTRA_RESET); - mi_extra(isam_info,HA_EXTRA_CACHE); + mi_extra(isam_info, HA_EXTRA_RESET, 0); + mi_extra(isam_info, HA_EXTRA_CACHE, 0); filepos=isam_info->s->pack.header_length; } else @@ -2120,14 +2120,14 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) filepos, 1)) || error != HA_ERR_END_OF_FILE) return (error); - mi_extra(isam_info,HA_EXTRA_NO_CACHE); + mi_extra(isam_info,HA_EXTRA_NO_CACHE, 0); if (info->current+1 == info->end) return(HA_ERR_END_OF_FILE); info->current++; isam_info= *info->current; filepos=isam_info->s->pack.header_length; - mi_extra(isam_info,HA_EXTRA_RESET); - mi_extra(isam_info,HA_EXTRA_CACHE); + mi_extra(isam_info,HA_EXTRA_RESET, 0); + mi_extra(isam_info,HA_EXTRA_CACHE, 0); } } |