diff options
Diffstat (limited to 'storage/myisam')
-rw-r--r-- | storage/myisam/TODO | 7 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 69 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.h | 2 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 6 | ||||
-rw-r--r-- | storage/myisam/mi_extra.c | 15 | ||||
-rw-r--r-- | storage/myisam/mi_info.c | 2 | ||||
-rw-r--r-- | storage/myisam/mi_key.c | 13 | ||||
-rw-r--r-- | storage/myisam/mi_locking.c | 6 | ||||
-rw-r--r-- | storage/myisam/mi_range.c | 72 | ||||
-rw-r--r-- | storage/myisam/mi_rkey.c | 4 | ||||
-rw-r--r-- | storage/myisam/mi_rnext.c | 4 | ||||
-rw-r--r-- | storage/myisam/mi_rnext_same.c | 4 | ||||
-rw-r--r-- | storage/myisam/mi_rprev.c | 4 | ||||
-rw-r--r-- | storage/myisam/myisamdef.h | 12 | ||||
-rw-r--r-- | storage/myisam/myisampack.c | 2 | ||||
-rw-r--r-- | storage/myisam/sort.c | 2 |
16 files changed, 173 insertions, 51 deletions
diff --git a/storage/myisam/TODO b/storage/myisam/TODO deleted file mode 100644 index cad9486e1bb..00000000000 --- a/storage/myisam/TODO +++ /dev/null @@ -1,7 +0,0 @@ -TODO: - -- Let packisam find the optimal way to store keys. -- kill when using 'myisamchk' should remove all temporary files. -- Text search index - (Sergei A. Golub is working on this) -- Add '%' packed to myisamchk for compressed tables with blobs. diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index da930f67ef4..2db068acbcb 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -96,6 +96,10 @@ static MYSQL_THDVAR_ENUM(stats_method, PLUGIN_VAR_RQCMDARG, "and NULLS_IGNORED", NULL, NULL, MI_STATS_METHOD_NULLS_NOT_EQUAL, &myisam_stats_method_typelib); +const char *MI_CHECK_INFO= "info"; +const char *MI_CHECK_WARNING= "warning"; +const char *MI_CHECK_ERROR= "error"; + #ifndef DBUG_OFF /** Causes the thread to wait in a spin lock for a query kill signal. @@ -130,6 +134,20 @@ static handler *myisam_create_handler(handlerton *hton, return new (mem_root) ha_myisam(hton, table); } + +static void mi_check_print(HA_CHECK *param, const char* msg_type, + const char *msgbuf) +{ + if (msg_type == MI_CHECK_INFO) + sql_print_information("%s.%s: %s", param->db_name, param->table_name, + msgbuf); + else if (msg_type == MI_CHECK_WARNING) + sql_print_warning("%s.%s: %s", param->db_name, param->table_name, + msgbuf); + else + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); +} + // collect errors printed by mi_check routines static void mi_check_print_msg(HA_CHECK *param, const char* msg_type, @@ -151,16 +169,21 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type, if (!thd->vio_ok()) { - sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); + mi_check_print(param, msg_type, msgbuf); return; } if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR)) { - my_message(ER_NOT_KEYFILE, msgbuf, MYF(MY_WME)); + myf flag= 0; + if (msg_type == MI_CHECK_INFO) + flag= ME_NOTE; + else if (msg_type == MI_CHECK_WARNING) + flag= ME_WARNING; + my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag)); if (thd->variables.log_warnings > 2 && ! thd->log_all_errors) - sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); + mi_check_print(param, msg_type, msgbuf); return; } length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) - @@ -185,7 +208,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type, sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n", msgbuf); else if (thd->variables.log_warnings > 2) - sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); + mi_check_print(param, msg_type, msgbuf); if (param->need_print_msg_lock) mysql_mutex_unlock(¶m->print_msg_mutex); @@ -592,7 +615,7 @@ void mi_check_print_error(HA_CHECK *param, const char *fmt,...) return; va_list args; va_start(args, fmt); - mi_check_print_msg(param, "error", fmt, args); + mi_check_print_msg(param, MI_CHECK_ERROR, fmt, args); va_end(args); } @@ -600,7 +623,7 @@ void mi_check_print_info(HA_CHECK *param, const char *fmt,...) { va_list args; va_start(args, fmt); - mi_check_print_msg(param, "info", fmt, args); + mi_check_print_msg(param, MI_CHECK_INFO, fmt, args); param->note_printed= 1; va_end(args); } @@ -611,7 +634,7 @@ void mi_check_print_warning(HA_CHECK *param, const char *fmt,...) param->out_flag|= O_DATA_LOST; va_list args; va_start(args, fmt); - mi_check_print_msg(param, "warning", fmt, args); + mi_check_print_msg(param, MI_CHECK_WARNING, fmt, args); va_end(args); } @@ -746,7 +769,8 @@ ulong ha_myisam::index_flags(uint inx, uint part, bool all_parts) const else { flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN; + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN | + HA_DO_RANGE_FILTER_PUSHDOWN; } return flags; } @@ -950,7 +974,6 @@ void ha_myisam::setup_vcols_for_repair(HA_CHECK *param) DBUG_ASSERT(file->s->base.reclength < file->s->vreclength); param->fix_record= compute_vcols; table->use_all_columns(); - table->vcol_set= &table->s->all_set; } void ha_myisam::restore_vcos_after_repair() @@ -1041,6 +1064,15 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) mysql_mutex_unlock(&share->intern_lock); info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE | HA_STATUS_CONST); + /* + Write a 'table is ok' message to error log if table is ok and + we have written to error log that table was getting checked + */ + if (!error && !(table->db_stat & HA_READ_ONLY) && + !mi_is_crashed(file) && thd->error_printed_to_log && + (param->warning_printed || param->error_printed || + param->note_printed)) + mi_check_print_info(param, "Table is fixed"); } } else if (!mi_is_crashed(file) && !thd->killed) @@ -1815,7 +1847,7 @@ bool ha_myisam::check_and_repair(THD *thd) sql_print_information("Making backup of index file %s with extension '%s'", file->s->index_file_name, buff); mi_make_backup_of_index(file, check_opt.start_time, - MYF(MY_WME | ME_JUST_WARNING)); + MYF(MY_WME | ME_WARNING)); } check_opt.flags= (((myisam_recover_options & @@ -1853,6 +1885,9 @@ int ha_myisam::index_init(uint idx, bool sorted) active_index=idx; if (pushed_idx_cond_keyno == idx) mi_set_index_cond_func(file, handler_index_cond_check, this); + if (pushed_rowid_filter) + mi_set_rowid_filter_func(file, handler_rowid_filter_check, + handler_rowid_filter_is_active, this); return 0; } @@ -1864,6 +1899,7 @@ int ha_myisam::index_end() //pushed_idx_cond_keyno= MAX_KEY; mi_set_index_cond_func(file, NULL, 0); in_range_check_pushed_down= FALSE; + mi_set_rowid_filter_func(file, NULL, NULL, 0); ds_mrr.dsmrr_close(); #if !defined(DBUG_OFF) && defined(SQL_SELECT_FIXED_FOR_UPDATE) file->update&= ~HA_STATE_AKTIV; // Forget active row @@ -1899,6 +1935,9 @@ int ha_myisam::index_read_idx_map(uchar *buf, uint index, const uchar *key, end_range= NULL; if (index == pushed_idx_cond_keyno) mi_set_index_cond_func(file, handler_index_cond_check, this); + if (pushed_rowid_filter) + mi_set_rowid_filter_func(file, handler_rowid_filter_check, + handler_rowid_filter_is_active, this); res= mi_rkey(file, buf, index, key, keypart_map, find_flag); mi_set_index_cond_func(file, NULL, 0); return res; @@ -2564,6 +2603,14 @@ Item *ha_myisam::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) return NULL; } +bool ha_myisam::rowid_filter_push(Rowid_filter* rowid_filter) +{ + pushed_rowid_filter= rowid_filter; + mi_set_rowid_filter_func(file, handler_rowid_filter_check, + handler_rowid_filter_is_active, this); + return false; +} + struct st_mysql_storage_engine myisam_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; @@ -2654,7 +2701,7 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, const char *table_name, If the table size is unknown the SELECT statement can't be cached. - When concurrent inserts are disabled at table open, mi_open() + When concurrent inserts are disabled at table open, mi_ondopen() does not assign a get_status() function. In this case the local ("current") status is never updated. We would wrongly think that we cannot cache the statement. diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 804963f5efc..f9f11b6f480 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -172,6 +172,8 @@ public: /* Index condition pushdown implementation */ Item *idx_cond_push(uint keyno, Item* idx_cond); + bool rowid_filter_push(Rowid_filter* rowid_filter); + private: DsMrr_impl ds_mrr; friend ICP_RESULT index_cond_func_myisam(void *arg); diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 5f9b5414174..01078c2a264 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -102,6 +102,9 @@ int chk_status(HA_CHECK *param, register MI_INFO *info) { MYISAM_SHARE *share=info->s; + /* Protection for HA_EXTRA_FLUSH */ + mysql_mutex_lock(&share->intern_lock); + if (mi_is_crashed_on_repair(info)) mi_check_print_warning(param, "Table is marked as crashed and last repair failed"); @@ -121,6 +124,7 @@ int chk_status(HA_CHECK *param, register MI_INFO *info) if (param->testflag & T_UPDATE_STATE) param->warning_printed=save; } + mysql_mutex_unlock(&share->intern_lock); return 0; } @@ -4782,7 +4786,7 @@ static int replace_data_file(HA_CHECK *param, MI_INFO *info, File new_file) my_create_backup_name(buff, "", param->backup_time); my_printf_error(ER_GET_ERRMSG, "Making backup of data file %s with extension '%s'", - MYF(ME_JUST_INFO | ME_NOREFRESH), share->data_file_name, + MYF(ME_NOTE | ME_ERROR_LOG), share->data_file_name, buff); } diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index dcb79a8dc3e..618c3251afc 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -334,7 +334,11 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) if (!share->temporary) flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, FLUSH_KEEP); + mysql_mutex_lock(&share->intern_lock); + /* Tell mi_lock_database() that we locked the intern_lock mutex */ + info->intern_lock_locked= 1; _mi_decrement_open_count(info); + info->intern_lock_locked= 0; if (share->not_flushed) { share->not_flushed=0; @@ -351,6 +355,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) } if (share->base.blobs) mi_alloc_rec_buff(info, -1, &info->rec_buff); + mysql_mutex_unlock(&share->intern_lock); break; case HA_EXTRA_NORMAL: /* Theese isn't in use */ info->quick_mode=0; @@ -420,6 +425,16 @@ void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func, info->index_cond_func_arg= func_arg; } +void mi_set_rowid_filter_func(MI_INFO *info, + rowid_filter_func_t check_func, + rowid_filter_func_t is_active_func, + void *func_arg) +{ + info->rowid_filter_func= check_func; + info->rowid_filter_is_active_func= is_active_func; + info->rowid_filter_func_arg= func_arg; +} + /* Start/Stop Inserting Duplicates Into a Table, WL#1648. */ diff --git a/storage/myisam/mi_info.c b/storage/myisam/mi_info.c index 3b9288eeb83..33ff6abb32d 100644 --- a/storage/myisam/mi_info.c +++ b/storage/myisam/mi_info.c @@ -127,7 +127,7 @@ void mi_report_error(int errcode, const char *file_name) if ((lgt= strlen(file_name)) > 64) file_name+= lgt - 64; - my_error(errcode, MYF(ME_NOREFRESH), file_name); + my_error(errcode, MYF(ME_ERROR_LOG), file_name); DBUG_VOID_RETURN; } diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 4bd01dcbfa0..8bf63af8f5f 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -529,6 +529,19 @@ ICP_RESULT mi_check_index_cond(register MI_INFO *info, uint keynr, return res; } + +int mi_check_rowid_filter(MI_INFO *info) +{ + return info->rowid_filter_func(info->rowid_filter_func_arg); +} + +int mi_check_rowid_filter_is_active(MI_INFO *info) +{ + if (info->rowid_filter_is_active_func == NULL) + return 0; + return info->rowid_filter_is_active_func(info->rowid_filter_func_arg); +} + /* Retrieve auto_increment info diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index b348429fd3c..f3030148044 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -53,7 +53,8 @@ int mi_lock_database(MI_INFO *info, int lock_type) error= 0; DBUG_EXECUTE_IF ("mi_lock_database_failure", error= EINVAL;); - mysql_mutex_lock(&share->intern_lock); + if (!info->intern_lock_locked) + mysql_mutex_lock(&share->intern_lock); if (share->kfile >= 0) /* May only be false on windows */ { switch (lock_type) { @@ -261,7 +262,8 @@ int mi_lock_database(MI_INFO *info, int lock_type) } } #endif - mysql_mutex_unlock(&share->intern_lock); + if (!info->intern_lock_locked) + mysql_mutex_unlock(&share->intern_lock); if (mark_crashed) mi_mark_crashed(info); DBUG_RETURN(error); diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index 2074c873979..a464b3d1e09 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -22,9 +22,10 @@ #include "myisamdef.h" #include "rt_index.h" -static ha_rows _mi_record_pos(MI_INFO *, const uchar *, key_part_map, - enum ha_rkey_function); -static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,uchar *, uint,uint,my_off_t); +static double _mi_record_pos(MI_INFO *, const uchar *, key_part_map, + enum ha_rkey_function); +static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,uchar *, uint,uint, + my_off_t,my_bool); static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *); /* @@ -48,7 +49,8 @@ static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *); ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key, key_range *max_key) { - ha_rows start_pos,end_pos,res; + ha_rows res; + double start_pos,end_pos,diff; DBUG_ENTER("mi_records_in_range"); if ((inx = _mi_check_index(info,inx)) < 0) @@ -94,16 +96,27 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, #endif case HA_KEY_ALG_BTREE: default: - start_pos= (min_key ? _mi_record_pos(info, min_key->key, - min_key->keypart_map, min_key->flag) - : (ha_rows) 0); + start_pos= (min_key ?_mi_record_pos(info, min_key->key, + min_key->keypart_map, min_key->flag) + : (double) 0); end_pos= (max_key ? _mi_record_pos(info, max_key->key, max_key->keypart_map, max_key->flag) - : info->state->records + (ha_rows) 1); + : (double) info->state->records); res= (end_pos < start_pos ? (ha_rows) 0 : - (end_pos == start_pos ? (ha_rows) 1 : end_pos-start_pos)); + (end_pos == start_pos ? (ha_rows) 1 : (ha_rows) (end_pos-start_pos))); if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR) res=HA_POS_ERROR; + else + { + diff= end_pos - start_pos; + if (diff >= 0) + { + if (!(res= (ha_rows) (diff + 0.5))) + res= 1; + } + else + res= 0; + } } if (info->s->concurrent_insert) @@ -115,11 +128,25 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, } - /* Find relative position (in records) for key in index-tree */ +/* + To find an approximate relative position of a key tuple among all index + key tuples would not be hard if we considered B-trees where all key + tuples were contained only in leaf nodes. If we consider a B-tree where + key tuples are stored also in non-leaf nodes we have to convert such + tree into the tree of the first type. The transformation procedure is + simple: the key tuple k goes alter the last key tuple in the most right + sub-tree pointer to which is coupled with k. As a result of this + transformation each leaf node except the most right one in the tree will + contain one extra key tuple following those originally belonging to + the leaf. +*/ + + +/* Find relative position (in records) for key in index-tree */ -static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key, - key_part_map keypart_map, - enum ha_rkey_function search_flag) +static double _mi_record_pos(MI_INFO *info, const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function search_flag) { uint inx=(uint) info->lastinx, nextflag, key_len; MI_KEYDEF *keyinfo=info->s->keyinfo+inx; @@ -175,13 +202,13 @@ static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key, */ pos=_mi_search_pos(info,keyinfo,key_buff,key_len, nextflag | SEARCH_SAVE_BUFF | SEARCH_UPDATE, - info->s->state.key_root[inx]); + info->s->state.key_root[inx], TRUE); if (pos >= 0.0) { - DBUG_PRINT("exit",("pos: %ld",(ulong) (pos*info->state->records))); - DBUG_RETURN((ulong) (pos*info->state->records+0.5)); + DBUG_PRINT("exit",("pos: %g",(pos*info->state->records))); + DBUG_RETURN(pos*info->state->records); } - DBUG_RETURN(HA_POS_ERROR); + DBUG_RETURN((double) (HA_POS_ERROR)); } @@ -191,7 +218,7 @@ static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key, static double _mi_search_pos(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, uint key_len, uint nextflag, - register my_off_t pos) + register my_off_t pos, my_bool last_in_level) { int flag; uint nod_flag,keynr,UNINIT_VAR(max_keynr); @@ -222,7 +249,8 @@ static double _mi_search_pos(register MI_INFO *info, if (flag > 0 && ! nod_flag) offset= 1.0; else if ((offset=_mi_search_pos(info,keyinfo,key,key_len,nextflag, - _mi_kpos(nod_flag,keypos))) < 0) + _mi_kpos(nod_flag,keypos), + last_in_level && after_key)) < 0) DBUG_RETURN(offset); } else @@ -241,13 +269,15 @@ static double _mi_search_pos(register MI_INFO *info, Matches keynr + [0-1] */ if ((offset=_mi_search_pos(info,keyinfo,key,key_len,SEARCH_FIND, - _mi_kpos(nod_flag,keypos))) < 0) + _mi_kpos(nod_flag,keypos), + last_in_level && after_key)) < 0) DBUG_RETURN(offset); /* Read error */ } } DBUG_PRINT("info",("keynr: %d offset: %g max_keynr: %d nod: %d flag: %d", keynr,offset,max_keynr,nod_flag,flag)); - DBUG_RETURN((keynr+offset)/(max_keynr+1)); + DBUG_RETURN((keynr+offset-MY_TEST(!nod_flag))/ + (max_keynr+MY_TEST(nod_flag || !last_in_level))); err: DBUG_PRINT("exit",("Error: %d",my_errno)); DBUG_RETURN (-1.0); diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index 1dddb8b49ad..c0f9b2046fc 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -120,7 +120,9 @@ int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, (search_flag != HA_READ_KEY_EXACT || last_used_keyseg != keyinfo->seg + keyinfo->keysegs)) || (info->index_cond_func && - (res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH)) + (res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH) || + (mi_check_rowid_filter_is_active(info) && + !mi_check_rowid_filter(info))) { uint not_used[2]; /* diff --git a/storage/myisam/mi_rnext.c b/storage/myisam/mi_rnext.c index 6e3701abe6b..c3af209fd71 100644 --- a/storage/myisam/mi_rnext.c +++ b/storage/myisam/mi_rnext.c @@ -102,7 +102,9 @@ int mi_rnext(MI_INFO *info, uchar *buf, int inx) while ((info->s->concurrent_insert && info->lastpos >= info->state->data_file_length) || (info->index_cond_func && - (icp_res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH)) + (icp_res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH) || + (mi_check_rowid_filter_is_active(info) && + !mi_check_rowid_filter(info))) { /* If we are at the last key on the key page, allow writers to diff --git a/storage/myisam/mi_rnext_same.c b/storage/myisam/mi_rnext_same.c index d6856459ae7..ac818bfa2da 100644 --- a/storage/myisam/mi_rnext_same.c +++ b/storage/myisam/mi_rnext_same.c @@ -95,7 +95,9 @@ int mi_rnext_same(MI_INFO *info, uchar *buf) */ if (info->lastpos < info->state->data_file_length && (!info->index_cond_func || - (icp_res= mi_check_index_cond(info, inx, buf)) != ICP_NO_MATCH)) + (icp_res= mi_check_index_cond(info, inx, buf)) != ICP_NO_MATCH) && + (!mi_check_rowid_filter_is_active(info) || + mi_check_rowid_filter(info))) break; } } diff --git a/storage/myisam/mi_rprev.c b/storage/myisam/mi_rprev.c index 27fbda95574..a78bab6a040 100644 --- a/storage/myisam/mi_rprev.c +++ b/storage/myisam/mi_rprev.c @@ -59,7 +59,9 @@ int mi_rprev(MI_INFO *info, uchar *buf, int inx) while ((share->concurrent_insert && info->lastpos >= info->state->data_file_length) || (info->index_cond_func && - (icp_res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH)) + (icp_res= mi_check_index_cond(info, inx, buf)) == ICP_NO_MATCH) || + (mi_check_rowid_filter_is_active(info) && + !mi_check_rowid_filter(info))) { /* If we are at the last (i.e. first?) key on the key page, diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index e350626f192..8ba2bbcc209 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -296,6 +296,7 @@ struct st_myisam_info uint preload_buff_size; /* When preloading indexes */ myf lock_wait; /* is 0 or MY_SHORT_WAIT */ my_bool was_locked; /* Was locked in panic */ + my_bool intern_lock_locked; /* locked in mi_extra() */ my_bool append_insert_at_end; /* Set if concurrent insert */ my_bool quick_mode; /* If info->buff can't be used for rnext */ @@ -305,6 +306,9 @@ struct st_myisam_info my_bool create_unique_index_by_sort; index_cond_func_t index_cond_func; /* Index condition function */ void *index_cond_func_arg; /* parameter for the func */ + rowid_filter_func_t rowid_filter_func; /* rowid filter check function */ + rowid_filter_func_t rowid_filter_is_active_func; /* is activefunction */ + void *rowid_filter_func_arg; /* parameter for the func */ THR_LOCK_DATA lock; uchar *rtree_recursion_state; /* For RTREE */ int rtree_recursion_depth; @@ -724,14 +728,20 @@ int mi_munmap_file(MI_INFO *info); void mi_remap_file(MI_INFO *info, my_off_t size); ICP_RESULT mi_check_index_cond(MI_INFO *info, uint keynr, uchar *record); +int mi_check_rowid_filter(MI_INFO *info); +int mi_check_rowid_filter_is_active(MI_INFO *info); /* Functions needed by mi_check */ int killed_ptr(HA_CHECK *param); void mi_check_print_error(HA_CHECK *param, const char *fmt, ...); void mi_check_print_warning(HA_CHECK *param, const char *fmt, ...); void mi_check_print_info(HA_CHECK *param, const char *fmt, ...); pthread_handler_t thr_find_all_keys(void *arg); -extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func, +extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t check_func, void *func_arg); +extern void mi_set_rowid_filter_func(MI_INFO *info, + rowid_filter_func_t check_func, + rowid_filter_func_t is_active_func, + void *func_arg); int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file, ulonglong *dirty_part_map); diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 4ea1602bec3..f69dd0196b3 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -2148,7 +2148,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) */ if (!(packed_tree=(uint*) my_alloca(sizeof(uint)*length*2))) { - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATALERROR), + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_FATAL), sizeof(uint)*length*2); return 0; } diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 533f2cd2aa6..aef3c9b42a8 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -28,12 +28,10 @@ /* static variables */ -#undef MYF_RW #undef DISK_BUFFER_SIZE #define MERGEBUFF 15 #define MERGEBUFF2 31 -#define MYF_RW MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL) #define DISK_BUFFER_SIZE (IO_SIZE*128) /* How many keys we can keep in memory */ |