diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2019-03-20 20:45:54 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2019-08-11 12:32:08 +0300 |
commit | 638e78853f8d7c0e2c1cf580f3847c5789f165e1 (patch) | |
tree | 1b4141a1583d75eb56be85f3e8826758f2363896 /sql | |
parent | 5851e668d7a0d51034c7d74779c39ef0f7b8d002 (diff) | |
download | mariadb-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')
-rw-r--r-- | sql/share/errmsg-utf8.txt | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 99af1c60287..39198912fbe 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7898,3 +7898,5 @@ ER_KEY_DOESNT_SUPPORT 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" 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 |