From 925e508a2e76c39173bb058ad8891202ce895d8f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 19 Jun 2010 15:40:19 +0400 Subject: MWL#121: DS-MRR support for clustered primary keys - First code (will need code cleanup) --- storage/maria/ha_maria.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 7c34a5f7595..43c6cd6606a 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3501,10 +3501,11 @@ static SHOW_VAR status_variables[]= { ***************************************************************************/ int ha_maria::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, - uint n_ranges, uint mode, + uint n_ranges, uint key_parts, uint mode, HANDLER_BUFFER *buf) { - return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf); + return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, key_parts, + mode, buf); } int ha_maria::multi_range_read_next(char **range_info) @@ -3528,11 +3529,11 @@ ha_rows ha_maria::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, } ha_rows ha_maria::multi_range_read_info(uint keyno, uint n_ranges, uint keys, - uint *bufsz, uint *flags, - COST_VECT *cost) + uint key_parts, uint *bufsz, + uint *flags, COST_VECT *cost) { ds_mrr.init(this, table); - return ds_mrr.dsmrr_info(keyno, n_ranges, keys, bufsz, flags, cost); + return ds_mrr.dsmrr_info(keyno, n_ranges, keys, key_parts, bufsz, flags, cost); } /* MyISAM MRR implementation ends */ -- cgit v1.2.1 From 488d352a662438a3c34fd1b41261a94be7572f38 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 22 Jun 2010 23:26:11 +0400 Subject: MWL#121: DS-MRR support for clustered primary keys - Remove back key_parts from multi_range_read_init() parameters - Related code simplification/cleanup --- storage/maria/ha_maria.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 43c6cd6606a..e27983989d8 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3501,11 +3501,10 @@ static SHOW_VAR status_variables[]= { ***************************************************************************/ int ha_maria::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, - uint n_ranges, uint key_parts, uint mode, - HANDLER_BUFFER *buf) + uint n_ranges, uint mode, + HANDLER_BUFFER *buf) { - return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, key_parts, - mode, buf); + return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf); } int ha_maria::multi_range_read_next(char **range_info) -- cgit v1.2.1 From 9d68ccdeb8692b05d9cc0479d8d3757edbc49368 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 7 Nov 2010 14:25:29 +0200 Subject: Added option BACKUP_ALL to mysqld --myisam-recover to also get a backup of the index file before it's repaired. Removed wrong call to translog_buffer_unlock() that caused 'unlocking not locked mutex' failure in Aria log handler. extra/replace.c: Updated call to my_redel() include/maria.h: Updated prototype for maria_change_to_newfile include/my_sys.h: Updated prototypes Added my_create_backup_name include/myisam.h: Updated prototypes include/myisamchk.h: Added 'backup_time' to st_handler_check_param to be able to generate same name for backuped data and index file mysys/my_redel.c: Added time_t option to my_redel() to be able to generate same backup extensions for many files sql/handler.cc: Added start_time to st_ha_check_opt sql/handler.h: Added start_time to HA_CHECK_OPT sql/mysqld.cc: Added option BACKUP_ALL to --myisam-recover storage/maria/ha_maria.cc: Remember start time for repair storage/maria/ma_check.c: Use remembered start time for backup file names Removed some dead code storage/maria/ma_loghandler.c: Removed wrong call to translog_buffer_unlock() that caused 'unlocking not locked mutex' failure in log handler. storage/maria/maria_chk.c: Removed dead code (O_NEW_INDEX was never set) Report if table was 'crashed on repair' storage/maria/maria_pack.c: Updated parameters to my_redel() storage/myisam/ha_myisam.cc: Added recover option BACKUP_ALL to get a backup of the index file before it's repaired. Print information to log if we make a backup of data as part of repair. storage/myisam/ha_myisam.h: Added HA_RECOVER_FULL_BACKUP storage/myisam/mi_check.c: Use remembered start time for backup file names Added mi_make_backup_of_index() storage/myisam/myisamchk.c: Removed dead code (O_NEW_INDEX was never set) Report if table was 'crashed on repair' storage/myisam/myisampack.c: Updated call to my_redel() --- storage/maria/ha_maria.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 2b26de17875..6852e84fc65 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1316,6 +1316,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM | (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT)); param.sort_buffer_length= THDVAR(thd, sort_buffer_size); + param.backup_time= check_opt->start_time; start_records= file->state->records; while ((error= repair(thd, ¶m, 0)) && param.retry_repair) { -- cgit v1.2.1 From 52090a443493f5a8410094b43bfa5cdde8c32f5d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 24 Nov 2010 00:08:48 +0200 Subject: Code cleanup to get fewer reallocs() during execution. - Changed TABLE->alias to String to get fewer reallocs when alias are used. - Preallocate some buffers Changed some String->c_ptr() -> String->ptr() when \0 is not needed. Fixed wrong usage of String->ptr() when we need a \0 terminated string. Use my_strtod() instead of my_atof() to avoid having to add \0 to string. c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. zr sql/event_db_repository.cc: Update usage of TABLE->alias sql/event_scheduler.cc: c_ptr() -> c_ptr_safe() sql/events.cc: c_ptr() -> ptr() as \0 was not needed sql/field.cc: Update usage of TABLE->alias sql/field.h: Update usage of TABLE->alias sql/ha_partition.cc: Update usage of TABLE->alias sql/handler.cc: Update usage of TABLE->alias Fixed wrong usage of str.ptr() sql/item.cc: Fixed error where code wrongly assumed string was \0 terminated. sql/item_func.cc: c_ptr() -> c_ptr_safe() Update usage of TABLE->alias sql/item_sum.h: Use my_strtod() instead of my_atof() to avoid having to add \0 to string sql/lock.cc: Update usage of TABLE->alias sql/log.cc: c_ptr() -> ptr() as \0 was not needed sql/log_event.cc: c_ptr_quick() -> ptr() as \0 was not needed sql/opt_range.cc: ptr() -> c_ptr() as \0 is needed sql/opt_subselect.cc: Update usage of TABLE->alias sql/opt_table_elimination.cc: Update usage of TABLE->alias sql/set_var.cc: ptr() -> c_ptr() as \0 is needed c_ptr() -> c_ptr_safe() sql/sp.cc: c_ptr() -> ptr() as \0 was not needed sql/sp_rcontext.cc: Update usage of TABLE->alias sql/sql_base.cc: Preallocate buffers Update usage of TABLE->alias sql/sql_class.cc: Fix arguments to sprintf() to work even if string is not \0 terminated sql/sql_insert.cc: Update usage of TABLE->alias c_ptr() -> ptr() as \0 was not needed sql/sql_load.cc: Preallocate buffers Trivial optimizations sql/sql_parse.cc: Trivial optimization sql/sql_plugin.cc: c_ptr() -> ptr() as \0 was not needed sql/sql_select.cc: Update usage of TABLE->alias sql/sql_show.cc: Update usage of TABLE->alias sql/sql_string.h: Added move() function to move allocated memory from one object to another. sql/sql_table.cc: Update usage of TABLE->alias c_ptr() -> c_ptr_safe() sql/sql_test.cc: ptr() -> c_ptr_safe() sql/sql_trigger.cc: Update usage of TABLE->alias c_ptr() -> c_ptr_safe() sql/sql_update.cc: Update usage of TABLE->alias sql/sql_view.cc: ptr() -> c_ptr_safe() sql/sql_yacc.yy: ptr() -> c_ptr() sql/table.cc: Update usage of TABLE->alias sql/table.h: Changed TABLE->alias to String to get fewer reallocs when alias are used. storage/federatedx/ha_federatedx.cc: Use c_ptr_safe() to ensure strings are \0 terminated. storage/maria/ha_maria.cc: Update usage of TABLE->alias storage/myisam/ha_myisam.cc: Update usage of TABLE->alias storage/xtradb/row/row0sel.c: Ensure that null bits in record are properly reset. (Old code didn't work as row_search_for_mysql() can be called twice while reading fields from one row. --- storage/maria/ha_maria.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 27958285a2e..6463b25e440 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1095,7 +1095,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) param.thd= thd; param.op_name= "check"; param.db_name= table->s->db.str; - param.table_name= table->alias; + param.table_name= table->alias.c_ptr(); param.testflag= check_opt->flags | T_CHECK | T_SILENT; param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method); @@ -1194,7 +1194,7 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt) param.thd= thd; param.op_name= "analyze"; param.db_name= table->s->db.str; - param.table_name= table->alias; + param.table_name= table->alias.c_ptr(); param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS | T_DONT_CHECK_CHECKSUM); param.using_global_keycache= 1; @@ -1488,7 +1488,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) _ma_copy_nontrans_state_information(file); param->db_name= table->s->db.str; - param->table_name= table->alias; + param->table_name= table->alias.c_ptr(); param->tmpfile_createflag= O_RDWR | O_TRUNC; param->using_global_keycache= 1; param->thd= thd; -- cgit v1.2.1 From 7c56b08216d5ff709d10e4ca662d0215cd823c09 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 27 Nov 2010 17:29:52 +0200 Subject: Added TRASH() to table->record[0] to find out if we access not initialzed data. - Changed Cached_item_field not copy data for fields with NULL value - In key_copy() and key_restore() don't copy data for fields with NULL value Fixed code to avoid valgrind warnings - Use c_ptr_safe instead of c_ptr() Removed "QQ" from comments (QQ was ment to be used for internal comments that should be removed before pushing) Fixed wrong alias used (from previous patch) sql/event_db_repository.cc: Update testing if event table is valid (to avoid valgrind errors) sql/ha_partition.cc: m_ordered_scan_ongoing was not initialized Reset null bits in record to avoid valgrind errors sql/handler.h: Added flag if storage engine will write row verbatim and the row contains varchar or null fields (in which case we must clear the row to avoid valgrind warnings) sql/item_buff.cc: Changed Cached_item_field not copy data for fields with NULL value (Optimization and avoids valgrind warnings) sql/item_func.cc: c_ptr() -> c_ptr_safe() sql/key.cc: In key_copy() and key_restore() don't copy data for fields with NULL value sql/opt_range.cc: c_ptr() -> c_ptr_safe() sql/sql_base.cc: Added TRASH() to table->record[0] to find out if we access not initialzed data. Initialize null_bytes to: - Get consistent tests - Ensure we don't get valgrind warnings for null fields (as we may only update a couple of bits in a byte) sql/sql_class.cc: Removed "QQ" from comments sql/sql_insert.cc: Initialize row to default values if we are using valgrind and row will be copied verbatim to disk in storage engine. sql/sql_load.cc: QQ -> TODO sql/sql_parse.cc: Removed old not used code marked QQ and withing "#ifdef REMOVED" sql/sql_select.cc: QQ -> TODO Initialize some variables that was used uninitialized Added DBUG_ASSERT() to find out if thd was not properly initialized for sub queries sql/sql_test.cc: Fixed format for printing to DBUG file Fixed wrong alias used (from previous patch) sql/sql_trigger.h: QQ -> TODO sql/table.cc: QQ -> TODO storage/maria/ha_maria.cc: Mark table with HA_RECORD_MUST_BE_CLEAN_ON_WRITE, if row is written verbatim to disk and contains varchar or null fields. storage/maria/ma_open.c: Added flags if table has varchar or null fields storage/maria/maria_def.h: Added flags if table has varchar or null fields storage/myisam/ha_myisam.cc: Mark table with HA_RECORD_MUST_BE_CLEAN_ON_WRITE, if row is written verbatim to disk and contains varchar or null fields. storage/myisam/mi_open.c: Fixed memory overrun bug when using fulltext keys storage/xtradb/row/row0sel.c: Removed initialization of null bits. (not needed anymore) --- storage/maria/ha_maria.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 6463b25e440..b95a6766878 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1036,6 +1036,16 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked) if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) int_table_flags |= HA_HAS_NEW_CHECKSUM; + /* + For static size rows, tell MariaDB that we will access all bytes + in the record when writing it. This signals MariaDB to initalize + the full row to ensure we don't get any errors from valgrind and + that all bytes in the row is properly reset. + */ + if (file->s->data_file_type == STATIC_RECORD && + (file->s->has_varchar_fields | file->s->has_null_fields)) + int_table_flags|= HA_RECORD_MUST_BE_CLEAN_ON_WRITE; + for (i= 0; i < table->s->keys; i++) { plugin_ref parser= table->key_info[i].parser; -- cgit v1.2.1 From fda18d8fa26d10dee034756b276fe4f46f477f3a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 27 Dec 2010 10:53:02 +0100 Subject: lpbug#665028 SHOW STORAGE ENGINES shows incorrect Transaction support for Aria don't fill in handlerton::commit member, as it's not used and makes MySQL believe that Aria is transactional. Fix the TRANSACTIONAL=1 warning. --- storage/maria/ha_maria.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 306728edb64..256455d4531 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3302,6 +3302,9 @@ static int ha_maria_init(void *p) maria_hton->panic= maria_hton_panic; maria_hton->commit= maria_commit; maria_hton->rollback= maria_rollback; +#ifdef MARIA_CANNOT_ROLLBACK + maria_hton->commit= 0; +#endif maria_hton->flush_logs= maria_flush_logs; maria_hton->show_status= maria_show_status; /* TODO: decide if we support Maria being used for log tables */ -- cgit v1.2.1 From 31a78529bc5c4431865eba06762e6cc66359f759 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 31 Dec 2010 10:39:14 +0100 Subject: virtual columns: * move a capability from a virtual handler method to table_flags() * rephrase error messages to avoid hard-coded English parts * admit in test cases that they need xtradb, not innodb mysql-test/suite/vcol/t/rpl_vcol.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_handler_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_keys_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_partition_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_select_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test: this test needs xtradb, it will fail with innodb mysql-test/suite/vcol/t/vcol_view_innodb.test: this test needs xtradb, it will fail with innodb sql/ha_partition.h: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS sql/handler.h: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS sql/share/errmsg.txt: no hard-coded english parts in the error messages (ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN) sql/sql_table.cc: no hard-coded english parts in the error messages sql/table.cc: * check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS * no "csv workaround" is needed * no hard-coded english parts in the error messages storage/maria/ha_maria.cc: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS storage/maria/ha_maria.h: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS storage/myisam/ha_myisam.cc: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS storage/myisam/ha_myisam.h: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS storage/xtradb/handler/ha_innodb.cc: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS storage/xtradb/handler/ha_innodb.h: check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS --- storage/maria/ha_maria.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 256455d4531..2b6e7c1b3a6 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -821,7 +821,7 @@ int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | HA_FILE_BASED | HA_CAN_GEOMETRY | CANNOT_ROLLBACK_FLAG | - HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS | + HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS | HA_CAN_VIRTUAL_COLUMNS | HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT), can_enable_indexes(1), bulk_insert_single_undo(BULK_INSERT_NONE) {} -- cgit v1.2.1 From 26f988594cc3d0224f4b391406b5390704df0248 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 7 Jan 2011 12:17:34 +0200 Subject: Aria fixes: - Don't delete pages without flushing that has had a tail or head information in pagecache_delete() This fixes a case where REPAIR could find old deleted rows. storage/maria/ha_maria.cc: Remove calls to depricated function ha_statistic_increment storage/maria/ma_blockrec.c: Don't delete pages without flushing that has had a tail or head information in pagecache_delete() storage/maria/ma_pagecache.c: Added possibility to mark pages to not be deleted by pagecache_delete() without beeing flushed. storage/maria/ma_pagecache.h: Added new prototype --- storage/maria/ha_maria.cc | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 2b6e7c1b3a6..dba930c1759 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1059,8 +1059,6 @@ int ha_maria::close(void) int ha_maria::write_row(uchar * buf) { - ha_statistic_increment(&SSV::ha_write_count); - /* If we have a timestamp column, update it to the current time */ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) table->timestamp_field->set_time(); @@ -2131,7 +2129,6 @@ bool ha_maria::is_crashed() const int ha_maria::update_row(const uchar * old_data, uchar * new_data) { CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONING("UPDATE in WRITE CONCURRENT"); - ha_statistic_increment(&SSV::ha_update_count); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) table->timestamp_field->set_time(); return maria_update(file, old_data, new_data); @@ -2141,7 +2138,6 @@ int ha_maria::update_row(const uchar * old_data, uchar * new_data) int ha_maria::delete_row(const uchar * buf) { CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONING("DELETE in WRITE CONCURRENT"); - ha_statistic_increment(&SSV::ha_delete_count); return maria_delete(file, buf); } @@ -2151,7 +2147,6 @@ int ha_maria::index_read_map(uchar * buf, const uchar * key, enum ha_rkey_function find_flag) { DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_key_count); int error= maria_rkey(file, buf, active_index, key, keypart_map, find_flag); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2162,7 +2157,6 @@ int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { - ha_statistic_increment(&SSV::ha_read_key_count); int error= maria_rkey(file, buf, index, key, keypart_map, find_flag); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2174,7 +2168,6 @@ int ha_maria::index_read_last_map(uchar * buf, const uchar * key, { DBUG_ENTER("ha_maria::index_read_last_map"); DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_key_count); int error= maria_rkey(file, buf, active_index, key, keypart_map, HA_READ_PREFIX_LAST); table->status= error ? STATUS_NOT_FOUND : 0; @@ -2185,7 +2178,6 @@ int ha_maria::index_read_last_map(uchar * buf, const uchar * key, int ha_maria::index_next(uchar * buf) { DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_next_count); int error= maria_rnext(file, buf, active_index); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2195,7 +2187,6 @@ int ha_maria::index_next(uchar * buf) int ha_maria::index_prev(uchar * buf) { DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_prev_count); int error= maria_rprev(file, buf, active_index); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2205,7 +2196,6 @@ int ha_maria::index_prev(uchar * buf) int ha_maria::index_first(uchar * buf) { DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_first_count); int error= maria_rfirst(file, buf, active_index); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2215,7 +2205,6 @@ int ha_maria::index_first(uchar * buf) int ha_maria::index_last(uchar * buf) { DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_last_count); int error= maria_rlast(file, buf, active_index); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2228,7 +2217,6 @@ int ha_maria::index_next_same(uchar * buf, { int error; DBUG_ASSERT(inited == INDEX); - ha_statistic_increment(&SSV::ha_read_next_count); /* TODO: Delete this loop in Maria 1.5 as versioning will ensure this never happens @@ -2260,7 +2248,6 @@ int ha_maria::rnd_end() int ha_maria::rnd_next(uchar *buf) { - ha_statistic_increment(&SSV::ha_read_rnd_next_count); int error= maria_scan(file, buf); table->status= error ? STATUS_NOT_FOUND : 0; return error; @@ -2282,7 +2269,6 @@ int ha_maria::restart_rnd_next(uchar *buf) int ha_maria::rnd_pos(uchar *buf, uchar *pos) { - ha_statistic_increment(&SSV::ha_read_rnd_count); int error= maria_rrnd(file, buf, my_get_ptr(pos, ref_length)); table->status= error ? STATUS_NOT_FOUND : 0; return error; -- cgit v1.2.1 From c0fc6d42ace74938c0d39907ddf8acfbeb4d247e Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 7 Jan 2011 17:58:12 +0200 Subject: Don't do DBUG_ASSERT for checksum errors when using REPAIR mysql_convert_table_format ignored --engine option. Fix that zerofill() doesn't write out wrong data to client if run with auto repair. Ensure that pagecache is properly flushed, even in case of errors. Handle checksum errors in BLOCK_RECORD format. scripts/mysql_convert_table_format.sh: Fixed that --engine option works storage/maria/ha_maria.cc: Fix that zerofill() doesn't write out wrong data to client if run with auto repair. storage/maria/ma_check.c: Set in_check_table when scanning table to not get DBUG_ASSERT for checksum error. Ensure that pagecache is properly flushed, even in case of errors. Handle checksum errors in BLOCK_RECORD format. storage/maria/ma_sort.c: Set in_check_table when scanning table to not get DBUG_ASSERT for checksum error. --- storage/maria/ha_maria.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 6852e84fc65..467b065513d 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2022,6 +2022,7 @@ bool ha_maria::check_and_repair(THD *thd) DBUG_ENTER("ha_maria::check_and_repair"); check_opt.init(); + check_opt.flags= T_MEDIUM | T_AUTO_REPAIR; error= 1; if ((file->s->state.changed & @@ -2042,7 +2043,6 @@ bool ha_maria::check_and_repair(THD *thd) DBUG_RETURN(error); error= 0; - check_opt.flags= T_MEDIUM | T_AUTO_REPAIR; // Don't use quick if deleted rows if (!file->state->del && (maria_recover_options & HA_RECOVER_QUICK)) check_opt.flags |= T_QUICK; -- cgit v1.2.1 From 713999a4fe628fb89b81de50a4e87c44273f2c33 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 12 Jan 2011 01:48:34 +0200 Subject: Allow one to decrease page-buffer-size down to 1M (from 128M) for maria_read_log Don't allow too low value of pagecache_buffer_size for mysqld storage/maria/ha_maria.cc: Don't allow too low value of pagecache_buffer_size (as it will stop mysqld from starting) storage/maria/maria_read_log.c: Allow one to decrease page-buffer-size down to 1M (from 128M) --- storage/maria/ha_maria.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 467b065513d..6a7d7cf50ea 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -191,7 +191,7 @@ static MYSQL_SYSVAR_ULONGLONG(pagecache_buffer_size, pagecache_buffer_size, "The size of the buffer used for index blocks for Maria tables. " "Increase this to get better index handling (for all reads and " "multiple writes) to as much as you can afford.", 0, 0, - KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, IO_SIZE); + KEY_CACHE_SIZE, 8192*16L, ~(ulong) 0, IO_SIZE); static MYSQL_SYSVAR_ULONG(pagecache_division_limit, pagecache_division_limit, PLUGIN_VAR_RQCMDARG, -- cgit v1.2.1 From ad78c24a20278f072017f3b0e397d01fc0ccec9f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 12 Jan 2011 15:00:10 +0300 Subject: BUG#665669: Result differences on query re-execution - Cause: handler::in_range_check_pushed_down was not reset when a command would call handler->idx_cond_push() without later calling handler->index_end(). - Fix: reset the variable in handler->reset(), too (like we do with other Index Condition Pushdown members). --- storage/maria/ha_maria.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 5ea8f1c9a40..7668caebd1c 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2456,6 +2456,7 @@ int ha_maria::reset(void) { pushed_idx_cond= NULL; pushed_idx_cond_keyno= MAX_KEY; + in_range_check_pushed_down= FALSE; ma_set_index_cond_func(file, NULL, 0); ds_mrr.dsmrr_close(); if (file->trn) -- cgit v1.2.1 From 418df96d51b54bb1b20344dcaaee547aeee3708e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 14 Jan 2011 12:03:41 +0100 Subject: use bulk insert and repair by sort for unique keys in Aria and MyISAM in create_internal_tmp_table_from_heap() (safe, as duplicates are impossible). This gives a HUGE speed boost! sql/opt_subselect.cc: Fixed problem with wrong recinfo in create_duplicate_weedout_tmp_tabl() Tagged the table with 'no_rows' so that when we create the table on disk, we only store the index data. This gave us a major speedup! sql/sql_select.cc: create_tmp_table_from_heap() now uses bulk_insert + repair_by_sort when creating Aria/MyISAM tables from HEAP tables. This gives a HUGE speed boost! storage/maria/ha_maria.cc: Extended bulk_insert() to recreate UNIQUE keys for internal temporary tables storage/maria/ma_open.c: Initialize m_info->lock.type properly for temporarly tables (needed for start_bulk_insert()) storage/maria/ma_write.c: Don't check uniques that are disabled storage/myisam/ha_myisam.cc: Extended bulk_insert() to recreate UNIQUE keys for internal temporary tables. --- storage/maria/ha_maria.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 7668caebd1c..9acabf29774 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1998,7 +1998,14 @@ void ha_maria::start_bulk_insert(ha_rows rows) @todo for a single-row INSERT SELECT, we will go into repair, which is more costly (flushes, syncs) than a row write. */ - maria_disable_non_unique_index(file, rows); + if (file->open_flags & HA_OPEN_INTERNAL_TABLE) + { + /* Internal table; If we get a duplicate something is very wrong */ + file->update|= HA_STATE_CHANGED; + maria_clear_all_keys_active(file->s->state.key_map); + } + else + maria_disable_non_unique_index(file, rows); if (share->now_transactional) { bulk_insert_single_undo= BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR; -- cgit v1.2.1 From 26565ae1d6bc02fac641abf2747da23bd1013976 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 24 Jan 2011 15:19:40 +0200 Subject: Aria issues: - Fix for LP#700623 "Aria recovery: ma_blockrec.c:3930: _ma_update_at_original_place: Assertion `block->org_bitmap_value == _ma_bitmap_get_page_bits(info, &info->s->bitmap, page)' failed" - Issue was that when deleting a tail page where all index entries where full, the page was marked wrongly in the bitmap. - If debug_assert_if_crashed_table is set, we now crash when we find Aria corrupted. - Write more information if we find something wrong with the bitmap. - Fixed that REPAIR also can fix wrong create_rename_lsn issues (a very unlikely event) - Define STATE_CRASHED_FLAGS as set of all CRASHED flags (to simplify code) storage/maria/ha_maria.cc: Mark the normal page cache (not the page cache for the logs) so that we can request extra debugging for it. Copy the value of debug_assert_if_crashed_table to maria_assert_if_crashed_table so that we can request a crash at exactly the point where we find Aria corrupted. Use STATE_CRASHED_FLAGS storage/maria/ma_bitmap.c: Made bits_to_txt extern so that we can use this in maria_chk Added extra information to the log files to be able to easier find bitmap failures in recovery. (When compiling with -DEXTRA_DEBUG_BITMAP) Added _ma_get_bitmap_description() to request a clear text description of the bitmap. Simplify _ma_check_bitmap_data(), as we know the bitmap pattern in the caller. storage/maria/ma_blockrec.c: In delete_head_or_tail(), fixed a bug where we sent wrong information to _ma_bitmap_set() if the directory was full for a page that should be freed. This fixed LP#700623 (failure in bitmap found during recovery) storage/maria/ma_blockrec.h: Added definitions for _ma_get_bitmap_description() and bits_to_txt storage/maria/ma_check.c: Simplify call to _ma_check_bitmap_data(). Write more information if we find something wrong with the bitmap. Moved getting clear text information about the bitmap to ma_bitmap.c::_ma_get_bitmap_description() storage/maria/ma_checkpoint.c: More asserts storage/maria/ma_create.c: Fix wrong create_rename_lsn during repair. (Create_rename_lsn can be too big if someone restores an old maria_log_file after an Aria file was created) storage/maria/ma_delete.c: Call _ma_set_fatal_error() in case of crashed file Remove not needed test of save_errno == HA_ERR_KEY_NOT_FOUND. (Handled by other code storage/maria/ma_extra.c: Call _ma_set_fatal_error() in case of crashed file Reset share->bitmap.changed_not_flushed to not cause new ASSERTS to trigger. Added _ma_file_callback_to_id() for writing share->id to log file in case of DEBUG logging. storage/maria/ma_init.c: Destroy also translog if it's readonly (as when called by maria_read_log -d) storage/maria/ma_key.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/ma_key_recover.c: STATE_CRASHED -> STATE_CRASHED_FLAGS storage/maria/ma_keycache.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/ma_locking.c: Call _ma_set_fatal_error() in case of crashed file. Added _ma_set_fatal_error() storage/maria/ma_open.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/ma_page.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/ma_pagecache.c: Added extra information to log file to simply debugging of bitmap errors. storage/maria/ma_pagecache.h: Added extra_debug flag to allow marking of row and index cache for extra logging (for debugging). storage/maria/ma_panic.c: Flush both data and index blocks in case of HA_PANIC_CLOSE Fixed wrong position of 'break'. (Not critical for MariaDB as MariaDB never uses this code) storage/maria/ma_recovery_util.c: Avoid writing extra not needed \n to DBUG log. storage/maria/ma_rkey.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/ma_search.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/ma_static.c: Define maria_assert_if_crashed_table storage/maria/ma_update.c: Call _ma_set_fatal_error() in case of crashed file. The new code also avoids a problem where we before would print the error twice. storage/maria/ma_write.c: Call _ma_set_fatal_error() in case of crashed file storage/maria/maria_chk.c: STATE_CRASHED -> STATE_CRASHED_FLAGS storage/maria/maria_def.h: Added STATE_CRASHED_PRINTED to avoid giving error message about crash twice. Added STATE_CRASHED_FLAGS to be able to easily detect and set all CRASHED related flags. Added prototypes for new functions. storage/myisam/mi_panic.c: Fixed wrong position of 'break'. (Not critical for MariaDB as MariaDB never uses this code) --- storage/maria/ha_maria.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 6a7d7cf50ea..580712b0d76 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1065,8 +1065,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) if (!maria_is_crashed(file) && (((param.testflag & T_CHECK_ONLY_CHANGED) && - !(share->state.changed & (STATE_CHANGED | STATE_CRASHED | - STATE_CRASHED_ON_REPAIR | + !(share->state.changed & (STATE_CHANGED | STATE_CRASHED_FLAGS | STATE_IN_REPAIR)) && share->state.open_count == 0) || ((param.testflag & T_FAST) && (share->state.open_count == @@ -1104,15 +1103,15 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) if (!error) { if ((share->state.changed & (STATE_CHANGED | - STATE_CRASHED_ON_REPAIR | STATE_IN_REPAIR | - STATE_CRASHED | STATE_NOT_ANALYZED)) || + STATE_CRASHED_FLAGS | + STATE_IN_REPAIR | STATE_NOT_ANALYZED)) || (param.testflag & T_STATISTICS) || maria_is_crashed(file)) { file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; pthread_mutex_lock(&share->intern_lock); DBUG_PRINT("info", ("Reseting crashed state")); - share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED | - STATE_CRASHED_ON_REPAIR | STATE_IN_REPAIR); + share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED_FLAGS | + STATE_IN_REPAIR); if (!(table->db_stat & HA_READ_ONLY)) error= maria_update_state_info(¶m, file, UPDATE_TIME | UPDATE_OPEN_COUNT | @@ -1544,8 +1543,8 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) if ((share->state.changed & STATE_CHANGED) || maria_is_crashed(file)) { DBUG_PRINT("info", ("Reseting crashed state")); - share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED | - STATE_CRASHED_ON_REPAIR | STATE_IN_REPAIR); + share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED_FLAGS | + STATE_IN_REPAIR); file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; } /* @@ -2025,8 +2024,7 @@ bool ha_maria::check_and_repair(THD *thd) check_opt.flags= T_MEDIUM | T_AUTO_REPAIR; error= 1; - if ((file->s->state.changed & - (STATE_CRASHED | STATE_CRASHED_ON_REPAIR | STATE_MOVED)) == + if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) == STATE_MOVED) { sql_print_information("Zerofilling moved table: '%s'", @@ -2077,7 +2075,7 @@ bool ha_maria::check_and_repair(THD *thd) bool ha_maria::is_crashed() const { - return (file->s->state.changed & (STATE_CRASHED | STATE_MOVED) || + return (file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED) || (my_disable_locking && file->s->state.open_count)); } @@ -3287,6 +3285,8 @@ static int ha_maria_init(void *p) ma_checkpoint_init(checkpoint_interval); maria_multi_threaded= maria_in_ha_maria= TRUE; maria_create_trn_hook= maria_create_trn_for_mysql; + maria_pagecache->extra_debug= 1; + maria_assert_if_crashed_table= debug_assert_if_crashed_table; #if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH) /* We can only test for sub paths if my_symlink.c is using realpath */ -- cgit v1.2.1 From 6db663d6141a6e0d3425f0e7e184c8b7922ba7c3 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 10 Feb 2011 20:33:51 +0200 Subject: Fixes for Aria storage engine: - Fixed bug lp:624099 ma_close.c:75: maria_close: Assertion `share->in_trans == 0' failed on UNLOCK TABLES - Fixed bug that caused table to be marked as not closed (crashed) during recovery testing. - Use maria_delete_table_files() instead of maria_delete_table() to delete tempoary tables (faster and safer) - Added checks to ensure that bitmap and internal mutex are always taken in right order. - For transactional tables, only mark the table as changed before page for table is to be written to disk (and thus the log is flushed). This speeds up things a bit and fixes a problem where open_count was incremented on disk but there was no log entry to fix it during recovery -> table was crashed. - Fixed a bug in repair() where table was not automaticly repaired. - Ensure that state->global_changed, share->changed and share->state.open_count are set and reset properly. - Added option --ignore-control-file to maria_chk to be able to run maria_chk even if the control file is locked. mysql-test/suite/maria/r/maria-recover.result: Test result changed as we now force checkpoint before copying table, which results in pagecache getting flushed and we have more rows to recover. mysql-test/suite/maria/r/maria.result: Added new tests mysql-test/suite/maria/t/maria-recover.test: Force checkpoint before copying table. This is needed as now the open-count is increased first when first page is flushed. mysql-test/suite/maria/t/maria.test: Added tests to verify fix for lp:624099 storage/maria/ha_maria.cc: Use table->in_use instead of current_thd (trivial optimization) Use maria_delete_table_files() instead of maria_delete_table() to delete tempoary tables (faster and safer) More DBUG_ASSERT() Reset locked tables count after locked tables have been moved to new transaction. This fixed lp:624099 storage/maria/ma_bitmap.c: Temporarly unlock bitmap mutex when calling _ma_mark_file_changed() and pagecache_delete_pages() to ensure right mutex lock order. Call _ma_bitmap_unpin_all() when bitmap->non_flusable is set to 0. This fixed a case when bitmap was not proparly unpinned. More comments Added DBUG_ASSERT() for detecting wrong share->bitmap usage storage/maria/ma_blockrec.c: More DBUG_ASSERT() Moved code around in _ma_apply_redo_insert_row_head_or_tail() to make things safer on error conditions. storage/maria/ma_check.c: Changed parameter for _ma_set_uuid() Corrected test for detecting if we lost many rows. This fixed some cases where auto-recovery failed. share->changed need to be set if state.open_count is changed. Removed setting of share->changed= 0 as called function sets it. storage/maria/ma_close.c: - Added code to properly decrement open_count and have it written by _ma_state_info_write() for transactional tables. (This is more correct and also saves us one extra write by _ma_decrement_open_count() at close. - Added DBUG_ASSERT() to detect if open_count is wrong at maria_close(). storage/maria/ma_delete.c: Updated argument to _ma_mark_file_changed() storage/maria/ma_delete_all.c: Updated argument to _ma_mark_file_changed() For transactional tables, call _ma_mark_file_changed() after log entry has been written (to allow recover to fix open_count) Reset more needed variables in _ma_reset_status() storage/maria/ma_delete_table.c: Moved deletion of Aria files to maria_delete_table_files(). Remove RAID usage (old not working code) storage/maria/ma_extra.c: Set share->changed=1 when state needs to be updated on disk. Don't reset share->changed after call to _ma_state_info_write() as this calls sets share->changed. Set share->state.open_count to 1 to force table to be auto repaired if drop fails. Set share->global_changed before call to _ma_flush_table_files() to ensure that we don't try to mark the table changed during flush. Added DBUG_ENTER storage/maria/ma_locking.c: Split _ma_mark_file_changed() into two functions to delay marking transactional tables as changed on disk until first disk write. Added argument to _ma_decrement_open_count() to tell if we should call ma_lock_database() or not. Don't decrement open count for transactional tables during _ma_decrement_open_count(). This will be done during close. Changed parameter for _ma_set_uuid() storage/maria/ma_open.c: Set share->open_count_not_zero_on_open if state.open_count is not zero. This is needed for DBUG_ASSERT() in maria_close() that is there to enforce that open_count is always 0 at close. This test doesn't however work for tables that had open_count != 0 already on disk (ie, crashed tables). Enforce right mutex order for share->intern_lock and share->bitmap.bitmap_lock Don't set share->changed to 0 if share->state.open_count != 0, as state needs to be be written at close storage/maria/ma_pagecache.c: Moved a bit of code in find_block() to avoid one if. More DBUG_ASSERT() (I left a comment in the code for Sanja to look at; The code probably works but we need to check if it's optimal) storage/maria/ma_pagecrc.c: For transactional tables, just before first write to disk, but after log is flushed, mark the file changed. This fixes some cases where recovery() did not detect that table was marked as changed and could thus not recover the marker. storage/maria/ma_recovery.c: Set share->changed when share->global_changed is set. storage/maria/ma_update.c: Updated parameter for _ma_mark_file_changed() storage/maria/ma_write.c: Updated parameter for _ma_mark_file_changed() storage/maria/maria_chk.c: Added option --ignore-control-file to be able to run maria_chk even if the control file is locked. storage/maria/maria_def.h: Updated function prototypes. Added open_count_not_zero_on_open to MARIA_SHARE. storage/myisam/ha_myisam.cc: current_thd -> table->in_use --- storage/maria/ha_maria.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 580712b0d76..8da234111b2 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1568,7 +1568,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) llstr(rows, llbuff), llstr(file->state->records, llbuff2)); /* Abort if warning was converted to error */ - if (current_thd->is_error()) + if (table->in_use->is_error()) error= 1; } } @@ -1803,7 +1803,7 @@ int ha_maria::enable_indexes(uint mode) } else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) { - THD *thd= current_thd; + THD *thd= table->in_use; HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); if (!¶m) return HA_ADMIN_INTERNAL_ERROR; @@ -1905,7 +1905,7 @@ int ha_maria::indexes_are_disabled(void) void ha_maria::start_bulk_insert(ha_rows rows) { DBUG_ENTER("ha_maria::start_bulk_insert"); - THD *thd= current_thd; + THD *thd= table->in_use; ulong size= min(thd->variables.read_buff_size, (ulong) (table->s->avg_row_length * rows)); MARIA_SHARE *share= file->s; @@ -2388,7 +2388,7 @@ int ha_maria::extra_opt(enum ha_extra_function operation, ulong cache_size) int ha_maria::delete_all_rows() { - THD *thd= current_thd; + THD *thd= table->in_use; (void) translog_log_debug_info(file->trn, LOGREC_DEBUG_INFO_QUERY, (uchar*) thd->query(), thd->query_length()); if (file->s->now_transactional && @@ -2418,8 +2418,9 @@ int ha_maria::delete_table(const char *name) void ha_maria::drop_table(const char *name) { + DBUG_ASSERT(file->s->temporary); (void) close(); - (void) maria_delete_table(name); + (void) maria_delete_table_files(name, 0); } @@ -2514,6 +2515,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) { DBUG_PRINT("info", ("locked_tables: %u", trnman_has_locked_tables(trn))); + DBUG_ASSERT(trnman_has_locked_tables(trn) > 0); if (trnman_has_locked_tables(trn) && !trnman_decrement_locked_tables(trn)) { @@ -2647,12 +2649,12 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) statement assuming they have a trn (see ha_maria::start_stmt()). */ trn= trnman_new_trn(& thd->transaction.wt); - /* This is just a commit, tables stay locked if they were: */ - trnman_reset_locked_tables(trn, locked_tables); THD_TRN= trn; if (unlikely(trn == NULL)) + { error= HA_ERR_OUT_OF_MEM; - + goto end; + } /* Move all locked tables to the new transaction We must do it here as otherwise file->thd and file->state may be @@ -2677,6 +2679,8 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) } } } + /* This is just a commit, tables stay locked if they were: */ + trnman_reset_locked_tables(trn, locked_tables); } end: DBUG_RETURN(error); @@ -2813,7 +2817,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ha_create_info->row_type != ROW_TYPE_PAGE && ha_create_info->row_type != ROW_TYPE_NOT_USED && ha_create_info->row_type != ROW_TYPE_DEFAULT) - push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_ILLEGAL_HA_CREATE_OPTION, "Row format set to PAGE because of TRANSACTIONAL=1 option"); -- cgit v1.2.1 From b12e3796dc70466eca5ef3f25d51234b32af5113 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 18 Feb 2011 17:43:59 +0200 Subject: Fix for lp:711565 "Index Condition Pushdown can make a thread hold MyISAM locks as well as be unKILLable for long time" - In Maria/MyISAM: Release/re-acquire locks to give queries that wait on them a chance to make progress - In Maria/MyISAM: Change from numeric constants to ICP_RES values. - In Maria: Do check index condition in maria_rprev() (was lost in the merge/backport?) - In Maria/MyISAM/XtraDB: Check if the query was killed, and return immediately if it was. Added new storage engine error: HA_ERR_ABORTED_BY_USER, for handler to signal that it detected a kill of the query and aborted Authors: Sergey Petrunia & Monty include/my_base.h: Added HA_ERR_ABORTED_BY_USER, for handler to signal that it detected a kill of the query and aborted include/my_handler.h: Added comment mysql-test/r/myisam_icp.result: Updated test mysql-test/t/myisam_icp.test: Drop used tables at start of test Added test case that can help with manual testing of killing index condition pushdown query. mysys/my_handler_errors.h: Text for new storage engine error sql/handler.cc: If engine got HA_ERR_ABORTED_BY_USER, send kill message. sql/multi_range_read.cc: Return error code storage/maria/ha_maria.cc: Added ma_killed_in_mariadb() to detect kill. Ensure that file->external_ref points to TABLE object. storage/maria/ma_extra.c: Dummy test-if-killed for standalone storage/maria/ma_key.c: If ma_check_index_cond() fails, set my_errno and info->cur_row.lastpos storage/maria/ma_rkey.c: Release/re-acquire locks to give queries that wait on them a chance to make progress Check if the query was killed, and return immediately if it was storage/maria/ma_rnext.c: Check if the query was killed, and return immediately if it was Added missing fast_ma_writeinfo(info) storage/maria/ma_rnext_same.c: Check if the query was killed, and return immediately if it was Added missing fast_ma_writeinfo(info) storage/maria/ma_rprev.c: Check if the query was killed, and return immediately if it was Added missing fast_ma_writeinfo(info) and ma_check_index_cond() storage/maria/ma_search.c: Give error message if we find a wrong key storage/maria/ma_static.c: Added pointer to test-if-killed function storage/maria/maria_def.h: New prototypes storage/myisam/ha_myisam.cc: Added mi_killed_in_mariadb() Ensure that file->external_ref points to TABLE object. storage/myisam/mi_extra.c: Dummy test-if-killed for standalone storage/myisam/mi_key.c: If ma_check_index_cond() fails, set my_errno and info->lastpos storage/myisam/mi_rkey.c: Ensure that info->lastpos= HA_OFFSET_ERROR in case of error Release/re-acquire locks to give queries that wait on them a chance to make progress Check if the query was killed, and return immediately if it was Reorder code to do less things in case of error. Added missing fast_mi_writeinfo() storage/myisam/mi_rnext.c: Check if the query was killed, and return immediately if it was Simplify old ICP code Added missing fast_ma_writeinfo(info) storage/myisam/mi_rnext_same.c: Check if the query was killed, and return immediately if it was Added missing fast_mi_writeinfo(info) storage/myisam/mi_rprev.c: Check if the query was killed, and return immediately if it was Simplify error handling of ICP Added missing fast_mi_writeinfo(info) storage/myisam/mi_search.c: Give error message if we find a wrong key storage/myisam/mi_static.c: Added pointer to test-if-killed function storage/myisam/myisamdef.h: New prototypes storage/xtradb/handler/ha_innodb.cc: Added DB_SEARCH_ABORTED_BY_USER and ha_innobase::is_thd_killed() Check if the query was killed, and return immediately if it was storage/xtradb/handler/ha_innodb.h: Added prototype storage/xtradb/include/db0err.h: Added DB_SEARCH_ABORTED_BY_USER storage/xtradb/include/row0mysql.h: Added possible ICP errors storage/xtradb/row/row0sel.c: Use ICP errors instead of constants. Detect if killed and return B_SEARCH_ABORTED_BY_USER --- storage/maria/ha_maria.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 9acabf29774..406def92808 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -758,7 +758,7 @@ void _ma_check_print_warning(HA_CHECK *param, const char *fmt, ...) static int maria_create_trn_for_mysql(MARIA_HA *info) { - THD *thd= (THD*) info->external_ptr; + THD *thd= ((TABLE*) info->external_ref)->in_use; TRN *trn= THD_TRN; DBUG_ENTER("maria_create_trn_for_mysql"); @@ -797,6 +797,11 @@ static int maria_create_trn_for_mysql(MARIA_HA *info) DBUG_RETURN(0); } +my_bool ma_killed_in_mariadb(MARIA_HA *info) +{ + return (((TABLE*) (info->external_ref))->in_use->killed != 0); +} + } /* extern "C" */ /** @@ -1013,6 +1018,8 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked) return (my_errno ? my_errno : -1); file->s->chst_invalidator= query_cache_invalidate_by_MyISAM_filename_ref; + /* Set external_ref, mainly for temporary tables */ + file->external_ref= (void*) table; // For ma_killed() if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE)) VOID(maria_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0)); @@ -2525,6 +2532,7 @@ void ha_maria::drop_table(const char *name) int ha_maria::external_lock(THD *thd, int lock_type) { DBUG_ENTER("ha_maria::external_lock"); + file->external_ref= (void*) table; // For ma_killed() /* We don't test now_transactional because it may vary between lock/unlock and thus confuse our reference counting. @@ -2543,8 +2551,6 @@ int ha_maria::external_lock(THD *thd, int lock_type) /* Transactional table */ if (lock_type != F_UNLCK) { - file->external_ptr= thd; // For maria_register_trn() - if (!file->s->lock_key_trees) // If we don't use versioning { /* @@ -3392,6 +3398,9 @@ static int ha_maria_init(void *p) #endif if (res) maria_hton= 0; + + ma_killed= ma_killed_in_mariadb; + return res ? HA_ERR_INITIALIZATION : 0; } -- cgit v1.2.1 From ff3da0f963b28d128005da8ca5d0c93a72d34b27 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 28 Feb 2011 12:48:50 +0200 Subject: Change TABLE->alias to String for less memory reallocation Changed some String.ptr() -> String.c_ptr() for String that are not guaranteed to end with \0 Removed some c_ptr() usage from parameters to functions that takes ptr & length Use preallocate buffers to avoid calling malloc() for most operations. sql/event_db_repository.cc: alias is now a String sql/event_scheduler.cc: c_ptr -> c_ptr_safe() to avoid warnings from valgrind. sql/events.cc: c_ptr -> c_ptr_safe() to avoid warnings from valgrind. c_ptr -> ptr() as function takes ptr & length sql/field.cc: alias is now a String sql/field.h: alias is now a String sql/ha_partition.cc: alias is now a String sql/handler.cc: alias is now a String ptr() -> c_ptr() as string is not guaranteed to be \0 terminated sql/item.cc: Store error parameter in separarte buffer to ensure correct error message sql/item_func.cc: ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated sql/item_sum.h: Use my_strtod() instead of my_atof() to not have to make string \0 terminated sql/lock.cc: alias is now a String sql/log.cc: c_ptr() -> ptr() as function takes ptr & length sql/log_event.cc: c_ptr_quick() -> ptr() as we only want to get the pointer to String buffer sql/opt_range.cc: ptr() -> c_ptr() as string is not guaranteed to be \0 terminated sql/opt_table_elimination.cc: alias is now a String sql/set_var.cc: ptr() -> c_ptr() as string is not guaranteed to be \0 terminated c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. c_ptr() -> ptr() as function takes ptr & length Simplify some code. sql/sp.cc: c_ptr() -> ptr() as function takes ptr & length sql/sp_rcontext.cc: alias is now a String sql/sql_base.cc: alias is now a String. Here we win a realloc() for most alias usage. sql/sql_class.cc: Use size descriptor for printf() to avoid accessing bytes outside of buffer sql/sql_insert.cc: Change allocation of TABLE as it's now contains a String _ptr() -> ptr() as function takes ptr & length sql/sql_load.cc: Use preallocate buffers to avoid calling malloc() for most operations. sql/sql_parse.cc: Use c_ptr_safe() to ensure string is \0 terminated. sql/sql_plugin.cc: c_ptr_quick() -> ptr() as function takes ptr & length sql/sql_select.cc: alias is now a String sql/sql_show.cc: alias is now a String sql/sql_string.h: Added move() function to change who owns the string (owner does the free) sql/sql_table.cc: alias is now a String c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. sql/sql_test.cc: c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. alias is now a String sql/sql_trigger.cc: c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. Use field->init() to setup pointers to alias. sql/sql_update.cc: alias is now a String sql/sql_view.cc: ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated sql/sql_yacc.yy: r() -> c_ptr() as string is not guaranteed to be \0 terminated sql/table.cc: alias is now a String sql/table.h: alias is now a String storage/federatedx/ha_federatedx.cc: Remove extra 1 byte alloc that is automaticly done by strmake() Ensure that error message ends with \0 storage/maria/ha_maria.cc: alias is now a String storage/myisam/ha_myisam.cc: alias is now a String --- storage/maria/ha_maria.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 67be01e2db9..4b4537f8312 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1093,7 +1093,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) param.thd= thd; param.op_name= "check"; param.db_name= table->s->db.str; - param.table_name= table->alias; + param.table_name= table->alias.c_ptr(); param.testflag= check_opt->flags | T_CHECK | T_SILENT; param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method); @@ -1192,7 +1192,7 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt) param.thd= thd; param.op_name= "analyze"; param.db_name= table->s->db.str; - param.table_name= table->alias; + param.table_name= table->alias.c_ptr(); param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS | T_DONT_CHECK_CHECKSUM); param.using_global_keycache= 1; @@ -1486,7 +1486,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) _ma_copy_nontrans_state_information(file); param->db_name= table->s->db.str; - param->table_name= table->alias; + param->table_name= table->alias.c_ptr(); param->tmpfile_createflag= O_RDWR | O_TRUNC; param->using_global_keycache= 1; param->thd= thd; -- cgit v1.2.1 From e6bd643c7573fcbf422635e7a7440260ed30c297 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 4 Mar 2011 12:06:03 +0300 Subject: MRR interface: change range_info's type from char* to range_id_t typedef. The goals are: - cleaner code - ability to change from using pointers to offsets at some point --- storage/maria/ha_maria.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 2cf981d5076..e29904897ba 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3633,7 +3633,7 @@ int ha_maria::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf); } -int ha_maria::multi_range_read_next(char **range_info) +int ha_maria::multi_range_read_next(range_id_t *range_info) { return ds_mrr.dsmrr_next(range_info); } -- cgit v1.2.1 From 997445bc8eb578355b41abc3f4e42f579f900043 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 2 Apr 2011 14:04:45 +0400 Subject: Make EXPLAIN better at displaying MRR/BKA: - "Using MRR" is no longer shown with range access. - Instead, both range and BKA accesses will show one of the following: = "Rowid-ordered scan" = "Key-ordered scan" = "Key-ordered Rowid-ordered scan" depending on whether DS-MRR implementation will do scan keys in order, rowids in order, or both. - The patch also introduces a way for other storage engines/MRR implementations to pass information to EXPLAIN output about the properties of employed MRR scans. --- storage/maria/ha_maria.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index e8a66a3265f..4c7e8ecce9f 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3665,6 +3665,11 @@ ha_rows ha_maria::multi_range_read_info(uint keyno, uint n_ranges, uint keys, return ds_mrr.dsmrr_info(keyno, n_ranges, keys, key_parts, bufsz, flags, cost); } +int ha_maria::multi_range_read_explain_info(uint mrr_mode, char *str, + size_t size) +{ + return ds_mrr.dsmrr_explain_info(mrr_mode, str, size); +} /* MyISAM MRR implementation ends */ -- cgit v1.2.1 From 6da8ac5f71a6501cb0fb1304ff144ec41b4d9389 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 28 Apr 2011 18:02:26 +0300 Subject: Added option "AND DISABLE CHECKPOINT" to "FLUSH TABLES WITH READ LOCK" This makes it possible to do safe multi volume snapshots as long as one snapshots the volume with the transaction logs last. include/mysql_com.h: Added REFRESH_CHECKPOINT mysql-test/r/flush.result: Added test of new FLUSH TABLES syntax + calls to checkpoint_status handler calls mysql-test/t/flush.test: Added test of new FLUSH TABLES syntax + calls to checkpoint_status handler calls sql/handler.cc: Added code to call checkpoint_state for all handlertons that supports it sql/handler.h: Added new checkpoint_state() handlerton call to temporarly disable checkpoints. sql/lex.h: Added CHECKPOINT keyword sql/sql_yacc.yy: Added support for FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT storage/maria/ha_maria.cc: Added handlerton call to disable checkpoints. storage/maria/ma_checkpoint.c: Don't do checkpoint if checkpoints are disabled. storage/maria/ma_static.c: Added maria_checkpoint_disabled storage/maria/maria_def.h: Added maria_checkpoint_disabled storage/xtradb/handler/ha_innodb.cc: Added handlerton call to disable checkpoints. storage/xtradb/include/log0log.h: Added option to log_checkpoint() to allow one to ignore not critical checkpoints during the time checkpoints are disabled. storage/xtradb/log/log0log.c: Added code to allow one to disable checkpoints during a FLUSH TABLES ... DISABLE CHECKPOINT This was done by adding a new argument to log_checkpoint() which tells us when the checkpoint is called by srv_master_thread (which are safe to ignore) storage/xtradb/srv/srv0srv.c: Tell log_checkpoint() that checkpoints from srv_master_thread() are safe to ignore (will just delay recovery time a bit). --- storage/maria/ha_maria.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 4c7e8ecce9f..7811ccca65a 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3167,6 +3167,14 @@ bool maria_flush_logs(handlerton *hton) } +int maria_checkpoint_state(handlerton *hton, bool disabled) +{ + maria_checkpoint_disabled= (my_bool) disabled; + return 0; +} + + + #define SHOW_MSG_LEN (FN_REFLEN + 20) /** @brief show status handler @@ -3355,6 +3363,7 @@ static int ha_maria_init(void *p) maria_hton->panic= maria_hton_panic; maria_hton->commit= maria_commit; maria_hton->rollback= maria_rollback; + maria_hton->checkpoint_state= maria_checkpoint_state; #ifdef MARIA_CANNOT_ROLLBACK maria_hton->commit= 0; #endif -- cgit v1.2.1 From 2721e912ba45f42f3ddf7c8366f6abbeef060833 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 28 Apr 2011 19:56:10 +0300 Subject: Added ALTER ONLINE TABLE, which will give an error if the change can't be done 'instantly' (without a table copy) mysql-test/r/alter_table_online.result: Test new feature mysql-test/t/alter_table_online.test: Test new feature sql/handler.cc: Added comment sql/lex.h: Added ONLINE keyword sql/mysql_priv.h: Added option to alter table to require online operation sql/share/errmsg.txt: Added error message if ONLINE can't be done sql/sql_lex.h: Added online option sql/sql_parse.cc: Added online option to mysql_alter_table() sql/sql_table.cc: Added test that gives error if table can't be done instantly when requsted to be online. Fixed wrong test if table includes a VARCHAR Fixed wrong (but unlikely) handling of error conditions in ALTER table sql/sql_yacc.yy: Added ALTER ONLINE TABLE syntax storage/maria/ha_maria.cc: Fixed bug where 'start_bulk_insert' used too small buffer if used with unknown number of rows --- storage/maria/ha_maria.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 7811ccca65a..1aadd3bdfa8 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1961,15 +1961,26 @@ void ha_maria::start_bulk_insert(ha_rows rows) { DBUG_ENTER("ha_maria::start_bulk_insert"); THD *thd= table->in_use; - ulong size= min(thd->variables.read_buff_size, - (ulong) (table->s->avg_row_length * rows)); MARIA_SHARE *share= file->s; - DBUG_PRINT("info", ("start_bulk_insert: rows %lu size %lu", - (ulong) rows, size)); + DBUG_PRINT("info", ("start_bulk_insert: rows %lu", (ulong) rows)); /* don't enable row cache if too few rows */ if (!rows || (rows > MARIA_MIN_ROWS_TO_USE_WRITE_CACHE)) + { + size_t size= thd->variables.read_buff_size; + if (rows) + { + if (file->state->records) + { + MARIA_INFO maria_info; + maria_status(file, &maria_info, HA_STATUS_NO_LOCK |HA_STATUS_VARIABLE); + set_if_smaller(size, maria_info.mean_reclength * rows); + } + else if (table->s->avg_row_length) + set_if_smaller(size, (size_t) (table->s->avg_row_length * rows)); + } maria_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &size); + } can_enable_indexes= (maria_is_all_keys_active(share->state.key_map, share->base.keys)); -- cgit v1.2.1 From 35352d4da67c9a81a48ad398ca5cdb9e3848d236 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 2 May 2011 13:25:53 +0300 Subject: mysql-test/suite/funcs_1/r/storedproc.result: Fixed test failure mysql-test/suite/funcs_1/t/storedproc.test: Fixed test failure (The error changed as syntax for alter changed with ALTER ONLINE) storage/maria/ha_maria.cc: fixed compiler warning --- storage/maria/ha_maria.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 1aadd3bdfa8..5d2b2ea42cb 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1967,7 +1967,7 @@ void ha_maria::start_bulk_insert(ha_rows rows) /* don't enable row cache if too few rows */ if (!rows || (rows > MARIA_MIN_ROWS_TO_USE_WRITE_CACHE)) { - size_t size= thd->variables.read_buff_size; + ulonglong size= thd->variables.read_buff_size, tmp; if (rows) { if (file->state->records) @@ -1979,7 +1979,8 @@ void ha_maria::start_bulk_insert(ha_rows rows) else if (table->s->avg_row_length) set_if_smaller(size, (size_t) (table->s->avg_row_length * rows)); } - maria_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &size); + tmp= (ulong) size; // Safe becasue of limits + maria_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &tmp); } can_enable_indexes= (maria_is_all_keys_active(share->state.key_map, -- cgit v1.2.1 From 9e3570ea6c0872bcb8a9e0c7de4216945d8d3523 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 9 Jun 2011 21:39:31 +0300 Subject: Removed depricated --maria-options from mysqld. --- storage/maria/ha_maria.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 42387459024..aa51163f693 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -29,7 +29,6 @@ #include "ha_maria.h" #include "trnman_public.h" #include "trnman.h" -#include "compat_aliases.h" C_MODE_START #include "maria_def.h" @@ -3369,7 +3368,6 @@ bool ha_maria::is_changed() const static int ha_maria_init(void *p) { int res; - copy_variable_aliases(); const char *log_dir= maria_data_root; maria_hton= (handlerton *)p; maria_hton->state= SHOW_OPTION_YES; @@ -3717,7 +3715,6 @@ struct st_mysql_storage_engine maria_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; maria_declare_plugin(aria) -compat_aliases, { MYSQL_STORAGE_ENGINE_PLUGIN, &maria_storage_engine, -- cgit v1.2.1 From e5403ec95a82002ff30b74fd8d556a1641426d31 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 Jun 2011 11:41:46 +0300 Subject: Fixed build failures with maria3.test and widows build mysql-test/suite/maria/t/maria3.test: Fix when compiling with safemalloc storage/maria/ha_maria.cc: Fix that MAX_FILE_SIZE is not limited on 32 bit machines. --- storage/maria/ha_maria.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index aa51163f693..47c3e994ebb 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -212,7 +212,8 @@ static MYSQL_SYSVAR_ULONGLONG(max_sort_file_size, maria_max_temp_length, PLUGIN_VAR_RQCMDARG, "Don't use the fast sort index method to created index if the " "temporary file would get bigger than this.", - 0, 0, MAX_FILE_SIZE & ~(1*MB-1), 0, MAX_FILE_SIZE, 1*MB); + 0, 0, MAX_FILE_SIZE & ~((ulonglong) (1*MB-1)), + 0, MAX_FILE_SIZE, 1*MB); static MYSQL_SYSVAR_ULONG(pagecache_age_threshold, pagecache_age_threshold, PLUGIN_VAR_RQCMDARG, -- cgit v1.2.1 From ba9a890f0c389a93925c8c21a30e64801f397f18 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 27 Jun 2011 19:07:24 +0300 Subject: New status variables: Rows_tmp_read, Handler_tmp_update and Handler_tmp_write Split status variable Rows_read to Rows_read and Rows_tmp_read so that one can see how much real data is read. Same was done with with Handler_update and Handler_write. Fixed bug in MEMORY tables where some variables was counted twice. Added new internal handler call 'ha_close()' to have one place to gather statistics. Fixed bug where thd->open_options was set to wrong value when doing admin_recreate_table() mysql-test/r/status.result: Updated test results and added new tests mysql-test/r/status_user.result: Udated test results mysql-test/t/status.test: Added new test for temporary table status variables sql/ha_partition.cc: Changed to call ha_close() instead of close() sql/handler.cc: Added internal_tmp_table variable for easy checking of temporary tables. Added new internal handler call 'ha_close()' to have one place to gather statistics. Gather statistics for internal temporary tables. sql/handler.h: Added handler variables internal_tmp_table, rows_tmp_read. Split function update_index_statistics() to two. Added ha_update_tmp_row() for faster tmp table handling with more statistics. sql/item_sum.cc: ha_write_row() -> ha_write_tmp_row() sql/multi_range_read.cc: close() -> ha_close() sql/mysqld.cc: New status variables: Rows_tmp_read, Handler_tmp_update and Handler_tmp_write sql/opt_range.cc: close() -> ha_close() sql/sql_base.cc: close() -> ha_close() sql/sql_class.cc: Added handling of rows_tmp_read sql/sql_class.h: Added new satistics variables. rows_read++ -> update_rows_read() to be able to correctly count reads to internal temp tables. Added handler::ha_update_tmp_row() sql/sql_connect.cc: Added comment sql/sql_expression_cache.cc: ha_write_row() -> ha_write_tmp_row() sql/sql_select.cc: close() -> ha_close() ha_update_row() -> ha_update_tmp_row() sql/sql_show.cc: ha_write_row() -> ha_write_tmp_row() sql/sql_table.cc: Fixed bug where thd->open_options was set to wrong value when doing admin_recreate_table() sql/sql_union.cc: ha_write_row() -> ha_write_tmp_row() sql/sql_update.cc: ha_write_row() -> ha_write_tmp_row() sql/table.cc: close() -> ha_close() storage/heap/ha_heap.cc: Removed double counting of statistic variables. close -> ha_close() to get tmp table statistics. storage/maria/ha_maria.cc: close -> ha_close() to get tmp table statistics. --- storage/maria/ha_maria.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 4963e6e7a04..57045ff2cd3 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2524,7 +2524,7 @@ int ha_maria::delete_table(const char *name) void ha_maria::drop_table(const char *name) { DBUG_ASSERT(file->s->temporary); - (void) close(); + (void) ha_close(); (void) maria_delete_table_files(name, 0); } -- cgit v1.2.1 From 5e876bd3003870afe4e3e2dae866bcb0954c2298 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 30 Jun 2011 00:37:12 +0300 Subject: Aria bug fixes and improvements: - Fixed performance bug in alter table with Aria; Aria didn't use disable keys + enable keys - Fixed wrong warning about 'Wrong CRC on datapage' from REPAIR TABLE with aria block tables. - Fixed bug in aria_chk that disabled performance counters. - Added --translog_buffer_size to maria_read_log. storage/maria/ha_maria.cc: Fixed performance bug in alter table with Aria; Aria didn't use disable keys + enable keys storage/maria/ma_bitmap.c: Added some DBUG_ASSERT()'s and made code more uniform storage/maria/ma_check.c: Fixed wrong warning about 'Wrong CRC on datapage' from REPAIR TABLE with aria block tables. storage/maria/ma_pagecache.c: Copy read pages to buffer even if there was an error (to be able to detect zero filled pages) storage/maria/maria_chk.c: Fixed bug in aria_chk that disabled performance counters. storage/maria/maria_read_log.c: Added option to set translog_buffer_size --- storage/maria/ha_maria.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index be8f4c4dde5..58264513da9 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1966,19 +1966,21 @@ void ha_maria::start_bulk_insert(ha_rows rows) we don't want to update the key statistics based of only a few rows. Index file rebuild requires an exclusive lock, so if versioning is on don't do it (see how ha_maria::store_lock() tries to predict repair). - We can repair index only if we have an exclusive (TL_WRITE) lock. To - see if table is empty, we shouldn't rely on the old records' count from - our transaction's start (if that old count is 0 but now there are - records in the table, we would wrongly destroy them). - So we need to look at share->state.state.records. - As a safety net for now, we don't remove the test of - file->state->records, because there is uncertainty on what will happen - during repair if the two states disagree. + We can repair index only if we have an exclusive (TL_WRITE) lock or + if this is inside an ALTER TABLE, in which case lock_type == TL_UNLOCK. + + To see if table is empty, we shouldn't rely on the old record + count from our transaction's start (if that old count is 0 but + now there are records in the table, we would wrongly destroy + them). So we need to look at share->state.state.records. As a + safety net for now, we don't remove the test of + file->state->records, because there is uncertainty on what will + happen during repair if the two states disagree. */ if ((file->state->records == 0) && (share->state.state.records == 0) && can_enable_indexes && (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES) && - (file->lock.type == TL_WRITE)) + (file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK)) { /** @todo for a single-row INSERT SELECT, we will go into repair, which -- cgit v1.2.1 From 3c78bfe7f1a1530daea83f5dae091bd654ea6d37 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 1 Jul 2011 15:08:30 +0300 Subject: Added progress reporting for alter table, LOAD DATA INFILE and for aria tables: check table, repair table, analyze table. - The client gets a progress report message that triggers a callback function if requested with mysql_options(MYSQL_PROGRESS_CALLBACK, function) - Added Progress field last to 'show processlist' - Stage, Max_stage and Progress field added to information_schema.progresslist - The 'mysql' client by defaults enables progress reports when the output is a tty. - Added progress_report_time time variable to configure how often progress reports is sent to client Added read only system variable 'in_transaction' which is 1 if we have executed a BEGIN statement. client/client_priv.h: Added OPT_REPORT_PROGRESS client/mysql.cc: Added option --progress-reports (on by default if not batch mode) Progress reports is written to stdout for long running commands include/Makefile.am: Added mysql/service_progress_report.h include/myisamchk.h: Added variables to be able to do progress reporting in Aria and later in MyISAM include/mysql.h: Added new mysql_options() parameter: MYSQL_PROGRESS_CALLBACK include/mysql.h.pp: Added new mysql_options() parameter: MYSQL_PROGRESS_CALLBACK include/mysql/plugin.h: Added functions for reporting progress. include/mysql/plugin_auth.h.pp: Added functions for reporting progress. include/mysql_com.h: Added CLIENT_PROGRESS mysql_real_connect() flag. include/sql_common.h: Added callback function for reporting progress mysql-test/r/old-mode.result: Ensure that SHOW PROGRESSLIST doesn't have the Progress column in old mode. mysql-test/suite/funcs_1/datadict/datadict_priv.inc: Added new column mysql-test/suite/funcs_1/datadict/processlist_priv.inc: Test all new PROCESSLIST columns mysql-test/suite/funcs_1/r/is_columns_is.result: Updated results mysql-test/suite/funcs_1/r/is_columns_is_embedded.result: Updated results mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result: Updated results mysql-test/suite/funcs_1/r/is_tables_is_embedded.result: Updated results mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result: Updated results mysql-test/suite/funcs_1/r/processlist_priv_ps.result: Updated results mysql-test/suite/funcs_1/r/processlist_val_no_prot.result: Updated results mysql-test/suite/funcs_1/r/processlist_val_ps.result: Updated results mysql-test/suite/pbxt/r/pbxt_locking.result: Updated results mysql-test/suite/pbxt/r/skip_name_resolve.result: Updated results mysql-test/t/old-mode.test: Ensure that SHOW PROGRESSLIST doesn't have the Progress column in old mode. plugin/handler_socket/handlersocket/Makefile.am: Added -lmysqlservices scripts/mytop.sh: Made 'State' field width dynamic. Added 'Progress' to process list display. sql-common/client.c: Added handling of progress messages. Removed check_license() function. sql/mysql_priv.h: Added opt_progress_report_time sql/mysqld.cc: Added progress_report_time time variable to configure how often progress reports is sent to client sql/protocol.cc: Added net_send_progress_packet() sql/protocol.h: New prototypes sql/set_var.cc: Added variables progress_report_time and in_transaction sql/sql_acl.cc: Safety fix: Made client_capabilities ulonglong sql/sql_class.cc: Added interface functions for progress reporting sql/sql_class.h: Added varibles in THD for progress reporting. Added CF_REPORT_PROGRESS sql/sql_load.cc: Added progress reporting for LOAD DATA INFILE sql/sql_parse.cc: Added CF_REPORT_PROGRESS for top level commands for which it's safe to send progress reports to client sql/sql_show.cc: Added Progress field last to 'show processlist' Stage, Max_stage and Progress field added to information_schema.progresslist sql/sql_table.cc: Added progress reporting for ALTER TABLE Added THD as argument to copy_data_between_tables() storage/maria/ha_maria.cc: Added progress reporting for check table, repair table, analyze table Fixed a bug in start_bulk_insert() that caused alter table to always run with all keys enabled. storage/maria/ma_check.c: Added progress reporting Remember old state before starting repair. This removes some warnings from optimize_table if create-with-sort fails. storage/maria/ma_check_standalone.h: Added dummy reporting function for standalone Aria programs. storage/maria/ma_sort.c: Added progress reporting storage/maria/maria_chk.c: Updated version storage/maria/maria_def.h: Added new prototypes tests/mysql_client_test.c: Added test case for progress reporting --- storage/maria/ha_maria.cc | 73 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 12 deletions(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 57045ff2cd3..88995980f3d 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -711,6 +711,34 @@ int _ma_killed_ptr(HA_CHECK *param) } +/* + Report progress to mysqld + + This is a bit more complex than what a normal progress report + function normally is. + + The reason is that this is called by enable_index/repair which + is one stage in ALTER TABLE and we can't use the external + stage/max_stage for this. + + thd_progress_init/thd_progress_next_stage is to be called by + high level commands like CHECK TABLE or REPAIR TABLE, not + by sub commands like enable_index(). + + In ma_check.c it's easier to work with stages than with a total + progress, so we use internal stage/max_stage here to keep the + code simple. +*/ + +void _ma_report_progress(HA_CHECK *param, ulonglong progress, + ulonglong max_progress) +{ + thd_progress_report((THD*)param->thd, + progress + max_progress * param->stage, + max_progress * param->max_stage); +} + + void _ma_check_print_error(HA_CHECK *param, const char *fmt, ...) { va_list args; @@ -1104,7 +1132,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) int error; HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); MARIA_SHARE *share= file->s; - const char *old_proc_info= thd_proc_info(thd, "Checking table"); + const char *old_proc_info; TRN *old_trn= file->trn; if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR; @@ -1132,12 +1160,18 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) return HA_ADMIN_ALREADY_DONE; maria_chk_init_for_check(¶m, file); + old_proc_info= thd_proc_info(thd, "Checking status"); + thd_progress_init(thd, 3); (void) maria_chk_status(¶m, file); // Not fatal error= maria_chk_size(¶m, file); if (!error) error|= maria_chk_del(¶m, file, param.testflag); + thd_proc_info(thd, "Checking keys"); + thd_progress_next_stage(thd); if (!error) error= maria_chk_key(¶m, file); + thd_proc_info(thd, "Checking data"); + thd_progress_next_stage(thd); if (!error) { if ((!(param.testflag & T_QUICK) && @@ -1188,6 +1222,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) /* Reset trn, that may have been set by repair */ _ma_set_trn_for_table(file, old_trn); thd_proc_info(thd, old_proc_info); + thd_progress_end(thd); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } @@ -1203,6 +1238,7 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt) int error= 0; HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); MARIA_SHARE *share= file->s; + const char *old_proc_info; if (!¶m) return HA_ADMIN_INTERNAL_ERROR; @@ -1220,6 +1256,8 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt) if (!(share->state.changed & STATE_NOT_ANALYZED)) return HA_ADMIN_ALREADY_DONE; + old_proc_info= thd_proc_info(thd, "Scanning"); + thd_progress_init(thd, 1); error= maria_chk_key(¶m, file); if (!error) { @@ -1229,6 +1267,8 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt) } else if (!maria_is_crashed(file) && !thd->killed) maria_mark_crashed(file); + thd_proc_info(thd, old_proc_info); + thd_progress_end(thd); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } @@ -1362,6 +1402,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) int error; HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param)); ha_rows start_records; + const char *old_proc_info; if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR; @@ -1375,6 +1416,8 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) param.sort_buffer_length= THDVAR(thd, sort_buffer_size); param.backup_time= check_opt->start_time; start_records= file->state->records; + old_proc_info= thd_proc_info(thd, "Checking table"); + thd_progress_init(thd, 1); while ((error= repair(thd, ¶m, 0)) && param.retry_repair) { param.retry_repair= 0; @@ -1410,6 +1453,8 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) llstr(start_records, llbuff2), table->s->path.str); } + thd_proc_info(thd, old_proc_info); + thd_progress_end(thd); return error; } @@ -1457,14 +1502,15 @@ int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt) param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE | T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX); param.sort_buffer_length= THDVAR(thd, sort_buffer_size); + thd_progress_init(thd, 1); if ((error= repair(thd, ¶m, 1)) && param.retry_repair) { sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying", my_errno, param.db_name, param.table_name); param.testflag &= ~T_REP_BY_SORT; - error= repair(thd, ¶m, 1); + error= repair(thd, ¶m, 0); } - + thd_progress_end(thd); return error; } @@ -1638,6 +1684,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) } pthread_mutex_unlock(&share->intern_lock); thd_proc_info(thd, old_proc_info); + thd_progress_end(thd); // Mark done if (!thd->locked_tables) maria_lock_database(file, F_UNLCK); @@ -1999,19 +2046,21 @@ void ha_maria::start_bulk_insert(ha_rows rows) we don't want to update the key statistics based of only a few rows. Index file rebuild requires an exclusive lock, so if versioning is on don't do it (see how ha_maria::store_lock() tries to predict repair). - We can repair index only if we have an exclusive (TL_WRITE) lock. To - see if table is empty, we shouldn't rely on the old records' count from - our transaction's start (if that old count is 0 but now there are - records in the table, we would wrongly destroy them). - So we need to look at share->state.state.records. - As a safety net for now, we don't remove the test of - file->state->records, because there is uncertainty on what will happen - during repair if the two states disagree. + We can repair index only if we have an exclusive (TL_WRITE) lock or + if this is inside an ALTER TABLE, in which case lock_type == TL_UNLOCK. + + To see if table is empty, we shouldn't rely on the old record + count from our transaction's start (if that old count is 0 but + now there are records in the table, we would wrongly destroy + them). So we need to look at share->state.state.records. As a + safety net for now, we don't remove the test of + file->state->records, because there is uncertainty on what will + happen during repair if the two states disagree. */ if ((file->state->records == 0) && (share->state.state.records == 0) && can_enable_indexes && (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES) && - (file->lock.type == TL_WRITE)) + (file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK)) { /** @todo for a single-row INSERT SELECT, we will go into repair, which -- cgit v1.2.1 From 2a9c86be268c8770d6309b4fde1c79116127d71d Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 14 Jul 2011 17:44:37 +0400 Subject: BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 - Make {ha_myisam,ha_maria}::index_read_idx_map check pushed index condition. - Address review feedback (added comments) --- storage/maria/ha_maria.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 88995980f3d..4609e9fba12 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2259,7 +2259,14 @@ int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { - int error= maria_rkey(file, buf, index, key, keypart_map, find_flag); + int error; + /* Use the pushed index condition if it matches the index we're scanning */ + if (index == pushed_idx_cond_keyno) + ma_set_index_cond_func(file, index_cond_func_maria, this); + + error= maria_rkey(file, buf, index, key, keypart_map, find_flag); + + ma_set_index_cond_func(file, NULL, 0); table->status= error ? STATUS_NOT_FOUND : 0; return error; } -- cgit v1.2.1 From 08fa757a738e554383f148c3aeadc4073854fb8a Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 15 Jul 2011 03:29:38 +0400 Subject: Valgrind fix for the previous cset: - {ha_myisam,ha_maria}::index_read_idx_map should also initialize end_range, because index condition function will attempt to check it. We initialize it like index_init() does. --- storage/maria/ha_maria.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 4609e9fba12..4ecdde7d28e 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2261,6 +2261,7 @@ int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key, { int error; /* Use the pushed index condition if it matches the index we're scanning */ + end_range= NULL; if (index == pushed_idx_cond_keyno) ma_set_index_cond_func(file, index_cond_func_maria, this); -- cgit v1.2.1 From b95d2778aa9d4abe5331f9e6f593fd05e1cb2de6 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 15 Aug 2011 16:39:53 +0300 Subject: Fixes bugs found by testcase for lp:815022 and lp:726374 "ma_blockrec.c:3000: write_block_record: Assertion `cur_block[1].page_count == 0' failed with a multi-index Aria workload" The issues was: - For some tables with a lot of not packed fields, we didn't allocate enough memory in head page which caused DBUG_ASSERT's - Removed wrong DBUG_ASSERT() - Fixed a problem with underflow() where it generates a key page where all keys didn't fit. - Max key length is now limited by block_size/3 (was block_size /2). This is required for underflow() to work with packed keys. mysql-test/lib/v1/mysql-test-run.pl: Remove --alignment=8 as this doesn't work on 64 bit systems mysql-test/suite/maria/r/small_blocksize.result: Test case for Aria bug mysql-test/suite/maria/t/small_blocksize-master.opt: Test case for Aria bug mysql-test/suite/maria/t/small_blocksize.test: Test case for Aria bug storage/maria/ha_maria.cc: Fixed comment storage/maria/ma_bitmap.c: Fixed wrong variable usage in find_where_to_split_row() where we allocated too little memory for head page. We did not take into account space for head extents (long VARCHAR) when trying to split row on head page. This caused us to allocate too little space from bitmap which lead to ASSERT failures later. storage/maria/ma_blockrec.c: Made some argument const (to ensure they was not accidently changed) Removed wrong DBUG_ASSERT() storage/maria/ma_blockrec.h: Removed not used variable storage/maria/ma_delete.c: Added my_afree() in case of error More comments and DBUG_ASSERT() for underflow() storage/maria/ma_open.c: Make keyinfo->underflow_block_length smaller for packed keys. This has to be done as for long packed keys, underflow() otherwise generates a key page where all keys didn't fit. storage/maria/ma_page.c: New DBUG_ASSERT() storage/maria/ma_write.c: Fixed comment storage/maria/maria_def.h: We have to have space for at least 3 keys on a key page. (Otherwise the underflow() code doesn't work for packed keys, even when we have an underflow() for an empty key page) --- storage/maria/ha_maria.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/maria/ha_maria.cc') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 58264513da9..33609afcb9b 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -874,7 +874,7 @@ double ha_maria::scan_time() } /* - We need to be able to store at least two keys on an index page as the + We need to be able to store at least 2 keys on an index page as the splitting algorithms depends on this. (With only one key on a page we also can't use any compression, which may make the index file much larger) -- cgit v1.2.1