Move alter partition flags to alter_info->partition_flags

This is done to get more free flag bits for alter_info->flags

Renamed all ALTER PARTITION defines to start with ALTER_PARTITION_
Renamed ALTER_PARTITION to ALTER_PARTITION_INFO
Renamed ALTER_TABLE_REORG to ALTER_PARTITION_TABLE_REORG

Other things:
- Shifted some ALTER_xxx defines to get empty bits at end
This commit is contained in:
Monty 2018-02-19 11:23:20 +02:00
parent 2dbeebdb16
commit ab1941266c
14 changed files with 186 additions and 164 deletions

View File

@ -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_ADMIN_PARTITION) ||
if (!(thd->lex->alter_info.partition_flags & ALTER_PARTITION_ADMIN) ||
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_TRUNCATE_PARTITION))
! (thd->lex->alter_info.partition_flags & ALTER_PARTITION_TRUNCATE))
{
m_part_info->print_no_partition_found(table, errflag);
DBUG_VOID_RETURN;
@ -9871,8 +9871,11 @@ 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_PARTITION)
if (ha_alter_info->alter_info->partition_flags == ALTER_PARTITION_INFO)
{
DBUG_ASSERT(ha_alter_info->alter_info->flags == 0);
DBUG_RETURN(HA_ALTER_INPLACE_NO_LOCK);
}
part_inplace_ctx=
new (thd->mem_root) ha_partition_inplace_ctx(thd, m_tot_parts);
@ -9938,8 +9941,11 @@ 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_PARTITION)
if (ha_alter_info->alter_info->partition_flags == ALTER_PARTITION_INFO)
{
DBUG_ASSERT(ha_alter_info->alter_info->flags == 0);
DBUG_RETURN(false);
}
part_inplace_ctx=
static_cast<class ha_partition_inplace_ctx*>(ha_alter_info->handler_ctx);
@ -9971,8 +9977,11 @@ 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_PARTITION)
if (ha_alter_info->alter_info->partition_flags == ALTER_PARTITION_INFO)
{
DBUG_ASSERT(ha_alter_info->alter_info->flags == 0);
DBUG_RETURN(false);
}
part_inplace_ctx=
static_cast<class ha_partition_inplace_ctx*>(ha_alter_info->handler_ctx);
@ -10011,8 +10020,11 @@ 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_PARTITION)
if (ha_alter_info->alter_info->partition_flags == ALTER_PARTITION_INFO)
{
DBUG_ASSERT(ha_alter_info->alter_info->flags == 0);
DBUG_RETURN(false);
}
part_inplace_ctx=
static_cast<class ha_partition_inplace_ctx*>(ha_alter_info->handler_ctx);

View File

@ -597,35 +597,10 @@ typedef ulonglong alter_table_operations;
#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)
@ -713,30 +688,60 @@ typedef ulonglong alter_table_operations;
#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)
#define ALTER_VIRTUAL_GCOL_EXPR (1ULL << 55)
#define ALTER_STORED_GCOL_EXPR (1ULL << 56)
// column's engine options changed, something in field->option_struct
#define ALTER_COLUMN_OPTION (1ULL << 59)
#define ALTER_COLUMN_OPTION (1ULL << 57)
// MySQL alias for the same thing:
#define ALTER_COLUMN_STORAGE_TYPE (1ULL << 60)
#define ALTER_COLUMN_STORAGE_TYPE (1ULL << 58)
// Change the column format of column
#define ALTER_COLUMN_COLUMN_FORMAT (1ULL << 61)
#define ALTER_COLUMN_COLUMN_FORMAT (1ULL << 59)
/**
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)
#define ALTER_COLUMN_VCOL (1ULL << 60)
/**
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)
#define ALTER_PARTITIONED (1ULL << 61)
/*
Flags set in partition_flags when altering partitions
*/
// Set for ADD PARTITION
#define ALTER_PARTITION_ADD (1ULL << 1)
// Set for DROP PARTITION
#define ALTER_PARTITION_DROP (1ULL << 2)
// Set for COALESCE PARTITION
#define ALTER_PARTITION_COALESCE (1ULL << 3)
// Set for REORGANIZE PARTITION ... INTO
#define ALTER_PARTITION_REORGANIZE (1ULL << 4)
// Set for partition_options
#define ALTER_PARTITION_INFO (1ULL << 5)
// Set for LOAD INDEX INTO CACHE ... PARTITION
// Set for CACHE INDEX ... PARTITION
#define ALTER_PARTITION_ADMIN (1ULL << 6)
// Set for REBUILD PARTITION
#define ALTER_PARTITION_REBUILD (1ULL << 7)
// Set for partitioning operations specifying ALL keyword
#define ALTER_PARTITION_ALL (1ULL << 8)
// Set for REMOVE PARTITIONING
#define ALTER_PARTITION_REMOVE (1ULL << 9)
// Set for EXCHANGE PARITION
#define ALTER_PARTITION_EXCHANGE (1ULL << 10)
// Set by Sql_cmd_alter_table_truncate_partition::execute()
#define ALTER_PARTITION_TRUNCATE (1ULL << 11)
// Set for REORGANIZE PARTITION
#define ALTER_PARTITION_TABLE_REORG (1ULL << 12)
/*
This is master database for most of system tables. However there
@ -2285,6 +2290,9 @@ public:
*/
alter_table_operations handler_flags;
/* Alter operations involving parititons are strored here */
ulong partition_flags;
/**
Partition_info taking into account the partition changes to be performed.
Contains all partitions which are present in the old version of the table

View File

@ -2442,7 +2442,7 @@ static bool strcmp_null(const char *a, const char *b)
such partitioned tables using numeric colums in the partitioning expression.
For more info see bug#14521864.
Does not check if columns etc has changed, i.e. only for
alter_info->flags == ALTER_PARTITION.
alter_info->partition_flags == ALTER_PARTITION_INFO.
*/
bool partition_info::has_same_partitioning(partition_info *new_part_info)

View File

@ -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_ADMIN_PARTITION ||
if (lex->alter_info.partition_flags & ALTER_PARTITION_ADMIN ||
!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_ADMIN_PARTITION)
if (alter_info->partition_flags & ALTER_PARTITION_ADMIN)
{
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_ADMIN_PARTITION)
if (alter_info->partition_flags & ALTER_PARTITION_ADMIN)
{
protocol->store(STRING_WITH_LEN(
"Table does not support optimize on partitions. All partitions "
@ -1046,10 +1046,10 @@ send_result_message:
save_flags= alter_info->flags;
/*
Reset the ALTER_ADMIN_PARTITION bit in alter_info->flags
Reset the ALTER_PARTITION_ADMIN bit in alter_info->flags
to force analyze on all partitions.
*/
alter_info->flags &= ~(ALTER_ADMIN_PARTITION);
alter_info->partition_flags &= ~(ALTER_PARTITION_ADMIN);
result_code= table->table->file->ha_analyze(thd, check_opt);
if (result_code == HA_ADMIN_ALREADY_DONE)
result_code= HA_ADMIN_OK;

View File

@ -27,7 +27,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
key_list(rhs.key_list, mem_root),
create_list(rhs.create_list, mem_root),
check_constraint_list(rhs.check_constraint_list, mem_root),
flags(rhs.flags),
flags(rhs.flags), partition_flags(rhs.partition_flags),
keys_onoff(rhs.keys_onoff),
partition_names(rhs.partition_names, mem_root),
num_parts(rhs.num_parts),
@ -225,13 +225,14 @@ 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_DROP_PARTITION | ALTER_RENAME))
if ((alter_info.partition_flags & ALTER_PARTITION_DROP) ||
(alter_info.flags & ALTER_RENAME))
priv_needed|= DROP_ACL;
/* Must be set in the parser */
DBUG_ASSERT(select_lex->db.str);
DBUG_ASSERT(!(alter_info.flags & ALTER_EXCHANGE_PARTITION));
DBUG_ASSERT(!(alter_info.flags & ALTER_ADMIN_PARTITION));
DBUG_ASSERT(!(alter_info.partition_flags & ALTER_PARTITION_EXCHANGE));
DBUG_ASSERT(!(alter_info.partition_flags & ALTER_PARTITION_ADMIN));
if (check_access(thd, priv_needed, first_table->db.str,
&first_table->grant.privilege,
&first_table->grant.m_internal,

View File

@ -43,14 +43,14 @@ public:
bool partition_modifying() const
{
return flags & (
ALTER_DROP_PARTITION |
ALTER_COALESCE_PARTITION |
ALTER_REORGANIZE_PARTITION |
ALTER_REMOVE_PARTITIONING |
ALTER_TABLE_REORG |
ALTER_EXCHANGE_PARTITION |
ALTER_TRUNCATE_PARTITION);
return partition_flags & (
ALTER_PARTITION_DROP |
ALTER_PARTITION_COALESCE |
ALTER_PARTITION_REORGANIZE |
ALTER_PARTITION_REMOVE |
ALTER_PARTITION_TABLE_REORG |
ALTER_PARTITION_EXCHANGE |
ALTER_PARTITION_TRUNCATE);
}
/**
@ -106,6 +106,7 @@ public:
List<Virtual_column_info> check_constraint_list;
// Type of ALTER TABLE operation.
alter_table_operations flags;
ulong partition_flags;
// Enable or disable keys.
enum_enable_or_disable keys_onoff;
// List of partitions.
@ -119,7 +120,7 @@ public:
Alter_info() :
flags(0),
flags(0), partition_flags(0),
keys_onoff(LEAVE_AS_IS),
num_parts(0),
requested_algorithm(ALTER_TABLE_ALGORITHM_DEFAULT),
@ -134,6 +135,7 @@ public:
create_list.empty();
check_constraint_list.empty();
flags= 0;
partition_flags= 0;
keys_onoff= LEAVE_AS_IS;
num_parts= 0;
partition_names.empty();

View File

@ -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_ADD_PARTITION ||
alter_info.flags == ALTER_REORGANIZE_PARTITION));
(alter_info.partition_flags == ALTER_PARTITION_ADD ||
alter_info.partition_flags == ALTER_PARTITION_REORGANIZE));
}

View File

@ -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_ALL_PARTITION) ||
if ((alter_info->partition_flags & ALTER_PARTITION_ALL) ||
(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_ALL_PARTITION))
!(alter_info->partition_flags & ALTER_PARTITION_ALL))
{
/* Not all given partitions found, revert and return failure */
part_it.rewind();
@ -4828,8 +4828,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
DBUG_RETURN(TRUE);
}
/* Remove partitioning on a not partitioned table is not possible */
if (!table->part_info && (alter_info->flags &
ALTER_REMOVE_PARTITIONING))
if (!table->part_info && (alter_info->partition_flags &
ALTER_PARTITION_REMOVE))
{
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_ADD_PARTITION);
(alter_info->partition_flags & ALTER_PARTITION_ADD);
if (only_default_value_added &&
!thd->lex->part_info->num_columns)
thd->lex->part_info->num_columns= 1; // to make correct clone
@ -4864,18 +4864,18 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
!(thd->work_part_info= thd->work_part_info->get_clone(thd)))
DBUG_RETURN(TRUE);
/* ALTER_ADMIN_PARTITION is handled in mysql_admin_table */
DBUG_ASSERT(!(alter_info->flags & ALTER_ADMIN_PARTITION));
/* ALTER_PARTITION_ADMIN is handled in mysql_admin_table */
DBUG_ASSERT(!(alter_info->partition_flags & ALTER_PARTITION_ADMIN));
partition_info *saved_part_info= NULL;
if (alter_info->flags &
(ALTER_ADD_PARTITION |
ALTER_DROP_PARTITION |
ALTER_COALESCE_PARTITION |
ALTER_REORGANIZE_PARTITION |
ALTER_TABLE_REORG |
ALTER_REBUILD_PARTITION))
if (alter_info->partition_flags &
(ALTER_PARTITION_ADD |
ALTER_PARTITION_DROP |
ALTER_PARTITION_COALESCE |
ALTER_PARTITION_REORGANIZE |
ALTER_PARTITION_TABLE_REORG |
ALTER_PARTITION_REBUILD))
{
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_TABLE_REORG)
if (alter_info->partition_flags & ALTER_PARTITION_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_ADD_PARTITION;
alter_info->partition_flags|= ALTER_PARTITION_ADD;
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_COALESCE_PARTITION;
alter_info->partition_flags|= ALTER_PARTITION_COALESCE;
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_ADD_PARTITION) ||
(alter_info->flags & ALTER_REORGANIZE_PARTITION))
if ((alter_info->partition_flags & ALTER_PARTITION_ADD) ||
(alter_info->partition_flags & ALTER_PARTITION_REORGANIZE))
{
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_ADD_PARTITION)
if (alter_info->partition_flags & ALTER_PARTITION_ADD)
{
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_TABLE_REORG))
if (!(alter_info->partition_flags & ALTER_PARTITION_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_DROP_PARTITION)
else if (alter_info->partition_flags & ALTER_PARTITION_DROP)
{
/*
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_REBUILD_PARTITION)
else if (alter_info->partition_flags & ALTER_PARTITION_REBUILD)
{
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_COALESCE_PARTITION)
else if (alter_info->partition_flags & ALTER_PARTITION_COALESCE)
{
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_TABLE_REORG))
if (!(alter_info->partition_flags & ALTER_PARTITION_TABLE_REORG))
{
tab_part_info->use_default_num_partitions= FALSE;
tab_part_info->is_auto_partitioned= FALSE;
}
}
else if (alter_info->flags & ALTER_REORGANIZE_PARTITION)
else if (alter_info->partition_flags & ALTER_PARTITION_REORGANIZE)
{
/*
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_ADD_PARTITION ||
alter_info->flags & ALTER_REORGANIZE_PARTITION)
if (alter_info->partition_flags & (ALTER_PARTITION_ADD |
ALTER_PARTITION_REORGANIZE))
{
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_REORGANIZE_PARTITION &&
if (alter_info->partition_flags == ALTER_PARTITION_REORGANIZE &&
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_REMOVE_PARTITIONING)
if (alter_info->partition_flags & ALTER_PARTITION_REMOVE)
{
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_PARTITION ||
if (alter_info->partition_flags != ALTER_PARTITION_INFO ||
!table->part_info ||
alter_info->requested_algorithm !=
Alter_info::ALTER_TABLE_ALGORITHM_INPLACE ||
@ -6660,8 +6660,8 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
if (write_log_changed_partitions(lpt, &next_entry, (const char*)path))
goto error;
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
lpt->alter_info->flags &
ALTER_REORGANIZE_PARTITION))
lpt->alter_info->partition_flags &
ALTER_PARTITION_REORGANIZE))
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_DROP_PARTITION)
else if (alter_info->partition_flags & ALTER_PARTITION_DROP)
{
/*
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_ADD_PARTITION) &&
else if ((alter_info->partition_flags & ALTER_PARTITION_ADD) &&
(part_info->part_type == RANGE_PARTITION ||
part_info->part_type == LIST_PARTITION))
{

View File

@ -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_EXCHANGE_PARTITION);
DBUG_ASSERT(alter_info.partition_flags & ALTER_PARTITION_EXCHANGE);
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_EXCHANGE_PARTITION);
DBUG_ASSERT(alter_info->partition_flags & ALTER_PARTITION_EXCHANGE);
/* 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_ADMIN_PARTITION;
thd->lex->alter_info.partition_flags|= ALTER_PARTITION_ADMIN;
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_ADMIN_PARTITION;
thd->lex->alter_info.partition_flags|= ALTER_PARTITION_ADMIN;
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_ADMIN_PARTITION;
thd->lex->alter_info.partition_flags|= ALTER_PARTITION_ADMIN;
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_ADMIN_PARTITION;
thd->lex->alter_info.partition_flags|= ALTER_PARTITION_ADMIN;
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_ADMIN_PARTITION |
ALTER_TRUNCATE_PARTITION;
thd->lex->alter_info.partition_flags|= (ALTER_PARTITION_ADMIN |
ALTER_PARTITION_TRUNCATE);
/* Fix the lock types (not the same as ordinary ALTER TABLE). */
first_table->lock_type= TL_WRITE;

View File

@ -6404,7 +6404,7 @@ remove_key:
if (tab_part_info)
{
/* ALTER TABLE ADD PARTITION IF NOT EXISTS */
if ((alter_info->flags & ALTER_ADD_PARTITION) &&
if ((alter_info->partition_flags & ALTER_PARTITION_ADD) &&
thd->lex->create_info.if_not_exists())
{
partition_info *alt_part_info= thd->lex->part_info;
@ -6420,7 +6420,7 @@ remove_key:
ER_SAME_NAME_PARTITION,
ER_THD(thd, ER_SAME_NAME_PARTITION),
pe->partition_name);
alter_info->flags&= ~ALTER_ADD_PARTITION;
alter_info->partition_flags&= ~ALTER_PARTITION_ADD;
thd->work_part_info= NULL;
break;
}
@ -6428,7 +6428,7 @@ remove_key:
}
}
/* ALTER TABLE DROP PARTITION IF EXISTS */
if ((alter_info->flags & ALTER_DROP_PARTITION) &&
if ((alter_info->partition_flags & ALTER_PARTITION_DROP) &&
thd->lex->if_exists())
{
List_iterator<const char> names_it(alter_info->partition_names);
@ -6454,7 +6454,7 @@ remove_key:
}
}
if (alter_info->partition_names.elements == 0)
alter_info->flags&= ~ALTER_DROP_PARTITION;
alter_info->partition_flags&= ~ALTER_PARTITION_DROP;
}
}
#endif /*WITH_PARTITION_STORAGE_ENGINE*/
@ -6604,10 +6604,6 @@ static bool fill_alter_inplace_info(THD *thd,
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.
@ -9137,7 +9133,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_PARTITION)
if (alter_info->partition_flags & ALTER_PARTITION_INFO)
{
my_error(ER_WRONG_USAGE, MYF(0), "PARTITION", "log table");
DBUG_RETURN(true);
@ -9348,7 +9344,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_PARTITION) &&
(alter_info->partition_flags & ALTER_PARTITION_INFO)) &&
!table->file->can_switch_engines())
{
my_error(ER_ROW_IS_REFERENCED, MYF(0));
@ -9415,7 +9411,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
ALTER can become NOOP after handling
the IF (NOT) EXISTS options.
*/
if (alter_info->flags == 0)
if (alter_info->flags == 0 && alter_info->partition_flags == 0)
{
my_snprintf(alter_ctx.tmp_buff, sizeof(alter_ctx.tmp_buff),
ER_THD(thd, ER_INSERT_INFO), 0L, 0L,
@ -9438,6 +9434,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
as we are testing if flags == 0 above.
*/
if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) &&
alter_info->partition_flags == 0 &&
alter_info->requested_algorithm !=
Alter_info::ALTER_TABLE_ALGORITHM_COPY) // No need to touch frm.
{
@ -9498,7 +9495,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *n
/*
ALGORITHM and LOCK clauses are generally not allowed by the
parser for operations related to partitioning.
The exceptions are ALTER_PARTITION and ALTER_REMOVE_PARTITIONING.
The exceptions are ALTER_PARTITION_INFO and ALTER_PARTITION_REMOVE.
For consistency, we report ER_ALTER_OPERATION_NOT_SUPPORTED here.
*/
if (alter_info->requested_lock !=

View File

@ -5141,7 +5141,7 @@ partitioning:
}
if (lex->sql_command == SQLCOM_ALTER_TABLE)
{
lex->alter_info.flags|= ALTER_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_INFO;
}
}
partition
@ -7895,7 +7895,7 @@ alter_commands:
| add_partition_rule
| DROP PARTITION_SYM opt_if_exists alt_part_name_list
{
Lex->alter_info.flags|= ALTER_DROP_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_DROP;
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_REBUILD_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_REBUILD;
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_COALESCE_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_COALESCE;
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_EXCHANGE_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_EXCHANGE;
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_REMOVE_PARTITIONING;
Lex->alter_info.partition_flags|= ALTER_PARTITION_REMOVE;
}
;
all_or_alt_part_name_list:
ALL
{
Lex->alter_info.flags|= ALTER_ALL_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_ALL;
}
| alt_part_name_list
;
@ -8024,7 +8024,7 @@ add_partition_rule:
mem_alloc_error(sizeof(partition_info));
MYSQL_YYABORT;
}
lex->alter_info.flags|= ALTER_ADD_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_ADD;
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_TABLE_REORG;
Lex->alter_info.partition_flags|= ALTER_PARTITION_TABLE_REORG;
}
| alt_part_name_list
{
Lex->alter_info.flags|= ALTER_REORGANIZE_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_REORGANIZE;
}
INTO '(' part_def_list ')'
{
@ -8918,7 +8918,7 @@ preload_keys_parts:
adm_partition:
PARTITION_SYM have_partitioning
{
Lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_ADMIN;
}
'(' all_or_alt_part_name_list ')'
;

View File

@ -5092,7 +5092,7 @@ partitioning:
}
if (lex->sql_command == SQLCOM_ALTER_TABLE)
{
lex->alter_info.flags|= ALTER_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_INFO;
}
}
partition
@ -7727,7 +7727,7 @@ alter_commands:
| add_partition_rule
| DROP PARTITION_SYM opt_if_exists alt_part_name_list
{
Lex->alter_info.flags|= ALTER_DROP_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_DROP;
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_REBUILD_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_REBUILD;
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_COALESCE_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_COALESCE;
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_EXCHANGE_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_EXCHANGE;
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_REMOVE_PARTITIONING;
Lex->alter_info.partition_flags|= ALTER_PARTITION_REMOVE;
}
;
all_or_alt_part_name_list:
ALL
{
Lex->alter_info.flags|= ALTER_ALL_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_ALL;
}
| alt_part_name_list
;
@ -7856,7 +7856,7 @@ add_partition_rule:
mem_alloc_error(sizeof(partition_info));
MYSQL_YYABORT;
}
lex->alter_info.flags|= ALTER_ADD_PARTITION;
lex->alter_info.partition_flags|= ALTER_PARTITION_ADD;
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_TABLE_REORG;
Lex->alter_info.partition_flags|= ALTER_PARTITION_TABLE_REORG;
}
| alt_part_name_list
{
Lex->alter_info.flags|= ALTER_REORGANIZE_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_REORGANIZE;
}
INTO '(' part_def_list ')'
{
@ -8733,7 +8733,7 @@ preload_keys_parts:
adm_partition:
PARTITION_SYM have_partitioning
{
Lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
Lex->alter_info.partition_flags|= ALTER_PARTITION_ADMIN;
}
'(' all_or_alt_part_name_list ')'
;

View File

@ -11263,13 +11263,13 @@ int ha_spider::create(
trx->tmp_flg = TRUE;
DBUG_PRINT("info",
("spider alter_info.flags: %llu", thd->lex->alter_info.flags));
if (
(thd->lex->alter_info.flags &
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if ((thd->lex->alter_info.partition_flags &
(
SPIDER_ALTER_ADD_PARTITION | SPIDER_ALTER_DROP_PARTITION |
SPIDER_ALTER_COALESCE_PARTITION | SPIDER_ALTER_REORGANIZE_PARTITION |
SPIDER_ALTER_TABLE_REORG | SPIDER_ALTER_REBUILD_PARTITION
SPIDER_ALTER_PARTITION_ADD | SPIDER_ALTER_PARTITION_DROP |
SPIDER_ALTER_PARTITION_COALESCE | SPIDER_ALTER_PARTITION_REORGANIZE |
SPIDER_ALTER_PARTITION_TABLE_REORG | SPIDER_ALTER_PARTITION_REBUILD
)
) &&
memcmp(name + strlen(name) - 5, "#TMP#", 5)
@ -11459,13 +11459,14 @@ int ha_spider::rename_table(
}
DBUG_PRINT("info",
("spider alter_info.flags: %llu", thd->lex->alter_info.flags));
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if (
(thd->lex->alter_info.flags &
(thd->lex->alter_info.partition_flags &
(
SPIDER_ALTER_ADD_PARTITION | SPIDER_ALTER_DROP_PARTITION |
SPIDER_ALTER_COALESCE_PARTITION | SPIDER_ALTER_REORGANIZE_PARTITION |
SPIDER_ALTER_TABLE_REORG | SPIDER_ALTER_REBUILD_PARTITION
SPIDER_ALTER_PARTITION_ADD | SPIDER_ALTER_PARTITION_DROP |
SPIDER_ALTER_PARTITION_COALESCE | SPIDER_ALTER_PARTITION_REORGANIZE |
SPIDER_ALTER_PARTITION_TABLE_REORG | SPIDER_ALTER_PARTITION_REBUILD
)
)
)
@ -11654,14 +11655,15 @@ 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 alter_info.partition_flags: %lu",
thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if (
sql_command == SQLCOM_ALTER_TABLE &&
(thd->lex->alter_info.flags &
(thd->lex->alter_info.partition_flags &
(
SPIDER_ALTER_ADD_PARTITION | SPIDER_ALTER_DROP_PARTITION |
SPIDER_ALTER_COALESCE_PARTITION | SPIDER_ALTER_REORGANIZE_PARTITION |
SPIDER_ALTER_TABLE_REORG | SPIDER_ALTER_REBUILD_PARTITION
SPIDER_ALTER_PARTITION_ADD | SPIDER_ALTER_PARTITION_DROP |
SPIDER_ALTER_PARTITION_COALESCE | SPIDER_ALTER_PARTITION_REORGANIZE |
SPIDER_ALTER_PARTITION_TABLE_REORG | SPIDER_ALTER_PARTITION_REBUILD
)
)
)

View File

@ -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_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_ALTER_PARTITION_ADD ALTER_PARTITION_ADD
#define SPIDER_ALTER_PARTITION_DROP ALTER_PARTITION_DROP
#define SPIDER_ALTER_PARTITION_COALESCE ALTER_PARTITION_COALESCE
#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_PARTITION_REORGANIZE
#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_PARTITION_TABLE_REORG
#define SPIDER_ALTER_PARTITION_REBUILD ALTER_PARTITION_REBUILD
#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
@ -98,12 +98,12 @@
#endif
#define spider_user_defined_key_parts(A) (A)->key_parts
#define spider_join_table_count(A) (A)->tables
#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_ALTER_PARTITION_ADD ALTER_PARTITION_ADD
#define SPIDER_ALTER_PARTITION_DROP ALTER_PARTITION_DROP
#define SPIDER_ALTER_PARTITION_COALESCE ALTER_PARTITION_COALESCE
#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_PARTITION_REORGANIZE
#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_PARTITION_TABLE_REORG
#define SPIDER_ALTER_PARTITION_REBUILD ALTER_PARTITION_REBUILD
#define SPIDER_WARN_LEVEL_WARN MYSQL_ERROR::WARN_LEVEL_WARN
#define SPIDER_WARN_LEVEL_NOTE MYSQL_ERROR::WARN_LEVEL_NOTE
#define SPIDER_THD_KILL_CONNECTION THD::KILL_CONNECTION