summaryrefslogtreecommitdiff
path: root/sql/ha_myisam.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r--sql/ha_myisam.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index e9ef5b4ce12..4aae044148b 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -571,11 +571,12 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
}
if (!optimize ||
+ memcmp(file->state, & share->state.state, sizeof(MI_STATUS_INFO)) ||
((file->state->del || share->state.split != file->state->records) &&
(!(param.testflag & T_QUICK) ||
!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))
{
- ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?
+ ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?
((ulonglong) 1L << share->base.keys)-1 :
share->state.key_map);
uint testflag=param.testflag;
@@ -661,7 +662,15 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, 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)
{
@@ -674,9 +683,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;
@@ -694,6 +706,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))
{
@@ -962,7 +975,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;
}
@@ -1201,6 +1216,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];