Skip to content
Permalink
Browse files

MDEV-18862 Unfortunate error message upon attempt to drop system vers…

…ioning

Special case for DROP PERIOD when system fields are implicit.
  • Loading branch information...
midenok committed Mar 20, 2019
1 parent 5851e66 commit 638e78853f8d7c0e2c1cf580f3847c5789f165e1
@@ -616,5 +616,18 @@ Warning 1906 The value specified for generated column 'e' in table 't1' has been
Warning 1906 The value specified for generated column 'e' in table 't1' has been ignored
alter table t1 force;
set sql_mode= default;
#
# MDEV-18862 Unfortunate error message upon attempt to drop system versioning
#
set system_versioning_alter_history= keep;
create or replace table t1 (x int) with system versioning;
alter table t1 drop column `row_start`, drop column `row_end`, drop period for system_time, drop system versioning;
ERROR HY000: No 'PERIOD FOR SYSTEM_TIME' in system-versioned `t1`
alter table t1 drop period for system_time;
ERROR HY000: No 'PERIOD FOR SYSTEM_TIME' in system-versioned `t1`
alter table t1 drop column `row_start`, drop column `row_end`, drop system versioning;
ERROR 42000: Can't DROP COLUMN `row_start`; check that it exists
alter table t1 drop column `row_end`;
ERROR 42000: Can't DROP COLUMN `row_end`; check that it exists
drop database test;
create database test;
@@ -514,5 +514,19 @@ update t1 set e= 1;
alter table t1 force;
set sql_mode= default;

--echo #
--echo # MDEV-18862 Unfortunate error message upon attempt to drop system versioning
--echo #
set system_versioning_alter_history= keep;
create or replace table t1 (x int) with system versioning;
--error ER_VERS_NO_PERIOD
alter table t1 drop column `row_start`, drop column `row_end`, drop period for system_time, drop system versioning;
--error ER_VERS_NO_PERIOD
alter table t1 drop period for system_time;
--error ER_CANT_DROP_FIELD_OR_KEY
alter table t1 drop column `row_start`, drop column `row_end`, drop system versioning;
--error ER_CANT_DROP_FIELD_OR_KEY
alter table t1 drop column `row_end`;

drop database test;
create database test;
eng "%s index %`s does not support this operation"
ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD
eng "Changing table options requires the table to be rebuilt"
ER_VERS_NO_PERIOD
eng "No 'PERIOD FOR SYSTEM_TIME' in system-versioned %`s"
@@ -7833,6 +7833,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
KEY *key_info=table->key_info;
bool rc= TRUE;
bool modified_primary_key= FALSE;
bool vers_system_invisible= false;
Create_field *def;
Field **f_ptr,*field;
MY_BITMAP *dropped_fields= NULL; // if it's NULL - no dropped fields
@@ -7941,7 +7942,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
bitmap_set_bit(dropped_fields, field->field_index);
continue;
}

if (field->invisible == INVISIBLE_SYSTEM &&
field->flags & VERS_SYSTEM_FIELD)
{
vers_system_invisible= true;
}
/* invisible versioning column is dropped automatically on DROP SYSTEM VERSIONING */
if (!drop && field->invisible >= INVISIBLE_SYSTEM &&
field->flags & VERS_SYSTEM_FIELD &&
@@ -8059,7 +8064,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
dropped_sys_vers_fields &= VERS_SYSTEM_FIELD;
if ((dropped_sys_vers_fields ||
alter_info->flags & ALTER_DROP_PERIOD) &&
dropped_sys_vers_fields != VERS_SYSTEM_FIELD)
dropped_sys_vers_fields != VERS_SYSTEM_FIELD &&
!vers_system_invisible)
{
StringBuffer<NAME_LEN*3> tmp;
append_drop_column(thd, dropped_sys_vers_fields & VERS_SYS_START_FLAG,
@@ -8069,6 +8075,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr());
goto err;
}
else if (alter_info->flags & ALTER_DROP_PERIOD && vers_system_invisible)
{
my_error(ER_VERS_NO_PERIOD, MYF(0), table->s->table_name.str);
goto err;
}
alter_info->flags &= ~(ALTER_DROP_PERIOD | ALTER_ADD_PERIOD);
def_it.rewind();
while ((def=def_it++)) // Add new columns

0 comments on commit 638e788

Please sign in to comment.
You can’t perform that action at this time.