diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_isam.cc | 4 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 24 | ||||
-rw-r--r-- | sql/lock.cc | 42 | ||||
-rw-r--r-- | sql/log_event.cc | 8 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 | ||||
-rw-r--r-- | sql/sql_insert.cc | 2 | ||||
-rw-r--r-- | sql/sql_load.cc | 3 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/table.h | 2 |
9 files changed, 76 insertions, 15 deletions
diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc index 55d24f5edb9..052e6a4b9ec 100644 --- a/sql/ha_isam.cc +++ b/sql/ha_isam.cc @@ -244,7 +244,9 @@ int ha_isam::reset(void) int ha_isam::external_lock(THD *thd, int lock_type) { - return nisam_lock_database(file,lock_type); + if (!table->tmp_table) + return nisam_lock_database(file,lock_type); + return 0; } diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index bae455cbb3c..f96ef7210ac 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -657,7 +657,15 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) } -/* Deactive all not unique index that can be recreated fast */ +/* + Deactive all not unique index that can be recreated fast + + SYNOPSIS + deactivate_non_unique_index() + rows Rows to be inserted + 0 if we don't know + HA_POS_ERROR if we want to disable all keys +*/ void ha_myisam::deactivate_non_unique_index(ha_rows rows) { @@ -670,9 +678,12 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows) mi_extra(file, HA_EXTRA_NO_KEYS, 0); else { - mi_disable_non_unique_index(file,rows); + /* Only disable old index if the table was empty */ + if (file->state->records == 0) + mi_disable_non_unique_index(file,rows); ha_myisam::extra_opt(HA_EXTRA_BULK_INSERT_BEGIN, current_thd->variables.bulk_insert_buff_size); + table->bulk_insert= 1; } } enable_activate_all_index=1; @@ -690,6 +701,7 @@ bool ha_myisam::activate_all_index(THD *thd) DBUG_ENTER("activate_all_index"); mi_extra(file, HA_EXTRA_BULK_INSERT_END, 0); + table->bulk_insert= 0; if (enable_activate_all_index && share->state.key_map != set_bits(ulonglong, share->base.keys)) { @@ -958,7 +970,9 @@ int ha_myisam::delete_table(const char *name) int ha_myisam::external_lock(THD *thd, int lock_type) { - return mi_lock_database(file,lock_type); + if (!table->tmp_table) + return mi_lock_database(file,lock_type); + return 0; } @@ -1194,6 +1208,10 @@ longlong ha_myisam::get_auto_increment() return auto_increment_value; } + if (table->bulk_insert) + mi_extra(file, HA_EXTRA_BULK_INSERT_FLUSH, + (void*) &table->next_number_index); + longlong nr; int error; byte key[MI_MAX_KEY_LENGTH]; diff --git a/sql/lock.cc b/sql/lock.cc index 056ed0fec8f..ea627207e42 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -21,6 +21,46 @@ before getting internal locks. If we do it in the other order, the status information is not up to date when called from the lock handler. + GENERAL DESCRIPTION OF LOCKING + + When not using LOCK TABLES: + + - For each SQL statement mysql_lock_tables() is called for all involved + tables. + - mysql_lock_tables() will call + table_handler->external_lock(thd,locktype) for each table. + This is followed by a call to thr_multi_lock() for all tables. + + - When statement is done, we call mysql_unlock_tables(). + This will call thr_multi_unlock() followed by + table_handler->external_lock(thd, F_UNLCK) for each table. + + - Note that mysql_unlock_tables() may be called several times as + MySQL in some cases can free some tables earlier than others. + + - The above is true both for normal and temporary tables. + + - Temporary non transactional tables are never passed to thr_multi_lock() + and we never call external_lock(thd, F_UNLOCK) on these. + + When using LOCK TABLES: + + - LOCK TABLE will call mysql_lock_tables() for all tables. + mysql_lock_tables() will call + table_handler->external_lock(thd,locktype) for each table. + This is followed by a call to thr_multi_lock() for all tables. + + - For each statement, we will call table_handler->start_stmt(THD) + to inform the table handler that we are using the table. + + The tables used can only be tables used in LOCK TABLES or a + temporary table. + + - When statement is done, we will call ha_commit_stmt(thd); + + - When calling UNLOCK TABLES we call mysql_unlock_tables() for all + tables used in LOCK TABLES + TODO: Change to use my_malloc() ONLY when using LOCK TABLES command or when we are forced to use mysql_lock_merge. @@ -206,7 +246,7 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock) sql_lock->lock_count= found; } - /* Then to the same for the external locks */ + /* Then do the same for the external locks */ /* Move all write locked tables first */ TABLE **table=sql_lock->table; for (i=found=0 ; i < sql_lock->table_count ; i++) diff --git a/sql/log_event.cc b/sql/log_event.cc index ec5b7c4b5a5..2d634618e2d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -744,10 +744,10 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len, ident_offset = ROTATE_HEADER_LEN; } set_if_smaller(ident_len,FN_REFLEN-1); - if (!(new_log_ident= (char*) my_strdup_with_length((byte*) buf + - ident_offset, - (uint) ident_len, - MYF(MY_WME)))) + if (!(new_log_ident= my_strdup_with_length((byte*) buf + + ident_offset, + (uint) ident_len, + MYF(MY_WME)))) return; alloced = 1; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 94d9efa9108..fa189ac24df 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3477,7 +3477,7 @@ struct my_option my_long_options[] = "Max packetlength to send/receive from to server.", (gptr*) &global_system_variables.max_allowed_packet, (gptr*) &max_system_variables.max_allowed_packet, 0, GET_ULONG, - REQUIRED_ARG, 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, + REQUIRED_ARG, 1024*1024L, 80, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, "Can be used to restrict the total size used to cache a multi-transaction query.", (gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0, diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9b6e6a549c9..de2e15cd29d 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -202,6 +202,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields, thd->variables.read_buff_size); table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN, thd->variables.bulk_insert_buff_size); + table->bulk_insert= 1; } while ((values= its++)) @@ -290,6 +291,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields, error=1; } } + table->bulk_insert= 0; } if (id && values_list.elements != 1) thd->insert_id(id); // For update log diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 50e0ea9d5c8..8881c79eba4 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -248,8 +248,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, table->next_number_field=table->found_next_number_field; VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE, thd->variables.read_buff_size)); - VOID(table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN, - thd->variables.bulk_insert_buff_size)); + table->bulk_insert= 1; if (handle_duplicates == DUP_IGNORE || handle_duplicates == DUP_REPLACE) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index cf03288860f..94d4ae5cc5b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -18,10 +18,10 @@ /* drop and alter of tables */ #include "mysql_priv.h" -#include <hash.h> #ifdef HAVE_BERKELEY_DB -#include <ha_berkeley.h> +#include "ha_berkeley.h" #endif +#include <hash.h> #include <myisam.h> #include <assert.h> diff --git a/sql/table.h b/sql/table.h index 229d41a2df7..2c9a1b2c16a 100644 --- a/sql/table.h +++ b/sql/table.h @@ -91,7 +91,7 @@ struct st_table { my_bool null_row; /* All columns are null */ my_bool maybe_null,outer_join; /* Used with OUTER JOIN */ my_bool distinct,const_table,no_rows; - my_bool key_read; + my_bool key_read, bulk_insert; my_bool crypted; my_bool db_low_byte_first; /* Portable row format */ my_bool locked_by_flush; |