mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-17038 ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL - generates error if table uses SYSTEM VERSIONING
* Fine-grained inplace skipping by INNOBASE_ALTER_VERSIONED_REBUILD; * Fixed column WITHOUT SYSTEM VERSIONING + ADD COLUMN; * Fixed instant field change (MDEV-16330); * Revisited test versioning.online; * Merged the test versioning.trx_id_versioning_attribute_persistence to versioning.online; * Renamed some versioning functions: ** change_fields_versioning_cache() -> vers_change_fields_cache() ** change_field_versioning_try() -> vers_change_field_try() Skip condition moved out of func. Closes tempesta-tech/mariadb#414 Closes tempesta-tech/mariadb#540 Related to tempesta-tech/mariadb#281
This commit is contained in:
committed by
Marko Mäkelä
parent
d30124e844
commit
4acfc6ecd9
5
mysql-test/suite/versioning/innodb.combinations
Normal file
5
mysql-test/suite/versioning/innodb.combinations
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[timestamp]
|
||||||
|
default-storage-engine=innodb
|
||||||
|
|
||||||
|
[trx_id]
|
||||||
|
default-storage-engine=innodb
|
1
mysql-test/suite/versioning/innodb.inc
Normal file
1
mysql-test/suite/versioning/innodb.inc
Normal file
@ -0,0 +1 @@
|
|||||||
|
--source include/have_innodb.inc
|
@ -370,7 +370,7 @@ a b
|
|||||||
1 NULL
|
1 NULL
|
||||||
2 NULL
|
2 NULL
|
||||||
3 1
|
3 1
|
||||||
4 4
|
4 2
|
||||||
create or replace table t (a int) with system versioning;
|
create or replace table t (a int) with system versioning;
|
||||||
insert into t values (1), (2), (3);
|
insert into t values (1), (2), (3);
|
||||||
delete from t where a<3;
|
delete from t where a<3;
|
||||||
|
@ -1,34 +1,116 @@
|
|||||||
set system_versioning_alter_history=keep;
|
set system_versioning_alter_history=keep;
|
||||||
create or replace table t (a int, b int) engine=innodb;
|
create or replace table t (a int);
|
||||||
alter table t add system versioning, lock=none;
|
alter table t add system versioning, lock=none;
|
||||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
|
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned timestamp tables. Try LOCK=SHARED
|
||||||
|
alter table t add system versioning, algorithm=inplace;
|
||||||
|
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Not implemented for system-versioned timestamp tables. Try ALGORITHM=COPY
|
||||||
alter table t add system versioning, lock=shared;
|
alter table t add system versioning, lock=shared;
|
||||||
alter table t drop column b, lock=none;
|
alter table t add column b int, change column a a int without system versioning, lock=none;
|
||||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
|
|
||||||
alter table t drop column b, algorithm=inplace;
|
|
||||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Not implemented for system-versioned tables. Try ALGORITHM=COPY
|
|
||||||
alter table t add index idx(a), lock=none;
|
|
||||||
alter table t drop system versioning, lock=none;
|
alter table t drop system versioning, lock=none;
|
||||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
|
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned operations. Try LOCK=SHARED
|
||||||
alter table t drop system versioning, algorithm=inplace;
|
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
|
create or replace table t (
|
||||||
create or replace table t (a int, b int) engine=innodb;
|
a int, b int,
|
||||||
alter table t
|
row_start SYS_DATATYPE as row start invisible,
|
||||||
add s bigint unsigned as row start,
|
row_end SYS_DATATYPE as row end invisible,
|
||||||
add e bigint unsigned as row end,
|
period for system_time (row_start, row_end)
|
||||||
add period for system_time(s, e),
|
) with system versioning;
|
||||||
add system versioning,
|
insert into t values (1, 0);
|
||||||
lock=none;
|
insert into t values (2, 0);
|
||||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
|
delete from t where a = 2;
|
||||||
alter table t
|
|
||||||
add s bigint unsigned as row start,
|
|
||||||
add e bigint unsigned as row end,
|
|
||||||
add period for system_time(s, e),
|
|
||||||
add system versioning;
|
|
||||||
alter table t drop column b, lock=none;
|
alter table t drop column b, lock=none;
|
||||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
|
|
||||||
alter table t add index idx(a), lock=none;
|
alter table t add index idx(a), lock=none;
|
||||||
alter table t drop column s, drop column e;
|
select a, check_row(row_start, row_end) from t for system_time all order by a;
|
||||||
alter table t drop system versioning, lock=none;
|
a check_row(row_start, row_end)
|
||||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
|
1 CURRENT ROW
|
||||||
drop table t;
|
2 HISTORICAL ROW
|
||||||
|
# MDEV-17038 ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL -
|
||||||
|
# generates error if table uses SYSTEM VERSIONING [tempesta-tech/mariadb#540]
|
||||||
|
create or replace table t1 (a int, key(a)) with system versioning;
|
||||||
|
create or replace table t2 like t;
|
||||||
|
alter table t2 add foreign key(a) references t1(a);
|
||||||
|
alter table t2 modify column a int not null, lock=none;
|
||||||
|
drop table t2;
|
||||||
|
drop table t1;
|
||||||
|
# MDEV-16330 Allow instant change of WITH SYSTEM VERSIONING column attribute
|
||||||
|
create or replace table t1 (
|
||||||
|
a int,
|
||||||
|
b int,
|
||||||
|
row_start SYS_DATATYPE as row start invisible,
|
||||||
|
row_end SYS_DATATYPE as row end invisible,
|
||||||
|
period for system_time(row_start, row_end)
|
||||||
|
) with system versioning;
|
||||||
|
create or replace table t2 (
|
||||||
|
a int without system versioning,
|
||||||
|
b int,
|
||||||
|
row_start SYS_DATATYPE as row start invisible,
|
||||||
|
row_end SYS_DATATYPE as row end invisible,
|
||||||
|
period for system_time(row_start, row_end)
|
||||||
|
) with system versioning;
|
||||||
|
insert into t1 values (1,1);
|
||||||
|
insert into t2 values (1,1);
|
||||||
|
set @@system_versioning_alter_history=keep;
|
||||||
|
# without rebuild
|
||||||
|
alter table t1
|
||||||
|
change a a int without system versioning,
|
||||||
|
algorithm=instant;
|
||||||
|
affected rows: 0
|
||||||
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||||
|
alter table t2
|
||||||
|
change a a int with system versioning,
|
||||||
|
add primary key pk (a),
|
||||||
|
algorithm=instant;
|
||||||
|
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
|
||||||
|
# with rebuild
|
||||||
|
alter table t2
|
||||||
|
change a a int with system versioning,
|
||||||
|
add primary key pk (a);
|
||||||
|
affected rows: 0
|
||||||
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||||
|
update t1 set a=2;
|
||||||
|
select count(*) from t1 for system_time all;
|
||||||
|
count(*)
|
||||||
|
1
|
||||||
|
update t2 set a=2;
|
||||||
|
select count(*) from t2 for system_time all;
|
||||||
|
count(*)
|
||||||
|
2
|
||||||
|
drop table t1, t2;
|
||||||
|
# rollback ALTER TABLE: nothing should change
|
||||||
|
create or replace table t (
|
||||||
|
a int,
|
||||||
|
b int,
|
||||||
|
row_start SYS_DATATYPE as row start invisible,
|
||||||
|
row_end SYS_DATATYPE as row end invisible,
|
||||||
|
period for system_time(row_start, row_end)
|
||||||
|
) with system versioning;
|
||||||
|
insert into t values (1, 1);
|
||||||
|
select c.prtype from information_schema.innodb_sys_columns as c
|
||||||
|
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
|
||||||
|
where t.name='test/t' and c.name='b';
|
||||||
|
prtype
|
||||||
|
50179
|
||||||
|
set @@system_versioning_alter_history=keep;
|
||||||
|
select c.prtype from information_schema.innodb_sys_columns as c
|
||||||
|
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
|
||||||
|
where t.name='test/t' and c.name='b';
|
||||||
|
prtype
|
||||||
|
50179
|
||||||
|
show create table t;
|
||||||
|
Table Create Table
|
||||||
|
t CREATE TABLE `t` (
|
||||||
|
`a` int(11) DEFAULT NULL,
|
||||||
|
`b` int(11) DEFAULT NULL,
|
||||||
|
`row_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE,
|
||||||
|
`row_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE,
|
||||||
|
PERIOD FOR SYSTEM_TIME (`row_start`, `row_end`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||||
|
select count(*) from t for system_time all;
|
||||||
|
count(*)
|
||||||
|
1
|
||||||
|
update t set b=11;
|
||||||
|
select count(*) from t for system_time all;
|
||||||
|
count(*)
|
||||||
|
2
|
||||||
|
drop database test;
|
||||||
|
create database test;
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
CREATE OR REPLACE TABLE t1 (
|
|
||||||
a INT,
|
|
||||||
b INT,
|
|
||||||
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
|
|
||||||
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME(row_start, row_end)
|
|
||||||
) WITH SYSTEM VERSIONING ENGINE=INNODB;
|
|
||||||
CREATE OR REPLACE TABLE t2 (
|
|
||||||
a INT WITHOUT SYSTEM VERSIONING,
|
|
||||||
b INT,
|
|
||||||
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
|
|
||||||
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME(row_start, row_end)
|
|
||||||
) WITH SYSTEM VERSIONING ENGINE=INNODB;
|
|
||||||
INSERT INTO t1 VALUES (1,1);
|
|
||||||
INSERT INTO t2 VALUES (1,1);
|
|
||||||
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=KEEP;
|
|
||||||
# without rebuild
|
|
||||||
ALTER TABLE t1
|
|
||||||
CHANGE a a INT WITHOUT SYSTEM VERSIONING,
|
|
||||||
ALGORITHM=INSTANT;
|
|
||||||
affected rows: 0
|
|
||||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
||||||
ALTER TABLE t2
|
|
||||||
CHANGE a a INT WITH SYSTEM VERSIONING,
|
|
||||||
ADD PRIMARY KEY pk (a),
|
|
||||||
ALGORITHM=INSTANT;
|
|
||||||
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
|
|
||||||
# with rebuild
|
|
||||||
ALTER TABLE t2
|
|
||||||
CHANGE a a INT WITH SYSTEM VERSIONING,
|
|
||||||
ADD PRIMARY KEY pk (a);
|
|
||||||
affected rows: 0
|
|
||||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
||||||
UPDATE t1 SET a=2;
|
|
||||||
SELECT COUNT(*) FROM t1 FOR SYSTEM_TIME ALL;
|
|
||||||
COUNT(*)
|
|
||||||
1
|
|
||||||
UPDATE t2 SET a=2;
|
|
||||||
SELECT COUNT(*) FROM t2 FOR SYSTEM_TIME ALL;
|
|
||||||
COUNT(*)
|
|
||||||
2
|
|
||||||
DROP TABLE t1, t2;
|
|
||||||
# rollback ALTER TABLE: nothing should change
|
|
||||||
CREATE TABLE t (
|
|
||||||
a INT,
|
|
||||||
b INT,
|
|
||||||
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
|
|
||||||
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME(row_start, row_end)
|
|
||||||
) WITH SYSTEM VERSIONING ENGINE=INNODB;
|
|
||||||
INSERT INTO t VALUES (1, 1);
|
|
||||||
SELECT C.PRTYPE FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS C
|
|
||||||
JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t ON C.TABLE_ID=t.TABLE_ID
|
|
||||||
WHERE t.NAME='test/t' AND C.NAME='b';
|
|
||||||
PRTYPE
|
|
||||||
50179
|
|
||||||
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=KEEP;
|
|
||||||
SET @SAVED_DEBUG_DBUG = @@SESSION.DEBUG_DBUG;
|
|
||||||
SET DEBUG_DBUG='+d,ib_commit_inplace_fail_1';
|
|
||||||
ALTER TABLE t
|
|
||||||
CHANGE b b INT WITHOUT SYSTEM VERSIONING;
|
|
||||||
ERROR HY000: Internal error: Injected error!
|
|
||||||
SET DEBUG_DBUG = @SAVED_DEBUG_DBUG;
|
|
||||||
SELECT C.PRTYPE FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS C
|
|
||||||
JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t ON C.TABLE_ID=t.TABLE_ID
|
|
||||||
WHERE t.NAME='test/t' AND C.NAME='b';
|
|
||||||
PRTYPE
|
|
||||||
50179
|
|
||||||
SHOW CREATE TABLE t;
|
|
||||||
Table Create Table
|
|
||||||
t CREATE TABLE `t` (
|
|
||||||
`a` int(11) DEFAULT NULL,
|
|
||||||
`b` int(11) DEFAULT NULL,
|
|
||||||
`row_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START INVISIBLE,
|
|
||||||
`row_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME (`row_start`, `row_end`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
|
||||||
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
|
|
||||||
COUNT(*)
|
|
||||||
1
|
|
||||||
UPDATE t SET b=11;
|
|
||||||
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
|
|
||||||
COUNT(*)
|
|
||||||
2
|
|
||||||
DROP TABLE t;
|
|
@ -1,42 +1,138 @@
|
|||||||
--source include/have_innodb.inc
|
--source suite/versioning/innodb.inc
|
||||||
|
--source suite/versioning/common.inc
|
||||||
|
--source include/maybe_debug.inc
|
||||||
|
|
||||||
set system_versioning_alter_history=keep;
|
set system_versioning_alter_history=keep;
|
||||||
|
|
||||||
create or replace table t (a int, b int) engine=innodb;
|
create or replace table t (a int);
|
||||||
|
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
||||||
alter table t add system versioning, lock=none;
|
alter table t add system versioning, lock=none;
|
||||||
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
||||||
|
alter table t add system versioning, algorithm=inplace;
|
||||||
alter table t add system versioning, lock=shared;
|
alter table t add system versioning, lock=shared;
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
|
||||||
alter table t drop column b, lock=none;
|
alter table t add column b int, change column a a int without system versioning, lock=none;
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
|
||||||
alter table t drop column b, algorithm=inplace;
|
|
||||||
alter table t add index idx(a), lock=none;
|
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
||||||
alter table t drop system versioning, lock=none;
|
alter table t drop system versioning, lock=none;
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
|
||||||
alter table t drop system versioning, algorithm=inplace;
|
alter table t drop system versioning, algorithm=inplace;
|
||||||
|
|
||||||
|
--replace_result $sys_datatype_expl SYS_DATATYPE
|
||||||
create or replace table t (a int, b int) engine=innodb;
|
eval create or replace table t (
|
||||||
|
a int, b int,
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
alter table t
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
add s bigint unsigned as row start,
|
period for system_time (row_start, row_end)
|
||||||
add e bigint unsigned as row end,
|
) with system versioning;
|
||||||
add period for system_time(s, e),
|
insert into t values (1, 0);
|
||||||
add system versioning,
|
insert into t values (2, 0);
|
||||||
lock=none;
|
delete from t where a = 2;
|
||||||
alter table t
|
|
||||||
add s bigint unsigned as row start,
|
|
||||||
add e bigint unsigned as row end,
|
|
||||||
add period for system_time(s, e),
|
|
||||||
add system versioning;
|
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
|
||||||
alter table t drop column b, lock=none;
|
alter table t drop column b, lock=none;
|
||||||
alter table t add index idx(a), lock=none;
|
alter table t add index idx(a), lock=none;
|
||||||
alter table t drop column s, drop column e;
|
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
|
||||||
alter table t drop system versioning, lock=none;
|
|
||||||
|
|
||||||
drop table t;
|
select a, check_row(row_start, row_end) from t for system_time all order by a;
|
||||||
|
|
||||||
|
--echo # MDEV-17038 ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL -
|
||||||
|
--echo # generates error if table uses SYSTEM VERSIONING [tempesta-tech/mariadb#540]
|
||||||
|
create or replace table t1 (a int, key(a)) with system versioning;
|
||||||
|
create or replace table t2 like t;
|
||||||
|
alter table t2 add foreign key(a) references t1(a);
|
||||||
|
alter table t2 modify column a int not null, lock=none;
|
||||||
|
|
||||||
|
drop table t2;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
--echo # MDEV-16330 Allow instant change of WITH SYSTEM VERSIONING column attribute
|
||||||
|
--replace_result $sys_datatype_expl SYS_DATATYPE
|
||||||
|
eval create or replace table t1 (
|
||||||
|
a int,
|
||||||
|
b int,
|
||||||
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
|
period for system_time(row_start, row_end)
|
||||||
|
) with system versioning;
|
||||||
|
|
||||||
|
--replace_result $sys_datatype_expl SYS_DATATYPE
|
||||||
|
eval create or replace table t2 (
|
||||||
|
a int without system versioning,
|
||||||
|
b int,
|
||||||
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
|
period for system_time(row_start, row_end)
|
||||||
|
) with system versioning;
|
||||||
|
|
||||||
|
insert into t1 values (1,1);
|
||||||
|
insert into t2 values (1,1);
|
||||||
|
|
||||||
|
set @@system_versioning_alter_history=keep;
|
||||||
|
|
||||||
|
--enable_info
|
||||||
|
--echo # without rebuild
|
||||||
|
alter table t1
|
||||||
|
change a a int without system versioning,
|
||||||
|
algorithm=instant;
|
||||||
|
|
||||||
|
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
||||||
|
alter table t2
|
||||||
|
change a a int with system versioning,
|
||||||
|
add primary key pk (a),
|
||||||
|
algorithm=instant;
|
||||||
|
|
||||||
|
--echo # with rebuild
|
||||||
|
alter table t2
|
||||||
|
change a a int with system versioning,
|
||||||
|
add primary key pk (a);
|
||||||
|
--disable_info
|
||||||
|
|
||||||
|
--source include/restart_mysqld.inc
|
||||||
|
|
||||||
|
update t1 set a=2;
|
||||||
|
select count(*) from t1 for system_time all;
|
||||||
|
|
||||||
|
update t2 set a=2;
|
||||||
|
select count(*) from t2 for system_time all;
|
||||||
|
|
||||||
|
drop table t1, t2;
|
||||||
|
|
||||||
|
--echo # rollback ALTER TABLE: nothing should change
|
||||||
|
--replace_result $sys_datatype_expl SYS_DATATYPE
|
||||||
|
eval create or replace table t (
|
||||||
|
a int,
|
||||||
|
b int,
|
||||||
|
row_start $sys_datatype_expl as row start invisible,
|
||||||
|
row_end $sys_datatype_expl as row end invisible,
|
||||||
|
period for system_time(row_start, row_end)
|
||||||
|
) with system versioning;
|
||||||
|
|
||||||
|
insert into t values (1, 1);
|
||||||
|
|
||||||
|
select c.prtype from information_schema.innodb_sys_columns as c
|
||||||
|
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
|
||||||
|
where t.name='test/t' and c.name='b';
|
||||||
|
|
||||||
|
set @@system_versioning_alter_history=keep;
|
||||||
|
|
||||||
|
if ($have_debug) {
|
||||||
|
--disable_query_log
|
||||||
|
--disable_result_log
|
||||||
|
set debug_dbug='+d,ib_commit_inplace_fail_1';
|
||||||
|
--error ER_INTERNAL_ERROR
|
||||||
|
alter table t
|
||||||
|
change b b int without system versioning;
|
||||||
|
set debug_dbug= default;
|
||||||
|
--enable_query_log
|
||||||
|
--enable_result_log
|
||||||
|
}
|
||||||
|
|
||||||
|
select c.prtype from information_schema.innodb_sys_columns as c
|
||||||
|
join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
|
||||||
|
where t.name='test/t' and c.name='b';
|
||||||
|
|
||||||
|
--replace_result $sys_datatype_expl SYS_DATATYPE
|
||||||
|
show create table t;
|
||||||
|
|
||||||
|
select count(*) from t for system_time all;
|
||||||
|
update t set b=11;
|
||||||
|
select count(*) from t for system_time all;
|
||||||
|
|
||||||
|
drop database test;
|
||||||
|
create database test;
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
-- source include/have_innodb.inc
|
|
||||||
-- source include/have_debug.inc
|
|
||||||
|
|
||||||
CREATE OR REPLACE TABLE t1 (
|
|
||||||
a INT,
|
|
||||||
b INT,
|
|
||||||
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
|
|
||||||
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME(row_start, row_end)
|
|
||||||
) WITH SYSTEM VERSIONING ENGINE=INNODB;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TABLE t2 (
|
|
||||||
a INT WITHOUT SYSTEM VERSIONING,
|
|
||||||
b INT,
|
|
||||||
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
|
|
||||||
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME(row_start, row_end)
|
|
||||||
) WITH SYSTEM VERSIONING ENGINE=INNODB;
|
|
||||||
|
|
||||||
INSERT INTO t1 VALUES (1,1);
|
|
||||||
INSERT INTO t2 VALUES (1,1);
|
|
||||||
|
|
||||||
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=KEEP;
|
|
||||||
|
|
||||||
--enable_info
|
|
||||||
--echo # without rebuild
|
|
||||||
ALTER TABLE t1
|
|
||||||
CHANGE a a INT WITHOUT SYSTEM VERSIONING,
|
|
||||||
ALGORITHM=INSTANT;
|
|
||||||
|
|
||||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
|
||||||
ALTER TABLE t2
|
|
||||||
CHANGE a a INT WITH SYSTEM VERSIONING,
|
|
||||||
ADD PRIMARY KEY pk (a),
|
|
||||||
ALGORITHM=INSTANT;
|
|
||||||
|
|
||||||
--echo # with rebuild
|
|
||||||
ALTER TABLE t2
|
|
||||||
CHANGE a a INT WITH SYSTEM VERSIONING,
|
|
||||||
ADD PRIMARY KEY pk (a);
|
|
||||||
--disable_info
|
|
||||||
|
|
||||||
--source include/restart_mysqld.inc
|
|
||||||
|
|
||||||
UPDATE t1 SET a=2;
|
|
||||||
SELECT COUNT(*) FROM t1 FOR SYSTEM_TIME ALL;
|
|
||||||
|
|
||||||
UPDATE t2 SET a=2;
|
|
||||||
SELECT COUNT(*) FROM t2 FOR SYSTEM_TIME ALL;
|
|
||||||
|
|
||||||
DROP TABLE t1, t2;
|
|
||||||
|
|
||||||
--echo # rollback ALTER TABLE: nothing should change
|
|
||||||
CREATE TABLE t (
|
|
||||||
a INT,
|
|
||||||
b INT,
|
|
||||||
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
|
|
||||||
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
|
|
||||||
PERIOD FOR SYSTEM_TIME(row_start, row_end)
|
|
||||||
) WITH SYSTEM VERSIONING ENGINE=INNODB;
|
|
||||||
|
|
||||||
INSERT INTO t VALUES (1, 1);
|
|
||||||
|
|
||||||
SELECT C.PRTYPE FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS C
|
|
||||||
JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t ON C.TABLE_ID=t.TABLE_ID
|
|
||||||
WHERE t.NAME='test/t' AND C.NAME='b';
|
|
||||||
|
|
||||||
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=KEEP;
|
|
||||||
|
|
||||||
SET @SAVED_DEBUG_DBUG = @@SESSION.DEBUG_DBUG;
|
|
||||||
SET DEBUG_DBUG='+d,ib_commit_inplace_fail_1';
|
|
||||||
--error ER_INTERNAL_ERROR
|
|
||||||
ALTER TABLE t
|
|
||||||
CHANGE b b INT WITHOUT SYSTEM VERSIONING;
|
|
||||||
SET DEBUG_DBUG = @SAVED_DEBUG_DBUG;
|
|
||||||
|
|
||||||
SELECT C.PRTYPE FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS C
|
|
||||||
JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t ON C.TABLE_ID=t.TABLE_ID
|
|
||||||
WHERE t.NAME='test/t' AND C.NAME='b';
|
|
||||||
|
|
||||||
SHOW CREATE TABLE t;
|
|
||||||
|
|
||||||
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
|
|
||||||
UPDATE t SET b=11;
|
|
||||||
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
|
|
||||||
|
|
||||||
DROP TABLE t;
|
|
@ -73,6 +73,12 @@ static const alter_table_operations INNOBASE_DEFAULTS
|
|||||||
= ALTER_COLUMN_NOT_NULLABLE
|
= ALTER_COLUMN_NOT_NULLABLE
|
||||||
| ALTER_ADD_STORED_BASE_COLUMN;
|
| ALTER_ADD_STORED_BASE_COLUMN;
|
||||||
|
|
||||||
|
|
||||||
|
/** Operations that require knowledge about row_start, row_end values */
|
||||||
|
static const alter_table_operations INNOBASE_ALTER_VERSIONED_REBUILD
|
||||||
|
= ALTER_ADD_SYSTEM_VERSIONING
|
||||||
|
| ALTER_DROP_SYSTEM_VERSIONING;
|
||||||
|
|
||||||
/** Operations for rebuilding a table in place */
|
/** Operations for rebuilding a table in place */
|
||||||
static const alter_table_operations INNOBASE_ALTER_REBUILD
|
static const alter_table_operations INNOBASE_ALTER_REBUILD
|
||||||
= ALTER_ADD_PK_INDEX
|
= ALTER_ADD_PK_INDEX
|
||||||
@ -87,8 +93,7 @@ static const alter_table_operations INNOBASE_ALTER_REBUILD
|
|||||||
/*
|
/*
|
||||||
| ALTER_STORED_COLUMN_TYPE
|
| ALTER_STORED_COLUMN_TYPE
|
||||||
*/
|
*/
|
||||||
| ALTER_ADD_SYSTEM_VERSIONING
|
| INNOBASE_ALTER_VERSIONED_REBUILD
|
||||||
| ALTER_DROP_SYSTEM_VERSIONING
|
|
||||||
;
|
;
|
||||||
|
|
||||||
/** Operations that require changes to data */
|
/** Operations that require changes to data */
|
||||||
@ -867,10 +872,11 @@ ha_innobase::check_if_supported_inplace_alter(
|
|||||||
const bool need_rebuild = innobase_need_rebuild(ha_alter_info, table);
|
const bool need_rebuild = innobase_need_rebuild(ha_alter_info, table);
|
||||||
|
|
||||||
if (need_rebuild
|
if (need_rebuild
|
||||||
&& (table->versioned(VERS_TIMESTAMP)
|
&& altered_table->versioned(VERS_TIMESTAMP)
|
||||||
|| altered_table->versioned(VERS_TIMESTAMP))) {
|
&& (ha_alter_info->handler_flags
|
||||||
|
& INNOBASE_ALTER_VERSIONED_REBUILD)) {
|
||||||
ha_alter_info->unsupported_reason =
|
ha_alter_info->unsupported_reason =
|
||||||
"Not implemented for system-versioned tables";
|
"Not implemented for system-versioned timestamp tables";
|
||||||
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
|
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1409,13 +1415,12 @@ cannot_create_many_fulltext_index:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: implement Online DDL for system-versioned tables
|
// FIXME: implement Online DDL for system-versioned operations
|
||||||
if (need_rebuild &&
|
if (ha_alter_info->handler_flags & INNOBASE_ALTER_VERSIONED_REBUILD) {
|
||||||
(table->versioned(VERS_TRX_ID)
|
|
||||||
|| altered_table->versioned(VERS_TRX_ID))) {
|
|
||||||
if (ha_alter_info->online) {
|
if (ha_alter_info->online) {
|
||||||
ha_alter_info->unsupported_reason =
|
ha_alter_info->unsupported_reason =
|
||||||
"Not implemented for system-versioned tables";
|
"Not implemented for system-versioned operations";
|
||||||
}
|
}
|
||||||
|
|
||||||
online = false;
|
online = false;
|
||||||
@ -5366,7 +5371,9 @@ new_clustered_failed:
|
|||||||
ut_d(const dict_index_t* index
|
ut_d(const dict_index_t* index
|
||||||
= user_table->indexes.start);
|
= user_table->indexes.start);
|
||||||
DBUG_SLOW_ASSERT(col->mtype == old_col->mtype);
|
DBUG_SLOW_ASSERT(col->mtype == old_col->mtype);
|
||||||
DBUG_SLOW_ASSERT(col->prtype == old_col->prtype);
|
ut_ad(col->prtype == old_col->prtype
|
||||||
|
|| col->prtype
|
||||||
|
== (old_col->prtype & ~DATA_VERSIONED));
|
||||||
DBUG_SLOW_ASSERT(col->mbminlen
|
DBUG_SLOW_ASSERT(col->mbminlen
|
||||||
== old_col->mbminlen);
|
== old_col->mbminlen);
|
||||||
DBUG_SLOW_ASSERT(col->mbmaxlen
|
DBUG_SLOW_ASSERT(col->mbmaxlen
|
||||||
@ -8457,14 +8464,14 @@ innobase_update_foreign_cache(
|
|||||||
@retval false on success */
|
@retval false on success */
|
||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
change_field_versioning_try(
|
vers_change_field_try(
|
||||||
trx_t* trx,
|
trx_t* trx,
|
||||||
const char* table_name,
|
const char* table_name,
|
||||||
const table_id_t tableid,
|
const table_id_t tableid,
|
||||||
const ulint pos,
|
const ulint pos,
|
||||||
const ulint prtype)
|
const ulint prtype)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("change_field_versioning_try");
|
DBUG_ENTER("vers_change_field_try");
|
||||||
|
|
||||||
pars_info_t* info = pars_info_create();
|
pars_info_t* info = pars_info_create();
|
||||||
|
|
||||||
@ -8500,25 +8507,24 @@ change_field_versioning_try(
|
|||||||
@retval false on success */
|
@retval false on success */
|
||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
change_fields_versioning_try(
|
vers_change_fields_try(
|
||||||
const Alter_inplace_info* ha_alter_info,
|
const Alter_inplace_info* ha_alter_info,
|
||||||
const ha_innobase_inplace_ctx* ctx,
|
const ha_innobase_inplace_ctx* ctx,
|
||||||
trx_t* trx,
|
trx_t* trx,
|
||||||
const TABLE* table)
|
const TABLE* table)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("change_fields_versioning_try");
|
DBUG_ENTER("vers_change_fields_try");
|
||||||
|
|
||||||
DBUG_ASSERT(ha_alter_info);
|
DBUG_ASSERT(ha_alter_info);
|
||||||
DBUG_ASSERT(ctx);
|
DBUG_ASSERT(ctx);
|
||||||
|
|
||||||
if (!(ha_alter_info->handler_flags & ALTER_COLUMN_UNVERSIONED)){
|
|
||||||
DBUG_RETURN(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
List_iterator_fast<Create_field> it(
|
List_iterator_fast<Create_field> it(
|
||||||
ha_alter_info->alter_info->create_list);
|
ha_alter_info->alter_info->create_list);
|
||||||
|
|
||||||
while (const Create_field* create_field = it++) {
|
while (const Create_field* create_field = it++) {
|
||||||
|
if (!create_field->field) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (create_field->versioning
|
if (create_field->versioning
|
||||||
== Column_definition::VERSIONING_NOT_SET) {
|
== Column_definition::VERSIONING_NOT_SET) {
|
||||||
continue;
|
continue;
|
||||||
@ -8537,9 +8543,9 @@ change_fields_versioning_try(
|
|||||||
? col->prtype & ~DATA_VERSIONED
|
? col->prtype & ~DATA_VERSIONED
|
||||||
: col->prtype | DATA_VERSIONED;
|
: col->prtype | DATA_VERSIONED;
|
||||||
|
|
||||||
if (change_field_versioning_try(trx, table->s->table_name.str,
|
if (vers_change_field_try(trx, table->s->table_name.str,
|
||||||
new_table->id, pos,
|
new_table->id, pos,
|
||||||
new_prtype)) {
|
new_prtype)) {
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8554,12 +8560,12 @@ in the data dictionary cache.
|
|||||||
@param table MySQL table as it is before the ALTER operation */
|
@param table MySQL table as it is before the ALTER operation */
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
change_fields_versioning_cache(
|
vers_change_fields_cache(
|
||||||
Alter_inplace_info* ha_alter_info,
|
Alter_inplace_info* ha_alter_info,
|
||||||
const ha_innobase_inplace_ctx* ctx,
|
const ha_innobase_inplace_ctx* ctx,
|
||||||
const TABLE* table)
|
const TABLE* table)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("change_fields_versioning");
|
DBUG_ENTER("vers_change_fields_cache");
|
||||||
|
|
||||||
DBUG_ASSERT(ha_alter_info);
|
DBUG_ASSERT(ha_alter_info);
|
||||||
DBUG_ASSERT(ctx);
|
DBUG_ASSERT(ctx);
|
||||||
@ -8569,6 +8575,9 @@ change_fields_versioning_cache(
|
|||||||
ha_alter_info->alter_info->create_list);
|
ha_alter_info->alter_info->create_list);
|
||||||
|
|
||||||
while (const Create_field* create_field = it++) {
|
while (const Create_field* create_field = it++) {
|
||||||
|
if (!create_field->field) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
dict_col_t* col = dict_table_get_nth_col(
|
dict_col_t* col = dict_table_get_nth_col(
|
||||||
ctx->new_table, innodb_col_no(create_field->field));
|
ctx->new_table, innodb_col_no(create_field->field));
|
||||||
|
|
||||||
@ -8959,7 +8968,8 @@ commit_try_norebuild(
|
|||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_fields_versioning_try(ha_alter_info, ctx, trx, old_table)) {
|
if ((ha_alter_info->handler_flags & ALTER_COLUMN_UNVERSIONED)
|
||||||
|
&& vers_change_fields_try(ha_alter_info, ctx, trx, old_table)) {
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9220,7 +9230,7 @@ commit_cache_norebuild(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ha_alter_info->handler_flags & ALTER_COLUMN_UNVERSIONED) {
|
if (ha_alter_info->handler_flags & ALTER_COLUMN_UNVERSIONED) {
|
||||||
change_fields_versioning_cache(ha_alter_info, ctx, table);
|
vers_change_fields_cache(ha_alter_info, ctx, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MYSQL_RENAME_INDEX
|
#ifdef MYSQL_RENAME_INDEX
|
||||||
|
Reference in New Issue
Block a user