mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
bzr merge -r4209 maria/10.0.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2013, Monty Program Ab.
|
||||
Copyright (c) 2000, 2014, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2014, Monty Program Ab.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -6113,6 +6113,9 @@ static bool fill_alter_inplace_info(THD *thd,
|
||||
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_REMOVE_PARTITIONING;
|
||||
if (alter_info->flags & Alter_info::ALTER_ALL_PARTITION)
|
||||
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_ALL_PARTITION;
|
||||
/* Check for: ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE. */
|
||||
if (alter_info->flags & Alter_info::ALTER_RECREATE)
|
||||
ha_alter_info->handler_flags|= Alter_inplace_info::RECREATE_TABLE;
|
||||
|
||||
/*
|
||||
If we altering table with old VARCHAR fields we will be automatically
|
||||
@@ -6796,12 +6799,8 @@ static bool is_inplace_alter_impossible(TABLE *table,
|
||||
if (table->s->tmp_table)
|
||||
DBUG_RETURN(true);
|
||||
|
||||
|
||||
/*
|
||||
We also test if OPTIMIZE TABLE was given and was mapped to alter table.
|
||||
In that case we always do full copy (ALTER_RECREATE is set in this case).
|
||||
|
||||
For the ALTER TABLE tbl_name ORDER BY ... we also always use copy
|
||||
For the ALTER TABLE tbl_name ORDER BY ... we always use copy
|
||||
algorithm. In theory, this operation can be done in-place by some
|
||||
engine, but since a) no current engine does this and b) our current
|
||||
API lacks infrastructure for passing information about table ordering
|
||||
@@ -6811,26 +6810,17 @@ static bool is_inplace_alter_impossible(TABLE *table,
|
||||
not supported for in-place in combination with other operations.
|
||||
Alone, it will be done by simple_rename_or_index_change().
|
||||
*/
|
||||
if (alter_info->flags & (Alter_info::ALTER_RECREATE |
|
||||
Alter_info::ALTER_ORDER |
|
||||
if (alter_info->flags & (Alter_info::ALTER_ORDER |
|
||||
Alter_info::ALTER_KEYS_ONOFF))
|
||||
DBUG_RETURN(true);
|
||||
|
||||
/*
|
||||
Test also that engine was not given during ALTER TABLE, or
|
||||
we are force to run regular alter table (copy).
|
||||
E.g. ALTER TABLE tbl_name ENGINE=MyISAM.
|
||||
Note that in addition to checking flag in HA_CREATE_INFO we
|
||||
also check HA_CREATE_INFO::db_type value. This is done
|
||||
to cover cases in which engine is changed implicitly
|
||||
(e.g. when non-partitioned table becomes partitioned).
|
||||
|
||||
Note that we do copy even if the table is already using the
|
||||
given engine. Many users and tools depend on using ENGINE
|
||||
to force a table rebuild.
|
||||
If the table engine is changed explicitly (using ENGINE clause)
|
||||
or implicitly (e.g. when non-partitioned table becomes
|
||||
partitioned) a regular alter table (copy) needs to be
|
||||
performed.
|
||||
*/
|
||||
if (create_info->db_type != table->s->db_type() ||
|
||||
create_info->used_fields & HA_CREATE_USED_ENGINE)
|
||||
if (create_info->db_type != table->s->db_type())
|
||||
DBUG_RETURN(true);
|
||||
|
||||
/*
|
||||
@@ -7301,6 +7291,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
||||
if (!(used_fields & HA_CREATE_USED_TRANSACTIONAL))
|
||||
create_info->transactional= table->s->transactional;
|
||||
|
||||
if (!(used_fields & HA_CREATE_USED_CONNECTION))
|
||||
create_info->connect_string= table->s->connect_string;
|
||||
|
||||
restore_record(table, s->default_values); // Empty record for DEFAULT
|
||||
|
||||
if ((create_info->fields_option_struct= (ha_field_option_struct**)
|
||||
@@ -8567,6 +8560,15 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
alter_info->requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY;
|
||||
}
|
||||
|
||||
/*
|
||||
ALTER TABLE ... ENGINE to the same engine is a common way to
|
||||
request table rebuild. Set ALTER_RECREATE flag to force table
|
||||
rebuild.
|
||||
*/
|
||||
if (create_info->db_type == table->s->db_type() &&
|
||||
create_info->used_fields & HA_CREATE_USED_ENGINE)
|
||||
alter_info->flags|= Alter_info::ALTER_RECREATE;
|
||||
|
||||
/*
|
||||
If the old table had partitions and we are doing ALTER TABLE ...
|
||||
engine= <new_engine>, the new table must preserve the original
|
||||
@@ -9535,12 +9537,14 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
mysql_recreate_table()
|
||||
thd Thread handler
|
||||
tables Tables to recreate
|
||||
table_copy Recreate the table by using
|
||||
ALTER TABLE COPY algorithm
|
||||
|
||||
RETURN
|
||||
Like mysql_alter_table().
|
||||
*/
|
||||
|
||||
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list)
|
||||
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy)
|
||||
{
|
||||
HA_CREATE_INFO create_info;
|
||||
Alter_info alter_info;
|
||||
@@ -9558,6 +9562,10 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list)
|
||||
/* Force alter table to recreate table */
|
||||
alter_info.flags= (Alter_info::ALTER_CHANGE_COLUMN |
|
||||
Alter_info::ALTER_RECREATE);
|
||||
|
||||
if (table_copy)
|
||||
alter_info.requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY;
|
||||
|
||||
DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info,
|
||||
table_list, &alter_info, 0,
|
||||
(ORDER *) 0, 0));
|
||||
|
Reference in New Issue
Block a user