summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/alter_table_online.result59
-rw-r--r--mysql-test/t/alter_table_online.test33
-rw-r--r--sql/ha_partition.cc23
-rw-r--r--sql/ha_partition.h2
-rw-r--r--sql/handler.cc62
-rw-r--r--sql/handler.h340
-rw-r--r--sql/sql_admin.cc8
-rw-r--r--sql/sql_alter.cc7
-rw-r--r--sql/sql_alter.h77
-rw-r--r--sql/sql_lex.cc4
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_partition.cc66
-rw-r--r--sql/sql_partition_admin.cc16
-rw-r--r--sql/sql_table.cc256
-rw-r--r--sql/sql_yacc.yy103
-rw-r--r--sql/sql_yacc_ora.yy87
-rw-r--r--storage/connect/ha_connect.cc34
-rw-r--r--storage/example/ha_example.cc4
-rw-r--r--storage/innobase/handler/handler0alter.cc226
-rw-r--r--storage/mroonga/ha_mroonga.cpp88
-rw-r--r--storage/mroonga/ha_mroonga.hpp12
-rw-r--r--storage/mroonga/mrn_mysql_compat.h6
-rw-r--r--storage/mroonga/mrn_table.hpp2
-rw-r--r--storage/myisam/ha_myisam.cc26
-rw-r--r--storage/rocksdb/ha_rocksdb.cc34
-rw-r--r--storage/spider/ha_spider.cc6
-rw-r--r--storage/spider/spd_include.h12
-rw-r--r--storage/tokudb/ha_tokudb_alter_56.cc94
28 files changed, 842 insertions, 847 deletions
diff --git a/mysql-test/r/alter_table_online.result b/mysql-test/r/alter_table_online.result
index 54df4e0c96c..d5a2a028acc 100644
--- a/mysql-test/r/alter_table_online.result
+++ b/mysql-test/r/alter_table_online.result
@@ -1,22 +1,61 @@
-create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
+create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')) engine=myisam;
insert into t1 (a) values (1),(2),(3);
-alter online table t1 modify b int default 5;
+alter online table t1 modify b int default 5, alter c set default 'X';
alter online table t1 change b new_name int;
alter online table t1 modify e enum('a','b','c');
alter online table t1 comment "new comment";
+alter table t1 add constraint q check (a > 0);
+alter online table t1 drop constraint q;
alter online table t1 algorithm=INPLACE, lock=NONE;
alter online table t1;
alter table t1 algorithm=INPLACE;
alter table t1 lock=NONE;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `new_name` int(11) DEFAULT NULL,
+ `c` varchar(80) DEFAULT 'X',
+ `e` enum('a','b','c') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='new comment'
drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);
-alter online table t1 modify b int default 5;
+alter online table t1 modify b int default 5, alter c set default 'X';
alter online table t1 change b new_name int;
alter online table t1 modify e enum('a','b','c');
alter online table t1 comment "new comment";
alter online table t1 rename to t2;
+show create table t2;
+Table Create Table
+t2 CREATE TEMPORARY TABLE `t2` (
+ `a` int(11) NOT NULL,
+ `new_name` int(11) DEFAULT NULL,
+ `c` varchar(80) DEFAULT 'X',
+ `e` enum('a','b','c') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='new comment'
drop table t2;
+create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')) engine=aria;
+insert into t1 (a) values (1),(2),(3);
+alter online table t1 modify b int default 5;
+alter online table t1 change b new_name int;
+alter online table t1 modify e enum('a','b','c');
+alter online table t1 comment "new comment";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `new_name` int(11) DEFAULT NULL,
+ `c` varchar(80) DEFAULT NULL,
+ `e` enum('a','b','c') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 COMMENT='new comment'
+alter online table t1 page_checksum=1;
+alter online table t1 page_checksum=0;
+ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=SHARED
+drop table t1;
create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);
alter online table t1 drop column b, add b int;
@@ -35,11 +74,25 @@ alter online table t1 engine=memory;
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
alter online table t1 rename to t2;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE
+alter online table t1 checksum=1;
+ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=SHARED
+alter online table t1 add constraint check (b > 0);
+ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=SHARED
alter table t1 engine=innodb;
alter table t1 add index (b);
alter online table t1 add index c (c);
alter online table t1 drop index b;
alter online table t1 comment "new comment";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` varchar(80) DEFAULT NULL,
+ `e` enum('a','b') DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `c` (`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='new comment'
drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);
diff --git a/mysql-test/t/alter_table_online.test b/mysql-test/t/alter_table_online.test
index f5a40734535..6ef9661c43b 100644
--- a/mysql-test/t/alter_table_online.test
+++ b/mysql-test/t/alter_table_online.test
@@ -8,13 +8,15 @@
# Test of things that can be done online
#
-create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
+create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')) engine=myisam;
insert into t1 (a) values (1),(2),(3);
-alter online table t1 modify b int default 5;
+alter online table t1 modify b int default 5, alter c set default 'X';
alter online table t1 change b new_name int;
alter online table t1 modify e enum('a','b','c');
alter online table t1 comment "new comment";
+alter table t1 add constraint q check (a > 0);
+alter online table t1 drop constraint q;
# No OPs
@@ -22,7 +24,7 @@ alter online table t1 algorithm=INPLACE, lock=NONE;
alter online table t1;
alter table t1 algorithm=INPLACE;
alter table t1 lock=NONE;
-
+show create table t1;
drop table t1;
#
@@ -31,15 +33,31 @@ drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
insert into t1 (a) values (1),(2),(3);
-alter online table t1 modify b int default 5;
+alter online table t1 modify b int default 5, alter c set default 'X';
alter online table t1 change b new_name int;
alter online table t1 modify e enum('a','b','c');
alter online table t1 comment "new comment";
alter online table t1 rename to t2;
-
+show create table t2;
drop table t2;
#
+# Test also with Aria
+#
+
+create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')) engine=aria;
+insert into t1 (a) values (1),(2),(3);
+alter online table t1 modify b int default 5;
+alter online table t1 change b new_name int;
+alter online table t1 modify e enum('a','b','c');
+alter online table t1 comment "new comment";
+show create table t1;
+alter online table t1 page_checksum=1;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter online table t1 page_checksum=0;
+drop table t1;
+
+#
# Test of things that is not possible to do online
#
@@ -62,12 +80,17 @@ alter online table t1 add f int;
alter online table t1 engine=memory;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
alter online table t1 rename to t2;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter online table t1 checksum=1;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter online table t1 add constraint check (b > 0);
alter table t1 engine=innodb;
alter table t1 add index (b);
alter online table t1 add index c (c);
alter online table t1 drop index b;
alter online table t1 comment "new comment";
+show create table t1;
drop table t1;
create temporary table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b'));
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 76e80711a22..bf999371ec4 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -89,7 +89,7 @@ static handler *partition_create_handler(handlerton *hton,
TABLE_SHARE *share,
MEM_ROOT *mem_root);
static uint partition_flags();
-static ulonglong alter_table_flags(ulonglong flags);
+static alter_table_operations alter_table_flags(alter_table_operations flags);
/*
If frm_error() is called then we will use this to to find out what file
@@ -214,7 +214,7 @@ static uint partition_flags()
return HA_CAN_PARTITION;
}
-static ulonglong alter_table_flags(ulonglong /* flags */)
+static alter_table_operations alter_table_flags(alter_table_operations flags __attribute__((unused)))
{
return (HA_PARTITION_FUNCTION_SUPPORTED |
HA_FAST_CHANGE_PARTITION);
@@ -1380,7 +1380,7 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
when ALTER TABLE <CMD> PARTITION ...
it should only do named partitions, otherwise all partitions
*/
- if (!(thd->lex->alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION) ||
+ if (!(thd->lex->alter_info.flags & ALTER_ADMIN_PARTITION) ||
part_elem->part_state == PART_ADMIN)
{
if (m_is_sub_partitioned)
@@ -9655,7 +9655,7 @@ void ha_partition::print_error(int error, myf errflag)
/* Should probably look for my own errors first */
if ((error == HA_ERR_NO_PARTITION_FOUND) &&
- ! (thd->lex->alter_info.flags & Alter_info::ALTER_TRUNCATE_PARTITION))
+ ! (thd->lex->alter_info.flags & ALTER_TRUNCATE_PARTITION))
{
m_part_info->print_no_partition_found(table, errflag);
DBUG_VOID_RETURN;
@@ -9770,9 +9770,10 @@ handler::Table_flags ha_partition::table_flags() const
alter_table_flags must be on handler/table level, not on hton level
due to the ha_partition hton does not know what the underlying hton is.
*/
-ulonglong ha_partition::alter_table_flags(ulonglong flags)
+
+alter_table_operations ha_partition::alter_table_flags(alter_table_operations flags)
{
- ulonglong flags_to_return;
+ alter_table_operations flags_to_return;
DBUG_ENTER("ha_partition::alter_table_flags");
flags_to_return= ht->alter_table_flags(flags);
@@ -9870,7 +9871,7 @@ ha_partition::check_if_supported_inplace_alter(TABLE *altered_table,
Any other change would set partition_changed in
prep_alter_part_table() in mysql_alter_table().
*/
- if (ha_alter_info->alter_info->flags == Alter_info::ALTER_PARTITION)
+ if (ha_alter_info->alter_info->flags == ALTER_PARTITION)
DBUG_RETURN(HA_ALTER_INPLACE_NO_LOCK);
part_inplace_ctx=
@@ -9887,7 +9888,7 @@ ha_partition::check_if_supported_inplace_alter(TABLE *altered_table,
for (index= 0; index <= m_tot_parts; index++)
part_inplace_ctx->handler_ctx_array[index]= NULL;
- ha_alter_info->handler_flags |= Alter_inplace_info::ALTER_PARTITIONED;
+ ha_alter_info->handler_flags |= ALTER_PARTITIONED;
for (index= 0; index < m_tot_parts; index++)
{
enum_alter_inplace_result p_result=
@@ -9937,7 +9938,7 @@ bool ha_partition::prepare_inplace_alter_table(TABLE *altered_table,
Changing to similar partitioning, only update metadata.
Non allowed changes would be catched in prep_alter_part_table().
*/
- if (ha_alter_info->alter_info->flags == Alter_info::ALTER_PARTITION)
+ if (ha_alter_info->alter_info->flags == ALTER_PARTITION)
DBUG_RETURN(false);
part_inplace_ctx=
@@ -9970,7 +9971,7 @@ bool ha_partition::inplace_alter_table(TABLE *altered_table,
Changing to similar partitioning, only update metadata.
Non allowed changes would be catched in prep_alter_part_table().
*/
- if (ha_alter_info->alter_info->flags == Alter_info::ALTER_PARTITION)
+ if (ha_alter_info->alter_info->flags == ALTER_PARTITION)
DBUG_RETURN(false);
part_inplace_ctx=
@@ -10010,7 +10011,7 @@ bool ha_partition::commit_inplace_alter_table(TABLE *altered_table,
Changing to similar partitioning, only update metadata.
Non allowed changes would be catched in prep_alter_part_table().
*/
- if (ha_alter_info->alter_info->flags == Alter_info::ALTER_PARTITION)
+ if (ha_alter_info->alter_info->flags == ALTER_PARTITION)
DBUG_RETURN(false);
part_inplace_ctx=
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index 534b6335e79..e661d0badd3 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -1188,7 +1188,7 @@ public:
wrapper function for handlerton alter_table_flags, since
the ha_partition_hton cannot know all its capabilities
*/
- virtual ulonglong alter_table_flags(ulonglong flags);
+ virtual alter_table_operations alter_table_flags(alter_table_operations flags);
/*
unireg.cc will call the following to make sure that the storage engine
can handle the data it is about to send.
diff --git a/sql/handler.cc b/sql/handler.cc
index f60cd67edae..12674a19a52 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1419,7 +1419,7 @@ int ha_commit_trans(THD *thd, bool all)
#if 1 // FIXME: This should be done in ha_prepare().
if (rw_trans || (thd->lex->sql_command == SQLCOM_ALTER_TABLE &&
- thd->lex->alter_info.flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING))
+ thd->lex->alter_info.flags & ALTER_ADD_SYSTEM_VERSIONING))
{
ulonglong trx_start_id= 0, trx_end_id= 0;
for (Ha_trx_info *ha_info= trans->ha_list; ha_info; ha_info= ha_info->next())
@@ -4423,21 +4423,26 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table,
if (altered_table->versioned(VERS_TIMESTAMP))
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
- Alter_inplace_info::HA_ALTER_FLAGS inplace_offline_operations=
- Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH |
- Alter_inplace_info::ALTER_COLUMN_NAME |
- Alter_inplace_info::ALTER_COLUMN_DEFAULT |
- Alter_inplace_info::ALTER_COLUMN_OPTION |
- Alter_inplace_info::CHANGE_CREATE_OPTION |
- Alter_inplace_info::ALTER_PARTITIONED |
- Alter_inplace_info::ALTER_VIRTUAL_GCOL_EXPR |
- Alter_inplace_info::ALTER_RENAME;
+ alter_table_operations inplace_offline_operations=
+ ALTER_COLUMN_EQUAL_PACK_LENGTH |
+ ALTER_COLUMN_NAME |
+ ALTER_RENAME_COLUMN |
+ ALTER_CHANGE_COLUMN_DEFAULT |
+ ALTER_COLUMN_DEFAULT |
+ ALTER_COLUMN_OPTION |
+ ALTER_CHANGE_CREATE_OPTION |
+ ALTER_DROP_CHECK_CONSTRAINT |
+ ALTER_PARTITIONED |
+ ALTER_VIRTUAL_GCOL_EXPR |
+ ALTER_RENAME;
/* Is there at least one operation that requires copy algorithm? */
if (ha_alter_info->handler_flags & ~inplace_offline_operations)
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
/*
+ The following checks for changes related to ALTER_OPTIONS
+
ALTER TABLE tbl_name CONVERT TO CHARACTER SET .. and
ALTER TABLE table_name DEFAULT CHARSET = .. most likely
change column charsets and so not supported in-place through
@@ -4449,12 +4454,13 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table,
if (create_info->used_fields & (HA_CREATE_USED_CHARSET |
HA_CREATE_USED_DEFAULT_CHARSET |
HA_CREATE_USED_PACK_KEYS |
+ HA_CREATE_USED_CHECKSUM |
HA_CREATE_USED_MAX_ROWS) ||
(table->s->row_type != create_info->row_type))
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
uint table_changes= (ha_alter_info->handler_flags &
- Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH) ?
+ ALTER_COLUMN_EQUAL_PACK_LENGTH) ?
IS_EQUAL_PACK_LENGTH : IS_EQUAL_YES;
if (table->file->check_if_incompatible_data(create_info, table_changes)
== COMPATIBLE_DATA_YES)
@@ -6872,7 +6878,7 @@ static bool vers_create_sys_field(THD *thd, const char *field_name,
if (!f)
return true;
- alter_info->flags|= Alter_info::ALTER_ADD_COLUMN;
+ alter_info->flags|= ALTER_PARSER_ADD_COLUMN;
alter_info->create_list.push_back(f);
return false;
@@ -6887,7 +6893,7 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info, int *added)
if (*this)
return false;
- alter_info->flags|= Alter_info::ALTER_ADD_COLUMN;
+ alter_info->flags|= ALTER_PARSER_ADD_COLUMN;
system_time= start_end_t(default_start, default_end);
as_row= system_time;
@@ -6933,7 +6939,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
List<Item> *items,
bool *versioned_write)
{
- DBUG_ASSERT(!(alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING));
+ DBUG_ASSERT(!(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING));
int vers_tables= 0;
if (select_tables)
@@ -6946,11 +6952,11 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
}
DBUG_EXECUTE_IF("sysvers_force", if (!tmp_table()) {
- alter_info->flags|= Alter_info::ALTER_ADD_SYSTEM_VERSIONING;
+ alter_info->flags|= ALTER_ADD_SYSTEM_VERSIONING;
options|= HA_VERSIONED_TABLE; });
// Possibly override default storage engine to match one used in source table.
- if (vers_tables && alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING &&
+ if (vers_tables && alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING &&
!(used_fields & HA_CREATE_USED_ENGINE))
{
List_iterator_fast<Create_field> it(alter_info->create_list);
@@ -6971,14 +6977,14 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
return false;
if (!vers_info.versioned_fields && vers_info.unversioned_fields &&
- !(alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING))
+ !(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING))
{
// All is correct but this table is not versioned.
options&= ~HA_VERSIONED_TABLE;
return false;
}
- if (!(alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING) && vers_info)
+ if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) && vers_info)
{
my_error(ER_MISSING, MYF(0), create_table.table_name.str,
"WITH SYSTEM VERSIONING");
@@ -6997,7 +7003,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
while (Create_field *f= it++)
{
if ((f->versioning == Column_definition::VERSIONING_NOT_SET &&
- !(alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING)) ||
+ !(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) ||
f->versioning == Column_definition::WITHOUT_VERSIONING)
{
f->flags|= VERS_UPDATE_UNVERSIONED_FLAG;
@@ -7129,14 +7135,14 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return true;
}
- if (alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING &&
+ if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING &&
table->versioned())
{
my_error(ER_VERS_ALREADY_VERSIONED, MYF(0), table_name);
return true;
}
- if (alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING)
+ if (alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)
{
if (!share->versioned)
{
@@ -7167,7 +7173,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
}
}
- if ((alter_info->flags & Alter_info::ALTER_DROP_PERIOD ||
+ if ((alter_info->flags & ALTER_DROP_PERIOD ||
versioned_fields || unversioned_fields) && !share->versioned)
{
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table_name);
@@ -7176,7 +7182,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
if (share->versioned)
{
- if (alter_info->flags & Alter_info::ALTER_ADD_PERIOD)
+ if (alter_info->flags & ALTER_ADD_PERIOD)
{
my_error(ER_VERS_ALREADY_VERSIONED, MYF(0), table_name);
return true;
@@ -7215,7 +7221,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
if (fix_implicit(thd, alter_info))
return true;
- if (alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING)
+ if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)
{
if (check_with_conditions(table_name))
return true;
@@ -7288,10 +7294,10 @@ Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_
bool Vers_parse_info::need_check(const Alter_info *alter_info) const
{
return versioned_fields || unversioned_fields ||
- alter_info->flags & Alter_info::ALTER_ADD_PERIOD ||
- alter_info->flags & Alter_info::ALTER_DROP_PERIOD ||
- alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING ||
- alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING || *this;
+ alter_info->flags & ALTER_ADD_PERIOD ||
+ alter_info->flags & ALTER_DROP_PERIOD ||
+ alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING ||
+ alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING || *this;
}
bool Vers_parse_info::check_with_conditions(const char *table_name) const
diff --git a/sql/handler.h b/sql/handler.h
index 01d243a4451..2da92fcf07a 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -567,6 +567,177 @@ given at all. */
/* Create a sequence */
#define HA_CREATE_USED_SEQUENCE (1UL << 25)
+typedef ulonglong alter_table_operations;
+
+/*
+ These flags are set by the parser and describes the type of
+ operation(s) specified by the ALTER TABLE statement.
+*/
+
+// Set by parser for ADD [COLUMN]
+#define ALTER_PARSER_ADD_COLUMN (1ULL << 0)
+// Set by parser for DROP [COLUMN]
+#define ALTER_PARSER_DROP_COLUMN (1ULL << 1)
+// Set for CHANGE [COLUMN] | MODIFY [CHANGE] & mysql_recreate_table
+#define ALTER_CHANGE_COLUMN (1ULL << 2)
+// Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY |
+// ADD UNIQUE INDEX | ALTER ADD [COLUMN]
+#define ALTER_ADD_INDEX (1ULL << 3)
+// Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX
+#define ALTER_DROP_INDEX (1ULL << 4)
+// Set for RENAME [TO]
+#define ALTER_RENAME (1ULL << 5)
+// Set for ORDER BY
+#define ALTER_ORDER (1ULL << 6)
+// Set for table_options, like table comment
+#define ALTER_OPTIONS (1ULL << 7)
+// Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT
+#define ALTER_CHANGE_COLUMN_DEFAULT (1ULL << 8)
+// Set for DISABLE KEYS | ENABLE KEYS
+#define ALTER_KEYS_ONOFF (1ULL << 9)
+// Set for FORCE, ENGINE(same engine), by mysql_recreate_table()
+#define ALTER_RECREATE (1ULL << 10)
+// Set for ADD PARTITION
+#define ALTER_ADD_PARTITION (1ULL << 11)
+// Set for DROP PARTITION
+#define ALTER_DROP_PARTITION (1ULL << 12)
+// Set for COALESCE PARTITION
+#define ALTER_COALESCE_PARTITION (1ULL << 13)
+// Set for REORGANIZE PARTITION ... INTO
+#define ALTER_REORGANIZE_PARTITION (1ULL << 14)
+// Set for partition_options
+#define ALTER_PARTITION (1ULL << 15)
+// Set for LOAD INDEX INTO CACHE ... PARTITION
+// Set for CACHE INDEX ... PARTITION
+#define ALTER_ADMIN_PARTITION (1ULL << 16)
+// Set for REORGANIZE PARTITION
+#define ALTER_TABLE_REORG (1ULL << 17)
+// Set for REBUILD PARTITION
+#define ALTER_REBUILD_PARTITION (1ULL << 18)
+// Set for partitioning operations specifying ALL keyword
+#define ALTER_ALL_PARTITION (1ULL << 19)
+// Set for REMOVE PARTITIONING
+#define ALTER_REMOVE_PARTITIONING (1ULL << 20)
+// Set for ADD FOREIGN KEY
+#define ALTER_ADD_FOREIGN_KEY (1ULL << 21)
+// Set for DROP FOREIGN KEY
+#define ALTER_DROP_FOREIGN_KEY (1ULL << 22)
+// Set for EXCHANGE PARITION
+#define ALTER_EXCHANGE_PARTITION (1ULL << 23)
+// Set by Sql_cmd_alter_table_truncate_partition::execute()
+#define ALTER_TRUNCATE_PARTITION (1ULL << 24)
+// Set for ADD [COLUMN] FIRST | AFTER
+#define ALTER_COLUMN_ORDER (1ULL << 25)
+#define ALTER_ADD_CHECK_CONSTRAINT (1ULL << 27)
+#define ALTER_DROP_CHECK_CONSTRAINT (1ULL << 28)
+#define ALTER_RENAME_COLUMN (1ULL << 29)
+#define ALTER_COLUMN_UNVERSIONED (1ULL << 30)
+#define ALTER_ADD_SYSTEM_VERSIONING (1ULL << 31)
+#define ALTER_DROP_SYSTEM_VERSIONING (1ULL << 32)
+#define ALTER_ADD_PERIOD (1ULL << 33)
+#define ALTER_DROP_PERIOD (1ULL << 34)
+
+/*
+ Following defines are used by ALTER_INPLACE_TABLE
+
+ They do describe in more detail the type operation(s) to be executed
+ by the storage engine. For example, which type of type of index to be
+ added/dropped. These are set by fill_alter_inplace_info().
+*/
+
+#define ALTER_RECREATE_TABLE ALTER_RECREATE
+#define ALTER_CHANGE_CREATE_OPTION ALTER_OPTIONS
+#define ALTER_ADD_COLUMN (ALTER_ADD_VIRTUAL_COLUMN | \
+ ALTER_ADD_STORED_BASE_COLUMN | \
+ ALTER_ADD_STORED_GENERATED_COLUMN)
+#define ALTER_DROP_COLUMN (ALTER_DROP_VIRTUAL_COLUMN | \
+ ALTER_DROP_STORED_COLUMN)
+#define ALTER_COLUMN_DEFAULT ALTER_CHANGE_COLUMN_DEFAULT
+
+#define ALTER_DROP_HISTORICAL (1ULL << 35)
+
+// Add non-unique, non-primary index
+#define ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX (1ULL << 36)
+
+// Drop non-unique, non-primary index
+#define ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX (1ULL << 37)
+
+// Add unique, non-primary index
+#define ALTER_ADD_UNIQUE_INDEX (1ULL << 38)
+
+// Drop unique, non-primary index
+#define ALTER_DROP_UNIQUE_INDEX (1ULL << 39)
+
+// Add primary index
+#define ALTER_ADD_PK_INDEX (1ULL << 40)
+
+// Drop primary index
+#define ALTER_DROP_PK_INDEX (1ULL << 41)
+
+// Virtual generated column
+#define ALTER_ADD_VIRTUAL_COLUMN (1ULL << 42)
+// Stored base (non-generated) column
+#define ALTER_ADD_STORED_BASE_COLUMN (1ULL << 43)
+// Stored generated column
+#define ALTER_ADD_STORED_GENERATED_COLUMN (1ULL << 44)
+
+// Drop column
+#define ALTER_DROP_VIRTUAL_COLUMN (1ULL << 45)
+#define ALTER_DROP_STORED_COLUMN (1ULL << 46)
+
+// Rename column (verified; ALTER_RENAME_COLUMN may use original name)
+#define ALTER_COLUMN_NAME (1ULL << 47)
+
+// Change column datatype
+#define ALTER_VIRTUAL_COLUMN_TYPE (1ULL << 48)
+#define ALTER_STORED_COLUMN_TYPE (1ULL << 49)
+
+/**
+ Change column datatype in such way that new type has compatible
+ packed representation with old type, so it is theoretically
+ possible to perform change by only updating data dictionary
+ without changing table rows.
+*/
+#define ALTER_COLUMN_EQUAL_PACK_LENGTH (1ULL << 50)
+
+// Reorder column
+#define ALTER_STORED_COLUMN_ORDER (1ULL << 51)
+
+// Reorder column
+#define ALTER_VIRTUAL_COLUMN_ORDER (1ULL << 52)
+
+// Change column from NOT NULL to NULL
+#define ALTER_COLUMN_NULLABLE (1ULL << 53)
+
+// Change column from NULL to NOT NULL
+#define ALTER_COLUMN_NOT_NULLABLE (1ULL << 54)
+
+// Change column generation expression
+#define ALTER_VIRTUAL_GCOL_EXPR (1ULL << 56)
+#define ALTER_STORED_GCOL_EXPR (1ULL << 57)
+
+// column's engine options changed, something in field->option_struct
+#define ALTER_COLUMN_OPTION (1ULL << 59)
+
+// MySQL alias for the same thing:
+#define ALTER_COLUMN_STORAGE_TYPE (1ULL << 60)
+
+// Change the column format of column
+#define ALTER_COLUMN_COLUMN_FORMAT (1ULL << 61)
+
+/**
+ Changes in generated columns that affect storage,
+ for example, when a vcol type or expression changes
+ and this vcol is indexed or used in a partitioning expression
+*/
+#define ALTER_COLUMN_VCOL (1ULL << 62)
+
+/**
+ ALTER TABLE for a partitioned table. The engine needs to commit
+ online alter of all partitions atomically (using group_commit_ctx)
+*/
+#define ALTER_PARTITIONED (1ULL << 63)
+
/*
This is master database for most of system tables. However there
can be other databases which can hold system tables. Respective
@@ -1249,7 +1420,7 @@ struct handlerton
bool (*flush_logs)(handlerton *hton);
bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
uint (*partition_flags)();
- ulonglong (*alter_table_flags)(ulonglong flags);
+ alter_table_operations (*alter_table_flags)(alter_table_operations flags);
int (*alter_tablespace)(handlerton *hton, THD *thd, st_alter_tablespace *ts_info);
int (*fill_is_table)(handlerton *hton, THD *thd, TABLE_LIST *tables,
class Item *cond,
@@ -2025,166 +2196,6 @@ public:
class Alter_inplace_info
{
public:
- /**
- Bits to show in detail what operations the storage engine is
- to execute.
-
- All these operations are supported as in-place operations by the
- SQL layer. This means that operations that by their nature must
- be performed by copying the table to a temporary table, will not
- have their own flags here.
-
- We generally try to specify handler flags only if there are real
- changes. But in cases when it is cumbersome to determine if some
- attribute has really changed we might choose to set flag
- pessimistically, for example, relying on parser output only.
- */
- typedef ulonglong HA_ALTER_FLAGS;
-
- // Add non-unique, non-primary index
- static const HA_ALTER_FLAGS ADD_INDEX = 1ULL << 0;
-
- // Drop non-unique, non-primary index
- static const HA_ALTER_FLAGS DROP_INDEX = 1ULL << 1;
-
- // Add unique, non-primary index
- static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX = 1ULL << 2;
-
- // Drop unique, non-primary index
- static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX = 1ULL << 3;
-
- // Add primary index
- static const HA_ALTER_FLAGS ADD_PK_INDEX = 1ULL << 4;
-
- // Drop primary index
- static const HA_ALTER_FLAGS DROP_PK_INDEX = 1ULL << 5;
-
- // Virtual generated column
- static const HA_ALTER_FLAGS ADD_VIRTUAL_COLUMN = 1ULL << 6;
- // Stored base (non-generated) column
- static const HA_ALTER_FLAGS ADD_STORED_BASE_COLUMN = 1ULL << 7;
- // Stored generated column
- static const HA_ALTER_FLAGS ADD_STORED_GENERATED_COLUMN= 1ULL << 8;
- // Add generic column (convience constant).
- static const HA_ALTER_FLAGS ADD_COLUMN= ADD_VIRTUAL_COLUMN |
- ADD_STORED_BASE_COLUMN |
- ADD_STORED_GENERATED_COLUMN;
-
- // Drop column
- static const HA_ALTER_FLAGS DROP_VIRTUAL_COLUMN = 1ULL << 9;
- static const HA_ALTER_FLAGS DROP_STORED_COLUMN = 1ULL << 10;
- static const HA_ALTER_FLAGS DROP_COLUMN= DROP_VIRTUAL_COLUMN |
- DROP_STORED_COLUMN;
-
- // Rename column
- static const HA_ALTER_FLAGS ALTER_COLUMN_NAME = 1ULL << 11;
-
- // Change column datatype
- static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_TYPE = 1ULL << 12;
- static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_TYPE = 1ULL << 13;
-
- /**
- Change column datatype in such way that new type has compatible
- packed representation with old type, so it is theoretically
- possible to perform change by only updating data dictionary
- without changing table rows.
- */
- static const HA_ALTER_FLAGS ALTER_COLUMN_EQUAL_PACK_LENGTH = 1ULL << 14;
-
- // Reorder column
- static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_ORDER = 1ULL << 15;
-
- // Reorder column
- static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_ORDER = 1ULL << 16;
-
- // Change column from NOT NULL to NULL
- static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE = 1ULL << 17;
-
- // Change column from NULL to NOT NULL
- static const HA_ALTER_FLAGS ALTER_COLUMN_NOT_NULLABLE = 1ULL << 18;
-
- // Set or remove default column value
- static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT = 1ULL << 19;
-
- // Change column generation expression
- static const HA_ALTER_FLAGS ALTER_VIRTUAL_GCOL_EXPR = 1ULL << 20;
- static const HA_ALTER_FLAGS ALTER_STORED_GCOL_EXPR = 1ULL << 21;
- //
- // Add foreign key
- static const HA_ALTER_FLAGS ADD_FOREIGN_KEY = 1ULL << 22;
-
- // Drop foreign key
- static const HA_ALTER_FLAGS DROP_FOREIGN_KEY = 1ULL << 23;
-
- // table_options changed, see HA_CREATE_INFO::used_fields for details.
- static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION = 1ULL << 24;
-
- // Table is renamed
- static const HA_ALTER_FLAGS ALTER_RENAME = 1ULL << 25;
-
- // column's engine options changed, something in field->option_struct
- static const HA_ALTER_FLAGS ALTER_COLUMN_OPTION = 1ULL << 26;
-
- // MySQL alias for the same thing:
- static const HA_ALTER_FLAGS ALTER_COLUMN_STORAGE_TYPE = 1ULL << 26;
-
- // Change the column format of column
- static const HA_ALTER_FLAGS ALTER_COLUMN_COLUMN_FORMAT = 1ULL << 27;
-
- // Add partition
- static const HA_ALTER_FLAGS ADD_PARTITION = 1ULL << 28;
-
- // Drop partition
- static const HA_ALTER_FLAGS DROP_PARTITION = 1ULL << 29;
-
- // Changing partition options
- static const HA_ALTER_FLAGS ALTER_PARTITION = 1ULL << 30;
-
- // Coalesce partition
- static const HA_ALTER_FLAGS COALESCE_PARTITION = 1ULL << 31;
-
- // Reorganize partition ... into
- static const HA_ALTER_FLAGS REORGANIZE_PARTITION = 1ULL << 32;
-
- // Reorganize partition
- static const HA_ALTER_FLAGS ALTER_TABLE_REORG = 1ULL << 33;
-
- // Remove partitioning
- static const HA_ALTER_FLAGS ALTER_REMOVE_PARTITIONING = 1ULL << 34;
-
- // Partition operation with ALL keyword
- static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1ULL << 35;
-
- /**
- Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE
- and OPTIMIZE TABLE operations.
- */
- static const HA_ALTER_FLAGS RECREATE_TABLE = 1ULL << 36;
-
- /**
- Changes in generated columns that affect storage,
- for example, when a vcol type or expression changes
- and this vcol is indexed or used in a partitioning expression
- */
- static const HA_ALTER_FLAGS ALTER_COLUMN_VCOL = 1ULL << 37;
-
- /**
- ALTER TABLE for a partitioned table. The engine needs to commit
- online alter of all partitions atomically (using group_commit_ctx)
- */
- static const HA_ALTER_FLAGS ALTER_PARTITIONED = 1ULL << 38;
-
- static const HA_ALTER_FLAGS ALTER_ADD_CHECK_CONSTRAINT = 1ULL << 39;
-
- static const HA_ALTER_FLAGS ALTER_DROP_CHECK_CONSTRAINT= 1ULL << 40;
-
- static const HA_ALTER_FLAGS ALTER_DROP_HISTORICAL = 1ULL << 41;
-
- static const HA_ALTER_FLAGS ALTER_COLUMN_UNVERSIONED = 1ULL << 42;
-
- static const HA_ALTER_FLAGS ALTER_ADD_SYSTEM_VERSIONING= 1ULL << 43;
-
- static const HA_ALTER_FLAGS ALTER_DROP_SYSTEM_VERSIONING= 1ULL << 44;
/**
Create options (like MAX_ROWS) for the new version of table.
@@ -2269,9 +2280,10 @@ public:
inplace_alter_handler_ctx **group_commit_ctx;
/**
- Flags describing in detail which operations the storage engine is to execute.
+ Flags describing in detail which operations the storage engine is to
+ execute. Flags are defined in sql_alter.h
*/
- HA_ALTER_FLAGS handler_flags;
+ alter_table_operations handler_flags;
/**
Partition_info taking into account the partition changes to be performed.
@@ -4269,7 +4281,7 @@ public:
but we don't have a primary key
*/
virtual void use_hidden_primary_key();
- virtual ulonglong alter_table_flags(ulonglong flags)
+ virtual alter_table_operations alter_table_flags(alter_table_operations flags)
{
if (ht->alter_table_flags)
return ht->alter_table_flags(flags);
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 4cff69060d1..65f1f2d6627 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -339,7 +339,7 @@ static bool open_only_one_table(THD* thd, TABLE_LIST* table,
to differentiate from ALTER TABLE...CHECK PARTITION on which view is not
allowed.
*/
- if (lex->alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION ||
+ if (lex->alter_info.flags & ALTER_ADMIN_PARTITION ||
!is_view_operator_func)
{
table->required_type= TABLE_TYPE_NORMAL;
@@ -562,7 +562,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
*/
Alter_info *alter_info= &lex->alter_info;
- if (alter_info->flags & Alter_info::ALTER_ADMIN_PARTITION)
+ if (alter_info->flags & ALTER_ADMIN_PARTITION)
{
if (!table->table->part_info)
{
@@ -1002,7 +1002,7 @@ send_result_message:
Alter_info *alter_info= &lex->alter_info;
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
- if (alter_info->flags & Alter_info::ALTER_ADMIN_PARTITION)
+ if (alter_info->flags & ALTER_ADMIN_PARTITION)
{
protocol->store(STRING_WITH_LEN(
"Table does not support optimize on partitions. All partitions "
@@ -1049,7 +1049,7 @@ send_result_message:
Reset the ALTER_ADMIN_PARTITION bit in alter_info->flags
to force analyze on all partitions.
*/
- alter_info->flags &= ~(Alter_info::ALTER_ADMIN_PARTITION);
+ alter_info->flags &= ~(ALTER_ADMIN_PARTITION);
result_code= table->table->file->ha_analyze(thd, check_opt);
if (result_code == HA_ADMIN_ALREADY_DONE)
result_code= HA_ADMIN_OK;
diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc
index 2cc6504d2f3..fac0e43d499 100644
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@ -225,14 +225,13 @@ bool Sql_cmd_alter_table::execute(THD *thd)
We also require DROP priv for ALTER TABLE ... DROP PARTITION, as well
as for RENAME TO, as being done by SQLCOM_RENAME_TABLE
*/
- if (alter_info.flags & (Alter_info::ALTER_DROP_PARTITION |
- Alter_info::ALTER_RENAME))
+ if (alter_info.flags & (ALTER_DROP_PARTITION | ALTER_RENAME))
priv_needed|= DROP_ACL;
/* Must be set in the parser */
DBUG_ASSERT(select_lex->db.str);
- DBUG_ASSERT(!(alter_info.flags & Alter_info::ALTER_EXCHANGE_PARTITION));
- DBUG_ASSERT(!(alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION));
+ DBUG_ASSERT(!(alter_info.flags & ALTER_EXCHANGE_PARTITION));
+ DBUG_ASSERT(!(alter_info.flags & ALTER_ADMIN_PARTITION));
if (check_access(thd, priv_needed, first_table->db.str,
&first_table->grant.privilege,
&first_table->grant.m_internal,
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 4314d662d3d..3245e4b195c 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -29,85 +29,14 @@ class Key;
class Alter_info
{
public:
- /*
- These flags are set by the parser and describes the type of
- operation(s) specified by the ALTER TABLE statement.
-
- They do *not* describe the type operation(s) to be executed
- by the storage engine. For example, we don't yet know the
- type of index to be added/dropped.
- */
-
- /** Set for ADD [COLUMN] */
- static const ulonglong ALTER_ADD_COLUMN = 1ULL << 0;
- /** Set for DROP [COLUMN] */
- static const ulonglong ALTER_DROP_COLUMN = 1ULL << 1;
- /** Set for CHANGE [COLUMN] | MODIFY [CHANGE] & mysql_recreate_table */
- static const ulonglong ALTER_CHANGE_COLUMN = 1ULL << 2;
- /** Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY |
- ADD UNIQUE INDEX | ALTER ADD [COLUMN] */
- static const ulonglong ALTER_ADD_INDEX = 1ULL << 3;
- /** Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX */
- static const ulonglong ALTER_DROP_INDEX = 1ULL << 4;
- /** Set for RENAME [TO] */
- static const ulonglong ALTER_RENAME = 1ULL << 5;
- /** Set for ORDER BY */
- static const ulonglong ALTER_ORDER = 1ULL << 6;
- /** Set for table_options */
- static const ulonglong ALTER_OPTIONS = 1ULL << 7;
- /** Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT */
- static const ulonglong ALTER_CHANGE_COLUMN_DEFAULT = 1ULL << 8;
- /** Set for DISABLE KEYS | ENABLE KEYS */
- static const ulonglong ALTER_KEYS_ONOFF = 1ULL << 9;
- /** Set for FORCE, ENGINE(same engine), by mysql_recreate_table() */
- static const ulonglong ALTER_RECREATE = 1ULL << 10;
- /** Set for ADD PARTITION */
- static const ulonglong ALTER_ADD_PARTITION = 1ULL << 11;
- /** Set for DROP PARTITION */
- static const ulonglong ALTER_DROP_PARTITION = 1ULL << 12;
- /** Set for COALESCE PARTITION */
- static const ulonglong ALTER_COALESCE_PARTITION = 1ULL << 13;
- /** Set for REORGANIZE PARTITION ... INTO */
- static const ulonglong ALTER_REORGANIZE_PARTITION = 1ULL << 14;
- /** Set for partition_options */
- static const ulonglong ALTER_PARTITION = 1ULL << 15;
- /** Set for LOAD INDEX INTO CACHE ... PARTITION
- and CACHE INDEX ... PARTITION */
- static const ulonglong ALTER_ADMIN_PARTITION = 1ULL << 16;
- /** Set for REORGANIZE PARTITION */
- static const ulonglong ALTER_TABLE_REORG = 1ULL << 17;
- /** Set for REBUILD PARTITION */
- static const ulonglong ALTER_REBUILD_PARTITION = 1ULL << 18;
- /** Set for partitioning operations specifying ALL keyword */
- static const ulonglong ALTER_ALL_PARTITION = 1ULL << 19;
- /** Set for REMOVE PARTITIONING */
- static const ulonglong ALTER_REMOVE_PARTITIONING = 1ULL << 20;
- /** Set for ADD FOREIGN KEY */
- static const ulonglong ADD_FOREIGN_KEY = 1ULL << 21;
- /** Set for DROP FOREIGN KEY */
- static const ulonglong DROP_FOREIGN_KEY = 1ULL << 22;
- /** Set for EXCHANGE PARITION */
- static const ulonglong ALTER_EXCHANGE_PARTITION = 1ULL << 23;
- /** Set by Sql_cmd_alter_table_truncate_partition::execute() */
- static const ulonglong ALTER_TRUNCATE_PARTITION = 1ULL << 24;
- /** Set for ADD [COLUMN] FIRST | AFTER */
- static const ulonglong ALTER_COLUMN_ORDER = 1ULL << 25;
- static const ulonglong ALTER_ADD_CHECK_CONSTRAINT = 1ULL << 27;
- static const ulonglong ALTER_DROP_CHECK_CONSTRAINT = 1ULL << 28;
- static const ulonglong ALTER_RENAME_COLUMN = 1ULL << 29;
- static const ulonglong ALTER_COLUMN_UNVERSIONED = 1ULL << 30;
- static const ulonglong ALTER_ADD_SYSTEM_VERSIONING = 1ULL << 31;
- static const ulonglong ALTER_DROP_SYSTEM_VERSIONING= 1ULL << 32;
- static const ulonglong ALTER_ADD_PERIOD = 1ULL << 33;
- static const ulonglong ALTER_DROP_PERIOD = 1ULL << 34;
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
bool data_modifying() const
{
return flags & (
- ALTER_ADD_COLUMN |
- ALTER_DROP_COLUMN |
+ ALTER_PARSER_ADD_COLUMN |
+ ALTER_PARSER_DROP_COLUMN |
ALTER_CHANGE_COLUMN |
ALTER_COLUMN_ORDER);
}
@@ -176,7 +105,7 @@ public:
};
List<Virtual_column_info> check_constraint_list;
// Type of ALTER TABLE operation.
- ulonglong flags;
+ alter_table_operations flags;
// Enable or disable keys.
enum_enable_or_disable keys_onoff;
// List of partitions.
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index f012187a88a..15a0b0a0f12 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -5050,8 +5050,8 @@ int st_select_lex_unit::save_union_explain_part2(Explain_query *output)
bool LEX::is_partition_management() const
{
return (sql_command == SQLCOM_ALTER_TABLE &&
- (alter_info.flags == Alter_info::ALTER_ADD_PARTITION ||
- alter_info.flags == Alter_info::ALTER_REORGANIZE_PARTITION));
+ (alter_info.flags == ALTER_ADD_PARTITION ||
+ alter_info.flags == ALTER_REORGANIZE_PARTITION));
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 9856ca12324..2165deafba3 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -3662,7 +3662,7 @@ public:
MDL_SHARED_UPGRADABLE))
return true;
alter_info.reset();
- alter_info.flags= Alter_info::ALTER_ADD_INDEX;
+ alter_info.flags= ALTER_ADD_INDEX;
option_list= NULL;
return false;
}
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 18d991a6f72..61dc0b6d1e3 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4711,7 +4711,7 @@ bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
do
{
partition_element *part_elem= part_it++;
- if ((alter_info->flags & Alter_info::ALTER_ALL_PARTITION) ||
+ if ((alter_info->flags & ALTER_ALL_PARTITION) ||
(is_name_in_list(part_elem->partition_name,
alter_info->partition_names)))
{
@@ -4730,7 +4730,7 @@ bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
} while (++part_count < tab_part_info->num_parts);
if (num_parts_found != alter_info->partition_names.elements &&
- !(alter_info->flags & Alter_info::ALTER_ALL_PARTITION))
+ !(alter_info->flags & ALTER_ALL_PARTITION))
{
/* Not all given partitions found, revert and return failure */
part_it.rewind();
@@ -4821,15 +4821,15 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
DBUG_ENTER("prep_alter_part_table");
/* Foreign keys on partitioned tables are not supported, waits for WL#148 */
- if (table->part_info && (alter_info->flags & Alter_info::ADD_FOREIGN_KEY ||
- alter_info->flags & Alter_info::DROP_FOREIGN_KEY))
+ if (table->part_info && (alter_info->flags & (ALTER_ADD_FOREIGN_KEY |
+ ALTER_DROP_FOREIGN_KEY)))
{
my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0));
DBUG_RETURN(TRUE);
}
/* Remove partitioning on a not partitioned table is not possible */
if (!table->part_info && (alter_info->flags &
- Alter_info::ALTER_REMOVE_PARTITIONING))
+ ALTER_REMOVE_PARTITIONING))
{
my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
DBUG_RETURN(TRUE);
@@ -4849,7 +4849,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
alt_part_info->current_partition->list_val_list.head()->
col_val_array[0].max_value) &&
alt_part_info->part_type == LIST_PARTITION &&
- (alter_info->flags & Alter_info::ALTER_ADD_PARTITION);
+ (alter_info->flags & ALTER_ADD_PARTITION);
if (only_default_value_added &&
!thd->lex->part_info->num_columns)
thd->lex->part_info->num_columns= 1; // to make correct clone
@@ -4865,17 +4865,17 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
DBUG_RETURN(TRUE);
/* ALTER_ADMIN_PARTITION is handled in mysql_admin_table */
- DBUG_ASSERT(!(alter_info->flags & Alter_info::ALTER_ADMIN_PARTITION));
+ DBUG_ASSERT(!(alter_info->flags & ALTER_ADMIN_PARTITION));
partition_info *saved_part_info= NULL;
if (alter_info->flags &
- (Alter_info::ALTER_ADD_PARTITION |
- Alter_info::ALTER_DROP_PARTITION |
- Alter_info::ALTER_COALESCE_PARTITION |
- Alter_info::ALTER_REORGANIZE_PARTITION |
- Alter_info::ALTER_TABLE_REORG |
- Alter_info::ALTER_REBUILD_PARTITION))
+ (ALTER_ADD_PARTITION |
+ ALTER_DROP_PARTITION |
+ ALTER_COALESCE_PARTITION |
+ ALTER_REORGANIZE_PARTITION |
+ ALTER_TABLE_REORG |
+ ALTER_REBUILD_PARTITION))
{
partition_info *tab_part_info;
ulonglong flags= 0;
@@ -4904,7 +4904,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
tab_part_info= table->part_info;
- if (alter_info->flags & Alter_info::ALTER_TABLE_REORG)
+ if (alter_info->flags & ALTER_TABLE_REORG)
{
uint new_part_no, curr_part_no;
/*
@@ -4956,7 +4956,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
We will add more partitions, we use the ADD PARTITION without
setting the flag for no default number of partitions
*/
- alter_info->flags|= Alter_info::ALTER_ADD_PARTITION;
+ alter_info->flags|= ALTER_ADD_PARTITION;
thd->work_part_info->num_parts= new_part_no - curr_part_no;
}
else
@@ -4965,7 +4965,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
We will remove hash partitions, we use the COALESCE PARTITION
without setting the flag for no default number of partitions
*/
- alter_info->flags|= Alter_info::ALTER_COALESCE_PARTITION;
+ alter_info->flags|= ALTER_COALESCE_PARTITION;
alter_info->num_parts= curr_part_no - new_part_no;
}
}
@@ -4998,8 +4998,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
DBUG_RETURN(TRUE);
}
DBUG_PRINT("info", ("*fast_alter_table flags: 0x%llx", flags));
- if ((alter_info->flags & Alter_info::ALTER_ADD_PARTITION) ||
- (alter_info->flags & Alter_info::ALTER_REORGANIZE_PARTITION))
+ if ((alter_info->flags & ALTER_ADD_PARTITION) ||
+ (alter_info->flags & ALTER_REORGANIZE_PARTITION))
{
if (thd->work_part_info->part_type != tab_part_info->part_type)
{
@@ -5067,7 +5067,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
goto err;
}
}
- if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION)
+ if (alter_info->flags & ALTER_ADD_PARTITION)
{
if (*fast_alter_table && thd->locked_tables_mode)
{
@@ -5348,7 +5348,7 @@ that are reorganised.
of partitions anymore. We use this code also for Table reorganisations
and here we don't set any default flags to FALSE.
*/
- if (!(alter_info->flags & Alter_info::ALTER_TABLE_REORG))
+ if (!(alter_info->flags & ALTER_TABLE_REORG))
{
if (!alt_part_info->use_default_partitions)
{
@@ -5359,7 +5359,7 @@ that are reorganised.
tab_part_info->is_auto_partitioned= FALSE;
}
}
- else if (alter_info->flags & Alter_info::ALTER_DROP_PARTITION)
+ else if (alter_info->flags & ALTER_DROP_PARTITION)
{
/*
Drop a partition from a range partition and list partitioning is
@@ -5440,7 +5440,7 @@ that are reorganised.
}
tab_part_info->num_parts-= num_parts_dropped;
}
- else if (alter_info->flags & Alter_info::ALTER_REBUILD_PARTITION)
+ else if (alter_info->flags & ALTER_REBUILD_PARTITION)
{
set_engine_all_partitions(tab_part_info,
tab_part_info->default_engine_type);
@@ -5455,7 +5455,7 @@ that are reorganised.
goto err;
}
}
- else if (alter_info->flags & Alter_info::ALTER_COALESCE_PARTITION)
+ else if (alter_info->flags & ALTER_COALESCE_PARTITION)
{
uint num_parts_coalesced= alter_info->num_parts;
uint num_parts_remain= tab_part_info->num_parts - num_parts_coalesced;
@@ -5553,13 +5553,13 @@ state of p1.
} while (part_count < tab_part_info->num_parts);
tab_part_info->num_parts= num_parts_remain;
}
- if (!(alter_info->flags & Alter_info::ALTER_TABLE_REORG))
+ if (!(alter_info->flags & ALTER_TABLE_REORG))
{
tab_part_info->use_default_num_partitions= FALSE;
tab_part_info->is_auto_partitioned= FALSE;
}
}
- else if (alter_info->flags & Alter_info::ALTER_REORGANIZE_PARTITION)
+ else if (alter_info->flags & ALTER_REORGANIZE_PARTITION)
{
/*
Reorganise partitions takes a number of partitions that are next
@@ -5734,8 +5734,8 @@ the generated partition syntax in a correct manner.
}
*partition_changed= TRUE;
thd->work_part_info= tab_part_info;
- if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION ||
- alter_info->flags & Alter_info::ALTER_REORGANIZE_PARTITION)
+ if (alter_info->flags & ALTER_ADD_PARTITION ||
+ alter_info->flags & ALTER_REORGANIZE_PARTITION)
{
if (tab_part_info->use_default_subpartitions &&
!alt_part_info->use_default_subpartitions)
@@ -5754,7 +5754,7 @@ the generated partition syntax in a correct manner.
since this function "fixes" the item trees of the new partitions
to reorganize into
*/
- if (alter_info->flags == Alter_info::ALTER_REORGANIZE_PARTITION &&
+ if (alter_info->flags == ALTER_REORGANIZE_PARTITION &&
tab_part_info->part_type == RANGE_PARTITION &&
((is_last_partition_reorged &&
(tab_part_info->column_list ?
@@ -5837,7 +5837,7 @@ the generated partition syntax in a correct manner.
if (tab_part_info)
{
- if (alter_info->flags & Alter_info::ALTER_REMOVE_PARTITIONING)
+ if (alter_info->flags & ALTER_REMOVE_PARTITIONING)
{
DBUG_PRINT("info", ("Remove partitioning"));
if (!(create_info->used_fields & HA_CREATE_USED_ENGINE))
@@ -5908,7 +5908,7 @@ the generated partition syntax in a correct manner.
rebuild). This is to handle KEY (numeric_cols) partitioned tables
created in 5.1. For more info, see bug#14521864.
*/
- if (alter_info->flags != Alter_info::ALTER_PARTITION ||
+ if (alter_info->flags != ALTER_PARTITION ||
!table->part_info ||
alter_info->requested_algorithm !=
Alter_info::ALTER_TABLE_ALGORITHM_INPLACE ||
@@ -6661,7 +6661,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
goto error;
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
lpt->alter_info->flags &
- Alter_info::ALTER_REORGANIZE_PARTITION))
+ ALTER_REORGANIZE_PARTITION))
goto error;
if (write_log_replace_delete_frm(lpt, next_entry, shadow_path, path, TRUE))
goto error;
@@ -7116,7 +7116,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
goto err;
}
}
- else if (alter_info->flags & Alter_info::ALTER_DROP_PARTITION)
+ else if (alter_info->flags & ALTER_DROP_PARTITION)
{
/*
Now after all checks and setting state on dropped partitions we can
@@ -7216,7 +7216,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
goto err;
}
}
- else if ((alter_info->flags & Alter_info::ALTER_ADD_PARTITION) &&
+ else if ((alter_info->flags & ALTER_ADD_PARTITION) &&
(part_info->part_type == RANGE_PARTITION ||
part_info->part_type == LIST_PARTITION))
{
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 2e998878351..ea933cfd12a 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -73,7 +73,7 @@ bool Sql_cmd_alter_table_exchange_partition::execute(THD *thd)
/* Must be set in the parser */
DBUG_ASSERT(select_lex->db.str);
/* also check the table to be exchanged with the partition */
- DBUG_ASSERT(alter_info.flags & Alter_info::ALTER_EXCHANGE_PARTITION);
+ DBUG_ASSERT(alter_info.flags & ALTER_EXCHANGE_PARTITION);
if (check_access(thd, priv_needed, first_table->db.str,
&first_table->grant.privilege,
@@ -501,7 +501,7 @@ bool Sql_cmd_alter_table_exchange_partition::
uint table_counter;
bool error= TRUE;
DBUG_ENTER("mysql_exchange_partition");
- DBUG_ASSERT(alter_info->flags & Alter_info::ALTER_EXCHANGE_PARTITION);
+ DBUG_ASSERT(alter_info->flags & ALTER_EXCHANGE_PARTITION);
/* Don't allow to exchange with log table */
swap_table_list= table_list->next_local;
@@ -671,7 +671,7 @@ bool Sql_cmd_alter_table_analyze_partition::execute(THD *thd)
Flag that it is an ALTER command which administrates partitions, used
by ha_partition
*/
- thd->lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION;
+ thd->lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
res= Sql_cmd_analyze_table::execute(thd);
@@ -688,7 +688,7 @@ bool Sql_cmd_alter_table_check_partition::execute(THD *thd)
Flag that it is an ALTER command which administrates partitions, used
by ha_partition
*/
- thd->lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION;
+ thd->lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
res= Sql_cmd_check_table::execute(thd);
@@ -705,7 +705,7 @@ bool Sql_cmd_alter_table_optimize_partition::execute(THD *thd)
Flag that it is an ALTER command which administrates partitions, used
by ha_partition
*/
- thd->lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION;
+ thd->lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
res= Sql_cmd_optimize_table::execute(thd);
@@ -722,7 +722,7 @@ bool Sql_cmd_alter_table_repair_partition::execute(THD *thd)
Flag that it is an ALTER command which administrates partitions, used
by ha_partition
*/
- thd->lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION;
+ thd->lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
res= Sql_cmd_repair_table::execute(thd);
@@ -746,8 +746,8 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
Flag that it is an ALTER command which administrates partitions, used
by ha_partition.
*/
- thd->lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION |
- Alter_info::ALTER_TRUNCATE_PARTITION;
+ thd->lex->alter_info.flags|= ALTER_ADMIN_PARTITION |
+ ALTER_TRUNCATE_PARTITION;
/* Fix the lock types (not the same as ordinary ALTER TABLE). */
first_table->lock_type= TL_WRITE;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 99084152cf2..cd368da934b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6098,10 +6098,9 @@ drop_create_field:
it.remove();
if (alter_info->create_list.is_empty())
{
- alter_info->flags&= ~Alter_info::ALTER_ADD_COLUMN;
+ alter_info->flags&= ~ALTER_PARSER_ADD_COLUMN;
if (alter_info->key_list.is_empty())
- alter_info->flags&= ~(Alter_info::ALTER_ADD_INDEX |
- Alter_info::ADD_FOREIGN_KEY);
+ alter_info->flags&= ~(ALTER_ADD_INDEX | ALTER_ADD_FOREIGN_KEY);
}
}
}
@@ -6137,10 +6136,9 @@ drop_create_field:
it.remove();
if (alter_info->create_list.is_empty())
{
- alter_info->flags&= ~(Alter_info::ALTER_ADD_COLUMN |
- Alter_info::ALTER_CHANGE_COLUMN);
+ alter_info->flags&= ~(ALTER_PARSER_ADD_COLUMN | ALTER_CHANGE_COLUMN);
if (alter_info->key_list.is_empty())
- alter_info->flags&= ~Alter_info::ALTER_ADD_INDEX;
+ alter_info->flags&= ~ALTER_ADD_INDEX;
}
}
}
@@ -6174,7 +6172,7 @@ drop_create_field:
it.remove();
if (alter_info->alter_list.is_empty())
{
- alter_info->flags&= ~(Alter_info::ALTER_CHANGE_COLUMN_DEFAULT);
+ alter_info->flags&= ~(ALTER_CHANGE_COLUMN_DEFAULT);
}
}
}
@@ -6281,9 +6279,9 @@ drop_create_field:
drop->type_name(), drop->name);
drop_it.remove();
if (alter_info->drop_list.is_empty())
- alter_info->flags&= ~(Alter_info::ALTER_DROP_COLUMN |
- Alter_info::ALTER_DROP_INDEX |
- Alter_info::DROP_FOREIGN_KEY);
+ alter_info->flags&= ~(ALTER_PARSER_DROP_COLUMN |
+ ALTER_DROP_INDEX |
+ ALTER_DROP_FOREIGN_KEY);
}
}
}
@@ -6382,8 +6380,7 @@ remove_key:
key_it.remove();
}
if (alter_info->key_list.is_empty())
- alter_info->flags&= ~(Alter_info::ALTER_ADD_INDEX |
- Alter_info::ADD_FOREIGN_KEY);
+ alter_info->flags&= ~(ALTER_ADD_INDEX | ALTER_ADD_FOREIGN_KEY);
}
else
{
@@ -6394,7 +6391,7 @@ remove_key:
if (ad != NULL)
{
// Adding the index into the drop list for replacing
- alter_info->flags |= Alter_info::ALTER_DROP_INDEX;
+ alter_info->flags |= ALTER_DROP_INDEX;
alter_info->drop_list.push_back(ad, thd->mem_root);
}
}
@@ -6407,7 +6404,7 @@ remove_key:
if (tab_part_info)
{
/* ALTER TABLE ADD PARTITION IF NOT EXISTS */
- if ((alter_info->flags & Alter_info::ALTER_ADD_PARTITION) &&
+ if ((alter_info->flags & ALTER_ADD_PARTITION) &&
thd->lex->create_info.if_not_exists())
{
partition_info *alt_part_info= thd->lex->part_info;
@@ -6423,7 +6420,7 @@ remove_key:
ER_SAME_NAME_PARTITION,
ER_THD(thd, ER_SAME_NAME_PARTITION),
pe->partition_name);
- alter_info->flags&= ~Alter_info::ALTER_ADD_PARTITION;
+ alter_info->flags&= ~ALTER_ADD_PARTITION;
thd->work_part_info= NULL;
break;
}
@@ -6431,7 +6428,7 @@ remove_key:
}
}
/* ALTER TABLE DROP PARTITION IF EXISTS */
- if ((alter_info->flags & Alter_info::ALTER_DROP_PARTITION) &&
+ if ((alter_info->flags & ALTER_DROP_PARTITION) &&
thd->lex->if_exists())
{
List_iterator<const char> names_it(alter_info->partition_names);
@@ -6457,7 +6454,7 @@ remove_key:
}
}
if (alter_info->partition_names.elements == 0)
- alter_info->flags&= ~Alter_info::ALTER_DROP_PARTITION;
+ alter_info->flags&= ~ALTER_DROP_PARTITION;
}
}
#endif /*WITH_PARTITION_STORAGE_ENGINE*/
@@ -6487,7 +6484,7 @@ remove_key:
"CHECK", check->name.str);
it.remove();
if (alter_info->check_constraint_list.elements == 0)
- alter_info->flags&= ~Alter_info::ALTER_ADD_CHECK_CONSTRAINT;
+ alter_info->flags&= ~ALTER_ADD_CHECK_CONSTRAINT;
break;
}
@@ -6580,6 +6577,7 @@ static bool fill_alter_inplace_info(THD *thd,
uint candidate_key_count= 0;
Alter_info *alter_info= ha_alter_info->alter_info;
DBUG_ENTER("fill_alter_inplace_info");
+ DBUG_PRINT("info", ("alter_info->flags: %llu", alter_info->flags));
/* Allocate result buffers. */
if (! (ha_alter_info->index_drop_buffer=
@@ -6590,61 +6588,47 @@ static bool fill_alter_inplace_info(THD *thd,
DBUG_RETURN(true);
/*
+ Copy parser flags, but remove some flags that handlers doesn't
+ need to care about (old engines may not ignore these parser flags).
+ ALTER_RENAME_COLUMN is replaced by ALTER_COLUMN_NAME.
+ ALTER_CHANGE_COLUMN_DEFAULT is replaced by ALTER_CHANGE_COLUMN
+ ALTER_PARSE_ADD_COLUMN, ALTER_PARSE_DROP_COLUMN, ALTER_ADD_INDEX and
+ ALTER_DROP_INDEX are replaced with versions that have higher granuality.
+ */
+
+ ha_alter_info->handler_flags|= (alter_info->flags &
+ ~(ALTER_ADD_INDEX |
+ ALTER_DROP_INDEX |
+ ALTER_PARSER_ADD_COLUMN |
+ ALTER_PARSER_DROP_COLUMN |
+ ALTER_COLUMN_ORDER |
+ ALTER_RENAME_COLUMN |
+ ALTER_CHANGE_COLUMN |
+ ALTER_ADMIN_PARTITION |
+ ALTER_REBUILD_PARTITION |
+ ALTER_EXCHANGE_PARTITION |
+ ALTER_TRUNCATE_PARTITION |
+ ALTER_COLUMN_UNVERSIONED));
+ /*
Comparing new and old default values of column is cumbersome.
So instead of using such a comparison for detecting if default
has really changed we rely on flags set by parser to get an
approximate value for storage engine flag.
*/
- if (alter_info->flags & (Alter_info::ALTER_CHANGE_COLUMN |
- Alter_info::ALTER_CHANGE_COLUMN_DEFAULT))
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_DEFAULT;
- if (alter_info->flags & Alter_info::ADD_FOREIGN_KEY)
- ha_alter_info->handler_flags|= Alter_inplace_info::ADD_FOREIGN_KEY;
- if (alter_info->flags & Alter_info::DROP_FOREIGN_KEY)
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_FOREIGN_KEY;
- if (alter_info->flags & Alter_info::ALTER_OPTIONS)
- ha_alter_info->handler_flags|= Alter_inplace_info::CHANGE_CREATE_OPTION;
- if (alter_info->flags & Alter_info::ALTER_RENAME)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_RENAME;
- /* Check partition changes */
- if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION)
- ha_alter_info->handler_flags|= Alter_inplace_info::ADD_PARTITION;
- if (alter_info->flags & Alter_info::ALTER_DROP_PARTITION)
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_PARTITION;
- if (alter_info->flags & Alter_info::ALTER_PARTITION)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_PARTITION;
- if (alter_info->flags & Alter_info::ALTER_COALESCE_PARTITION)
- ha_alter_info->handler_flags|= Alter_inplace_info::COALESCE_PARTITION;
- if (alter_info->flags & Alter_info::ALTER_REORGANIZE_PARTITION)
- ha_alter_info->handler_flags|= Alter_inplace_info::REORGANIZE_PARTITION;
- if (alter_info->flags & Alter_info::ALTER_TABLE_REORG)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_TABLE_REORG;
- if (alter_info->flags & Alter_info::ALTER_REMOVE_PARTITIONING)
- 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 (alter_info->flags & Alter_info::ALTER_ADD_CHECK_CONSTRAINT)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_ADD_CHECK_CONSTRAINT;
- if (alter_info->flags & Alter_info::ALTER_DROP_CHECK_CONSTRAINT)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_DROP_CHECK_CONSTRAINT;
- if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_DROP)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_DROP_HISTORICAL;
- if (alter_info->flags & Alter_info::ALTER_COLUMN_UNVERSIONED)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_UNVERSIONED;
- if (alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_ADD_SYSTEM_VERSIONING;
- if (alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_DROP_SYSTEM_VERSIONING;
+ if (alter_info->flags & ALTER_CHANGE_COLUMN)
+ ha_alter_info->handler_flags|= ALTER_COLUMN_DEFAULT;
/*
If we altering table with old VARCHAR fields we will be automatically
upgrading VARCHAR column types.
*/
if (table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar)
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_STORED_COLUMN_TYPE;
+ ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
+
+ if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_DROP)
+ ha_alter_info->handler_flags|= ALTER_DROP_HISTORICAL;
+
+ DBUG_PRINT("info", ("handler_flags: %llu", ha_alter_info->handler_flags));
/*
Go through fields in old version of table and detect changes to them.
@@ -6690,11 +6674,9 @@ static bool fill_alter_inplace_info(THD *thd,
case IS_EQUAL_NO:
/* New column type is incompatible with old one. */
if (field->stored_in_db())
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_STORED_COLUMN_TYPE;
+ ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
else
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_VIRTUAL_COLUMN_TYPE;
+ ha_alter_info->handler_flags|= ALTER_VIRTUAL_COLUMN_TYPE;
if (table->s->tmp_table == NO_TMP_TABLE)
{
delete_statistics_for_column(thd, table, field);
@@ -6733,38 +6715,35 @@ static bool fill_alter_inplace_info(THD *thd,
be carried out by simply updating data dictionary without changing
actual data (for example, VARCHAR(300) is changed to VARCHAR(400)).
*/
- ha_alter_info->handler_flags|= Alter_inplace_info::
- ALTER_COLUMN_EQUAL_PACK_LENGTH;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_EQUAL_PACK_LENGTH;
break;
default:
DBUG_ASSERT(0);
/* Safety. */
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_STORED_COLUMN_TYPE;
+ ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
}
if (field->vcol_info || new_field->vcol_info)
{
/* base <-> virtual or stored <-> virtual */
if (field->stored_in_db() != new_field->stored_in_db())
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_STORED_COLUMN_TYPE |
- Alter_inplace_info::ALTER_VIRTUAL_COLUMN_TYPE;
+ ha_alter_info->handler_flags|= ( ALTER_STORED_COLUMN_TYPE |
+ ALTER_VIRTUAL_COLUMN_TYPE);
if (field->vcol_info && new_field->vcol_info)
{
bool value_changes= is_equal == IS_EQUAL_NO;
- Alter_inplace_info::HA_ALTER_FLAGS alter_expr;
+ alter_table_operations alter_expr;
if (field->stored_in_db())
- alter_expr= Alter_inplace_info::ALTER_STORED_GCOL_EXPR;
+ alter_expr= ALTER_STORED_GCOL_EXPR;
else
- alter_expr= Alter_inplace_info::ALTER_VIRTUAL_GCOL_EXPR;
+ alter_expr= ALTER_VIRTUAL_GCOL_EXPR;
if (!field->vcol_info->is_equal(new_field->vcol_info))
{
ha_alter_info->handler_flags|= alter_expr;
value_changes= true;
}
- if ((ha_alter_info->handler_flags & Alter_inplace_info::ALTER_COLUMN_DEFAULT)
+ if ((ha_alter_info->handler_flags & ALTER_COLUMN_DEFAULT)
&& !(ha_alter_info->handler_flags & alter_expr))
{ /*
a DEFAULT value of a some column was changed. see if this vcol
@@ -6783,15 +6762,13 @@ static bool fill_alter_inplace_info(THD *thd,
field->flags & PART_KEY_FLAG)
{
if (value_changes)
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_COLUMN_VCOL;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_VCOL;
else
maybe_alter_vcol= true;
}
}
else /* base <-> stored */
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_STORED_COLUMN_TYPE;
+ ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
}
/* Check if field was renamed */
@@ -6799,7 +6776,7 @@ static bool fill_alter_inplace_info(THD *thd,
&new_field->field_name))
{
field->flags|= FIELD_IS_RENAMED;
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NAME;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_NAME;
rename_column_in_stat_tables(thd, table, field,
new_field->field_name.str);
}
@@ -6809,11 +6786,9 @@ static bool fill_alter_inplace_info(THD *thd,
(uint) (field->flags & NOT_NULL_FLAG))
{
if (new_field->flags & NOT_NULL_FLAG)
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_NOT_NULLABLE;
else
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_COLUMN_NULLABLE;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_NULLABLE;
}
/*
@@ -6827,30 +6802,26 @@ static bool fill_alter_inplace_info(THD *thd,
if (field->stored_in_db())
{
if (field_stored_index != new_field_stored_index)
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_STORED_COLUMN_ORDER;
+ ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_ORDER;
}
else
{
if (field->field_index != new_field_index)
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_VIRTUAL_COLUMN_ORDER;
+ ha_alter_info->handler_flags|= ALTER_VIRTUAL_COLUMN_ORDER;
}
/* Detect changes in storage type of column */
if (new_field->field_storage_type() != field->field_storage_type())
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_COLUMN_STORAGE_TYPE;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_STORAGE_TYPE;
/* Detect changes in column format of column */
if (new_field->column_format() != field->column_format())
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ALTER_COLUMN_COLUMN_FORMAT;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_COLUMN_FORMAT;
if (engine_options_differ(field->option_struct, new_field->option_struct,
table->file->ht->field_options))
{
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_OPTION;
+ ha_alter_info->handler_flags|= ALTER_COLUMN_OPTION;
ha_alter_info->create_info->fields_option_struct[f_ptr - table->field]=
new_field->option_struct;
}
@@ -6861,9 +6832,9 @@ static bool fill_alter_inplace_info(THD *thd,
// Field is not present in new version of table and therefore was dropped.
field->flags|= FIELD_IS_DROPPED;
if (field->stored_in_db())
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_STORED_COLUMN;
+ ha_alter_info->handler_flags|= ALTER_DROP_STORED_COLUMN;
else
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_VIRTUAL_COLUMN;
+ ha_alter_info->handler_flags|= ALTER_DROP_VIRTUAL_COLUMN;
}
}
@@ -6875,12 +6846,11 @@ static bool fill_alter_inplace_info(THD *thd,
(FIXME), so let's just say that a vcol *might* be affected if any other
column was altered.
*/
- if (ha_alter_info->handler_flags &
- ( Alter_inplace_info::ALTER_STORED_COLUMN_TYPE
- | Alter_inplace_info::ALTER_VIRTUAL_COLUMN_TYPE
- | Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE
- | Alter_inplace_info::ALTER_COLUMN_OPTION ))
- ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
+ if (ha_alter_info->handler_flags & (ALTER_STORED_COLUMN_TYPE |
+ ALTER_VIRTUAL_COLUMN_TYPE |
+ ALTER_COLUMN_NOT_NULLABLE |
+ ALTER_COLUMN_OPTION))
+ ha_alter_info->handler_flags|= ALTER_COLUMN_VCOL;
}
new_field_it.init(alter_info->create_list);
@@ -6890,15 +6860,14 @@ static bool fill_alter_inplace_info(THD *thd,
{
// Field is not present in old version of table and therefore was added.
if (new_field->vcol_info)
+ {
if (new_field->stored_in_db())
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ADD_STORED_GENERATED_COLUMN;
+ ha_alter_info->handler_flags|= ALTER_ADD_STORED_GENERATED_COLUMN;
else
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ADD_VIRTUAL_COLUMN;
+ ha_alter_info->handler_flags|= ALTER_ADD_VIRTUAL_COLUMN;
+ }
else
- ha_alter_info->handler_flags|=
- Alter_inplace_info::ADD_STORED_BASE_COLUMN;
+ ha_alter_info->handler_flags|= ALTER_ADD_STORED_BASE_COLUMN;
}
}
@@ -7080,18 +7049,18 @@ static bool fill_alter_inplace_info(THD *thd,
*/
if ((uint) (table_key - table->key_info) == table->s->primary_key)
{
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_PK_INDEX;
+ ha_alter_info->handler_flags|= ALTER_DROP_PK_INDEX;
candidate_key_count--;
}
else
{
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_UNIQUE_INDEX;
+ ha_alter_info->handler_flags|= ALTER_DROP_UNIQUE_INDEX;
if (is_candidate_key(table_key))
candidate_key_count--;
}
}
else
- ha_alter_info->handler_flags|= Alter_inplace_info::DROP_INDEX;
+ ha_alter_info->handler_flags|= ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX;
}
/* Now figure out what kind of indexes we are adding. */
@@ -7110,20 +7079,21 @@ static bool fill_alter_inplace_info(THD *thd,
{
/* Candidate key or primary key! */
if (candidate_key_count == 0 || is_pk)
- ha_alter_info->handler_flags|= Alter_inplace_info::ADD_PK_INDEX;
+ ha_alter_info->handler_flags|= ALTER_ADD_PK_INDEX;
else
- ha_alter_info->handler_flags|= Alter_inplace_info::ADD_UNIQUE_INDEX;
+ ha_alter_info->handler_flags|= ALTER_ADD_UNIQUE_INDEX;
candidate_key_count++;
}
else
{
- ha_alter_info->handler_flags|= Alter_inplace_info::ADD_UNIQUE_INDEX;
+ ha_alter_info->handler_flags|= ALTER_ADD_UNIQUE_INDEX;
}
}
else
- ha_alter_info->handler_flags|= Alter_inplace_info::ADD_INDEX;
+ ha_alter_info->handler_flags|= ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX;
}
+ DBUG_PRINT("exit", ("handler_flags: %llu", ha_alter_info->handler_flags));
DBUG_RETURN(false);
}
@@ -7425,8 +7395,7 @@ 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_ORDER |
- Alter_info::ALTER_KEYS_ONOFF))
+ if (alter_info->flags & (ALTER_ORDER | ALTER_KEYS_ONOFF))
DBUG_RETURN(true);
/*
@@ -7527,7 +7496,7 @@ static bool mysql_inplace_alter_table(THD *thd,
inplace_supported == HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE) &&
(thd->locked_tables_mode == LTM_LOCK_TABLES ||
thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) ||
- alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE)
+ alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE)
{
if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
goto cleanup;
@@ -8003,7 +7972,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
*/
if (drop && field->invisible < INVISIBLE_SYSTEM &&
!(field->flags & VERS_SYSTEM_FIELD &&
- !(alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING)))
+ !(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)))
{
/* Reset auto_increment value if it was dropped */
if (MTYP_TYPENR(field->unireg_check) == Field::NEXT_NUMBER &&
@@ -8024,7 +7993,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
/* invisible versioning column is dropped automatically on DROP SYSTEM VERSIONING */
if (!drop && field->invisible >= INVISIBLE_SYSTEM &&
field->flags & VERS_SYSTEM_FIELD &&
- alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING)
+ alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)
{
if (table->s->tmp_table == NO_TMP_TABLE)
(void) delete_statistics_for_column(thd, table, field);
@@ -8035,7 +8004,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
If we are doing a rename of a column, update all references in virtual
column expressions, constraints and defaults to use the new column name
*/
- if (alter_info->flags & Alter_info::ALTER_RENAME_COLUMN)
+ if (alter_info->flags & ALTER_RENAME_COLUMN)
{
if (field->vcol_info)
field->vcol_info->expr->walk(&Item::rename_fields_processor, 1,
@@ -8083,7 +8052,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
def_it.remove();
}
}
- else if (alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING &&
+ else if (alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING &&
field->flags & VERS_SYSTEM_FIELD &&
field->invisible < INVISIBLE_SYSTEM)
{
@@ -8094,12 +8063,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
else if (drop && field->invisible < INVISIBLE_SYSTEM &&
field->flags & VERS_SYSTEM_FIELD &&
- !(alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING))
+ !(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING))
{
/* "dropping" a versioning field only hides it from the user */
def= new (thd->mem_root) Create_field(thd, field, field);
def->invisible= INVISIBLE_SYSTEM;
- alter_info->flags|= Alter_info::ALTER_CHANGE_COLUMN;
+ alter_info->flags|= ALTER_CHANGE_COLUMN;
if (field->flags & VERS_SYS_START_FLAG)
create_info->vers_info.as_row.start= def->field_name= Vers_parse_info::default_start;
else
@@ -8136,7 +8105,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
dropped_sys_vers_fields &= VERS_SYSTEM_FIELD;
if ((dropped_sys_vers_fields ||
- alter_info->flags & Alter_info::ALTER_DROP_PERIOD) &&
+ alter_info->flags & ALTER_DROP_PERIOD) &&
dropped_sys_vers_fields != VERS_SYSTEM_FIELD)
{
StringBuffer<NAME_LEN*3> tmp;
@@ -8147,8 +8116,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr());
goto err;
}
- alter_info->flags &=
- ~(Alter_info::ALTER_DROP_PERIOD | Alter_info::ALTER_ADD_PERIOD);
+ alter_info->flags &= ~(ALTER_DROP_PERIOD | ALTER_ADD_PERIOD);
def_it.rewind();
while ((def=def_it++)) // Add new columns
{
@@ -8194,7 +8162,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
alter_ctx->error_if_not_empty= TRUE;
}
if (def->flags & VERS_SYSTEM_FIELD &&
- !(alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING))
+ !(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING))
{
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str);
goto err;
@@ -8545,7 +8513,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
}
- if (table->versioned() && !(alter_info->flags & Alter_info::ALTER_DROP_SYSTEM_VERSIONING) &&
+ if (table->versioned() && !(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING) &&
new_create_list.elements == VERSIONING_FIELDS)
{
my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0), table->s->table_name.str);
@@ -9169,7 +9137,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
- if (alter_info->flags & Alter_info::ALTER_PARTITION)
+ if (alter_info->flags & ALTER_PARTITION)
{
my_error(ER_WRONG_USAGE, MYF(0), "PARTITION", "log table");
DBUG_RETURN(true);
@@ -9240,7 +9208,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
if (table_list->table->versioned(VERS_TRX_ID) &&
alter_info->requested_algorithm ==
- Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT &&
+ Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT &&
!table_list->table->s->partition_info_str)
{
// Changle default ALGORITHM to COPY for INNODB
@@ -9380,7 +9348,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
}
if ((create_info->db_type != table->s->db_type() ||
- alter_info->flags & Alter_info::ALTER_PARTITION) &&
+ alter_info->flags & ALTER_PARTITION) &&
!table->file->can_switch_engines())
{
my_error(ER_ROW_IS_REFERENCED, MYF(0));
@@ -9395,7 +9363,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
create_info->db_type is set here, check to parent table access is delayed
till this point for the alter operation.
*/
- if ((alter_info->flags & Alter_info::ADD_FOREIGN_KEY) &&
+ if ((alter_info->flags & ALTER_ADD_FOREIGN_KEY) &&
check_fk_parent_table_access(thd, create_info, alter_info, new_db->str))
DBUG_RETURN(true);
@@ -9469,8 +9437,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
Test if we are only doing RENAME or KEYS ON/OFF. This works
as we are testing if flags == 0 above.
*/
- if (!(alter_info->flags & ~(Alter_info::ALTER_RENAME |
- Alter_info::ALTER_KEYS_ONOFF)) &&
+ if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) &&
alter_info->requested_algorithm !=
Alter_info::ALTER_TABLE_ALGORITHM_COPY) // No need to touch frm.
{
@@ -9608,7 +9575,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
*/
if (create_info->db_type == table->s->db_type() &&
create_info->used_fields & HA_CREATE_USED_ENGINE)
- alter_info->flags|= Alter_info::ALTER_RECREATE;
+ alter_info->flags|= ALTER_RECREATE;
/*
If the old table had partitions and we are doing ALTER TABLE ...
@@ -9732,7 +9699,15 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
if (fill_alter_inplace_info(thd, table, varchar, &ha_alter_info))
goto err_new_table_cleanup;
- if (ha_alter_info.handler_flags == 0)
+ /*
+ We can ignore ALTER_COLUMN_ORDER and instead check
+ ALTER_STORED_COLUMN_ORDER & ALTER_VIRTUAL_COLUMN_ORDER. This
+ is ok as ALTER_COLUMN_ORDER may be wrong if we use AFTER last_field
+ ALTER_COLUMN_NAME is set if field really was renamed.
+ */
+
+ if (!(ha_alter_info.handler_flags &
+ ~(ALTER_COLUMN_ORDER | ALTER_RENAME_COLUMN)))
{
/*
No-op ALTER, no need to call handler API functions.
@@ -10139,7 +10114,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
{
DBUG_ASSERT(alter_info && table_list);
VTMD_rename vtmd(*table_list);
- bool rc= alter_info->flags & Alter_info::ALTER_RENAME ?
+ bool rc= alter_info->flags & ALTER_RENAME ?
vtmd.try_rename(thd, alter_ctx.new_db.str, alter_ctx.new_alias.str, backup_name.str) :
vtmd.update(thd, backup_name.str);
if (rc)
@@ -10729,8 +10704,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy)
create_info.row_type=ROW_TYPE_NOT_USED;
create_info.default_table_charset=default_charset_info;
/* Force alter table to recreate table */
- alter_info.flags= (Alter_info::ALTER_CHANGE_COLUMN |
- Alter_info::ALTER_RECREATE);
+ alter_info.flags= (ALTER_CHANGE_COLUMN | ALTER_RECREATE);
if (table_copy)
alter_info.requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 002ecc65478..538f067f577 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -710,7 +710,7 @@ bool LEX::add_alter_list(const char *name, Virtual_column_info *expr,
if (ac == NULL)
return true;
alter_info.alter_list.push_back(ac, mem_root);
- alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN_DEFAULT;
+ alter_info.flags|= ALTER_CHANGE_COLUMN_DEFAULT;
return false;
}
@@ -5141,7 +5141,7 @@ partitioning:
}
if (lex->sql_command == SQLCOM_ALTER_TABLE)
{
- lex->alter_info.flags|= Alter_info::ALTER_PARTITION;
+ lex->alter_info.flags|= ALTER_PARTITION;
}
}
partition
@@ -6282,7 +6282,7 @@ versioning_option:
}
else
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_SYSTEM_VERSIONING;
+ Lex->alter_info.flags|= ALTER_ADD_SYSTEM_VERSIONING;
Lex->create_info.options|= HA_VERSIONED_TABLE;
}
}
@@ -6474,7 +6474,7 @@ key_def:
lex->option_list= NULL;
/* Only used for ALTER TABLE. Ignored otherwise. */
- lex->alter_info.flags|= Alter_info::ADD_FOREIGN_KEY;
+ lex->alter_info.flags|= ALTER_ADD_FOREIGN_KEY;
}
;
@@ -6678,13 +6678,13 @@ vcol_attribute:
{
LEX *lex=Lex;
lex->last_field->flags|= UNIQUE_KEY_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| UNIQUE_SYM KEY_SYM
{
LEX *lex=Lex;
lex->last_field->flags|= UNIQUE_KEY_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
| INVISIBLE_SYM
@@ -7078,7 +7078,7 @@ attribute:
{
LEX *lex=Lex;
lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_KEY_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| COLLATE_SYM collation_name
{
@@ -7109,7 +7109,7 @@ asrow_attribute:
{
LEX *lex=Lex;
lex->last_field->flags|= PRI_KEY_FLAG | NOT_NULL_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| vcol_attribute
;
@@ -7153,13 +7153,13 @@ serial_attribute:
with_or_without_system:
WITH_SYSTEM_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_COLUMN_UNVERSIONED;
+ Lex->alter_info.flags|= ALTER_COLUMN_UNVERSIONED;
Lex->create_info.vers_info.versioned_fields= true;
$$= Column_definition::WITH_VERSIONING;
}
| WITHOUT SYSTEM
{
- Lex->alter_info.flags|= Alter_info::ALTER_COLUMN_UNVERSIONED;
+ Lex->alter_info.flags|= ALTER_COLUMN_UNVERSIONED;
Lex->create_info.vers_info.unversioned_fields= true;
$$= Column_definition::WITHOUT_VERSIONING;
}
@@ -7895,7 +7895,7 @@ alter_commands:
| add_partition_rule
| DROP PARTITION_SYM opt_if_exists alt_part_name_list
{
- Lex->alter_info.flags|= Alter_info::ALTER_DROP_PARTITION;
+ Lex->alter_info.flags|= ALTER_DROP_PARTITION;
DBUG_ASSERT(!Lex->if_exists());
Lex->create_info.add($3);
}
@@ -7903,7 +7903,7 @@ alter_commands:
all_or_alt_part_name_list
{
LEX *lex= Lex;
- lex->alter_info.flags|= Alter_info::ALTER_REBUILD_PARTITION;
+ lex->alter_info.flags|= ALTER_REBUILD_PARTITION;
lex->no_write_to_binlog= $3;
}
| OPTIMIZE PARTITION_SYM opt_no_write_to_binlog
@@ -7958,7 +7958,7 @@ alter_commands:
| COALESCE PARTITION_SYM opt_no_write_to_binlog real_ulong_num
{
LEX *lex= Lex;
- lex->alter_info.flags|= Alter_info::ALTER_COALESCE_PARTITION;
+ lex->alter_info.flags|= ALTER_COALESCE_PARTITION;
lex->no_write_to_binlog= $3;
lex->alter_info.num_parts= $4;
}
@@ -7984,7 +7984,7 @@ alter_commands:
MYSQL_YYABORT;
}
lex->name= $6->table;
- lex->alter_info.flags|= Alter_info::ALTER_EXCHANGE_PARTITION;
+ lex->alter_info.flags|= ALTER_EXCHANGE_PARTITION;
if (!lex->select_lex.add_table_to_list(thd, $6, NULL,
TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
@@ -8001,14 +8001,14 @@ alter_commands:
remove_partitioning:
REMOVE_SYM PARTITIONING_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_REMOVE_PARTITIONING;
+ Lex->alter_info.flags|= ALTER_REMOVE_PARTITIONING;
}
;
all_or_alt_part_name_list:
ALL
{
- Lex->alter_info.flags|= Alter_info::ALTER_ALL_PARTITION;
+ Lex->alter_info.flags|= ALTER_ALL_PARTITION;
}
| alt_part_name_list
;
@@ -8024,7 +8024,7 @@ add_partition_rule:
mem_alloc_error(sizeof(partition_info));
MYSQL_YYABORT;
}
- lex->alter_info.flags|= Alter_info::ALTER_ADD_PARTITION;
+ lex->alter_info.flags|= ALTER_ADD_PARTITION;
DBUG_ASSERT(!Lex->create_info.if_not_exists());
lex->create_info.set($3);
lex->no_write_to_binlog= $4;
@@ -8064,11 +8064,11 @@ reorg_partition_rule:
reorg_parts_rule:
/* empty */
{
- Lex->alter_info.flags|= Alter_info::ALTER_TABLE_REORG;
+ Lex->alter_info.flags|= ALTER_TABLE_REORG;
}
| alt_part_name_list
{
- Lex->alter_info.flags|= Alter_info::ALTER_REORGANIZE_PARTITION;
+ Lex->alter_info.flags|= ALTER_REORGANIZE_PARTITION;
}
INTO '(' part_def_list ')'
{
@@ -8105,46 +8105,45 @@ alter_list:
add_column:
ADD opt_column opt_if_not_exists_table_element
- {
- LEX *lex=Lex;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_COLUMN;
- }
;
alter_list_item:
add_column column_def opt_place
{
- Lex->create_last_non_select_table= Lex->last_table();
+ LEX *lex=Lex;
+ lex->create_last_non_select_table= lex->last_table();
+ lex->alter_info.flags|= ALTER_PARSER_ADD_COLUMN;
$2->after= $3;
}
| ADD key_def
{
Lex->create_last_non_select_table= Lex->last_table();
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ Lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| ADD period_for_system_time
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_PERIOD;
+ Lex->alter_info.flags|= ALTER_ADD_PERIOD;
}
| add_column '(' create_field_list ')'
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_COLUMN |
- Alter_info::ALTER_ADD_INDEX;
+ LEX *lex=Lex;
+ lex->alter_info.flags|= ALTER_PARSER_ADD_COLUMN;
+ if (!lex->alter_info.key_list.is_empty())
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| ADD constraint_def
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_CHECK_CONSTRAINT;
+ Lex->alter_info.flags|= ALTER_ADD_CHECK_CONSTRAINT;
}
| ADD CONSTRAINT IF_SYM not EXISTS field_ident check_constraint
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_CHECK_CONSTRAINT;
+ Lex->alter_info.flags|= ALTER_ADD_CHECK_CONSTRAINT;
Lex->add_constraint(&$6, $7, TRUE);
}
| CHANGE opt_column opt_if_exists_table_element field_ident
field_spec opt_place
{
- Lex->alter_info.flags|= (Alter_info::ALTER_CHANGE_COLUMN |
- Alter_info::ALTER_RENAME_COLUMN);
+ Lex->alter_info.flags|= ALTER_CHANGE_COLUMN | ALTER_RENAME_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
$5->change= $4;
$5->after= $6;
@@ -8152,7 +8151,7 @@ alter_list_item:
| MODIFY_SYM opt_column opt_if_exists_table_element
field_spec opt_place
{
- Lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN;
+ Lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
$4->change= $4->field_name;
$4->after= $5;
@@ -8165,7 +8164,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_COLUMN;
+ lex->alter_info.flags|= ALTER_PARSER_DROP_COLUMN;
}
| DROP CONSTRAINT opt_if_exists_table_element field_ident
{
@@ -8176,7 +8175,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_CHECK_CONSTRAINT;
+ lex->alter_info.flags|= ALTER_DROP_CHECK_CONSTRAINT;
}
| DROP FOREIGN KEY_SYM opt_if_exists_table_element field_ident
{
@@ -8186,7 +8185,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::DROP_FOREIGN_KEY;
+ lex->alter_info.flags|= ALTER_DROP_FOREIGN_KEY;
}
| DROP PRIMARY_SYM KEY_SYM
{
@@ -8197,7 +8196,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX;
+ lex->alter_info.flags|= ALTER_DROP_INDEX;
}
| DROP key_or_index opt_if_exists_table_element field_ident
{
@@ -8207,19 +8206,19 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX;
+ lex->alter_info.flags|= ALTER_DROP_INDEX;
}
| DISABLE_SYM KEYS
{
LEX *lex=Lex;
lex->alter_info.keys_onoff= Alter_info::DISABLE;
- lex->alter_info.flags|= Alter_info::ALTER_KEYS_ONOFF;
+ lex->alter_info.flags|= ALTER_KEYS_ONOFF;
}
| ENABLE_SYM KEYS
{
LEX *lex=Lex;
lex->alter_info.keys_onoff= Alter_info::ENABLE;
- lex->alter_info.flags|= Alter_info::ALTER_KEYS_ONOFF;
+ lex->alter_info.flags|= ALTER_KEYS_ONOFF;
}
| ALTER opt_column opt_if_exists_table_element field_ident SET DEFAULT column_default_expr
{
@@ -8244,7 +8243,7 @@ alter_list_item:
($3->db.str && check_db_name((LEX_STRING*) &$3->db)))
my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $3->table.str));
lex->name= $3->table;
- lex->alter_info.flags|= Alter_info::ALTER_RENAME;
+ lex->alter_info.flags|= ALTER_RENAME;
}
| CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate
{
@@ -8258,12 +8257,12 @@ alter_list_item:
$5->name, $4->csname));
if (Lex->create_info.add_alter_list_item_convert_to_charset($5))
MYSQL_YYABORT;
- Lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
+ Lex->alter_info.flags|= ALTER_OPTIONS;
}
| create_table_options_space_separated
{
LEX *lex=Lex;
- lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
+ lex->alter_info.flags|= ALTER_OPTIONS;
if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) &&
!lex->create_info.db_type)
{
@@ -8272,27 +8271,27 @@ alter_list_item:
}
| FORCE_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_RECREATE;
+ Lex->alter_info.flags|= ALTER_RECREATE;
}
| alter_order_clause
{
LEX *lex=Lex;
- lex->alter_info.flags|= Alter_info::ALTER_ORDER;
+ lex->alter_info.flags|= ALTER_ORDER;
}
| alter_algorithm_option
| alter_lock_option
| ADD SYSTEM VERSIONING_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_SYSTEM_VERSIONING;
+ Lex->alter_info.flags|= ALTER_ADD_SYSTEM_VERSIONING;
Lex->create_info.options|= HA_VERSIONED_TABLE;
}
| DROP SYSTEM VERSIONING_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_DROP_SYSTEM_VERSIONING;
+ Lex->alter_info.flags|= ALTER_DROP_SYSTEM_VERSIONING;
}
| DROP PERIOD_SYM FOR_SYSTEM_TIME_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_DROP_PERIOD;
+ Lex->alter_info.flags|= ALTER_DROP_PERIOD;
}
;
@@ -8373,13 +8372,13 @@ opt_place:
| AFTER_SYM ident
{
$$= $2;
- Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
+ Lex->alter_info.flags |= ALTER_COLUMN_ORDER;
}
| FIRST_SYM
{
$$.str= first_keyword;
$$.length= 5; /* Length of "first" */
- Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
+ Lex->alter_info.flags |= ALTER_COLUMN_ORDER;
}
;
@@ -8919,7 +8918,7 @@ preload_keys_parts:
adm_partition:
PARTITION_SYM have_partitioning
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION;
+ Lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
}
'(' all_or_alt_part_name_list ')'
;
@@ -12931,7 +12930,7 @@ drop:
MYSQL_YYABORT;
lex->sql_command= SQLCOM_DROP_INDEX;
lex->alter_info.reset();
- lex->alter_info.flags= Alter_info::ALTER_DROP_INDEX;
+ lex->alter_info.flags= ALTER_DROP_INDEX;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
if (!lex->current_select->add_table_to_list(thd, $6, NULL,
TL_OPTION_UPDATING,
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 2d171496337..e538763f136 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -5092,7 +5092,7 @@ partitioning:
}
if (lex->sql_command == SQLCOM_ALTER_TABLE)
{
- lex->alter_info.flags|= Alter_info::ALTER_PARTITION;
+ lex->alter_info.flags|= ALTER_PARTITION;
}
}
partition
@@ -6292,7 +6292,7 @@ key_def:
lex->option_list= NULL;
/* Only used for ALTER TABLE. Ignored otherwise. */
- lex->alter_info.flags|= Alter_info::ADD_FOREIGN_KEY;
+ lex->alter_info.flags|= ALTER_ADD_FOREIGN_KEY;
}
;
@@ -6438,13 +6438,13 @@ vcol_attribute:
{
LEX *lex=Lex;
lex->last_field->flags|= UNIQUE_KEY_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| UNIQUE_SYM KEY_SYM
{
LEX *lex=Lex;
lex->last_field->flags|= UNIQUE_KEY_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
| INVISIBLE_SYM
@@ -6934,7 +6934,7 @@ attribute:
{
LEX *lex=Lex;
lex->last_field->flags|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_KEY_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| COLLATE_SYM collation_name
{
@@ -6952,7 +6952,7 @@ serial_attribute:
{
LEX *lex=Lex;
lex->last_field->flags|= PRI_KEY_FLAG | NOT_NULL_FLAG;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| vcol_attribute
| IDENT_sys equal TEXT_STRING_sys
@@ -7727,7 +7727,7 @@ alter_commands:
| add_partition_rule
| DROP PARTITION_SYM opt_if_exists alt_part_name_list
{
- Lex->alter_info.flags|= Alter_info::ALTER_DROP_PARTITION;
+ Lex->alter_info.flags|= ALTER_DROP_PARTITION;
DBUG_ASSERT(!Lex->if_exists());
Lex->create_info.add($3);
}
@@ -7735,7 +7735,7 @@ alter_commands:
all_or_alt_part_name_list
{
LEX *lex= Lex;
- lex->alter_info.flags|= Alter_info::ALTER_REBUILD_PARTITION;
+ lex->alter_info.flags|= ALTER_REBUILD_PARTITION;
lex->no_write_to_binlog= $3;
}
| OPTIMIZE PARTITION_SYM opt_no_write_to_binlog
@@ -7790,7 +7790,7 @@ alter_commands:
| COALESCE PARTITION_SYM opt_no_write_to_binlog real_ulong_num
{
LEX *lex= Lex;
- lex->alter_info.flags|= Alter_info::ALTER_COALESCE_PARTITION;
+ lex->alter_info.flags|= ALTER_COALESCE_PARTITION;
lex->no_write_to_binlog= $3;
lex->alter_info.num_parts= $4;
}
@@ -7816,7 +7816,7 @@ alter_commands:
MYSQL_YYABORT;
}
lex->name= $6->table;
- lex->alter_info.flags|= Alter_info::ALTER_EXCHANGE_PARTITION;
+ lex->alter_info.flags|= ALTER_EXCHANGE_PARTITION;
if (!lex->select_lex.add_table_to_list(thd, $6, NULL,
TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
@@ -7833,14 +7833,14 @@ alter_commands:
remove_partitioning:
REMOVE_SYM PARTITIONING_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_REMOVE_PARTITIONING;
+ Lex->alter_info.flags|= ALTER_REMOVE_PARTITIONING;
}
;
all_or_alt_part_name_list:
ALL
{
- Lex->alter_info.flags|= Alter_info::ALTER_ALL_PARTITION;
+ Lex->alter_info.flags|= ALTER_ALL_PARTITION;
}
| alt_part_name_list
;
@@ -7856,7 +7856,7 @@ add_partition_rule:
mem_alloc_error(sizeof(partition_info));
MYSQL_YYABORT;
}
- lex->alter_info.flags|= Alter_info::ALTER_ADD_PARTITION;
+ lex->alter_info.flags|= ALTER_ADD_PARTITION;
DBUG_ASSERT(!Lex->create_info.if_not_exists());
lex->create_info.set($3);
lex->no_write_to_binlog= $4;
@@ -7896,11 +7896,11 @@ reorg_partition_rule:
reorg_parts_rule:
/* empty */
{
- Lex->alter_info.flags|= Alter_info::ALTER_TABLE_REORG;
+ Lex->alter_info.flags|= ALTER_TABLE_REORG;
}
| alt_part_name_list
{
- Lex->alter_info.flags|= Alter_info::ALTER_REORGANIZE_PARTITION;
+ Lex->alter_info.flags|= ALTER_REORGANIZE_PARTITION;
}
INTO '(' part_def_list ')'
{
@@ -7937,42 +7937,41 @@ alter_list:
add_column:
ADD opt_column opt_if_not_exists_table_element
- {
- LEX *lex=Lex;
- lex->alter_info.flags|= Alter_info::ALTER_ADD_COLUMN;
- }
;
alter_list_item:
add_column column_def opt_place
{
- Lex->create_last_non_select_table= Lex->last_table();
+ LEX *lex=Lex;
+ lex->create_last_non_select_table= lex->last_table();
+ lex->alter_info.flags|= ALTER_PARSER_ADD_COLUMN;
$2->after= $3;
}
| ADD key_def
{
Lex->create_last_non_select_table= Lex->last_table();
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
+ Lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| add_column '(' create_field_list ')'
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_COLUMN |
- Alter_info::ALTER_ADD_INDEX;
+ LEX *lex=Lex;
+ lex->alter_info.flags|= ALTER_PARSER_ADD_COLUMN;
+ if (!lex->alter_info.key_list.is_empty())
+ lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| ADD constraint_def
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_CHECK_CONSTRAINT;
+ Lex->alter_info.flags|= ALTER_ADD_CHECK_CONSTRAINT;
}
| ADD CONSTRAINT IF_SYM not EXISTS field_ident check_constraint
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADD_CHECK_CONSTRAINT;
+ Lex->alter_info.flags|= ALTER_ADD_CHECK_CONSTRAINT;
Lex->add_constraint(&$6, $7, TRUE);
}
| CHANGE opt_column opt_if_exists_table_element field_ident
field_spec opt_place
{
- Lex->alter_info.flags|= (Alter_info::ALTER_CHANGE_COLUMN |
- Alter_info::ALTER_RENAME_COLUMN);
+ Lex->alter_info.flags|= ALTER_CHANGE_COLUMN | ALTER_RENAME_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
$5->change= $4;
$5->after= $6;
@@ -7980,7 +7979,7 @@ alter_list_item:
| MODIFY_SYM opt_column opt_if_exists_table_element
field_spec opt_place
{
- Lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN;
+ Lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
$4->change= $4->field_name;
$4->after= $5;
@@ -7993,7 +7992,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_COLUMN;
+ lex->alter_info.flags|= ALTER_PARSER_DROP_COLUMN;
}
| DROP CONSTRAINT opt_if_exists_table_element field_ident
{
@@ -8004,7 +8003,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_CHECK_CONSTRAINT;
+ lex->alter_info.flags|= ALTER_DROP_CHECK_CONSTRAINT;
}
| DROP FOREIGN KEY_SYM opt_if_exists_table_element field_ident
{
@@ -8014,7 +8013,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::DROP_FOREIGN_KEY;
+ lex->alter_info.flags|= ALTER_DROP_FOREIGN_KEY;
}
| DROP PRIMARY_SYM KEY_SYM
{
@@ -8025,7 +8024,7 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX;
+ lex->alter_info.flags|= ALTER_DROP_INDEX;
}
| DROP key_or_index opt_if_exists_table_element field_ident
{
@@ -8035,19 +8034,19 @@ alter_list_item:
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
- lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX;
+ lex->alter_info.flags|= ALTER_DROP_INDEX;
}
| DISABLE_SYM KEYS
{
LEX *lex=Lex;
lex->alter_info.keys_onoff= Alter_info::DISABLE;
- lex->alter_info.flags|= Alter_info::ALTER_KEYS_ONOFF;
+ lex->alter_info.flags|= ALTER_KEYS_ONOFF;
}
| ENABLE_SYM KEYS
{
LEX *lex=Lex;
lex->alter_info.keys_onoff= Alter_info::ENABLE;
- lex->alter_info.flags|= Alter_info::ALTER_KEYS_ONOFF;
+ lex->alter_info.flags|= ALTER_KEYS_ONOFF;
}
| ALTER opt_column opt_if_exists_table_element field_ident SET DEFAULT column_default_expr
{
@@ -8072,7 +8071,7 @@ alter_list_item:
($3->db.str && check_db_name((LEX_STRING*) &$3->db)))
my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $3->table.str));
lex->name= $3->table;
- lex->alter_info.flags|= Alter_info::ALTER_RENAME;
+ lex->alter_info.flags|= ALTER_RENAME;
}
| CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate
{
@@ -8086,12 +8085,12 @@ alter_list_item:
$5->name, $4->csname));
if (Lex->create_info.add_alter_list_item_convert_to_charset($5))
MYSQL_YYABORT;
- Lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
+ Lex->alter_info.flags|= ALTER_OPTIONS;
}
| create_table_options_space_separated
{
LEX *lex=Lex;
- lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
+ lex->alter_info.flags|= ALTER_OPTIONS;
if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) &&
!lex->create_info.db_type)
{
@@ -8100,12 +8099,12 @@ alter_list_item:
}
| FORCE_SYM
{
- Lex->alter_info.flags|= Alter_info::ALTER_RECREATE;
+ Lex->alter_info.flags|= ALTER_RECREATE;
}
| alter_order_clause
{
LEX *lex=Lex;
- lex->alter_info.flags|= Alter_info::ALTER_ORDER;
+ lex->alter_info.flags|= ALTER_ORDER;
}
| alter_algorithm_option
| alter_lock_option
@@ -8188,13 +8187,13 @@ opt_place:
| AFTER_SYM ident
{
$$= $2;
- Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
+ Lex->alter_info.flags |= ALTER_COLUMN_ORDER;
}
| FIRST_SYM
{
$$.str= first_keyword;
$$.length= 5; /* Length of "first" */
- Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
+ Lex->alter_info.flags |= ALTER_COLUMN_ORDER;
}
;
@@ -8734,7 +8733,7 @@ preload_keys_parts:
adm_partition:
PARTITION_SYM have_partitioning
{
- Lex->alter_info.flags|= Alter_info::ALTER_ADMIN_PARTITION;
+ Lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
}
'(' all_or_alt_part_name_list ')'
;
@@ -12679,7 +12678,7 @@ drop:
MYSQL_YYABORT;
lex->sql_command= SQLCOM_DROP_INDEX;
lex->alter_info.reset();
- lex->alter_info.flags= Alter_info::ALTER_DROP_INDEX;
+ lex->alter_info.flags= ALTER_DROP_INDEX;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
if (!lex->current_select->add_table_to_list(thd, $6, NULL,
TL_OPTION_UPDATING,
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index eb1b564994f..d9772b837dd 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -6937,21 +6937,23 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
outward= (!IsFileType(type) || (oldopt->filename && *oldopt->filename));
// Index operations
- Alter_inplace_info::HA_ALTER_FLAGS index_operations=
- Alter_inplace_info::ADD_INDEX |
- Alter_inplace_info::DROP_INDEX |
- Alter_inplace_info::ADD_UNIQUE_INDEX |
- Alter_inplace_info::DROP_UNIQUE_INDEX |
- Alter_inplace_info::ADD_PK_INDEX |
- Alter_inplace_info::DROP_PK_INDEX;
-
- Alter_inplace_info::HA_ALTER_FLAGS inplace_offline_operations=
- Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH |
- Alter_inplace_info::ALTER_COLUMN_NAME |
- Alter_inplace_info::ALTER_COLUMN_DEFAULT |
- Alter_inplace_info::CHANGE_CREATE_OPTION |
- Alter_inplace_info::ALTER_RENAME |
- Alter_inplace_info::ALTER_PARTITIONED | index_operations;
+ alter_table_operations index_operations=
+ ALTER_ADD_INDEX |
+ ALTER_DROP_INDEX |
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_ADD_UNIQUE_INDEX |
+ ALTER_DROP_UNIQUE_INDEX |
+ ALTER_ADD_PK_INDEX |
+ ALTER_DROP_PK_INDEX;
+
+ alter_table_operations inplace_offline_operations=
+ ALTER_COLUMN_EQUAL_PACK_LENGTH |
+ ALTER_COLUMN_NAME |
+ ALTER_COLUMN_DEFAULT |
+ ALTER_CHANGE_CREATE_OPTION |
+ ALTER_RENAME |
+ ALTER_PARTITIONED | index_operations;
if (ha_alter_info->handler_flags & index_operations ||
!SameString(altered_table, "optname") ||
@@ -7045,7 +7047,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
#if 0
uint table_changes= (ha_alter_info->handler_flags &
- Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH) ?
+ ALTER_COLUMN_EQUAL_PACK_LENGTH) ?
IS_EQUAL_PACK_LENGTH : IS_EQUAL_YES;
if (table->file->check_if_incompatible_data(create_info, table_changes)
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 657f5cb9d01..c83139b786f 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -928,7 +928,7 @@ ha_example::check_if_supported_inplace_alter(TABLE* altered_table,
HA_CREATE_INFO *info= ha_alter_info->create_info;
DBUG_ENTER("ha_example::check_if_supported_inplace_alter");
- if (ha_alter_info->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION)
+ if (ha_alter_info->handler_flags & ALTER_CHANGE_CREATE_OPTION)
{
/*
This example shows how custom engine specific table and field
@@ -964,7 +964,7 @@ ha_example::check_if_supported_inplace_alter(TABLE* altered_table,
}
}
- if (ha_alter_info->handler_flags & Alter_inplace_info::ALTER_COLUMN_OPTION)
+ if (ha_alter_info->handler_flags & ALTER_COLUMN_OPTION)
{
for (uint i= 0; i < table->s->fields; i++)
{
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index b331d9e549c..682644ea3ac 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -68,63 +68,64 @@ static const char *MSG_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN=
"combined with other ALTER TABLE actions";
/** Operations for creating secondary indexes (no rebuild needed) */
-static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ONLINE_CREATE
- = Alter_inplace_info::ADD_INDEX
- | Alter_inplace_info::ADD_UNIQUE_INDEX;
+static const alter_table_operations INNOBASE_ONLINE_CREATE
+ = ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX
+ | ALTER_ADD_UNIQUE_INDEX;
/** Operations for rebuilding a table in place */
-static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ALTER_REBUILD
- = Alter_inplace_info::ADD_PK_INDEX
- | Alter_inplace_info::DROP_PK_INDEX
- | Alter_inplace_info::CHANGE_CREATE_OPTION
+static const alter_table_operations INNOBASE_ALTER_REBUILD
+ = ALTER_ADD_PK_INDEX
+ | ALTER_DROP_PK_INDEX
+ | ALTER_CHANGE_CREATE_OPTION
/* CHANGE_CREATE_OPTION needs to check create_option_need_rebuild() */
- | Alter_inplace_info::ALTER_COLUMN_NULLABLE
- | Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE
- | Alter_inplace_info::ALTER_STORED_COLUMN_ORDER
- | Alter_inplace_info::DROP_STORED_COLUMN
- | Alter_inplace_info::ADD_STORED_BASE_COLUMN
- | Alter_inplace_info::RECREATE_TABLE
+ | ALTER_COLUMN_NULLABLE
+ | ALTER_COLUMN_NOT_NULLABLE
+ | ALTER_STORED_COLUMN_ORDER
+ | ALTER_DROP_STORED_COLUMN
+ | ALTER_ADD_STORED_BASE_COLUMN
+ | ALTER_RECREATE_TABLE
/*
- | Alter_inplace_info::ALTER_STORED_COLUMN_TYPE
+ | ALTER_STORED_COLUMN_TYPE
*/
- | Alter_inplace_info::ALTER_COLUMN_UNVERSIONED
- | Alter_inplace_info::ALTER_ADD_SYSTEM_VERSIONING
- | Alter_inplace_info::ALTER_DROP_SYSTEM_VERSIONING
+ | ALTER_COLUMN_UNVERSIONED
+ | ALTER_ADD_SYSTEM_VERSIONING
+ | ALTER_DROP_SYSTEM_VERSIONING
;
/** Operations that require changes to data */
-static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ALTER_DATA
+static const alter_table_operations INNOBASE_ALTER_DATA
= INNOBASE_ONLINE_CREATE | INNOBASE_ALTER_REBUILD;
/** Operations for altering a table that InnoDB does not care about */
-static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_INPLACE_IGNORE
- = Alter_inplace_info::ALTER_COLUMN_DEFAULT
- | Alter_inplace_info::ALTER_PARTITIONED
- | Alter_inplace_info::ALTER_COLUMN_COLUMN_FORMAT
- | Alter_inplace_info::ALTER_COLUMN_STORAGE_TYPE
- | Alter_inplace_info::ALTER_VIRTUAL_GCOL_EXPR
- | Alter_inplace_info::ALTER_RENAME;
+static const alter_table_operations INNOBASE_INPLACE_IGNORE
+ = ALTER_COLUMN_DEFAULT
+ | ALTER_CHANGE_COLUMN_DEFAULT
+ | ALTER_PARTITIONED
+ | ALTER_COLUMN_COLUMN_FORMAT
+ | ALTER_COLUMN_STORAGE_TYPE
+ | ALTER_VIRTUAL_GCOL_EXPR
+ | ALTER_DROP_CHECK_CONSTRAINT
+ | ALTER_RENAME;
/** Operations on foreign key definitions (changing the schema only) */
-static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_FOREIGN_OPERATIONS
- = Alter_inplace_info::DROP_FOREIGN_KEY
- | Alter_inplace_info::ADD_FOREIGN_KEY;
+static const alter_table_operations INNOBASE_FOREIGN_OPERATIONS
+ = ALTER_DROP_FOREIGN_KEY
+ | ALTER_ADD_FOREIGN_KEY;
/** Operations that InnoDB cares about and can perform without rebuild */
-static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ALTER_NOREBUILD
+static const alter_table_operations INNOBASE_ALTER_NOREBUILD
= INNOBASE_ONLINE_CREATE
| INNOBASE_FOREIGN_OPERATIONS
- | Alter_inplace_info::DROP_INDEX
- | Alter_inplace_info::DROP_UNIQUE_INDEX
+ | ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX
+ | ALTER_DROP_UNIQUE_INDEX
#ifdef MYSQL_RENAME_INDEX
- | Alter_inplace_info::RENAME_INDEX
+ | ALTER_RENAME_INDEX
#endif
- | Alter_inplace_info::ALTER_COLUMN_NAME
- | Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH
- //| Alter_inplace_info::ALTER_INDEX_COMMENT
- | Alter_inplace_info::ADD_VIRTUAL_COLUMN
- | Alter_inplace_info::DROP_VIRTUAL_COLUMN
- | Alter_inplace_info::ALTER_VIRTUAL_COLUMN_ORDER;
+ | ALTER_COLUMN_NAME
+ | ALTER_COLUMN_EQUAL_PACK_LENGTH
+ | ALTER_ADD_VIRTUAL_COLUMN
+ | ALTER_DROP_VIRTUAL_COLUMN
+ | ALTER_VIRTUAL_COLUMN_ORDER;
struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
{
@@ -477,7 +478,7 @@ static bool create_option_need_rebuild(
const TABLE* table)
{
DBUG_ASSERT(ha_alter_info->handler_flags
- & Alter_inplace_info::CHANGE_CREATE_OPTION);
+ & ALTER_CHANGE_CREATE_OPTION);
if (ha_alter_info->create_info->used_fields
& (HA_CREATE_USED_ROW_FORMAT
@@ -518,7 +519,7 @@ innobase_need_rebuild(
const TABLE* table)
{
if ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
- == Alter_inplace_info::CHANGE_CREATE_OPTION) {
+ == ALTER_CHANGE_CREATE_OPTION) {
return create_option_need_rebuild(ha_alter_info, table);
}
@@ -546,7 +547,7 @@ check_v_col_in_order(
/* We don't support any adding new virtual column before
existed virtual column. */
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_VIRTUAL_COLUMN) {
+ & ALTER_ADD_VIRTUAL_COLUMN) {
bool has_new = false;
List_iterator_fast<Create_field> cf_it(
@@ -576,7 +577,7 @@ check_v_col_in_order(
/* directly return true if ALTER_VIRTUAL_COLUMN_ORDER is not on */
if (!(ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_VIRTUAL_COLUMN_ORDER)) {
+ & ALTER_VIRTUAL_COLUMN_ORDER)) {
return(true);
}
@@ -635,12 +636,12 @@ instant_alter_column_possible(
const TABLE* table)
{
// Making table system-versioned instantly is not implemented yet.
- if (ha_alter_info->handler_flags & Alter_inplace_info::ALTER_ADD_SYSTEM_VERSIONING) {
+ if (ha_alter_info->handler_flags & ALTER_ADD_SYSTEM_VERSIONING) {
return false;
}
if (~ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_STORED_BASE_COLUMN) {
+ & ALTER_ADD_STORED_BASE_COLUMN) {
return false;
}
@@ -663,13 +664,13 @@ instant_alter_column_possible(
columns. */
if (ha_alter_info->handler_flags
& ((INNOBASE_ALTER_REBUILD | INNOBASE_ONLINE_CREATE)
- & ~Alter_inplace_info::ADD_STORED_BASE_COLUMN
- & ~Alter_inplace_info::CHANGE_CREATE_OPTION)) {
+ & ~ALTER_ADD_STORED_BASE_COLUMN
+ & ~ALTER_CHANGE_CREATE_OPTION)) {
return false;
}
return !(ha_alter_info->handler_flags
- & Alter_inplace_info::CHANGE_CREATE_OPTION)
+ & ALTER_CHANGE_CREATE_OPTION)
|| !create_option_need_rebuild(ha_alter_info, table);
}
@@ -738,7 +739,7 @@ ha_innobase::check_if_supported_inplace_alter(
| INNOBASE_ALTER_REBUILD)) {
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_STORED_COLUMN_TYPE) {
+ & ALTER_STORED_COLUMN_TYPE) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COLUMN_TYPE);
}
@@ -747,7 +748,7 @@ ha_innobase::check_if_supported_inplace_alter(
/* Only support online add foreign key constraint when
check_foreigns is turned off */
- if ((ha_alter_info->handler_flags & Alter_inplace_info::ADD_FOREIGN_KEY)
+ if ((ha_alter_info->handler_flags & ALTER_ADD_FOREIGN_KEY)
&& m_prebuilt->trx->check_foreigns) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_CHECK);
@@ -771,7 +772,7 @@ ha_innobase::check_if_supported_inplace_alter(
In-Place will fail with an error when trying to convert
NULL to a NOT NULL value. */
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE)
+ & ALTER_COLUMN_NOT_NULLABLE)
&& !thd_is_strict_mode(m_user_thd)) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL);
@@ -781,9 +782,8 @@ ha_innobase::check_if_supported_inplace_alter(
/* DROP PRIMARY KEY is only allowed in combination with ADD
PRIMARY KEY. */
if ((ha_alter_info->handler_flags
- & (Alter_inplace_info::ADD_PK_INDEX
- | Alter_inplace_info::DROP_PK_INDEX))
- == Alter_inplace_info::DROP_PK_INDEX) {
+ & (ALTER_ADD_PK_INDEX | ALTER_DROP_PK_INDEX))
+ == ALTER_DROP_PK_INDEX) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOPK);
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
@@ -794,7 +794,7 @@ ha_innobase::check_if_supported_inplace_alter(
table should be rebuild. The change should
only go through the "Copy" method. */
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NULLABLE)) {
+ & ALTER_COLUMN_NULLABLE)) {
const uint my_primary_key = altered_table->s->primary_key;
/* See if MYSQL table has no pk but we do. */
@@ -860,27 +860,27 @@ ha_innobase::check_if_supported_inplace_alter(
with these 2 options alone with inplace interface for now */
if (ha_alter_info->handler_flags
- & (Alter_inplace_info::ADD_VIRTUAL_COLUMN
- | Alter_inplace_info::DROP_VIRTUAL_COLUMN
- | Alter_inplace_info::ALTER_VIRTUAL_COLUMN_ORDER)) {
+ & (ALTER_ADD_VIRTUAL_COLUMN
+ | ALTER_DROP_VIRTUAL_COLUMN
+ | ALTER_VIRTUAL_COLUMN_ORDER)) {
ulonglong flags = ha_alter_info->handler_flags;
/* TODO: uncomment the flags below, once we start to
support them */
- flags &= ~(Alter_inplace_info::ADD_VIRTUAL_COLUMN
- | Alter_inplace_info::DROP_VIRTUAL_COLUMN
- | Alter_inplace_info::ALTER_VIRTUAL_COLUMN_ORDER
- | Alter_inplace_info::ALTER_VIRTUAL_GCOL_EXPR
- | Alter_inplace_info::ALTER_COLUMN_VCOL
+ flags &= ~(ALTER_ADD_VIRTUAL_COLUMN
+ | ALTER_DROP_VIRTUAL_COLUMN
+ | ALTER_VIRTUAL_COLUMN_ORDER
+ | ALTER_VIRTUAL_GCOL_EXPR
+ | ALTER_COLUMN_VCOL
/*
- | Alter_inplace_info::ADD_STORED_BASE_COLUMN
- | Alter_inplace_info::DROP_STORED_COLUMN
- | Alter_inplace_info::ALTER_STORED_COLUMN_ORDER
- | Alter_inplace_info::ADD_UNIQUE_INDEX
+ | ALTER_ADD_STORED_BASE_COLUMN
+ | ALTER_DROP_STORED_COLUMN
+ | ALTER_STORED_COLUMN_ORDER
+ | ALTER_ADD_UNIQUE_INDEX
*/
- | Alter_inplace_info::ADD_INDEX
- | Alter_inplace_info::DROP_INDEX);
+ | ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX
+ | ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX);
if (flags != 0
|| IF_PARTITIONING((altered_table->s->partition_info_str
@@ -953,7 +953,7 @@ ha_innobase::check_if_supported_inplace_alter(
/* This is an added column. */
DBUG_ASSERT(ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_COLUMN);
+ & ALTER_ADD_COLUMN);
/* We cannot replace a hidden FTS_DOC_ID
with a user-visible FTS_DOC_ID. */
@@ -988,7 +988,7 @@ ha_innobase::check_if_supported_inplace_alter(
virtual column, while there is also a drop
virtual column in the same clause */
if (ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_VIRTUAL_COLUMN) {
+ & ALTER_DROP_VIRTUAL_COLUMN) {
ha_alter_info->unsupported_reason =
MSG_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN;
@@ -1058,7 +1058,7 @@ ha_innobase::check_if_supported_inplace_alter(
while (Create_field* cf = cf_it++) {
DBUG_ASSERT(cf->field
|| (ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_COLUMN));
+ & ALTER_ADD_COLUMN));
if (const Field* f = cf->field) {
/* This could be changing an existing column
@@ -1166,7 +1166,7 @@ next_column:
/* We already determined that only a non-locking
operation is possible. */
} else if (((ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_PK_INDEX)
+ & ALTER_ADD_PK_INDEX)
|| innobase_need_rebuild(ha_alter_info, table))
&& (innobase_fulltext_exist(altered_table)
|| innobase_spatial_exist(altered_table)
@@ -1197,7 +1197,7 @@ cannot_create_many_fulltext_index:
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FTS);
}
} else if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_INDEX)) {
+ & ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX)) {
/* ADD FULLTEXT|SPATIAL INDEX requires a lock.
We could do ADD FULLTEXT INDEX without a lock if the
@@ -3208,7 +3208,7 @@ innobase_build_col_map(
+ dict_table_get_n_v_cols(old_table)
>= table->s->fields + DATA_N_SYS_COLS);
DBUG_ASSERT(!!add_cols == !!(ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_COLUMN));
+ & ALTER_ADD_COLUMN));
DBUG_ASSERT(!add_cols || dtuple_get_n_fields(add_cols)
== dict_table_get_n_cols(new_table));
@@ -3371,7 +3371,7 @@ innobase_get_col_names(
DBUG_ENTER("innobase_get_col_names");
DBUG_ASSERT(user_table->n_t_def > table->s->fields);
DBUG_ASSERT(ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NAME);
+ & ALTER_COLUMN_NAME);
cols = static_cast<const char**>(
mem_heap_zalloc(heap, user_table->n_def * sizeof *cols));
@@ -4773,7 +4773,7 @@ prepare_inplace_alter_table_dict(
trx_start_if_not_started_xa(ctx->prebuilt->trx, true);
if (ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_VIRTUAL_COLUMN) {
+ & ALTER_DROP_VIRTUAL_COLUMN) {
if (prepare_inplace_drop_virtual(
ha_alter_info, altered_table, old_table)) {
DBUG_RETURN(true);
@@ -4781,7 +4781,7 @@ prepare_inplace_alter_table_dict(
}
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_VIRTUAL_COLUMN) {
+ & ALTER_ADD_VIRTUAL_COLUMN) {
if (prepare_inplace_add_virtual(
ha_alter_info, altered_table, old_table)) {
DBUG_RETURN(true);
@@ -4791,7 +4791,7 @@ prepare_inplace_alter_table_dict(
for create index */
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_INDEX) {
+ & ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX) {
add_v = static_cast<dict_add_v_col_t*>(
mem_heap_alloc(ctx->heap, sizeof *add_v));
add_v->n_v_col = ctx->num_to_add_vcol;
@@ -5103,7 +5103,7 @@ new_clustered_failed:
dict_table_add_system_columns(ctx->new_table, ctx->heap);
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_COLUMN) {
+ & ALTER_ADD_COLUMN) {
add_cols = dtuple_create_with_vcol(
ctx->heap,
dict_table_get_n_cols(ctx->new_table),
@@ -5359,7 +5359,7 @@ not_instant_add_column:
}
if (ha_alter_info->handler_flags
- & Alter_inplace_info::CHANGE_CREATE_OPTION) {
+ & ALTER_CHANGE_CREATE_OPTION) {
const ha_table_option_struct& alt_opt=
*ha_alter_info->create_info->option_struct;
const ha_table_option_struct& opt=
@@ -5492,7 +5492,7 @@ new_table_failed:
ctx->prebuilt->trx,
clust_index, ctx->new_table,
!(ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_PK_INDEX),
+ & ALTER_ADD_PK_INDEX),
ctx->add_cols, ctx->col_map, path);
rw_lock_x_unlock(&clust_index->lock);
@@ -6190,7 +6190,7 @@ ha_innobase::prepare_inplace_alter_table(
info.set_tablespace_type(indexed_table->space != TRX_SYS_SPACE);
- if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) {
+ if (ha_alter_info->handler_flags & ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX) {
if (info.gcols_in_fulltext_or_spatial()) {
goto err_exit_no_heap;
}
@@ -6274,7 +6274,7 @@ err_exit_no_heap:
/* Prohibit renaming a column to something that the table
already contains. */
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NAME) {
+ & ALTER_COLUMN_NAME) {
List_iterator_fast<Create_field> cf_it(
ha_alter_info->alter_info->create_list);
@@ -6418,7 +6418,7 @@ check_if_ok_to_rename:
heap = mem_heap_create(1024);
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NAME) {
+ & ALTER_COLUMN_NAME) {
col_names = innobase_get_col_names(
ha_alter_info, altered_table, table,
indexed_table, heap);
@@ -6431,7 +6431,7 @@ check_if_ok_to_rename:
}
if (ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_FOREIGN_KEY) {
+ & ALTER_DROP_FOREIGN_KEY) {
DBUG_ASSERT(ha_alter_info->alter_info->drop_list.elements > 0);
drop_fk = static_cast<dict_foreign_t**>(
@@ -6488,9 +6488,9 @@ found_fk:
dict_index_t* drop_primary = NULL;
DBUG_ASSERT(ha_alter_info->handler_flags
- & (Alter_inplace_info::DROP_INDEX
- | Alter_inplace_info::DROP_UNIQUE_INDEX
- | Alter_inplace_info::DROP_PK_INDEX));
+ & (ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX
+ | ALTER_DROP_UNIQUE_INDEX
+ | ALTER_DROP_PK_INDEX));
/* Check which indexes to drop. */
drop_index = static_cast<dict_index_t**>(
mem_heap_alloc(
@@ -6610,7 +6610,7 @@ check_if_can_drop_indexes:
/* Check if any of the existing indexes are marked as corruption
and if they are, refuse adding more indexes. */
- if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) {
+ if (ha_alter_info->handler_flags & ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX) {
for (dict_index_t* index = dict_table_get_first_index(indexed_table);
index != NULL; index = dict_table_get_next_index(index)) {
@@ -6664,7 +6664,7 @@ check_if_can_drop_indexes:
n_add_fk = 0;
if (ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_FOREIGN_KEY) {
+ & ALTER_ADD_FOREIGN_KEY) {
ut_ad(!m_prebuilt->trx->check_foreigns);
alter_fill_stored_column(altered_table, m_prebuilt->table,
@@ -6716,7 +6716,7 @@ err_exit:
if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA)
|| ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
- == Alter_inplace_info::CHANGE_CREATE_OPTION
+ == ALTER_CHANGE_CREATE_OPTION
&& !create_option_need_rebuild(ha_alter_info, table))) {
if (heap) {
@@ -6741,14 +6741,14 @@ err_exit:
}
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_VIRTUAL_COLUMN)
+ & ALTER_DROP_VIRTUAL_COLUMN)
&& prepare_inplace_drop_virtual(
ha_alter_info, altered_table, table)) {
DBUG_RETURN(true);
}
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_VIRTUAL_COLUMN)
+ & ALTER_ADD_VIRTUAL_COLUMN)
&& prepare_inplace_add_virtual(
ha_alter_info, altered_table, table)) {
DBUG_RETURN(true);
@@ -6797,9 +6797,9 @@ err_exit:
doc_col_no == fts_doc_col_no
|| doc_col_no == ULINT_UNDEFINED
|| (ha_alter_info->handler_flags
- & (Alter_inplace_info::ALTER_STORED_COLUMN_ORDER
- | Alter_inplace_info::DROP_STORED_COLUMN
- | Alter_inplace_info::ADD_STORED_BASE_COLUMN)));
+ & (ALTER_STORED_COLUMN_ORDER
+ | ALTER_DROP_STORED_COLUMN
+ | ALTER_ADD_STORED_BASE_COLUMN)));
}
}
@@ -6822,7 +6822,7 @@ err_exit:
/* This is an added column. */
DBUG_ASSERT(!new_field->field);
DBUG_ASSERT(ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_COLUMN);
+ & ALTER_ADD_COLUMN);
field = altered_table->field[i];
@@ -7001,7 +7001,7 @@ ok_exit:
}
if ((ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)
- == Alter_inplace_info::CHANGE_CREATE_OPTION
+ == ALTER_CHANGE_CREATE_OPTION
&& !create_option_need_rebuild(ha_alter_info, table)) {
goto ok_exit;
}
@@ -7041,7 +7041,7 @@ ok_exit:
rebuild_templ
= ctx->need_rebuild()
|| ((ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH)
+ & ALTER_COLUMN_EQUAL_PACK_LENGTH)
&& alter_templ_needs_rebuild(
altered_table, ha_alter_info, ctx->new_table));
@@ -7098,7 +7098,7 @@ ok_exit:
altered_table, ctx->add_cols, ctx->col_map,
ctx->add_autoinc, ctx->sequence, ctx->skip_pk_sort,
ctx->m_stage, add_v, eval_table,
- ha_alter_info->handler_flags & Alter_inplace_info::ALTER_DROP_HISTORICAL);
+ ha_alter_info->handler_flags & ALTER_DROP_HISTORICAL);
#ifndef DBUG_OFF
oom:
@@ -7377,7 +7377,7 @@ rollback_inplace_alter_table(
}
} else {
DBUG_ASSERT(!(ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_PK_INDEX));
+ & ALTER_ADD_PK_INDEX));
DBUG_ASSERT(ctx->new_table == prebuilt->table);
innobase_rollback_sec_index(
@@ -7740,7 +7740,7 @@ innobase_rename_columns_try(
DBUG_ASSERT(ctx);
DBUG_ASSERT(ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NAME);
+ & ALTER_COLUMN_NAME);
for (Field** fp = table->field; *fp; fp++, i++) {
bool is_virtual = innobase_is_v_fld(*fp);
@@ -7949,8 +7949,8 @@ innobase_rename_or_enlarge_columns_cache(
dict_table_t* user_table)
{
if (!(ha_alter_info->handler_flags
- & (Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH
- | Alter_inplace_info::ALTER_COLUMN_NAME))) {
+ & (ALTER_COLUMN_EQUAL_PACK_LENGTH
+ | ALTER_COLUMN_NAME))) {
return;
}
@@ -8029,7 +8029,7 @@ commit_set_autoinc(
btr_write_autoinc(dict_table_get_first_index(ctx->new_table),
autoinc - 1, true);
} else if ((ha_alter_info->handler_flags
- & Alter_inplace_info::CHANGE_CREATE_OPTION)
+ & ALTER_CHANGE_CREATE_OPTION)
&& (ha_alter_info->create_info->used_fields
& HA_CREATE_USED_AUTO)) {
/* An AUTO_INCREMENT value was supplied by the user.
@@ -8339,7 +8339,7 @@ commit_try_rebuild(
DBUG_ASSERT(ctx->need_rebuild());
DBUG_ASSERT(trx->dict_operation_lock_mode == RW_X_LATCH);
DBUG_ASSERT(!(ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_FOREIGN_KEY)
+ & ALTER_DROP_FOREIGN_KEY)
|| ctx->num_to_drop_fk > 0);
for (dict_index_t* index = dict_table_get_first_index(rebuilt_table);
@@ -8438,7 +8438,7 @@ commit_try_rebuild(
}
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NAME)
+ & ALTER_COLUMN_NAME)
&& innobase_rename_columns_try(ha_alter_info, ctx, old_table,
trx, table_name)) {
DBUG_RETURN(true);
@@ -8585,7 +8585,7 @@ commit_try_norebuild(
DBUG_ASSERT(!ctx->need_rebuild());
DBUG_ASSERT(trx->dict_operation_lock_mode == RW_X_LATCH);
DBUG_ASSERT(!(ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_FOREIGN_KEY)
+ & ALTER_DROP_FOREIGN_KEY)
|| ctx->num_to_drop_fk > 0);
DBUG_ASSERT(ctx->num_to_drop_fk
== ha_alter_info->alter_info->drop_list.elements
@@ -8675,14 +8675,14 @@ commit_try_norebuild(
}
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_NAME)
+ & ALTER_COLUMN_NAME)
&& innobase_rename_columns_try(ha_alter_info, ctx, old_table,
trx, table_name)) {
DBUG_RETURN(true);
}
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH)
+ & ALTER_COLUMN_EQUAL_PACK_LENGTH)
&& innobase_enlarge_columns_try(ha_alter_info, old_table,
ctx->old_table, trx, table_name)) {
DBUG_RETURN(true);
@@ -8690,14 +8690,14 @@ commit_try_norebuild(
#ifdef MYSQL_RENAME_INDEX
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::RENAME_INDEX)
+ & ALTER_RENAME_INDEX)
&& rename_indexes_in_data_dictionary(ctx, ha_alter_info, trx)) {
DBUG_RETURN(true);
}
#endif /* MYSQL_RENAME_INDEX */
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::DROP_VIRTUAL_COLUMN)
+ & ALTER_DROP_VIRTUAL_COLUMN)
&& innobase_drop_virtual_try(
ha_alter_info, altered_table, old_table,
ctx->old_table, trx)) {
@@ -8705,7 +8705,7 @@ commit_try_norebuild(
}
if ((ha_alter_info->handler_flags
- & Alter_inplace_info::ADD_VIRTUAL_COLUMN)
+ & ALTER_ADD_VIRTUAL_COLUMN)
&& innobase_add_virtual_try(
ha_alter_info, altered_table, old_table,
ctx->old_table, trx)) {
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp
index e0d3fadba00..55c6b5d330e 100644
--- a/storage/mroonga/ha_mroonga.cpp
+++ b/storage/mroonga/ha_mroonga.cpp
@@ -1754,15 +1754,15 @@ static int mrn_set_geometry(grn_ctx *ctx, grn_obj *buf,
#endif
#ifdef MRN_HAVE_HTON_ALTER_TABLE_FLAGS
-static ulonglong mrn_alter_table_flags(ulonglong flags)
+static alter_table_operations mrn_alter_table_flags(alter_table_operations flags)
{
ulonglong alter_flags = 0;
#ifdef HA_INPLACE_ADD_INDEX_NO_READ_WRITE
bool is_inplace_index_change;
# ifdef MRN_HAVE_ALTER_INFO
- is_inplace_index_change = (((flags & Alter_info::ALTER_ADD_INDEX) &&
- (flags & Alter_info::ALTER_DROP_INDEX)) ||
- (flags & Alter_info::ALTER_CHANGE_COLUMN));
+ is_inplace_index_change = (((flags & ALTER_ADD_INDEX) &&
+ (flags & ALTER_DROP_INDEX)) ||
+ (flags & ALTER_CHANGE_COLUMN));
# else
is_inplace_index_change = (((flags & ALTER_ADD_INDEX) &&
(flags & ALTER_DROP_INDEX)) ||
@@ -14517,23 +14517,23 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
if (
- (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) &&
+ (ha_alter_info->handler_flags & ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX) &&
(ha_alter_info->handler_flags &
(
- Alter_inplace_info::ADD_COLUMN |
- Alter_inplace_info::DROP_COLUMN |
+ ALTER_ADD_COLUMN |
+ ALTER_DROP_COLUMN |
MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_TYPE |
MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_ORDER |
- Alter_inplace_info::ALTER_COLUMN_NULLABLE |
- Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE |
- Alter_inplace_info::ALTER_COLUMN_STORAGE_TYPE |
- Alter_inplace_info::ALTER_COLUMN_COLUMN_FORMAT
+ ALTER_COLUMN_NULLABLE |
+ ALTER_COLUMN_NOT_NULLABLE |
+ ALTER_COLUMN_STORAGE_TYPE |
+ ALTER_COLUMN_COLUMN_FORMAT
)
)
) {
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
- if (ha_alter_info->handler_flags & Alter_inplace_info::ALTER_RENAME)
+ if (ha_alter_info->handler_flags & ALTER_RENAME)
{
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
@@ -14572,7 +14572,7 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
}
}
if (!alter_index_drop_count) {
- alter_handler_flags &= ~Alter_inplace_info::DROP_INDEX;
+ alter_handler_flags &= ~ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX;
}
n_keys = ha_alter_info->index_add_count;
for (i = 0; i < n_keys; ++i) {
@@ -14587,7 +14587,7 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
}
}
if (!alter_index_add_count) {
- alter_handler_flags &= ~Alter_inplace_info::ADD_INDEX;
+ alter_handler_flags &= ~ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX;
}
uint add_index_pos = 0;
n_keys = ha_alter_info->key_count;
@@ -14635,19 +14635,19 @@ enum_alter_inplace_result ha_mroonga::storage_check_if_supported_inplace_alter(
Alter_inplace_info *ha_alter_info)
{
MRN_DBUG_ENTER_METHOD();
- Alter_inplace_info::HA_ALTER_FLAGS explicitly_unsupported_flags =
- Alter_inplace_info::ADD_FOREIGN_KEY |
- Alter_inplace_info::DROP_FOREIGN_KEY;
- Alter_inplace_info::HA_ALTER_FLAGS supported_flags =
- Alter_inplace_info::ADD_INDEX |
- Alter_inplace_info::DROP_INDEX |
- Alter_inplace_info::ADD_UNIQUE_INDEX |
- Alter_inplace_info::DROP_UNIQUE_INDEX |
+ alter_table_operations explicitly_unsupported_flags =
+ ALTER_ADD_FOREIGN_KEY |
+ ALTER_DROP_FOREIGN_KEY;
+ alter_table_operations supported_flags =
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_ADD_UNIQUE_INDEX |
+ ALTER_DROP_UNIQUE_INDEX |
MRN_ALTER_INPLACE_INFO_ADD_VIRTUAL_COLUMN |
MRN_ALTER_INPLACE_INFO_ADD_STORED_BASE_COLUMN |
MRN_ALTER_INPLACE_INFO_ADD_STORED_GENERATED_COLUMN |
- Alter_inplace_info::DROP_COLUMN |
- Alter_inplace_info::ALTER_COLUMN_NAME;
+ ALTER_DROP_COLUMN |
+ ALTER_COLUMN_NAME;
if (ha_alter_info->handler_flags & explicitly_unsupported_flags) {
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
} else if (ha_alter_info->handler_flags & supported_flags) {
@@ -15393,41 +15393,41 @@ bool ha_mroonga::storage_inplace_alter_table(
have_error = true;
}
- Alter_inplace_info::HA_ALTER_FLAGS drop_index_related_flags =
- Alter_inplace_info::DROP_INDEX |
- Alter_inplace_info::DROP_UNIQUE_INDEX |
- Alter_inplace_info::DROP_PK_INDEX;
+ alter_table_operations drop_index_related_flags =
+ ALTER_DROP_INDEX |
+ ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_UNIQUE_INDEX |
+ ALTER_DROP_PK_INDEX;
if (!have_error &&
(ha_alter_info->handler_flags & drop_index_related_flags)) {
have_error = storage_inplace_alter_table_drop_index(altered_table,
ha_alter_info);
}
- Alter_inplace_info::HA_ALTER_FLAGS add_column_related_flags =
- Alter_inplace_info::ADD_COLUMN;
+ alter_table_operations add_column_related_flags =
+ ALTER_ADD_COLUMN;
if (!have_error &&
(ha_alter_info->handler_flags & add_column_related_flags)) {
have_error = storage_inplace_alter_table_add_column(altered_table, ha_alter_info);
}
- Alter_inplace_info::HA_ALTER_FLAGS drop_column_related_flags =
- Alter_inplace_info::DROP_COLUMN;
+ alter_table_operations drop_column_related_flags = ALTER_DROP_COLUMN;
if (!have_error &&
(ha_alter_info->handler_flags & drop_column_related_flags)) {
have_error = storage_inplace_alter_table_drop_column(altered_table, ha_alter_info);
}
- Alter_inplace_info::HA_ALTER_FLAGS rename_column_related_flags =
- Alter_inplace_info::ALTER_COLUMN_NAME;
+ alter_table_operations rename_column_related_flags = ALTER_COLUMN_NAME;
if (!have_error &&
(ha_alter_info->handler_flags & rename_column_related_flags)) {
have_error = storage_inplace_alter_table_rename_column(altered_table, ha_alter_info);
}
- Alter_inplace_info::HA_ALTER_FLAGS add_index_related_flags =
- Alter_inplace_info::ADD_INDEX |
- Alter_inplace_info::ADD_UNIQUE_INDEX |
- Alter_inplace_info::ADD_PK_INDEX;
+ alter_table_operations add_index_related_flags =
+ ALTER_ADD_INDEX |
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_ADD_UNIQUE_INDEX |
+ ALTER_ADD_PK_INDEX;
if (!have_error &&
(ha_alter_info->handler_flags & add_index_related_flags)) {
have_error = storage_inplace_alter_table_add_index(altered_table,
@@ -15533,9 +15533,9 @@ void ha_mroonga::notify_table_changed()
DBUG_VOID_RETURN;
}
#else
-uint ha_mroonga::wrapper_alter_table_flags(uint flags)
+alter_table_operations ha_mroonga::wrapper_alter_table_flags(alter_table_operations flags)
{
- uint res;
+ alter_table_operations res;
MRN_DBUG_ENTER_METHOD();
MRN_SET_WRAP_SHARE_KEY(share, table->s);
MRN_SET_WRAP_TABLE_KEY(this, table);
@@ -15545,17 +15545,17 @@ uint ha_mroonga::wrapper_alter_table_flags(uint flags)
DBUG_RETURN(res);
}
-uint ha_mroonga::storage_alter_table_flags(uint flags)
+alter_table_operations ha_mroonga::storage_alter_table_flags(alter_table_operations flags)
{
MRN_DBUG_ENTER_METHOD();
- uint res = handler::alter_table_flags(flags);
+ alter_table_operations res = handler::alter_table_flags(flags);
DBUG_RETURN(res);
}
-uint ha_mroonga::alter_table_flags(uint flags)
+alter_table_operations ha_mroonga::alter_table_flags(alter_table_operations flags)
{
MRN_DBUG_ENTER_METHOD();
- uint res;
+ alter_table_operations res;
if (share->wrapper_mode)
{
res = wrapper_alter_table_flags(flags);
diff --git a/storage/mroonga/ha_mroonga.hpp b/storage/mroonga/ha_mroonga.hpp
index 15497e70c59..15f972cef82 100644
--- a/storage/mroonga/ha_mroonga.hpp
+++ b/storage/mroonga/ha_mroonga.hpp
@@ -226,9 +226,9 @@ extern "C" {
#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50709) || \
(defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100203)
# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_TYPE \
- Alter_inplace_info::ALTER_STORED_COLUMN_TYPE
+ ALTER_STORED_COLUMN_TYPE
# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_ORDER \
- Alter_inplace_info::ALTER_STORED_COLUMN_ORDER
+ ALTER_STORED_COLUMN_ORDER
#else
# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_TYPE \
Alter_inplace_info::ALTER_COLUMN_TYPE
@@ -338,7 +338,7 @@ private:
handler_add_index *hnd_add_index;
#endif
#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
- Alter_inplace_info::HA_ALTER_FLAGS alter_handler_flags;
+ alter_table_operations alter_handler_flags;
KEY *alter_key_info_buffer;
uint alter_key_count;
uint alter_index_drop_count;
@@ -560,7 +560,7 @@ public:
check_if_supported_inplace_alter(TABLE *altered_table,
Alter_inplace_info *ha_alter_info);
#else
- uint alter_table_flags(uint flags);
+ alter_table_operations alter_table_flags(alter_table_operations flags);
# ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys,
handler_add_index **add);
@@ -1208,8 +1208,8 @@ private:
void wrapper_notify_table_changed();
void storage_notify_table_changed();
#else
- uint wrapper_alter_table_flags(uint flags);
- uint storage_alter_table_flags(uint flags);
+ alter_table_operations wrapper_alter_table_flags(alter_table_operations flags);
+ alter_table_operations storage_alter_table_flags(alter_table_operations flags);
# ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
int wrapper_add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys,
handler_add_index **add);
diff --git a/storage/mroonga/mrn_mysql_compat.h b/storage/mroonga/mrn_mysql_compat.h
index 3bc19e5d8aa..f573c0e01cc 100644
--- a/storage/mroonga/mrn_mysql_compat.h
+++ b/storage/mroonga/mrn_mysql_compat.h
@@ -430,11 +430,11 @@
#if ((defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100203)) || \
(!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50711)
# define MRN_ALTER_INPLACE_INFO_ADD_VIRTUAL_COLUMN \
- Alter_inplace_info::ADD_VIRTUAL_COLUMN
+ ALTER_ADD_VIRTUAL_COLUMN
# define MRN_ALTER_INPLACE_INFO_ADD_STORED_BASE_COLUMN \
- Alter_inplace_info::ADD_STORED_BASE_COLUMN
+ ALTER_ADD_STORED_BASE_COLUMN
# define MRN_ALTER_INPLACE_INFO_ADD_STORED_GENERATED_COLUMN \
- Alter_inplace_info::ADD_STORED_GENERATED_COLUMN
+ ALTER_ADD_STORED_GENERATED_COLUMN
#else
# define MRN_ALTER_INPLACE_INFO_ADD_VIRTUAL_COLUMN 0
# define MRN_ALTER_INPLACE_INFO_ADD_STORED_BASE_COLUMN \
diff --git a/storage/mroonga/mrn_table.hpp b/storage/mroonga/mrn_table.hpp
index 0066fc23f08..422d48d234d 100644
--- a/storage/mroonga/mrn_table.hpp
+++ b/storage/mroonga/mrn_table.hpp
@@ -96,7 +96,7 @@ struct st_mrn_slot_data
};
#define MRN_SET_WRAP_ALTER_KEY(file, ha_alter_info) \
- Alter_inplace_info::HA_ALTER_FLAGS base_handler_flags = ha_alter_info->handler_flags; \
+ alter_table_operations base_handler_flags = ha_alter_info->handler_flags; \
KEY *base_key_info_buffer = ha_alter_info->key_info_buffer; \
uint base_key_count = ha_alter_info->key_count; \
uint base_index_drop_count = ha_alter_info->index_drop_count; \
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index cd7df789858..c540f7df14b 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -2308,19 +2308,19 @@ ha_myisam::check_if_supported_inplace_alter(TABLE *new_table,
{
DBUG_ENTER("ha_myisam::check_if_supported_inplace_alter");
- const Alter_inplace_info::HA_ALTER_FLAGS readd_index=
- Alter_inplace_info::ADD_INDEX |
- Alter_inplace_info::DROP_INDEX;
- const Alter_inplace_info::HA_ALTER_FLAGS readd_unique=
- Alter_inplace_info::ADD_UNIQUE_INDEX |
- Alter_inplace_info::DROP_UNIQUE_INDEX;
- const Alter_inplace_info::HA_ALTER_FLAGS readd_pk=
- Alter_inplace_info::ADD_PK_INDEX |
- Alter_inplace_info::DROP_PK_INDEX;
-
- const Alter_inplace_info::HA_ALTER_FLAGS op= alter_info->handler_flags;
-
- if (op & Alter_inplace_info::ALTER_COLUMN_VCOL)
+ const alter_table_operations readd_index=
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX;
+ const alter_table_operations readd_unique=
+ ALTER_ADD_UNIQUE_INDEX |
+ ALTER_DROP_UNIQUE_INDEX;
+ const alter_table_operations readd_pk=
+ ALTER_ADD_PK_INDEX |
+ ALTER_DROP_PK_INDEX;
+
+ const alter_table_operations op= alter_info->handler_flags;
+
+ if (op & ALTER_COLUMN_VCOL)
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
/*
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 5fe4c792d13..5eeaecc0b86 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -10925,17 +10925,17 @@ my_core::enum_alter_inplace_result ha_rocksdb::check_if_supported_inplace_alter(
DBUG_ASSERT(ha_alter_info != nullptr);
if (ha_alter_info->handler_flags &
- ~(my_core::Alter_inplace_info::DROP_INDEX |
- my_core::Alter_inplace_info::DROP_UNIQUE_INDEX |
- my_core::Alter_inplace_info::ADD_INDEX |
- my_core::Alter_inplace_info::ALTER_PARTITIONED |
- my_core::Alter_inplace_info::ADD_UNIQUE_INDEX)) {
+ ~(ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_UNIQUE_INDEX |
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_PARTITIONED |
+ ALTER_ADD_UNIQUE_INDEX)) {
DBUG_RETURN(my_core::HA_ALTER_INPLACE_NOT_SUPPORTED);
}
/* We don't support unique keys on table w/ no primary keys */
if ((ha_alter_info->handler_flags &
- my_core::Alter_inplace_info::ADD_UNIQUE_INDEX) &&
+ ALTER_ADD_UNIQUE_INDEX) &&
has_hidden_pk(altered_table)) {
DBUG_RETURN(my_core::HA_ALTER_INPLACE_NOT_SUPPORTED);
}
@@ -11001,10 +11001,10 @@ bool ha_rocksdb::prepare_inplace_alter_table(
m_tbl_def->m_hidden_pk_val.load(std::memory_order_relaxed);
if (ha_alter_info->handler_flags &
- (my_core::Alter_inplace_info::DROP_INDEX |
- my_core::Alter_inplace_info::DROP_UNIQUE_INDEX |
- my_core::Alter_inplace_info::ADD_INDEX |
- my_core::Alter_inplace_info::ADD_UNIQUE_INDEX) &&
+ (ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_UNIQUE_INDEX |
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_ADD_UNIQUE_INDEX) &&
create_key_defs(altered_table, new_tdef, table, m_tbl_def)) {
/* Delete the new key descriptors */
delete[] new_key_descr;
@@ -11120,8 +11120,8 @@ bool ha_rocksdb::inplace_alter_table(
static_cast<Rdb_inplace_alter_ctx *>(ha_alter_info->handler_ctx);
if (ha_alter_info->handler_flags &
- (my_core::Alter_inplace_info::ADD_INDEX |
- my_core::Alter_inplace_info::ADD_UNIQUE_INDEX)) {
+ (ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_ADD_UNIQUE_INDEX)) {
/*
Buffers need to be set up again to account for new, possibly longer
secondary keys.
@@ -11137,7 +11137,7 @@ bool ha_rocksdb::inplace_alter_table(
if ((err = alloc_key_buffers(
altered_table, ctx->m_new_tdef,
ha_alter_info->handler_flags &
- my_core::Alter_inplace_info::ADD_UNIQUE_INDEX))) {
+ ALTER_ADD_UNIQUE_INDEX))) {
my_error(ER_OUT_OF_RESOURCES, MYF(0));
DBUG_RETURN(err);
}
@@ -11476,10 +11476,10 @@ bool ha_rocksdb::commit_inplace_alter_table(
ha_alter_info->group_commit_ctx = nullptr;
if (ha_alter_info->handler_flags &
- (my_core::Alter_inplace_info::DROP_INDEX |
- my_core::Alter_inplace_info::DROP_UNIQUE_INDEX |
- my_core::Alter_inplace_info::ADD_INDEX |
- my_core::Alter_inplace_info::ADD_UNIQUE_INDEX)) {
+ (ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_UNIQUE_INDEX |
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_ADD_UNIQUE_INDEX)) {
const std::unique_ptr<rocksdb::WriteBatch> wb = dict_manager.begin();
rocksdb::WriteBatch *const batch = wb.get();
std::unordered_set<GL_INDEX_ID> create_index_ids;
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index 38f157d3c4f..393c33845f3 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -11263,7 +11263,7 @@ int ha_spider::create(
trx->tmp_flg = TRUE;
DBUG_PRINT("info",
- ("spider alter_info.flags=%llu", thd->lex->alter_info.flags));
+ ("spider alter_info.flags: %llu", thd->lex->alter_info.flags));
if (
(thd->lex->alter_info.flags &
(
@@ -11459,7 +11459,7 @@ int ha_spider::rename_table(
}
DBUG_PRINT("info",
- ("spider alter_info.flags=%llu", thd->lex->alter_info.flags));
+ ("spider alter_info.flags: %llu", thd->lex->alter_info.flags));
if (
(thd->lex->alter_info.flags &
(
@@ -11654,7 +11654,7 @@ int ha_spider::delete_table(
DBUG_RETURN(0);
DBUG_PRINT("info",
- ("spider alter_info.flags=%llu", thd->lex->alter_info.flags));
+ ("spider alter_info.flags: %llu", thd->lex->alter_info.flags));
if (
sql_command == SQLCOM_ALTER_TABLE &&
(thd->lex->alter_info.flags &
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index e6a2a8ef3b2..96d75b84ada 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -74,12 +74,12 @@
#define spider_user_defined_key_parts(A) (A)->user_defined_key_parts
#define spider_join_table_count(A) (A)->table_count
#define SPIDER_CAN_BG_UPDATE (1LL << 39)
-#define SPIDER_ALTER_ADD_PARTITION Alter_info::ALTER_ADD_PARTITION
-#define SPIDER_ALTER_DROP_PARTITION Alter_info::ALTER_DROP_PARTITION
-#define SPIDER_ALTER_COALESCE_PARTITION Alter_info::ALTER_COALESCE_PARTITION
-#define SPIDER_ALTER_REORGANIZE_PARTITION Alter_info::ALTER_REORGANIZE_PARTITION
-#define SPIDER_ALTER_TABLE_REORG Alter_info::ALTER_TABLE_REORG
-#define SPIDER_ALTER_REBUILD_PARTITION Alter_info::ALTER_REBUILD_PARTITION
+#define SPIDER_ALTER_ADD_PARTITION ALTER_ADD_PARTITION
+#define SPIDER_ALTER_DROP_PARTITION ALTER_DROP_PARTITION
+#define SPIDER_ALTER_COALESCE_PARTITION ALTER_COALESCE_PARTITION
+#define SPIDER_ALTER_REORGANIZE_PARTITION ALTER_REORGANIZE_PARTITION
+#define SPIDER_ALTER_TABLE_REORG ALTER_TABLE_REORG
+#define SPIDER_ALTER_REBUILD_PARTITION ALTER_REBUILD_PARTITION
#define SPIDER_WARN_LEVEL_WARN Sql_condition::WARN_LEVEL_WARN
#define SPIDER_WARN_LEVEL_NOTE Sql_condition::WARN_LEVEL_NOTE
#define SPIDER_THD_KILL_CONNECTION KILL_CONNECTION
diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc
index 5b43496eb6f..c2d07110ecb 100644
--- a/storage/tokudb/ha_tokudb_alter_56.cc
+++ b/storage/tokudb/ha_tokudb_alter_56.cc
@@ -187,7 +187,7 @@ static ulong fix_handler_flags(
#if 100000 <= MYSQL_VERSION_ID
// This is automatically supported, hide the flag from later checks
- handler_flags &= ~Alter_inplace_info::ALTER_PARTITIONED;
+ handler_flags &= ~ALTER_PARTITIONED;
#endif
// workaround for fill_alter_inplace_info bug (#5193)
@@ -196,31 +196,29 @@ static ulong fix_handler_flags(
// the following code turns the ADD_INDEX and DROP_INDEX flags so that
// we can do hot column addition later.
if (handler_flags &
- (Alter_inplace_info::ADD_COLUMN + Alter_inplace_info::DROP_COLUMN)) {
+ (ALTER_ADD_COLUMN + ALTER_DROP_COLUMN)) {
if (handler_flags &
- (Alter_inplace_info::ADD_INDEX + Alter_inplace_info::DROP_INDEX)) {
+ (ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX + ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX)) {
if (tables_have_same_keys(
table,
altered_table,
tokudb::sysvars::alter_print_error(thd) != 0, false)) {
handler_flags &=
- ~(Alter_inplace_info::ADD_INDEX +
- Alter_inplace_info::DROP_INDEX);
+ ~(ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX +
+ ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX);
}
}
}
// always allow rename table + any other operation, so turn off the
// rename flag
- if (handler_flags & Alter_inplace_info::TOKU_ALTER_RENAME) {
- handler_flags &= ~Alter_inplace_info::TOKU_ALTER_RENAME;
- }
+ handler_flags &= ~ALTER_RENAME;
// ALTER_STORED_COLUMN_TYPE may be set when no columns have been changed,
// so turn off the flag
- if (handler_flags & Alter_inplace_info::ALTER_STORED_COLUMN_TYPE) {
+ if (handler_flags & ALTER_STORED_COLUMN_TYPE) {
if (all_fields_are_same_type(table, altered_table)) {
- handler_flags &= ~Alter_inplace_info::ALTER_STORED_COLUMN_TYPE;
+ handler_flags &= ~ALTER_STORED_COLUMN_TYPE;
}
}
@@ -299,10 +297,10 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
; // do nothing
} else if (only_flags(
ctx->handler_flags,
- Alter_inplace_info::DROP_INDEX +
- Alter_inplace_info::DROP_UNIQUE_INDEX +
- Alter_inplace_info::ADD_INDEX +
- Alter_inplace_info::ADD_UNIQUE_INDEX)) {
+ ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX +
+ ALTER_DROP_UNIQUE_INDEX +
+ ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX +
+ ALTER_ADD_UNIQUE_INDEX)) {
// add or drop index
if (table->s->null_bytes == altered_table->s->null_bytes &&
(ha_alter_info->index_add_count > 0 ||
@@ -314,8 +312,8 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
is_disjoint_add_drop(ha_alter_info)) {
if (ctx->handler_flags &
- (Alter_inplace_info::DROP_INDEX +
- Alter_inplace_info::DROP_UNIQUE_INDEX)) {
+ (ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX +
+ ALTER_DROP_UNIQUE_INDEX)) {
// the fractal tree can not handle dropping an index concurrent
// with querying with the index.
// we grab an exclusive MDL for the drop index.
@@ -331,7 +329,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
// only one add or drop
ha_alter_info->index_drop_count == 0 &&
// must be add index not add unique index
- ctx->handler_flags == Alter_inplace_info::ADD_INDEX &&
+ ctx->handler_flags == ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX &&
// must be a create index command
thd_sql_command(thd) == SQLCOM_CREATE_INDEX &&
// must be enabled
@@ -344,15 +342,15 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
}
} else if (only_flags(
ctx->handler_flags,
- Alter_inplace_info::ALTER_COLUMN_DEFAULT)) {
+ ALTER_COLUMN_DEFAULT)) {
// column default
if (table->s->null_bytes == altered_table->s->null_bytes)
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
- } else if (ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_NAME &&
+ } else if (ctx->handler_flags & ALTER_COLUMN_NAME &&
only_flags(
ctx->handler_flags,
- Alter_inplace_info::ALTER_COLUMN_NAME +
- Alter_inplace_info::ALTER_COLUMN_DEFAULT)) {
+ ALTER_COLUMN_NAME |
+ ALTER_COLUMN_DEFAULT)) {
// column rename
// we have identified a possible column rename,
// but let's do some more checks
@@ -369,15 +367,15 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
table,
altered_table,
(ctx->handler_flags &
- Alter_inplace_info::ALTER_STORED_COLUMN_ORDER) != 0);
+ ALTER_STORED_COLUMN_ORDER) != 0);
if (cr_supported)
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
- } else if (ctx->handler_flags & Alter_inplace_info::ADD_COLUMN &&
+ } else if (ctx->handler_flags & ALTER_ADD_COLUMN &&
only_flags(
ctx->handler_flags,
- Alter_inplace_info::ADD_COLUMN +
- Alter_inplace_info::ALTER_STORED_COLUMN_ORDER) &&
+ ALTER_ADD_COLUMN |
+ ALTER_STORED_COLUMN_ORDER) &&
setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) {
// add column
@@ -403,11 +401,11 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
}
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
- } else if (ctx->handler_flags & Alter_inplace_info::DROP_COLUMN &&
+ } else if (ctx->handler_flags & ALTER_DROP_COLUMN &&
only_flags(
ctx->handler_flags,
- Alter_inplace_info::DROP_COLUMN +
- Alter_inplace_info::ALTER_STORED_COLUMN_ORDER) &&
+ ALTER_DROP_COLUMN |
+ ALTER_STORED_COLUMN_ORDER) &&
setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) {
// drop column
@@ -433,11 +431,11 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
} else if ((ctx->handler_flags &
- Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH) &&
+ ALTER_COLUMN_EQUAL_PACK_LENGTH) &&
only_flags(
ctx->handler_flags,
- Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH +
- Alter_inplace_info::ALTER_COLUMN_DEFAULT) &&
+ ALTER_COLUMN_EQUAL_PACK_LENGTH |
+ ALTER_COLUMN_DEFAULT) &&
table->s->fields == altered_table->s->fields &&
find_changed_fields(
table,
@@ -452,11 +450,11 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
ha_alter_info, ctx)) {
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
- } else if ((ctx->handler_flags & Alter_inplace_info::ALTER_STORED_COLUMN_TYPE) &&
+ } else if ((ctx->handler_flags & ALTER_STORED_COLUMN_TYPE) &&
only_flags(
ctx->handler_flags,
- Alter_inplace_info::ALTER_STORED_COLUMN_TYPE +
- Alter_inplace_info::ALTER_COLUMN_DEFAULT) &&
+ ALTER_STORED_COLUMN_TYPE |
+ ALTER_COLUMN_DEFAULT) &&
table->s->fields == altered_table->s->fields &&
find_changed_fields(
table,
@@ -473,7 +471,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
}
} else if (only_flags(
ctx->handler_flags,
- Alter_inplace_info::CHANGE_CREATE_OPTION)) {
+ ALTER_CHANGE_CREATE_OPTION)) {
HA_CREATE_INFO* create_info = ha_alter_info->create_info;
#if TOKU_INCLUDE_OPTION_STRUCTS
@@ -508,8 +506,8 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
#if TOKU_OPTIMIZE_WITH_RECREATE
else if (only_flags(
ctx->handler_flags,
- Alter_inplace_info::RECREATE_TABLE +
- Alter_inplace_info::ALTER_COLUMN_DEFAULT)) {
+ ALTER_RECREATE_TABLE |
+ ALTER_COLUMN_DEFAULT)) {
ctx->optimize_needed = true;
result = HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE;
}
@@ -569,24 +567,24 @@ bool ha_tokudb::inplace_alter_table(
if (error == 0 &&
(ctx->handler_flags &
- (Alter_inplace_info::DROP_INDEX +
- Alter_inplace_info::DROP_UNIQUE_INDEX))) {
+ (ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
+ ALTER_DROP_UNIQUE_INDEX))) {
error = alter_table_drop_index(altered_table, ha_alter_info);
}
if (error == 0 &&
(ctx->handler_flags &
- (Alter_inplace_info::ADD_INDEX +
- Alter_inplace_info::ADD_UNIQUE_INDEX))) {
+ (ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX +
+ ALTER_ADD_UNIQUE_INDEX))) {
error = alter_table_add_index(altered_table, ha_alter_info);
}
if (error == 0 &&
(ctx->handler_flags &
- (Alter_inplace_info::ADD_COLUMN +
- Alter_inplace_info::DROP_COLUMN))) {
+ (ALTER_ADD_COLUMN |
+ ALTER_DROP_COLUMN))) {
error = alter_table_add_or_drop_column(altered_table, ha_alter_info);
}
if (error == 0 &&
- (ctx->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) &&
+ (ctx->handler_flags & ALTER_CHANGE_CREATE_OPTION) &&
(create_info->used_fields & HA_CREATE_USED_AUTO)) {
error = write_auto_inc_create(
share->status_block,
@@ -594,7 +592,7 @@ bool ha_tokudb::inplace_alter_table(
ctx->alter_txn);
}
if (error == 0 &&
- (ctx->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) &&
+ (ctx->handler_flags & ALTER_CHANGE_CREATE_OPTION) &&
(create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) {
// Get the current compression
DB *db = share->key_file[0];
@@ -801,13 +799,13 @@ int ha_tokudb::alter_table_add_or_drop_column(
memset(columns, 0, sizeof(columns));
// generate the array of columns
- if (ha_alter_info->handler_flags & Alter_inplace_info::DROP_COLUMN) {
+ if (ha_alter_info->handler_flags & ALTER_DROP_COLUMN) {
find_changed_columns(
columns,
&num_columns,
altered_table,
table);
- } else if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_COLUMN) {
+ } else if (ha_alter_info->handler_flags & ALTER_ADD_COLUMN) {
find_changed_columns(
columns,
&num_columns,
@@ -863,7 +861,7 @@ int ha_tokudb::alter_table_add_or_drop_column(
i,
// true if adding columns, otherwise is a drop
(ha_alter_info->handler_flags &
- Alter_inplace_info::ADD_COLUMN) != 0);
+ ALTER_ADD_COLUMN) != 0);
DBT column_dbt; memset(&column_dbt, 0, sizeof column_dbt);
column_dbt.data = column_extra;