cleanup of ha_myisam::deactivate_non_unique_index() and Co.
This commit is contained in:
parent
7c27065c3e
commit
a66fe8dcd5
@ -3966,10 +3966,11 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
|
|||||||
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows)
|
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows)
|
||||||
{
|
{
|
||||||
MYISAM_SHARE *share=info->s;
|
MYISAM_SHARE *share=info->s;
|
||||||
uint i;
|
|
||||||
if (!info->state->records) /* Don't do this if old rows */
|
|
||||||
{
|
|
||||||
MI_KEYDEF *key=share->keyinfo;
|
MI_KEYDEF *key=share->keyinfo;
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
DBUG_ASSERT(info->state->records == 0 &&
|
||||||
|
(!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES));
|
||||||
for (i=0 ; i < share->base.keys ; i++,key++)
|
for (i=0 ; i < share->base.keys ; i++,key++)
|
||||||
{
|
{
|
||||||
if (!(key->flag & (HA_NOSAME | HA_SPATIAL | HA_AUTO_KEY)) &&
|
if (!(key->flag & (HA_NOSAME | HA_SPATIAL | HA_AUTO_KEY)) &&
|
||||||
@ -3979,7 +3980,6 @@ void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows)
|
|||||||
info->update|= HA_STATE_CHANGED;
|
info->update|= HA_STATE_CHANGED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -916,8 +916,8 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows)
|
|||||||
DBUG_ENTER("_mi_init_bulk_insert");
|
DBUG_ENTER("_mi_init_bulk_insert");
|
||||||
DBUG_PRINT("enter",("cache_size: %lu", cache_size));
|
DBUG_PRINT("enter",("cache_size: %lu", cache_size));
|
||||||
|
|
||||||
if (info->bulk_insert || (rows && rows < MI_MIN_ROWS_TO_USE_BULK_INSERT))
|
DBUG_ASSERT(!info->bulk_insert &&
|
||||||
DBUG_RETURN(0);
|
(!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT));
|
||||||
|
|
||||||
for (i=total_keylength=num_keys=0 ; i < share->base.keys ; i++)
|
for (i=total_keylength=num_keys=0 ; i < share->base.keys ; i++)
|
||||||
{
|
{
|
||||||
|
@ -416,6 +416,7 @@ typedef struct st_mi_sort_param
|
|||||||
|
|
||||||
#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */
|
#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */
|
||||||
#define MI_MIN_ROWS_TO_USE_BULK_INSERT 100
|
#define MI_MIN_ROWS_TO_USE_BULK_INSERT 100
|
||||||
|
#define MI_MIN_ROWS_TO_DISABLE_INDEXES 100
|
||||||
|
|
||||||
/* The UNIQUE check is done with a hashed long key */
|
/* The UNIQUE check is done with a hashed long key */
|
||||||
|
|
||||||
|
@ -818,26 +818,19 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
|
|||||||
deactivate_non_unique_index()
|
deactivate_non_unique_index()
|
||||||
rows Rows to be inserted
|
rows Rows to be inserted
|
||||||
0 if we don't know
|
0 if we don't know
|
||||||
HA_POS_ERROR if we want to disable all keys
|
HA_POS_ERROR if we want to force disabling
|
||||||
|
and make it permanent (save on disk)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
||||||
{
|
{
|
||||||
MYISAM_SHARE* share = file->s;
|
MYISAM_SHARE* share = file->s;
|
||||||
bool do_warning=0;
|
|
||||||
if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
|
if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
|
||||||
{
|
{
|
||||||
if (!(specialflag & SPECIAL_SAFE_MODE))
|
if (!(specialflag & SPECIAL_SAFE_MODE))
|
||||||
{
|
{
|
||||||
if (rows == HA_POS_ERROR)
|
if (rows == HA_POS_ERROR) // force disable and save it on disk!
|
||||||
{
|
|
||||||
uint orig_update= file->update;
|
|
||||||
file->update ^= HA_STATE_CHANGED;
|
|
||||||
uint check_update= file->update;
|
|
||||||
mi_extra(file, HA_EXTRA_NO_KEYS, 0);
|
mi_extra(file, HA_EXTRA_NO_KEYS, 0);
|
||||||
do_warning= (file->update == check_update) && file->state->records;
|
|
||||||
file->update= orig_update;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -847,14 +840,15 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
|||||||
we don't want to update the key statistics based of only a few rows.
|
we don't want to update the key statistics based of only a few rows.
|
||||||
*/
|
*/
|
||||||
if (file->state->records == 0 &&
|
if (file->state->records == 0 &&
|
||||||
(!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
|
(!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
|
||||||
mi_disable_non_unique_index(file,rows);
|
mi_disable_non_unique_index(file,rows);
|
||||||
else
|
else
|
||||||
|
if (!file->bulk_insert &&
|
||||||
|
(!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
|
||||||
{
|
{
|
||||||
mi_init_bulk_insert(file,
|
mi_init_bulk_insert(file,
|
||||||
current_thd->variables.bulk_insert_buff_size,
|
current_thd->variables.bulk_insert_buff_size,
|
||||||
rows);
|
rows);
|
||||||
table->bulk_insert= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -863,10 +857,6 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
enable_activate_all_index=0;
|
enable_activate_all_index=0;
|
||||||
if (do_warning)
|
|
||||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
|
||||||
ER_ILLEGAL_HA,
|
|
||||||
ER(ER_ILLEGAL_HA), table->table_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -878,7 +868,6 @@ bool ha_myisam::activate_all_index(THD *thd)
|
|||||||
DBUG_ENTER("activate_all_index");
|
DBUG_ENTER("activate_all_index");
|
||||||
|
|
||||||
mi_end_bulk_insert(file);
|
mi_end_bulk_insert(file);
|
||||||
table->bulk_insert= 0;
|
|
||||||
if (enable_activate_all_index &&
|
if (enable_activate_all_index &&
|
||||||
share->state.key_map != set_bits(ulonglong, share->base.keys))
|
share->state.key_map != set_bits(ulonglong, share->base.keys))
|
||||||
{
|
{
|
||||||
@ -1393,7 +1382,7 @@ longlong ha_myisam::get_auto_increment()
|
|||||||
return auto_increment_value;
|
return auto_increment_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table->bulk_insert)
|
/* it's safe to call the following if bulk_insert isn't on */
|
||||||
mi_flush_bulk_insert(file, table->next_number_index);
|
mi_flush_bulk_insert(file, table->next_number_index);
|
||||||
|
|
||||||
longlong nr;
|
longlong nr;
|
||||||
|
@ -280,7 +280,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||||||
table->next_number_field=table->found_next_number_field;
|
table->next_number_field=table->found_next_number_field;
|
||||||
VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
|
VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
|
||||||
thd->variables.read_buff_size));
|
thd->variables.read_buff_size));
|
||||||
table->bulk_insert= 1;
|
|
||||||
if (handle_duplicates == DUP_IGNORE ||
|
if (handle_duplicates == DUP_IGNORE ||
|
||||||
handle_duplicates == DUP_REPLACE)
|
handle_duplicates == DUP_REPLACE)
|
||||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||||
|
@ -109,7 +109,7 @@ struct st_table {
|
|||||||
my_bool maybe_null,outer_join; /* Used with OUTER JOIN */
|
my_bool maybe_null,outer_join; /* Used with OUTER JOIN */
|
||||||
my_bool force_index;
|
my_bool force_index;
|
||||||
my_bool distinct,const_table,no_rows;
|
my_bool distinct,const_table,no_rows;
|
||||||
my_bool key_read, bulk_insert;
|
my_bool key_read;
|
||||||
my_bool crypted;
|
my_bool crypted;
|
||||||
my_bool db_low_byte_first; /* Portable row format */
|
my_bool db_low_byte_first; /* Portable row format */
|
||||||
my_bool locked_by_flush;
|
my_bool locked_by_flush;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user