summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2019-03-20 20:45:54 +0300
committerAleksey Midenkov <midenok@gmail.com>2019-08-11 12:32:08 +0300
commit638e78853f8d7c0e2c1cf580f3847c5789f165e1 (patch)
tree1b4141a1583d75eb56be85f3e8826758f2363896 /sql/sql_table.cc
parent5851e668d7a0d51034c7d74779c39ef0f7b8d002 (diff)
downloadmariadb-git-638e78853f8d7c0e2c1cf580f3847c5789f165e1.tar.gz
MDEV-18862 Unfortunate error message upon attempt to drop system versioning
Special case for DROP PERIOD when system fields are implicit.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 62f7a7c4952..a615dd9f1ed 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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