diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/archive/ha_archive.cc | 54 | ||||
-rw-r--r-- | storage/archive/ha_archive.h | 4 | ||||
-rw-r--r-- | storage/blackhole/ha_blackhole.cc | 20 | ||||
-rw-r--r-- | storage/blackhole/ha_blackhole.h | 8 | ||||
-rw-r--r-- | storage/csv/ha_tina.cc | 39 | ||||
-rw-r--r-- | storage/csv/ha_tina.h | 12 | ||||
-rw-r--r-- | storage/example/ha_example.cc | 7 | ||||
-rw-r--r-- | storage/example/ha_example.h | 4 | ||||
-rw-r--r-- | storage/heap/hp_extra.c | 17 | ||||
-rw-r--r-- | storage/heap/hp_test2.c | 2 | ||||
-rw-r--r-- | storage/myisam/ft_boolean_search.c | 5 | ||||
-rw-r--r-- | storage/myisam/mi_extra.c | 56 | ||||
-rw-r--r-- | storage/myisam/mi_search.c | 38 | ||||
-rw-r--r-- | storage/myisam/mi_test2.c | 4 | ||||
-rw-r--r-- | storage/myisam/myisampack.c | 4 | ||||
-rw-r--r-- | storage/myisammrg/myrg_extra.c | 26 |
16 files changed, 177 insertions, 123 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index e39ee976eb1..970744566c9 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -139,7 +139,7 @@ static HASH archive_open_tables; #define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption /* Static declarations for handerton */ -static handler *archive_create_handler(TABLE_SHARE *table); +static handler *archive_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root); /* Number of rows that will force a bulk insert. */ @@ -189,9 +189,9 @@ handlerton archive_hton = { }; -static handler *archive_create_handler(TABLE_SHARE *table) +static handler *archive_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { - return new ha_archive(table); + return new (mem_root) ha_archive(table); } /* @@ -697,8 +697,8 @@ int ha_archive::create(const char *name, TABLE *table_arg, int error; DBUG_ENTER("ha_archive::create"); - auto_increment_value= (create_info->auto_increment_value ? - create_info->auto_increment_value -1 : + stats.auto_increment_value= (create_info->auto_increment_value ? + create_info->auto_increment_value -1 : (ulonglong) 0); if ((create_file= my_create(fn_format(name_buff,name,"",ARM, @@ -727,7 +727,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, } } - write_meta_file(create_file, 0, auto_increment_value, 0, + write_meta_file(create_file, 0, stats.auto_increment_value, 0, (char *)create_info->data_file_name, FALSE); my_close(create_file,MYF(0)); @@ -923,7 +923,7 @@ int ha_archive::write_row(byte *buf) else { if (temp_auto > share->auto_increment_value) - auto_increment_value= share->auto_increment_value= temp_auto; + stats.auto_increment_value= share->auto_increment_value= temp_auto; } } @@ -1058,7 +1058,7 @@ int ha_archive::rnd_init(bool scan) { scan_rows= share->rows_recorded; DBUG_PRINT("info", ("archive will retrieve %llu rows", scan_rows)); - records= 0; + stats.records= 0; /* If dirty, we lock, and then reset/flush the data. @@ -1095,6 +1095,7 @@ int ha_archive::get_row(azio_stream *file_to_read, byte *buf) uint *ptr, *end; char *last; size_t total_blob_length= 0; + MY_BITMAP *read_set= table->read_set; DBUG_ENTER("ha_archive::get_row"); read= azread(file_to_read, buf, table->s->reclength); @@ -1120,8 +1121,9 @@ int ha_archive::get_row(azio_stream *file_to_read, byte *buf) ptr != end ; ptr++) { - if (ha_get_bit_in_read_set(((Field_blob*) table->field[*ptr])->fieldnr)) - total_blob_length += ((Field_blob*) table->field[*ptr])->get_length(); + if (bitmap_is_set(read_set, + (((Field_blob*) table->field[*ptr])->field_index))) + total_blob_length += ((Field_blob*) table->field[*ptr])->get_length(); } /* Adjust our row buffer if we need be */ @@ -1136,7 +1138,8 @@ int ha_archive::get_row(azio_stream *file_to_read, byte *buf) size_t size= ((Field_blob*) table->field[*ptr])->get_length(); if (size) { - if (ha_get_bit_in_read_set(((Field_blob*) table->field[*ptr])->fieldnr)) + if (bitmap_is_set(read_set, + ((Field_blob*) table->field[*ptr])->field_index)) { read= azread(file_to_read, last, size); if ((size_t) read != size) @@ -1177,7 +1180,7 @@ int ha_archive::rnd_next(byte *buf) if (rc != HA_ERR_END_OF_FILE) - records++; + stats.records++; DBUG_RETURN(rc); } @@ -1298,7 +1301,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) if (!rc) { share->rows_recorded= 0; - auto_increment_value= share->auto_increment_value= 0; + stats.auto_increment_value= share->auto_increment_value= 0; while (!(rc= get_row(&archive, buf))) { real_write_row(buf, &writer); @@ -1308,7 +1311,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) ulonglong auto_value= (ulonglong) field->val_int((char*)(buf + field->offset())); if (share->auto_increment_value < auto_value) - auto_increment_value= share->auto_increment_value= + stats.auto_increment_value= share->auto_increment_value= auto_value; } share->rows_recorded++; @@ -1423,7 +1426,7 @@ void ha_archive::update_create_info(HA_CREATE_INFO *create_info) ha_archive::info(HA_STATUS_AUTO | HA_STATUS_CONST); if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) { - create_info->auto_increment_value= auto_increment_value; + create_info->auto_increment_value= stats.auto_increment_value; } if (*share->real_path) create_info->data_file_name= share->real_path; @@ -1440,8 +1443,8 @@ void ha_archive::info(uint flag) This should be an accurate number now, though bulk and delayed inserts can cause the number to be inaccurate. */ - records= share->rows_recorded; - deleted= 0; + stats.records= share->rows_recorded; + stats.deleted= 0; /* Costs quite a bit more to get all information */ if (flag & HA_STATUS_TIME) { @@ -1449,17 +1452,17 @@ void ha_archive::info(uint flag) VOID(my_stat(share->data_file_name, &file_stat, MYF(MY_WME))); - mean_rec_length= table->s->reclength + buffer.alloced_length(); - data_file_length= file_stat.st_size; - create_time= file_stat.st_ctime; - update_time= file_stat.st_mtime; - max_data_file_length= share->rows_recorded * mean_rec_length; + stats.mean_rec_length= table->s->reclength + buffer.alloced_length(); + stats.data_file_length= file_stat.st_size; + stats.create_time= file_stat.st_ctime; + stats.update_time= file_stat.st_mtime; + stats.max_data_file_length= share->rows_recorded * stats.mean_rec_length; } - delete_length= 0; - index_file_length=0; + stats.delete_length= 0; + stats.index_file_length=0; if (flag & HA_STATUS_AUTO) - auto_increment_value= share->auto_increment_value; + stats.auto_increment_value= share->auto_increment_value; DBUG_VOID_RETURN; } @@ -1586,5 +1589,6 @@ mysql_declare_plugin(archive) NULL, /* Plugin Init */ archive_db_done, /* Plugin Deinit */ 0x0100 /* 1.0 */, + 0 } mysql_declare_plugin_end; diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 4663531b674..f35858ff382 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -74,9 +74,9 @@ public: const char *table_type() const { return "ARCHIVE"; } const char *index_type(uint inx) { return "NONE"; } const char **bas_ext() const; - ulong table_flags() const + ulonglong table_flags() const { - return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_CAN_BIT_FIELD | + return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD | HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY); } ulong index_flags(uint idx, uint part, bool all_parts) const diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index e9fd1c2319d..ffcf9536ff2 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -26,7 +26,8 @@ /* Static declarations for handlerton */ -static handler *blackhole_create_handler(TABLE_SHARE *table); +static handler *blackhole_create_handler(TABLE_SHARE *table, + MEM_ROOT *mem_root); static const char blackhole_hton_name[]= "BLACKHOLE"; @@ -74,9 +75,10 @@ handlerton blackhole_hton= { }; -static handler *blackhole_create_handler(TABLE_SHARE *table) +static handler *blackhole_create_handler(TABLE_SHARE *table, + MEM_ROOT *mem_root) { - return new ha_blackhole(table); + return new (mem_root) ha_blackhole(table); } @@ -171,16 +173,9 @@ void ha_blackhole::info(uint flag) { DBUG_ENTER("ha_blackhole::info"); - records= 0; - deleted= 0; - errkey= 0; - mean_rec_length= 0; - data_file_length= 0; - index_file_length= 0; - max_data_file_length= 0; - delete_length= 0; + bzero((char*) &stats, sizeof(stats)); if (flag & HA_STATUS_AUTO) - auto_increment_value= 1; + stats.auto_increment_value= 1; DBUG_VOID_RETURN; } @@ -266,5 +261,6 @@ mysql_declare_plugin(blackhole) NULL, /* Plugin Init */ NULL, /* Plugin Deinit */ 0x0100 /* 1.0 */, + 0 } mysql_declare_plugin_end; diff --git a/storage/blackhole/ha_blackhole.h b/storage/blackhole/ha_blackhole.h index 15e12659aa0..55c26f6f02e 100644 --- a/storage/blackhole/ha_blackhole.h +++ b/storage/blackhole/ha_blackhole.h @@ -40,12 +40,11 @@ public: */ const char *index_type(uint key_number); const char **bas_ext() const; - ulong table_flags() const + ulonglong table_flags() const { return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | - HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | - HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME | - HA_CAN_INSERT_DELAYED); + HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | + HA_FILE_BASED | HA_CAN_GEOMETRY | HA_CAN_INSERT_DELAYED); } ulong index_flags(uint inx, uint part, bool all_parts) const { @@ -84,5 +83,4 @@ public: THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); - bool has_transactions() { return 1; } }; diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index de69df90ed5..c70e21a0be7 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -74,7 +74,7 @@ static int write_meta_file(File meta_file, ha_rows rows, bool dirty); pthread_mutex_t tina_mutex; static HASH tina_open_tables; static int tina_init= 0; -static handler *tina_create_handler(TABLE_SHARE *table); +static handler *tina_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root); static int tina_init_func(); static const char tina_hton_name[]= "CSV"; @@ -114,7 +114,8 @@ handlerton tina_hton= { NULL, /* Fill FILES Table */ HTON_CAN_RECREATE, NULL, /* binlog_func */ - NULL /* binlog_log_query */ + NULL, /* binlog_log_query */ + 0 }; /***************************************************************************** @@ -478,9 +479,9 @@ byte * find_eoln(byte *data, off_t begin, off_t end) } -static handler *tina_create_handler(TABLE_SHARE *table) +static handler *tina_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { - return new ha_tina(table); + return new (mem_root) ha_tina(table); } @@ -507,8 +508,10 @@ ha_tina::ha_tina(TABLE_SHARE *table_arg) int ha_tina::encode_quote(byte *buf) { char attribute_buffer[1024]; - String attribute(attribute_buffer, sizeof(attribute_buffer), &my_charset_bin); + String attribute(attribute_buffer, sizeof(attribute_buffer), + &my_charset_bin); + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); buffer.length(0); for (Field **field=table->field ; *field ; field++) { @@ -569,6 +572,7 @@ int ha_tina::encode_quote(byte *buf) buffer.append('\n'); //buffer.replace(buffer.length(), 0, "\n", 1); + dbug_tmp_restore_column_map(table->read_set, old_map); return (buffer.length()); } @@ -621,6 +625,7 @@ int ha_tina::find_current_row(byte *buf) { byte *mapped_ptr; byte *end_ptr; + my_bitmap_map *org_bitmap; DBUG_ENTER("ha_tina::find_current_row"); mapped_ptr= (byte *)share->mapped_file + current_position; @@ -633,6 +638,9 @@ int ha_tina::find_current_row(byte *buf) local_saved_data_file_length)) == 0) DBUG_RETURN(HA_ERR_END_OF_FILE); + /* Avoid asserts in ::store() for columns that are not going to be updated */ + org_bitmap= dbug_tmp_use_all_columns(table, table->write_set); + for (Field **field=table->field ; *field ; field++) { buffer.length(0); @@ -676,11 +684,13 @@ int ha_tina::find_current_row(byte *buf) buffer.append(*mapped_ptr); } } - (*field)->store(buffer.ptr(), buffer.length(), system_charset_info); + if (bitmap_is_set(table->read_set, (*field)->field_index)) + (*field)->store(buffer.ptr(), buffer.length(), system_charset_info); } next_position= (end_ptr - share->mapped_file)+1; /* Maybe use \N for null? */ memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */ + tmp_restore_column_map(table->write_set, org_bitmap); DBUG_RETURN(0); } @@ -898,7 +908,7 @@ int ha_tina::write_row(byte * buf) update_status(); pthread_mutex_unlock(&share->mutex); - records++; + stats.records++; DBUG_RETURN(0); } @@ -957,7 +967,7 @@ int ha_tina::delete_row(const byte * buf) if (chain_append()) DBUG_RETURN(-1); - --records; + stats.records--; /* DELETE should never happen on the log table */ DBUG_ASSERT(!share->is_log_table); @@ -1005,7 +1015,7 @@ int ha_tina::rnd_init(bool scan) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); current_position= next_position= 0; - records= 0; + stats.records= 0; records_is_known= 0; chain_ptr= chain; #ifdef HAVE_MADVISE @@ -1047,7 +1057,7 @@ int ha_tina::rnd_next(byte *buf) if ((rc= find_current_row(buf))) DBUG_RETURN(rc); - records++; + stats.records++; DBUG_RETURN(0); } @@ -1090,8 +1100,8 @@ void ha_tina::info(uint flag) { DBUG_ENTER("ha_tina::info"); /* This is a lie, but you don't want the optimizer to see zero or 1 */ - if (!records_is_known && records < 2) - records= 2; + if (!records_is_known && stats.records < 2) + stats.records= 2; DBUG_VOID_RETURN; } @@ -1204,6 +1214,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) goto end; } + /* Don't assert in field::val() functions */ + table->use_all_columns(); if (!(buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -1307,7 +1319,7 @@ int ha_tina::delete_all_rows() if (get_mmap(share, 0) > 0) DBUG_RETURN(-1); - records=0; + stats.records=0; DBUG_RETURN(rc); } @@ -1412,6 +1424,7 @@ mysql_declare_plugin(csv) tina_init_func, /* Plugin Init */ tina_done_func, /* Plugin Deinit */ 0x0100 /* 1.0 */, + 0 } mysql_declare_plugin_end; diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index d155a614780..d3a8c5092b6 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -87,14 +87,16 @@ public: const char *table_type() const { return "CSV"; } const char *index_type(uint inx) { return "NONE"; } const char **bas_ext() const; - ulong table_flags() const + ulonglong table_flags() const { - return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | - HA_NO_AUTO_INCREMENT ); + return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT); } ulong index_flags(uint idx, uint part, bool all_parts) const { - /* We will never have indexes so this will never be called(AKA we return zero) */ + /* + We will never have indexes so this will never be called(AKA we return + zero) + */ return 0; } uint max_record_length() const { return HA_MAX_REC_LENGTH; } @@ -104,7 +106,7 @@ public: /* Called in test_quick_select to determine if indexes should be used. */ - virtual double scan_time() { return (double) (records+deleted) / 20.0+10; } + virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; } /* The next method will never be called */ virtual bool fast_key_read() { return 1;} /* diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 2ce543dfbb0..f2f4694b54e 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -72,7 +72,7 @@ #include <mysql/plugin.h> -static handler* example_create_handler(TABLE_SHARE *table); +static handler *example_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root); static int example_init_func(); static bool example_init_func_for_handlerton(); static int example_panic(enum ha_panic_function flag); @@ -244,9 +244,9 @@ static int free_share(EXAMPLE_SHARE *share) } -static handler* example_create_handler(TABLE_SHARE *table) +static handler* example_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root) { - return new ha_example(table); + return new (mem_root) ha_example(table); } @@ -756,6 +756,7 @@ mysql_declare_plugin(example) example_init_func, /* Plugin Init */ example_done_func, /* Plugin Deinit */ 0x0001 /* 0.1 */, + 0 } mysql_declare_plugin_end; diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h index 139a50a3281..956dc62311c 100644 --- a/storage/example/ha_example.h +++ b/storage/example/ha_example.h @@ -62,7 +62,7 @@ public: implements. The current table flags are documented in handler.h */ - ulong table_flags() const + ulonglong table_flags() const { return 0; } @@ -97,7 +97,7 @@ public: /* Called in test_quick_select to determine if indexes should be used. */ - virtual double scan_time() { return (double) (records+deleted) / 20.0+10; } + virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; } /* The next method will never be called if you do not implement indexes. */ diff --git a/storage/heap/hp_extra.c b/storage/heap/hp_extra.c index dd41d6c5f19..abb632707f2 100644 --- a/storage/heap/hp_extra.c +++ b/storage/heap/hp_extra.c @@ -32,13 +32,8 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function) DBUG_ENTER("heap_extra"); switch (function) { - case HA_EXTRA_RESET: case HA_EXTRA_RESET_STATE: - info->lastinx= -1; - info->current_record= (ulong) ~0L; - info->current_hash_ptr=0; - info->update=0; - break; + heap_reset(info); case HA_EXTRA_NO_READCHECK: info->opt_flag&= ~READ_CHECK_USED; /* No readcheck */ break; @@ -56,6 +51,16 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function) } /* heap_extra */ +int heap_reset(HP_INFO *info) +{ + info->lastinx= -1; + info->current_record= (ulong) ~0L; + info->current_hash_ptr=0; + info->update=0; + return 0; +} + + /* Start/Stop Inserting Duplicates Into a Table, WL#1648. */ diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index a74872dbd11..8d2a8bc3da2 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -469,7 +469,7 @@ int main(int argc, char *argv[]) #endif printf("- Read through all records with scan\n"); - if (heap_extra(file,HA_EXTRA_RESET) || heap_extra(file,HA_EXTRA_CACHE)) + if (heap_reset(file) || heap_extra(file,HA_EXTRA_CACHE)) { puts("got error from heap_extra"); goto end; diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 8d48f533203..4f58b44722d 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -602,8 +602,9 @@ static int ftb_phrase_add_word(void *param, char *word, int word_len, { FT_WORD *phrase_word= (FT_WORD *)phrase->data; FT_WORD *document_word= (FT_WORD *)document->data; - if (my_strnncoll(phrase_param->cs, phrase_word->pos, phrase_word->len, - document_word->pos, document_word->len)) + if (my_strnncoll(phrase_param->cs, (uchar*) phrase_word->pos, + phrase_word->len, + (uchar*) document_word->pos, document_word->len)) return 0; } phrase_param->match++; diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 04beb36bb47..c1ed29c4734 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -47,29 +47,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) DBUG_PRINT("enter",("function: %d",(int) function)); switch (function) { - case HA_EXTRA_RESET: - /* - Free buffers and reset the following flags: - EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK - - If the row buffer cache is large (for dynamic tables), reduce it - to save memory. - */ - if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) - { - info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); - error=end_io_cache(&info->rec_cache); - } - if (share->base.blobs) - mi_alloc_rec_buff(info, -1, &info->rec_buff); -#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) - if (info->opt_flag & MEMMAP_USED) - madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM); -#endif - info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); - info->quick_mode=0; - /* Fall through */ - case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */ info->lastinx= 0; /* Use first index as def */ info->last_search_keypage=info->lastpos= HA_OFFSET_ERROR; @@ -425,3 +402,36 @@ static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function) } } + +int mi_reset(MI_INFO *info) +{ + int error= 0; + MYISAM_SHARE *share=info->s; + DBUG_ENTER("mi_reset"); + /* + Free buffers and reset the following flags: + EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK + + If the row buffer cache is large (for dynamic tables), reduce it + to save memory. + */ + if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) + { + info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + error= end_io_cache(&info->rec_cache); + } + if (share->base.blobs) + mi_alloc_rec_buff(info, -1, &info->rec_buff); +#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) + if (info->opt_flag & MEMMAP_USED) + madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM); +#endif + info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); + info->quick_mode=0; + info->lastinx= 0; /* Use first index as def */ + info->last_search_keypage= info->lastpos= HA_OFFSET_ERROR; + info->page_changed= 1; + info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND | + HA_STATE_PREV_FOUND); + DBUG_RETURN(error); +} diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 05f8459a4b4..2117e9fdf15 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -259,15 +259,16 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, { mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; - DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx", - length, (long) page, (long) end)); + DBUG_PRINT("error", + ("Found wrong key: length: %u page: 0x%lx end: 0x%lx", + length, (long) page, (long) end)); DBUG_RETURN(MI_FOUND_WRONG_KEY); } if ((flag=ha_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag, not_used)) >= 0) break; #ifdef EXTRA_DEBUG - DBUG_PRINT("loop",("page: %lx key: '%s' flag: %d", (long) page, t_buff, + DBUG_PRINT("loop",("page: 0x%lx key: '%s' flag: %d", (long) page, t_buff, flag)); #endif memcpy(buff,t_buff,length); @@ -276,7 +277,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, if (flag == 0) memcpy(buff,t_buff,length); /* Result is first key */ *last_key= page == end; - DBUG_PRINT("exit",("flag: %d ret_pos: %lx", flag, (long) *ret_pos)); + DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos)); DBUG_RETURN(flag); } /* _mi_seq_search */ @@ -416,8 +417,9 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, { mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; - DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx", - length, (long) page, (long) end)); + DBUG_PRINT("error", + ("Found wrong key: length: %u page: 0x%lx end: %lx", + length, (long) page, (long) end)); DBUG_RETURN(MI_FOUND_WRONG_KEY); } @@ -551,7 +553,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, *last_key= page == end; - DBUG_PRINT("exit",("flag: %d ret_pos: %lx", flag, (long) *ret_pos)); + DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos)); DBUG_RETURN(flag); } /* _mi_prefix_search */ @@ -813,7 +815,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, if (length > keyseg->length) { DBUG_PRINT("error", - ("Found too long null packed key: %u of %u at %lx", + ("Found too long null packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); @@ -870,7 +872,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, } if (length > (uint) keyseg->length) { - DBUG_PRINT("error",("Found too long packed key: %u of %u at %lx", + DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); @@ -936,8 +938,9 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { if (length > keyinfo->maxlength) { - DBUG_PRINT("error",("Found too long binary packed key: %u of %u at %lx", - length, keyinfo->maxlength, (long) *page_pos)); + DBUG_PRINT("error", + ("Found too long binary packed key: %u of %u at 0x%lx", + length, keyinfo->maxlength, (long) *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; @@ -984,7 +987,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, length-=tmp; from=page; from_end=page_end; } - DBUG_PRINT("info",("key: %lx from: %lx length: %u", + DBUG_PRINT("info",("key: 0x%lx from: 0x%lx length: %u", (long) key, (long) from, length)); memmove((byte*) key, (byte*) from, (size_t) length); key+=length; @@ -1042,7 +1045,7 @@ uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, } } } - DBUG_PRINT("exit",("page: %lx length: %u", (long) page, + DBUG_PRINT("exit",("page: 0x%lx length: %u", (long) page, *return_key_length)); DBUG_RETURN(page); } /* _mi_get_key */ @@ -1095,7 +1098,8 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uint nod_flag; uchar *lastpos; DBUG_ENTER("_mi_get_last_key"); - DBUG_PRINT("enter",("page: %lx endpos: %lx", (long) page, (long) endpos)); + DBUG_PRINT("enter",("page: 0x%lx endpos: 0x%lx", (long) page, + (long) endpos)); nod_flag=mi_test_if_nod(page); if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) @@ -1115,7 +1119,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey); if (*return_key_length == 0) { - DBUG_PRINT("error",("Couldn't find last key: page: %lx", + DBUG_PRINT("error",("Couldn't find last key: page: 0x%lx", (long) page)); mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; @@ -1123,7 +1127,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, } } } - DBUG_PRINT("exit",("lastpos: %lx length: %u", (long) lastpos, + DBUG_PRINT("exit",("lastpos: 0x%lx length: %u", (long) lastpos, *return_key_length)); DBUG_RETURN(lastpos); } /* _mi_get_last_key */ @@ -1660,7 +1664,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, ref_length=0; next_length_pack=0; } - DBUG_PRINT("test",("length: %d next_key: %lx", length, + DBUG_PRINT("test",("length: %d next_key: 0x%lx", length, (long) next_key)); { diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 357ebb1b9bc..357128b7a40 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -708,7 +708,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,0) || mi_extra(file,HA_EXTRA_CACHE,0)) + if (mi_reset(file) || mi_extra(file,HA_EXTRA_CACHE,0)) { if (locking || (!use_blob && !pack_fields)) { @@ -751,7 +751,7 @@ int main(int argc, char *argv[]) DBUG_PRINT("progpos",("Removing keys")); lastpos = HA_OFFSET_ERROR; /* DBUG_POP(); */ - mi_extra(file,HA_EXTRA_RESET,0); + mi_reset(file); found_parts=0; while ((error=mi_rrnd(file,read_record,HA_OFFSET_ERROR)) != HA_ERR_END_OF_FILE) diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 5b3067cb115..556d0f46145 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -3033,7 +3033,7 @@ 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, 0); + mi_reset(isam_info); mi_extra(isam_info, HA_EXTRA_CACHE, 0); filepos=isam_info->s->pack.header_length; } @@ -3056,7 +3056,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) info->current++; isam_info= *info->current; filepos=isam_info->s->pack.header_length; - mi_extra(isam_info,HA_EXTRA_RESET, 0); + mi_reset(isam_info); mi_extra(isam_info,HA_EXTRA_CACHE, 0); } } diff --git a/storage/myisammrg/myrg_extra.c b/storage/myisammrg/myrg_extra.c index 62cf5f01aba..ef7eeb9d4d9 100644 --- a/storage/myisammrg/myrg_extra.c +++ b/storage/myisammrg/myrg_extra.c @@ -38,10 +38,10 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function, } else { - if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET || - function == HA_EXTRA_PREPARE_FOR_UPDATE) + if (function == HA_EXTRA_NO_CACHE || + function == HA_EXTRA_PREPARE_FOR_UPDATE) info->cache_in_use=0; - if (function == HA_EXTRA_RESET || function == HA_EXTRA_RESET_STATE) + if (function == HA_EXTRA_RESET_STATE) { info->current_table=0; info->last_used_table=info->open_tables; @@ -66,3 +66,23 @@ void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv) DBUG_VOID_RETURN; } + + +int myrg_reset(MYRG_INFO *info) +{ + int save_error= 0; + MYRG_TABLE *file; + DBUG_ENTER("myrg_reset"); + + info->cache_in_use=0; + info->current_table=0; + info->last_used_table= info->open_tables; + + for (file=info->open_tables ; file != info->end_table ; file++) + { + int error; + if ((error= mi_reset(file->table))) + save_error=error; + } + DBUG_RETURN(save_error); +} |