diff options
author | unknown <pem@mysql.com> | 2003-12-01 16:14:40 +0100 |
---|---|---|
committer | unknown <pem@mysql.com> | 2003-12-01 16:14:40 +0100 |
commit | 38f853d291075a8eaa9d408a23626b09aa7ac1d2 (patch) | |
tree | 024f2d18e3cf9f65db53f9f8c2d5413859781e16 /myisam | |
parent | 6573b851e36de43d4cfa39d5eba0b740c3226521 (diff) | |
parent | 91de6fdbce2a5c545532acf1124f35378a75ea0c (diff) | |
download | mariadb-git-38f853d291075a8eaa9d408a23626b09aa7ac1d2.tar.gz |
Merge 4.1 to 5.0
BitKeeper/etc/ignore:
auto-union
BitKeeper/etc/logging_ok:
auto-union
configure.in:
Auto merged
client/mysql.cc:
Auto merged
client/mysqltest.c:
Auto merged
include/my_global.h:
Auto merged
include/my_pthread.h:
Auto merged
include/mysql_com.h:
Auto merged
libmysql/libmysql.c:
Auto merged
myisam/mi_check.c:
Auto merged
myisam/myisamchk.c:
Auto merged
myisam/myisamdef.h:
Auto merged
myisam/sort.c:
Auto merged
mysql-test/install_test_db.sh:
Auto merged
mysql-test/r/subselect.result:
Auto merged
mysql-test/r/symlink.result:
Auto merged
mysql-test/t/subselect.test:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/handler.h:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/protocol.cc:
Auto merged
sql/protocol.h:
Auto merged
sql/protocol_cursor.cc:
Auto merged
sql/repl_failsafe.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_derived.cc:
Auto merged
sql/sql_error.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_list.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_select.h:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_test.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/ft_boolean_search.c | 58 | ||||
-rw-r--r-- | myisam/ft_dump.c | 10 | ||||
-rw-r--r-- | myisam/ft_update.c | 6 | ||||
-rw-r--r-- | myisam/mi_check.c | 172 | ||||
-rw-r--r-- | myisam/mi_close.c | 2 | ||||
-rw-r--r-- | myisam/mi_delete.c | 2 | ||||
-rw-r--r-- | myisam/mi_delete_all.c | 2 | ||||
-rw-r--r-- | myisam/mi_extra.c | 14 | ||||
-rw-r--r-- | myisam/mi_keycache.c | 26 | ||||
-rw-r--r-- | myisam/mi_locking.c | 4 | ||||
-rw-r--r-- | myisam/mi_page.c | 10 | ||||
-rw-r--r-- | myisam/mi_panic.c | 2 | ||||
-rw-r--r-- | myisam/mi_preload.c | 10 | ||||
-rw-r--r-- | myisam/mi_test1.c | 2 | ||||
-rw-r--r-- | myisam/mi_test2.c | 6 | ||||
-rw-r--r-- | myisam/mi_test3.c | 2 | ||||
-rw-r--r-- | myisam/mi_write.c | 2 | ||||
-rw-r--r-- | myisam/myisamchk.c | 29 | ||||
-rw-r--r-- | myisam/myisamdef.h | 4 | ||||
-rw-r--r-- | myisam/myisamlog.c | 13 | ||||
-rw-r--r-- | myisam/myisampack.c | 14 | ||||
-rw-r--r-- | myisam/sort.c | 22 | ||||
-rw-r--r-- | myisam/sp_test.c | 7 |
23 files changed, 236 insertions, 183 deletions
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f3b593f7341..f48a12b6f28 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -61,10 +61,11 @@ typedef struct st_ftb_expr FTB_EXPR; struct st_ftb_expr { FTB_EXPR *up; - byte *quot, *qend; - my_off_t docid[2]; /* for index search and for scan */ + my_off_t docid[2]; +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ float weight; float cur_weight; + byte *quot, *qend; uint flags; uint yesses; /* number of "yes" words matched */ uint nos; /* number of "no" words matched */ @@ -77,6 +78,7 @@ typedef struct st_ftb_word FTB_EXPR *up; MI_KEYDEF *keyinfo; my_off_t docid[2]; /* for index search and for scan */ +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ my_off_t key_root; float weight; uint ndepth; @@ -166,11 +168,7 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end, ftbw->word[0]=w.len; if (param.yesno > 0) up->ythresh++; queue_insert(& ftb->queue, (byte *)ftbw); -#ifdef TO_BE_REMOVED - /* after removing the following line, - ftb->with_scan handling can be simplified (no longer a bitmap) */ ftb->with_scan|=(param.trunc & FTB_FLAG_TRUNC); -#endif break; case 2: /* left bracket */ ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR)); @@ -251,7 +249,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) } /* going up to the first-level tree to continue search there */ - _mi_dpointer(info, ftbw->word+ftbw->off+HA_FT_WLEN, ftbw->key_root); + _mi_dpointer(info, (uchar*) (ftbw->word+ftbw->off+HA_FT_WLEN), + ftbw->key_root); ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->keyinfo=info->s->keyinfo+ftb->keynr; ftbw->off=0; @@ -298,13 +297,15 @@ static void _ftb_init_index_search(FT_INFO *ftb) if (ftbw->flags & FTB_FLAG_TRUNC) { /* - special treatment for truncation operator :(( - 1. +trunc* and there're other (not +trunc*) words + special treatment for truncation operator + 1. there are some (besides this) +words | no need to search in the index, it can never ADD new rows | to the result, and to remove half-matched rows we do scan anyway 2. -trunc* | same as 1. - 3. trunc* + 3. in 1 and 2, +/- need not be on the same expr. level, + but can be on any upper level, as in +word +(trunc1* trunc2*) + 4. otherwise | We have to index-search for this prefix. | It may cause duplicates, as in the index (sorted by <word,docid>) | <aaaa,row1> @@ -312,22 +313,31 @@ static void _ftb_init_index_search(FT_INFO *ftb) | <aacc,row1> | Searching for "aa*" will find row1 twice... */ - if ( test(ftbw->flags&FTB_FLAG_NO) || /* 2 */ - (test(ftbw->flags&FTB_FLAG_YES) && /* 1 */ - ftbw->up->ythresh - ftbw->up->yweaks >1)) /* 1 */ - { - ftbw->docid[0]=HA_POS_ERROR; - ftbw->up->yweaks++; - continue; - } - else /* 3 */ + FTB_EXPR *ftbe; + for (ftbe=(FTB_EXPR*)ftbw; + ftbe->up && !(ftbe->up->flags & FTB_FLAG_TRUNC); + ftbe->up->flags|= FTB_FLAG_TRUNC, ftbe=ftbe->up) { - if (!is_tree_inited(& ftb->no_dupes)) - init_tree(&ftb->no_dupes,0,0,sizeof(my_off_t), - _ftb_no_dupes_cmp, 0, NULL, NULL); - else - reset_tree(& ftb->no_dupes); + if (ftbe->flags & FTB_FLAG_NO || /* 2 */ + ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ + { + FTB_EXPR *top_ftbe=ftbe->up->up; + ftbw->docid[0]=HA_POS_ERROR; + for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) + if (ftbe->flags & FTB_FLAG_YES) + ftbe->yweaks++; + ftbe=0; + break; + } } + if (!ftbe) + continue; + /* 3 */ + if (!is_tree_inited(& ftb->no_dupes)) + init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), + _ftb_no_dupes_cmp,0,0,0); + else + reset_tree(& ftb->no_dupes); } if (_ft2_search(ftb, ftbw, 1)) diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 5591a6ddb3e..8c40878cf00 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -80,7 +80,7 @@ int main(int argc,char *argv[]) if (argc < 2) usage(); - init_key_cache(dflt_keycache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT,0); + init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0); if (!(info=mi_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED))) goto err; @@ -172,9 +172,9 @@ int main(int argc,char *argv[]) if (dump) { if (subkeys>=0) - printf("%9qx %20.7f %s\n",info->lastpos,weight,buf); + printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf); else - printf("%9qx => %17d %s\n",info->lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); @@ -189,12 +189,12 @@ int main(int argc,char *argv[]) if ((ulong) count >= total/2) break; } - printf("Total rows: %qu\nTotal words: %lu\n" + printf("Total rows: %lu\nTotal words: %lu\n" "Unique words: %lu\nLongest word: %lu chars (%s)\n" "Median length: %u\n" "Average global weight: %f\n" "Most common word: %lu times, weight: %f (%s)\n", - (ulonglong)info->state->records, total, uniq, maxlen, buf_maxlen, + (long) info->state->records, total, uniq, maxlen, buf_maxlen, inx, avg_gws/uniq, max_doc_cnt, min_gws, buf_min_gws); } if (lstats) diff --git a/myisam/ft_update.c b/myisam/ft_update.c index a87f239b8f8..b94a174b292 100644 --- a/myisam/ft_update.c +++ b/myisam/ft_update.c @@ -304,7 +304,7 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) my_off_t root; DYNAMIC_ARRAY *da=info->ft1_to_ft2; MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo; - uchar *key_ptr=dynamic_array_ptr(da, 0), *end; + uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end; uint length, key_length; DBUG_ENTER("_mi_ft_convert_to_ft2"); @@ -329,13 +329,13 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) DBUG_RETURN(-1); /* inserting the rest of key values */ - end=dynamic_array_ptr(da, da->elements); + end= (uchar*) dynamic_array_ptr(da, da->elements); for (key_ptr+=length; key_ptr < end; key_ptr+=keyinfo->keylength) if(_mi_ck_real_write_btree(info, keyinfo, key_ptr, 0, &root, SEARCH_SAME)) DBUG_RETURN(-1); /* now, writing the word key entry */ - ft_intXstore(key+key_length, -da->elements); + ft_intXstore(key+key_length, - (int) da->elements); _mi_dpointer(info, key+key_length+HA_FT_WLEN, root); DBUG_RETURN(_mi_ck_real_write_btree(info, diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 4f8fc9b981a..c077e267dde 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -77,6 +77,7 @@ void myisamchk_init(MI_CHECK *param) param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL); param->start_check_pos=0; + param->max_record_length= LONGLONG_MAX; param->key_cache_block_size= KEY_CACHE_BLOCK_SIZE; } @@ -242,7 +243,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) if (next_link > info->state->key_file_length || next_link & (info->s->blocksize-1)) DBUG_RETURN(1); - if (!(buff=key_cache_read(*info->s->key_cache, + if (!(buff=key_cache_read(info->s->key_cache, info->s->kfile, next_link, DFLT_INIT_HITS, (byte*) info->buff, myisam_block_size, block_size, 1))) @@ -262,7 +263,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) } /* check_k_link */ - /* Kontrollerar storleken p} filerna */ + /* Check sizes of files */ int chk_size(MI_CHECK *param, register MI_INFO *info) { @@ -273,8 +274,9 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) if (!(param->testflag & T_SILENT)) puts("- check file-size"); - flush_key_blocks(*info->s->key_cache, - info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */ + /* The following is needed if called externally (not from myisamchk) */ + flush_key_blocks(info->s->key_cache, + info->s->kfile, FLUSH_FORCE_WRITE); size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); if ((skr=(my_off_t) info->state->key_file_length) != size) @@ -502,7 +504,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) param->record_checksum=old_record_checksum-init_checksum; /* Remove delete links */ else param->record_checksum=0; - DBUG_RETURN(0); + DBUG_RETURN(result); } /* chk_key */ @@ -522,7 +524,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (!(temp_buff=(uchar*) my_alloca((uint) keyinfo->block_length))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for keyblock"); DBUG_RETURN(-1); } @@ -711,7 +713,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0)))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for record"); DBUG_RETURN(-1); } records=del_blocks=0; @@ -814,16 +816,17 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) goto next; } mi_check_print_error(param,"Wrong bytesec: %d-%d-%d at linkstart: %s", - block_info.header[0],block_info.header[1], - block_info.header[2], - llstr(start_block,llbuff)); + block_info.header[0],block_info.header[1], + block_info.header[2], + llstr(start_block,llbuff)); goto err2; } if (info->state->data_file_length < block_info.filepos+ block_info.block_len) { - mi_check_print_error(param,"Recordlink that points outside datafile at %s", - llstr(pos,llbuff)); + mi_check_print_error(param, + "Recordlink that points outside datafile at %s", + llstr(pos,llbuff)); got_error=1; break; } @@ -834,9 +837,9 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) pos=block_info.filepos+block_info.block_len; if (block_info.rec_len > (uint) info->s->base.max_pack_length) { - mi_check_print_error(param,"Found too long record (%d) at %s", - block_info.rec_len, - llstr(start_recpos,llbuff)); + mi_check_print_error(param,"Found too long record (%lu) at %s", + (ulong) block_info.rec_len, + llstr(start_recpos,llbuff)); got_error=1; break; } @@ -845,8 +848,10 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) if (!(to= mi_alloc_rec_buff(info, block_info.rec_len, &info->rec_buff))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(start_recpos,llbuff)); + mi_check_print_error(param, + "Not enough memory (%lu) for blob at %s", + (ulong) block_info.rec_len, + llstr(start_recpos,llbuff)); got_error=1; break; } @@ -857,9 +862,11 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) } if (left_length < block_info.data_len) { - mi_check_print_error(param,"Found too long record at %s", - llstr(start_recpos,llbuff)); - got_error=1; break; + mi_check_print_error(param,"Found too long record (%lu) at %s", + (ulong) block_info.data_len, + llstr(start_recpos,llbuff)); + got_error=1; + break; } if (_mi_read_cache(¶m->read_cache,(byte*) to,block_info.filepos, (uint) block_info.data_len, @@ -1142,9 +1149,12 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + if (!param->using_global_keycache) - VOID(init_key_cache(dflt_keycache, param->key_cache_block_size, - param->use_buffers, &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size, + param->use_buffers, 0, 0)); if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, @@ -1163,7 +1173,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { - mi_check_print_error(param,"Not enough memory for extra record"); + mi_check_print_error(param, "Not enough memory for extra record"); goto err; } @@ -1355,6 +1365,7 @@ err: VOID(my_close(new_file,MYF(0))); VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks, MYF(MY_WME))); + info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */ } mi_mark_crashed_on_repair(info); } @@ -1365,7 +1376,7 @@ err: VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); VOID(end_io_cache(&info->rec_cache)); - got_error|=flush_blocks(param, *share->key_cache, share->kfile); + got_error|=flush_blocks(param, share->key_cache, share->kfile); if (!got_error && param->testflag & T_UNPACK) { share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD; @@ -1501,7 +1512,7 @@ void lock_memory(MI_CHECK *param __attribute__((unused))) /* Flush all changed blocks to disk */ -int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file) +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) { if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) { @@ -1564,7 +1575,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) } /* Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); share->state.version=(ulong) time((time_t*) 0); old_state= share->state; /* save state if not stored */ @@ -1625,7 +1636,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (!(buff=(uchar*) my_alloca((uint) keyinfo->block_length))) { - mi_check_print_error(param,"Not Enough memory"); + mi_check_print_error(param,"Not enough memory for key block"); DBUG_RETURN(-1); } if (!_mi_fetch_keypage(info,keyinfo,pagepos,DFLT_INIT_HITS,buff,0)) @@ -1811,6 +1822,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); bzero((char *)&sort_param, sizeof(sort_param)); if (!(sort_info.key_block= @@ -1834,7 +1848,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { - mi_check_print_error(param,"Not enough memory for extra record"); + mi_check_print_error(param, "Not enough memory for extra record"); goto err; } if (!rep_quick) @@ -1874,7 +1888,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -1884,7 +1898,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2076,7 +2090,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, memcpy( &share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, *share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2182,6 +2196,9 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); if (!(sort_info.key_block= alloc_key_blocks(param, @@ -2237,7 +2254,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -2247,7 +2264,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2267,17 +2284,19 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, rec_length=share->base.min_block_length; else rec_length=share->base.pack_reclength; + /* + +1 below is required hack for parallel repair mode. + The info->state->records value, that is compared later + to sort_info.max_records and cannot exceed it, is + increased in sort_key_write. In mi_repair_by_sort, sort_key_write + is called after sort_key_read, where the comparison is performed, + but in parallel mode master thread can call sort_key_write + before some other repair thread calls sort_key_read. + Furthermore I'm not even sure +1 would be enough. + May be sort_info.max_records shold be always set to max value in + parallel mode. + */ sort_info.max_records= - /* +1 below is required hack for parallel repair mode. - The info->state->records value, that is compared later - to sort_info.max_records and cannot exceed it, is - increased in sort_key_write. In mi_repair_by_sort, sort_key_write - is called after sort_key_read, where the comparison is performed, - but in parallel mode master thread can call sort_key_write - before some other repair thread calls sort_key_read. - Furthermore I'm not even sure +1 would be enough. - May be sort_info.max_records shold be always set to max value in - parallel mode. */ ((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records + 1: (ha_rows) (sort_info.filelength/rec_length+1)); @@ -2291,7 +2310,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, (sizeof(MI_SORT_PARAM) + share->base.pack_reclength), MYF(MY_ZEROFILL)))) { - mi_check_print_error(param,"Not enough memory!"); + mi_check_print_error(param,"Not enough memory for key!"); goto err; } total_key_length=0; @@ -2483,7 +2502,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, memcpy(&share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param, *share->key_cache, share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2847,9 +2866,20 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (!(to=mi_alloc_rec_buff(info,block_info.rec_len, &(sort_param->rec_buff)))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(sort_param->start_recpos,llbuff)); - DBUG_RETURN(1); + if (param->max_record_length >= block_info.rec_len) + { + mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", + llstr(sort_param->start_recpos,llbuff), + (ulong) block_info.rec_len); + DBUG_RETURN(1); + } + else + { + mi_check_print_info(param,"Not enough memory for blob at %s (need %lu); Row skipped", + llstr(sort_param->start_recpos,llbuff), + (ulong) block_info.rec_len); + goto try_next; + } } } else @@ -2857,14 +2887,16 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (left_length < block_info.data_len || ! block_info.data_len) { - mi_check_print_info(param,"Found block with too small length at %s; Skipped", + mi_check_print_info(param, + "Found block with too small length at %s; Skipped", llstr(sort_param->start_recpos,llbuff)); goto try_next; } if (block_info.filepos + block_info.data_len > sort_param->read_cache.end_of_file) { - mi_check_print_info(param,"Found block that points outside data file at %s", + mi_check_print_info(param, + "Found block that points outside data file at %s", llstr(sort_param->start_recpos,llbuff)); goto try_next; } @@ -3269,30 +3301,28 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) ft_buf->buf=0; return error; } - else - { - /* flushing buffer */ - if ((error=sort_ft_buf_flush(sort_param))) - return error; -word_init_ft_buf: - a_len+=val_len; - memcpy(ft_buf->lastkey, a, a_len); - ft_buf->buf=ft_buf->lastkey+a_len; - ft_buf->end=ft_buf->lastkey+ (sort_param->keyinfo->block_length-32); - /* 32 is just a safety margin here - (at least max(val_len, sizeof(nod_flag)) should be there). - May be better performance could be achieved if we'd put - (sort_info->keyinfo->block_length-32)/XXX - instead. - TODO: benchmark the best value for XXX. - */ + /* flushing buffer */ + if ((error=sort_ft_buf_flush(sort_param))) + return error; - return 0; - } - return -1; /* impossible */ +word_init_ft_buf: + a_len+=val_len; + memcpy(ft_buf->lastkey, a, a_len); + ft_buf->buf=ft_buf->lastkey+a_len; + /* + 32 is just a safety margin here + (at least max(val_len, sizeof(nod_flag)) should be there). + May be better performance could be achieved if we'd put + (sort_info->keyinfo->block_length-32)/XXX + instead. + TODO: benchmark the best value for XXX. + */ + ft_buf->end=ft_buf->lastkey+ (sort_param->keyinfo->block_length-32); + return 0; } /* sort_ft_key_write */ + /* get pointer to record from a key */ static my_off_t get_record_for_key(MI_INFO *info, MI_KEYDEF *keyinfo, @@ -3499,7 +3529,7 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint blocks, buffer_length+IO_SIZE)*blocks, MYF(0)))) { - mi_check_print_error(param,"Not Enough memory for sort-key-blocks"); + mi_check_print_error(param,"Not enough memory for sort-key-blocks"); return(0); } for (i=0 ; i < blocks ; i++) diff --git a/myisam/mi_close.c b/myisam/mi_close.c index 66d5b08bbc4..deb0ccee8f3 100644 --- a/myisam/mi_close.c +++ b/myisam/mi_close.c @@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*share->key_cache, share->kfile, + flush_key_blocks(share->key_cache, share->kfile, share->temporary ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error=my_errno; diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index f21b0e928b6..a55d5b2a5ca 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -241,7 +241,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (info->ft1_to_ft2) { /* we're in ft1->ft2 conversion mode. Saving key data */ - insert_dynamic(info->ft1_to_ft2, lastkey+off); + insert_dynamic(info->ft1_to_ft2, (char*) (lastkey+off)); } else { diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 357df9ebe3e..3033249886f 100644 --- a/myisam/mi_delete_all.c +++ b/myisam/mi_delete_all.c @@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info) If we are using delayed keys or if the user has done changes to the tables since it was locked then there may be key blocks in the key cache */ - flush_key_blocks(*share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) || my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) ) goto err; diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 327d795d17b..10f52f1e39a 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -33,15 +33,11 @@ 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. - HA_EXTRA_BULK_INSERT_FLUSH - extra_arg is a a pointer to which index to flush (uint*) - RETURN VALUES - 0 ok + RETURN VALUES + 0 ok + # error */ - int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { int error=0; @@ -283,7 +279,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); - if (flush_key_blocks(*share->keycache, share->kfile, + if (flush_key_blocks(share->key_cache, share->kfile, (function == HA_EXTRA_FORCE_REOPEN ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) { @@ -329,7 +325,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) break; case HA_EXTRA_FLUSH: if (!share->temporary) - flush_key_blocks(*share->key_cache, share->kfile, FLUSH_KEEP); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP); #ifdef HAVE_PWRITE _mi_decrement_open_count(info); #endif diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index c6fd1801740..99a2fd6db15 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -49,19 +49,19 @@ int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map __attribute__((unused)), - KEY_CACHE_VAR *key_cache) + KEY_CACHE *key_cache) { int error= 0; MYISAM_SHARE* share= info->s; DBUG_ENTER("mi_assign_to_key_cache"); DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx", - share->key_cache, &key_cache->cache)); + share->key_cache, key_cache)); /* Skip operation if we didn't change key cache. This can happen if we call this for all open instances of the same table */ - if (*share->key_cache == key_cache->cache) + if (share->key_cache == key_cache) DBUG_RETURN(0); /* @@ -76,7 +76,7 @@ int mi_assign_to_key_cache(MI_INFO *info, in the old key cache. */ - if (flush_key_blocks(*share->key_cache, share->kfile, FLUSH_REMOVE)) + if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)) { error= my_errno; mi_mark_crashed(info); /* Mark that table must be checked */ @@ -90,18 +90,24 @@ int mi_assign_to_key_cache(MI_INFO *info, (This can never fail as there is never any not written data in the new key cache) */ - (void) flush_key_blocks(key_cache->cache, share->kfile, FLUSH_REMOVE); + (void) flush_key_blocks(key_cache, share->kfile, FLUSH_RELEASE); /* + ensure that setting the key cache and changing the multi_key_cache + is done atomicly + */ + pthread_mutex_lock(&share->intern_lock); + /* Tell all threads to use the new key cache This should be seen at the lastes for the next call to an myisam function. */ - share->key_cache= &key_cache->cache; + share->key_cache= key_cache; /* store the key cache in the global hash structure for future opens */ if (multi_key_cache_set(share->unique_file_name, share->unique_name_length, share->key_cache)) error= my_errno; + pthread_mutex_unlock(&share->intern_lock); DBUG_RETURN(error); } @@ -127,8 +133,8 @@ int mi_assign_to_key_cache(MI_INFO *info, */ -void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache) +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { LIST *pos; DBUG_ENTER("mi_change_key_cache"); @@ -141,7 +147,7 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, { MI_INFO *info= (MI_INFO*) pos->data; MYISAM_SHARE *share= info->s; - if (share->key_cache == &old_key_cache->cache) + if (share->key_cache == old_key_cache) mi_assign_to_key_cache(info, (ulonglong) ~0, new_key_cache); } @@ -150,6 +156,6 @@ void mi_change_key_cache(KEY_CACHE_VAR *old_key_cache, MyISAM list structure to ensure that another thread is not trying to open a new table that will be associted with the old key cache */ - multi_key_cache_change(&old_key_cache->cache, &new_key_cache->cache); + multi_key_cache_change(old_key_cache, new_key_cache); pthread_mutex_unlock(&THR_LOCK_myisam); } diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 2056b018a16..67ccca52d08 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -61,7 +61,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) count= --share->w_locks; --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && - !share->delay_key_write && flush_key_blocks(*share->key_cache, + !share->delay_key_write && flush_key_blocks(share->key_cache, share->kfile,FLUSH_KEEP)) { error=my_errno; @@ -389,7 +389,7 @@ int _mi_test_if_changed(register MI_INFO *info) { /* Keyfile has changed */ DBUG_PRINT("info",("index file changed")); if (share->state.process != share->this_process) - VOID(flush_key_blocks(*share->key_cache, share->kfile, FLUSH_RELEASE)); + VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)); share->last_process=share->state.process; info->last_unique= share->state.unique; info->last_loop= share->state.update_count; diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 0aae267e05e..c70209c2da6 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -32,7 +32,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_ENTER("_mi_fetch_keypage"); DBUG_PRINT("enter",("page: %ld",page)); - tmp=(uchar*) key_cache_read(*info->s->key_cache, + tmp=(uchar*) key_cache_read(info->s->key_cache, info->s->kfile, page, level, (byte*) buff, (uint) keyinfo->block_length, (uint) keyinfo->block_length, @@ -52,7 +52,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); - DBUG_DUMP("page", tmp, keyinfo->block_length); + DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; my_errno = HA_ERR_CRASHED; tmp = 0; @@ -95,7 +95,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, length=keyinfo->block_length; } #endif - DBUG_RETURN((key_cache_write(*info->s->key_cache, + DBUG_RETURN((key_cache_write(info->s->key_cache, info->s->kfile,page, level, (byte*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || @@ -117,7 +117,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, info->s->state.key_del[keyinfo->block_size]=pos; mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; - DBUG_RETURN(key_cache_write(*info->s->key_cache, + DBUG_RETURN(key_cache_write(info->s->key_cache, info->s->kfile, pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, @@ -146,7 +146,7 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level) } else { - if (!key_cache_read(*info->s->key_cache, + if (!key_cache_read(info->s->key_cache, info->s->kfile, pos, level, buff, (uint) sizeof(buff), diff --git a/myisam/mi_panic.c b/myisam/mi_panic.c index cefb3423ccc..78698d88c54 100644 --- a/myisam/mi_panic.c +++ b/myisam/mi_panic.c @@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag) if (info->s->options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 3219c00b0e2..5e03d489efe 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -69,7 +69,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); - if (flush_key_blocks(*share->key_cache,share->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) goto err; do @@ -87,7 +87,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (mi_test_if_nod(buff)) { - if (key_cache_insert(*share->key_cache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, block_length)) goto err; @@ -99,7 +99,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } else { - if (key_cache_insert(*share->key_cache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, length)) goto err; @@ -108,11 +108,11 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } while (pos != key_file_length); - my_free(buff, MYF(0)); + my_free((char*) buff, MYF(0)); DBUG_RETURN(0); err: - my_free(buff, MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) buff, MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(my_errno= errno); } diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index c1b76408a7c..64ffbe2db1d 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(dflt_keycache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0); get_options(argc,argv); exit(run_test("test1")); diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 5918a2485b0..d3c3cc2c492 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) if (!silent) printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,key_cache_block_size,key_cache_size,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0); if (locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) } } if (key_cacheing) - resize_key_cache(dflt_keycache,key_cache_block_size,key_cache_size*2); + resize_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size*2,0,0); if (!silent) printf("- Delete\n"); @@ -829,7 +829,7 @@ reads: %10lu\n", my_cache_r_requests, my_cache_read); #endif } - end_key_cache(*dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/myisam/mi_test3.c b/myisam/mi_test3.c index baeaba7bf24..dca04a9a64b 100644 --- a/myisam/mi_test3.c +++ b/myisam/mi_test3.c @@ -177,7 +177,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache, KEY_CACHE_BLOCK_SIZE, 65536L,0); + init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 86c45e0692f..d13ba6c2c4e 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -521,7 +521,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, we cannot easily dispatch an empty page here */ b+=blen+ft2len+2; for (a=anc_buff+a_length ; b < a ; b+=ft2len+2) - insert_dynamic(info->ft1_to_ft2, b); + insert_dynamic(info->ft1_to_ft2, (char*) b); /* fixing the page's length - it contains only one key now */ mi_putint(anc_buff,2+blen+ft2len+2,0); diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 5193a817a3a..d65fac009f8 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -110,7 +110,8 @@ int main(int argc, char **argv) VOID(fflush(stderr)); if ((check_param.error_printed | check_param.warning_printed) && (check_param.testflag & T_FORCE_CREATE) && - (!(check_param.testflag & (T_REP | T_SORT_RECORDS | T_SORT_INDEX)))) + (!(check_param.testflag & (T_REP | T_REP_BY_SORT | T_SORT_RECORDS | + T_SORT_INDEX)))) { uint old_testflag=check_param.testflag; if (!(check_param.testflag & T_REP)) @@ -153,7 +154,7 @@ enum options_mc { OPT_KEY_CACHE_BLOCK_SIZE, OPT_MYISAM_BLOCK_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN, - OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT + OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT, OPT_MAX_RECORD_LENGTH }; static struct my_option my_long_options[] = @@ -215,6 +216,11 @@ static struct my_option my_long_options[] = (gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, + {"max-record-length", OPT_MAX_RECORD_LENGTH, + "Skip rows bigger than this if myisamchk can't allocate memory to hold it", + (gptr*) &check_param.max_record_length, + (gptr*) &check_param.max_record_length, + 0, GET_ULL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0}, {"medium-check", 'm', "Faster than extend-check, but only finds 99.99% of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -321,13 +327,13 @@ static struct my_option my_long_options[] = { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXLEN, 10, HA_FT_MAXLEN, 0, 1, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void print_version(void) { - printf("%s Ver 2.6 for %s at %s\n", my_progname, SYSTEM_TYPE, + printf("%s Ver 2.7 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -394,6 +400,9 @@ static void usage(void) -k, --keys-used=# Tell MyISAM to update only some specific keys. # is a\n\ bit mask of which keys to use. This can be used to\n\ get faster inserts.\n\ + --max-record-length=#\n\ + Skip rows bigger than this if myisamchk can't allocate\n\ + memory to hold it.\n\ -r, --recover Can fix almost anything except unique keys that aren't\n\ unique.\n\ -n, --sort-recover Forces recovering with sorting even if the temporary\n\ @@ -1032,8 +1041,8 @@ 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(dflt_keycache,opt_key_cache_block_size, - param->use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, + param->use_buffers, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1047,7 +1056,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) HA_OPTION_COMPRESS_RECORD)) || (param->testflag & (T_EXTEND | T_MEDIUM))) error|=chk_data_link(param, info, param->testflag & T_EXTEND); - error|=flush_blocks(param, *share->key_cache, share->kfile); + error|=flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(¶m->read_cache)); } if (!error) @@ -1456,8 +1465,8 @@ 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(dflt_keycache, opt_key_cache_block_size, param->use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers, + 0, 0); 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))) @@ -1571,7 +1580,7 @@ err: my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); sort_info.buff=0; share->state.sortkey=sort_key; - DBUG_RETURN(flush_blocks(param, *share->key_cache, share->kfile) | + DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) | got_error); } /* sort_records */ diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 20574e43ac3..3788eeca1e3 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -166,7 +166,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */ char *data_file_name, /* Resolved path names from symlinks */ *index_file_name; byte *file_map; /* mem-map of file if possible */ - KEY_CACHE_HANDLE *key_cache; /* ref to the current key cache */ + KEY_CACHE *key_cache; /* ref to the current key cache */ MI_DECODE_TREE *decode_trees; uint16 *decode_tables; int (*read_record)(struct st_myisam_info*, my_off_t, byte*); @@ -713,7 +713,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param); #ifdef THREAD pthread_handler_decl(thr_find_all_keys,arg); #endif -int flush_blocks(MI_CHECK *param, KEY_CACHE_HANDLE key_cache, File file); +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file); int sort_write_record(MI_SORT_PARAM *sort_param); int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index fbe8b675821..c9b00be7d9e 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -71,7 +71,7 @@ static void printf_log(const char *str,...); static bool cmp_filename(struct file_info *file_info,my_string name); static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0, - recover=0,prefix_remove=0,opt_processes=0,opt_myisam_with_debug=0; + recover=0,prefix_remove=0,opt_processes=0; static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0; static ulong com_count[10][3],number_of_commands=(ulong) ~0L, isamlog_process; @@ -201,9 +201,6 @@ static void get_options(register int *argc, register char ***argv) update=1; recover++; break; - case 'D': - opt_myisam_with_debug=1; - break; case 'P': opt_processes=1; break; @@ -333,8 +330,8 @@ 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(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0, 0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && @@ -648,7 +645,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(*dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -668,7 +665,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(*dflt_keycache, 1); + end_key_cache(dflt_key_cache, 1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 5ca57248204..93edde33bdb 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -51,7 +51,7 @@ struct st_file_buffer { char *buffer,*pos,*end; my_off_t pos_in_file; int bits; - uint byte; + uint current_byte; }; struct st_huff_tree; @@ -1912,7 +1912,7 @@ static void init_file_buffer(File file, pbool read_buffer) file_buffer.pos=file_buffer.buffer; file_buffer.bits=BITS_SAVED; } - file_buffer.byte=0; + file_buffer.current_byte=0; } @@ -1961,13 +1961,13 @@ static void write_bits (register ulong value, register uint bits) { if ((file_buffer.bits-=(int) bits) >= 0) { - file_buffer.byte|=value << file_buffer.bits; + file_buffer.current_byte|=value << file_buffer.bits; } else { reg3 uint byte_buff; bits= (uint) -file_buffer.bits; - byte_buff=file_buffer.byte | (uint) (value >> bits); + byte_buff=file_buffer.current_byte | (uint) (value >> bits); #if BITS_SAVED == 32 *file_buffer.pos++= (byte) (byte_buff >> 24) ; *file_buffer.pos++= (byte) (byte_buff >> 16) ; @@ -1993,7 +1993,7 @@ static void write_bits (register ulong value, register uint bits) if (file_buffer.pos >= file_buffer.end) VOID(flush_buffer((uint) ~0)); file_buffer.bits=(int) (BITS_SAVED - bits); - file_buffer.byte=(uint) (value << (BITS_SAVED - bits)); + file_buffer.current_byte=(uint) (value << (BITS_SAVED - bits)); } return; } @@ -2005,7 +2005,7 @@ static void flush_bits (void) uint bits,byte_buff; bits=(file_buffer.bits) & ~7; - byte_buff = file_buffer.byte >> bits; + byte_buff = file_buffer.current_byte >> bits; bits=BITS_SAVED - bits; while (bits > 0) { @@ -2013,7 +2013,7 @@ static void flush_bits (void) *file_buffer.pos++= (byte) (uchar) (byte_buff >> bits) ; } file_buffer.bits=BITS_SAVED; - file_buffer.byte=0; + file_buffer.current_byte=0; return; } diff --git a/myisam/sort.c b/myisam/sort.c index 4617dec46f4..6f255881a42 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -84,7 +84,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file, char* key, uint sort_length, uint count); -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs); +inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file, byte *bufs); /* Creates a index of sorted keys @@ -622,21 +622,25 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, DBUG_RETURN(0); } /* write_keys */ -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs) + +inline int my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs) { int err; - uint16 len = _mi_keylength(info->keyinfo,bufs); + uint16 len = _mi_keylength(info->keyinfo, (uchar*) bufs); - if ((err= my_b_write(to_file,(byte*)&len,sizeof(len)))) + /* The following is safe as this is a local file */ + if ((err= my_b_write(to_file, (byte*)&len, sizeof(len)))) return (err); - if ((err= my_b_write(to_file,(byte*)bufs,(uint) len))) + if ((err= my_b_write(to_file,bufs, (uint) len))) return (err); return (0); } -static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_keys, - uint count, BUFFPEK *buffpek, IO_CACHE *tempfile) +static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, + register uchar **sort_keys, + uint count, BUFFPEK *buffpek, + IO_CACHE *tempfile) { uchar **end; int err; @@ -653,7 +657,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k buffpek->count=count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if ((err= my_var_write(info,tempfile,*sort_keys))) + if ((err= my_var_write(info,tempfile, (byte*) *sort_keys))) DBUG_RETURN(err); } DBUG_RETURN(0); @@ -816,7 +820,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, for (idx=1;idx<=count;idx++) { int err; - if ((err= my_var_write(info,to_file,bufs))) + if ((err= my_var_write(info,to_file, (byte*) bufs))) return (err); bufs=bufs+sort_length; } diff --git a/myisam/sp_test.c b/myisam/sp_test.c index c4847217efd..16a97771887 100644 --- a/myisam/sp_test.c +++ b/myisam/sp_test.c @@ -271,7 +271,8 @@ int run_test(const char *filename) create_key(key, nrecords*upd); print_key(key," INTERSECT\n"); - hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0,0); + hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0, + HA_READ_KEY_EXACT); printf(" %ld rows\n", (long) hrows); @@ -351,7 +352,7 @@ static void print_record(char * record, my_off_t offs,const char * tail) printf(" len=%d ",len); memcpy_fixed(&ptr,pos,sizeof(char*)); if(ptr) - rtree_PrintWKB(ptr,SPDIMS); + rtree_PrintWKB((uchar*) ptr,SPDIMS); else printf("<NULL> "); printf(" offs=%ld ",(long int)offs); @@ -406,7 +407,7 @@ static void create_linestring(char *record,uint rownr) pos++; memset(blob_key,0,sizeof(blob_key)); - tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints,blob_key); + tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key); int4store(pos,tmp); pos+=4; |