Commit d8aabb44 authored by Eugene Kosov's avatar Eugene Kosov Committed by GitHub

SQL: prohibit ALTER ... AS ROW START|END [fixes #429]

parent ea49441c
......@@ -429,8 +429,8 @@ alter table t1 engine=myisam;
# MDEV-14692 crash in MDL_context::upgrade_shared_lock()
create or replace temporary table t (a int);
alter table t change column if exists b c bigint unsigned generated always as row start;
ERROR HY000: GENERATED AS ROW START prohibited for TEMPORARY tables
ERROR HY000: This is not yet supported for generated columns
alter table t change column if exists b c bigint unsigned generated always as row end;
ERROR HY000: GENERATED AS ROW END prohibited for TEMPORARY tables
ERROR HY000: This is not yet supported for generated columns
drop database test;
create database test;
......@@ -290,7 +290,7 @@ insert into t1(x) values (1);
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
set global system_versioning_transaction_registry= on;
Warnings:
Warning 4144 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
Warning 4143 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (
x int,
y int as (x) virtual,
......
......@@ -14,7 +14,7 @@ alter table t drop system versioning, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Not implemented for system-versioned tables. Try ALGORITHM=COPY
set global system_versioning_transaction_registry=on;
Warnings:
Warning 4144 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
Warning 4143 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t (a int, b int) engine=innodb;
alter table t
add s bigint unsigned as row start,
......
......@@ -10,7 +10,7 @@ period for system_time (sys_trx_start, sys_trx_end)
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
set global system_versioning_transaction_registry= 1;
Warnings:
Warning 4144 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
Warning 4143 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
......@@ -32,7 +32,7 @@ return if(cond = 1, '[CORRECT]', '[INCORRECT]');
set @@system_versioning_alter_history=keep;
set global system_versioning_transaction_registry=on;
Warnings:
Warning 4144 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
Warning 4143 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (x int) engine innodb;
insert into t1 values (1);
alter table t1
......
......@@ -316,10 +316,10 @@ create or replace table non_empty (
) engine innodb;
insert into non_empty values (1, 100, 200);
--error ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table non_empty
change column sys_trx_start sys_trx_start bigint(20) unsigned as row start invisible;
--error ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table non_empty
change column sys_trx_end sys_trx_end bigint(20) unsigned as row end invisible;
drop table non_empty;
......@@ -364,9 +364,9 @@ alter table t1 engine=myisam;
--echo # MDEV-14692 crash in MDL_context::upgrade_shared_lock()
create or replace temporary table t (a int);
--error ER_VERS_TEMPORARY
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t change column if exists b c bigint unsigned generated always as row start;
--error ER_VERS_TEMPORARY
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t change column if exists b c bigint unsigned generated always as row end;
......
......@@ -7295,31 +7295,14 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return false;
}
if (!share->versioned)
{
List_iterator_fast<Create_field> it(alter_info->create_list);
while (Create_field *f= it++)
{
if (f->change.length && f->flags & VERS_SYSTEM_FIELD)
{
if (share->table_category == TABLE_CATEGORY_TEMPORARY) {
my_error(ER_VERS_TEMPORARY, MYF(0),
f->flags & VERS_SYS_START_FLAG ? "GENERATED AS ROW START"
: "GENERATED AS ROW END");
return true;
}
if (thd->mdl_context.upgrade_shared_lock(
table->mdl_ticket, MDL_EXCLUSIVE,
thd->variables.lock_wait_timeout))
return true;
if (table->file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME))
return true;
if (0 < table->file->records())
{
my_error(ER_VERS_GENERATED_ALWAYS_NOT_EMPTY, MYF(0), f->change.str);
return true;
}
break;
my_error(ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, MYF(0));
return true;
}
}
}
......
......@@ -7915,9 +7915,6 @@ ER_VERS_SYS_FIELD_NOT_HIDDEN
ER_NOT_LOG_TABLE
eng "Table %`s.%`s is not a log table"
ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
eng "Can not modify column %`s to GENERATED ALWAYS AS ROW START/END for non-empty table"
ER_VERS_TRT_IS_DISABLED
eng "Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry)."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment