Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sql/sql_alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
partition_names(rhs.partition_names, mem_root),
num_parts(rhs.num_parts),
requested_algorithm(rhs.requested_algorithm),
requested_lock(rhs.requested_lock)
requested_lock(rhs.requested_lock),
seq_checked(0)
{
/*
Make deep copies of used objects.
Expand Down
4 changes: 4 additions & 0 deletions sql/sql_alter.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Alter_info
/* Delete/update statistics in EITS tables */
void apply_statistics_deletes_renames(THD *thd, TABLE *table);

// Sequence field error
bool seq_checked;
private:
// Type of ALTER TABLE algorithm.
enum_alter_table_algorithm requested_algorithm;
Expand All @@ -201,6 +203,7 @@ class Alter_info
keys_onoff(LEAVE_AS_IS),
original_table(0),
num_parts(0),
seq_checked(0),
requested_algorithm(ALTER_TABLE_ALGORITHM_NONE),
requested_lock(ALTER_TABLE_LOCK_DEFAULT)
{}
Expand All @@ -225,6 +228,7 @@ class Alter_info
partition_names.empty();
requested_algorithm= ALTER_TABLE_ALGORITHM_NONE;
requested_lock= ALTER_TABLE_LOCK_DEFAULT;
seq_checked= false;
}


Expand Down
21 changes: 17 additions & 4 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2869,9 +2869,10 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
}

/* The user specified fields: check that structure is ok */
if (check_sequence_fields(thd->lex, &alter_info->create_list,
alter_info->db, alter_info->table_name))
DBUG_RETURN(TRUE);
if (!alter_info->seq_checked)
if (check_sequence_fields(thd->lex, &alter_info->create_list,
alter_info->db, alter_info->table_name))
DBUG_RETURN(TRUE);
}


Expand Down Expand Up @@ -8506,7 +8507,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}

if (likely(find && !find->field))
find_it.remove();
find_it.remove();
else
{
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change.str,
Expand Down Expand Up @@ -8598,6 +8599,18 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,

new_create_list.append(&new_create_tail);

/* When new_create_list (list that will be swaped to alter_info->create_list)
is created we should check the case if the table is sequence
and check the fields, as an early check, prior to `mysql_prepare_create_table`.
*/
if (create_info->sequence)
{
if (check_sequence_fields(thd->lex, &new_create_list,
table->s->db, table->s->table_name))
goto err;
alter_info->seq_checked= true;
}

if (unlikely(alter_info->alter_list.elements))
{
my_error(ER_BAD_FIELD_ERROR, MYF(0),
Expand Down