diff options
Diffstat (limited to 'mysql-test/suite')
155 files changed, 9905 insertions, 164 deletions
diff --git a/mysql-test/suite/archive/archive.result b/mysql-test/suite/archive/archive.result index d294d3dfe58..f0ef14495fa 100644 --- a/mysql-test/suite/archive/archive.result +++ b/mysql-test/suite/archive/archive.result @@ -3,18 +3,18 @@ call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired DROP TABLE if exists t1,t2,t3,t4,t5,t6; SET storage_engine=ARCHIVE; CREATE TABLE t1 ( -Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE=archive; INSERT INTO t1 VALUES (9410,9412); -select period FROM t1; -period +select period_ FROM t1; +period_ 9410 select * FROM t1; -Period Varor_period +Period_ Varor_period 9410 9412 select t1.* FROM t1; -Period Varor_period +Period_ Varor_period 9410 9412 CREATE TABLE t2 ( auto int, diff --git a/mysql-test/suite/archive/archive.test b/mysql-test/suite/archive/archive.test index 30f2766507e..19b46195682 100644 --- a/mysql-test/suite/archive/archive.test +++ b/mysql-test/suite/archive/archive.test @@ -15,13 +15,13 @@ SET storage_engine=ARCHIVE; let $MYSQLD_DATADIR= `SELECT @@datadir`; CREATE TABLE t1 ( - Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, + Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE=archive; INSERT INTO t1 VALUES (9410,9412); -select period FROM t1; +select period_ FROM t1; select * FROM t1; select t1.* FROM t1; diff --git a/mysql-test/suite/archive/disabled.def b/mysql-test/suite/archive/disabled.def new file mode 100644 index 00000000000..1aeb519e763 --- /dev/null +++ b/mysql-test/suite/archive/disabled.def @@ -0,0 +1,12 @@ +############################################################################## +# +# List the test cases that are to be disabled temporarily. +# +# Separate the test case name and the comment with ':'. +# +# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment> +# +# Do not use any TAB characters for whitespace. +# +############################################################################## +archive-big: versioning branch
\ No newline at end of file diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result index feed949a71a..ac2b2003f30 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result +++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result @@ -1,16 +1,16 @@ CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); drop table if exists t1,t2; CREATE TABLE t1 ( -Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE=blackhole; INSERT INTO t1 VALUES (9410,9412); -select period from t1; -period +select period_ from t1; +period_ select * from t1; -Period Varor_period +Period_ Varor_period select t1.* from t1; -Period Varor_period +Period_ Varor_period CREATE TABLE t2 ( auto int NOT NULL auto_increment, fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, diff --git a/mysql-test/suite/csv/csv.result b/mysql-test/suite/csv/csv.result index 220b84b222e..c9f7c617b40 100644 --- a/mysql-test/suite/csv/csv.result +++ b/mysql-test/suite/csv/csv.result @@ -3,18 +3,18 @@ call mtr.add_suppression("Table 'test_repair_table4' is marked as crashed and sh call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( -Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE = CSV; INSERT INTO t1 VALUES (9410,9412); -select period from t1; -period +select period_ from t1; +period_ 9410 select * from t1; -Period Varor_period +Period_ Varor_period 9410 9412 select t1.* from t1; -Period Varor_period +Period_ Varor_period 9410 9412 CREATE TABLE t2 ( auto int not null, @@ -4919,12 +4919,12 @@ DROP TABLE t1; ALTER TABLE t2 RENAME t1; DROP TABLE t1; CREATE TABLE t1 ( -Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE = CSV; INSERT INTO t1 VALUES (9410,9412); -select period from t1; -period +select period_ from t1; +period_ 9410 drop table if exists t1,t2,t3,t4; Warnings: diff --git a/mysql-test/suite/csv/csv.test b/mysql-test/suite/csv/csv.test index 3da9aca7b16..711351a32ae 100644 --- a/mysql-test/suite/csv/csv.test +++ b/mysql-test/suite/csv/csv.test @@ -17,13 +17,13 @@ drop table if exists t1,t2,t3,t4; --enable_warnings CREATE TABLE t1 ( - Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, + Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE = CSV; INSERT INTO t1 VALUES (9410,9412); -select period from t1; +select period_ from t1; select * from t1; select t1.* from t1; @@ -1308,13 +1308,13 @@ ALTER TABLE t2 RENAME t1; DROP TABLE t1; CREATE TABLE t1 ( - Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, + Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL ) ENGINE = CSV; INSERT INTO t1 VALUES (9410,9412); -select period from t1; +select period_ from t1; drop table if exists t1,t2,t3,t4; diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index abbb82d51f6..d92d3495cb8 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -12,4 +12,3 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably - diff --git a/mysql-test/suite/encryption/r/encrypt_and_grep.result b/mysql-test/suite/encryption/r/encrypt_and_grep.result index 05ebefd28b5..55309310f5e 100644 --- a/mysql-test/suite/encryption/r/encrypt_and_grep.result +++ b/mysql-test/suite/encryption/r/encrypt_and_grep.result @@ -15,6 +15,7 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME mysql/innodb_table_stats mysql/innodb_index_stats +mysql/vtmd_template test/t1 test/t2 innodb_system @@ -33,12 +34,13 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME mysql/innodb_table_stats mysql/innodb_index_stats -test/t2 +mysql/vtmd_template test/t3 innodb_system SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME test/t1 +test/t2 # t1 yes on expecting NOT FOUND NOT FOUND /foobarsecret/ in t1.ibd # t2 ... default expecting FOUND @@ -57,6 +59,7 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME mysql/innodb_table_stats mysql/innodb_index_stats +mysql/vtmd_template test/t1 test/t2 innodb_system diff --git a/mysql-test/suite/encryption/r/innodb-spatial-index.result b/mysql-test/suite/encryption/r/innodb-spatial-index.result index c2a41ac4c2e..3efea81acc8 100644 --- a/mysql-test/suite/encryption/r/innodb-spatial-index.result +++ b/mysql-test/suite/encryption/r/innodb-spatial-index.result @@ -38,6 +38,7 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME mysql/innodb_table_stats mysql/innodb_index_stats +mysql/vtmd_template test/t1 test/t2 innodb_system diff --git a/mysql-test/suite/encryption/t/debug_key_management.test b/mysql-test/suite/encryption/t/debug_key_management.test index 5001ac6a516..edc8745b5f6 100644 --- a/mysql-test/suite/encryption/t/debug_key_management.test +++ b/mysql-test/suite/encryption/t/debug_key_management.test @@ -8,13 +8,13 @@ if (`select count(*) = 0 from information_schema.plugins set global innodb_encrypt_tables=ON; show variables like 'innodb_encrypt%'; -let $wait_condition= select count(*) = 3 from information_schema.innodb_tablespaces_encryption where current_key_version=1; +let $wait_condition= select count(*) = 4 from information_schema.innodb_tablespaces_encryption where current_key_version=1; --source include/wait_condition.inc select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 1; set global debug_key_management_version=10; -let $wait_condition= select count(*) = 3 from information_schema.innodb_tablespaces_encryption where current_key_version=10; +let $wait_condition= select count(*) = 4 from information_schema.innodb_tablespaces_encryption where current_key_version=10; --source include/wait_condition.inc select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10; diff --git a/mysql-test/suite/encryption/t/encrypt_and_grep.test b/mysql-test/suite/encryption/t/encrypt_and_grep.test index b0bf41a640d..f7a01192e33 100644 --- a/mysql-test/suite/encryption/t/encrypt_and_grep.test +++ b/mysql-test/suite/encryption/t/encrypt_and_grep.test @@ -27,7 +27,7 @@ insert t3 values (repeat('dummysecret', 12)); --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 ---let $wait_condition=SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 +--let $wait_condition=SELECT COUNT(*) <= 2 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 --source include/wait_condition.inc SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_03.result b/mysql-test/suite/funcs_1/r/innodb_trig_03.result index 98f599da3e5..7666b86bc94 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_03.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_03.result @@ -78,7 +78,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke TRIGGER on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.t1 to test_yesprivs@localhost; @@ -168,7 +168,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke UPDATE on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER, UPDATE on *.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; @@ -183,7 +183,7 @@ test_noprivs@localhost use priv_db; show grants; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' select f1 from t1 order by f1; f1 insert 3.5.3.2-no @@ -248,7 +248,7 @@ connection no_privs_424b; show grants; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' use priv_db; create trigger trg4b_1 before UPDATE on t1 for each row set new.f1 = 'trig 3.5.3.7-1b'; @@ -329,7 +329,7 @@ connection no_privs_424c; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' use priv_db; create trigger trg4c_1 before INSERT on t1 for each row set new.f1 = 'trig 3.5.3.7-1c'; @@ -441,7 +441,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke SELECT on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER, SELECT on *.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; @@ -457,7 +457,7 @@ test_noprivs@localhost use priv_db; show grants; Grants for test_noprivs@localhost -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' create trigger trg5a_1 before INSERT on t1 for each row set @test_var = new.f1; connection default; @@ -503,7 +503,7 @@ revoke SELECT on priv_db.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.* to test_yesprivs@localhost; @@ -518,7 +518,7 @@ connection no_privs_425b; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' use priv_db; create trigger trg5b_1 before UPDATE on t1 for each row set @test_var= new.f1; @@ -565,7 +565,7 @@ revoke SELECT on priv_db.t1 from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.t1 to test_yesprivs@localhost; @@ -580,7 +580,7 @@ connection no_privs_425c; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' use priv_db; create trigger trg5c_1 before INSERT on t1 for each row set @test_var= new.f1; diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_03e.result b/mysql-test/suite/funcs_1/r/innodb_trig_03e.result index b29c0271fdc..90dabe044e8 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_03e.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_03e.result @@ -603,7 +603,7 @@ trig 1_1-yes revoke TRIGGER on *.* from test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' disconnect yes_privs; connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; select current_user; @@ -656,7 +656,7 @@ root@localhost grant TRIGGER on priv_db.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT TRIGGER ON `priv_db`.* TO 'test_yesprivs'@'localhost' trigger privilege on db level for create: @@ -929,7 +929,7 @@ grant TRIGGER on priv1_db.t1 to test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT USAGE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `priv1_db`.* TO 'test_yesprivs'@'localhost' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, DELETE VERSIONING ROWS ON `priv1_db`.* TO 'test_yesprivs'@'localhost' GRANT SELECT, UPDATE ON `priv2_db`.* TO 'test_yesprivs'@'localhost' GRANT TRIGGER ON `priv1_db`.`t1` TO 'test_yesprivs'@'localhost' diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result index 5a27cb65b3d..7468d5db0be 100644 --- a/mysql-test/suite/funcs_1/r/innodb_views.result +++ b/mysql-test/suite/funcs_1/r/innodb_views.result @@ -3551,11 +3551,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3585,7 +3585,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3614,7 +3614,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/is_column_privileges.result b/mysql-test/suite/funcs_1/r/is_column_privileges.result index a56ef002935..033fb64f689 100644 --- a/mysql-test/suite/funcs_1/r/is_column_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_column_privileges.result @@ -140,6 +140,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE 'testuser3'@'localhost' def db_datadict CREATE TEMPORARY TABLES NO 'testuser3'@'localhost' def db_datadict CREATE VIEW NO 'testuser3'@'localhost' def db_datadict DELETE NO +'testuser3'@'localhost' def db_datadict DELETE VERSIONING ROWS NO 'testuser3'@'localhost' def db_datadict DROP NO 'testuser3'@'localhost' def db_datadict EVENT NO 'testuser3'@'localhost' def db_datadict EXECUTE NO diff --git a/mysql-test/suite/funcs_1/r/is_columns.result b/mysql-test/suite/funcs_1/r/is_columns.result index 982f4de5116..f1c784e2839 100644 --- a/mysql-test/suite/funcs_1/r/is_columns.result +++ b/mysql-test/suite/funcs_1/r/is_columns.result @@ -106,6 +106,7 @@ table_catalog table_schema table_name column_name Warnings: Warning 1286 Unknown storage engine 'InnoDB' Warning 1286 Unknown storage engine 'InnoDB' +Warning 1286 Unknown storage engine 'InnoDB' ############################################################################### # Testcase 3.2.6.2 + 3.2.6.3: INFORMATION_SCHEMA.COLUMNS accessible information ############################################################################### diff --git a/mysql-test/suite/funcs_1/r/is_key_column_usage.result b/mysql-test/suite/funcs_1/r/is_key_column_usage.result index fa2a738788e..84a226dd0ef 100644 --- a/mysql-test/suite/funcs_1/r/is_key_column_usage.result +++ b/mysql-test/suite/funcs_1/r/is_key_column_usage.result @@ -143,6 +143,7 @@ def mysql PRIMARY def mysql time_zone_transition_type Time_zone_id def mysql PRIMARY def mysql time_zone_transition_type Transition_type_id def mysql PRIMARY def mysql user Host def mysql PRIMARY def mysql user User +def mysql PRIMARY def mysql vtmd_template end ######################################################################################## # Testcase 3.2.7.2 + 3.2.7.3: INFORMATION_SCHEMA.KEY_COLUMN_USAGE accessible information ######################################################################################## diff --git a/mysql-test/suite/funcs_1/r/is_schema_privileges.result b/mysql-test/suite/funcs_1/r/is_schema_privileges.result index cf9b70308de..1339639106f 100644 --- a/mysql-test/suite/funcs_1/r/is_schema_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_schema_privileges.result @@ -68,6 +68,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE ''@'%' def test CREATE ROUTINE ''@'%' def test EVENT ''@'%' def test TRIGGER +''@'%' def test DELETE VERSIONING ROWS ''@'%' def test\_% SELECT ''@'%' def test\_% INSERT ''@'%' def test\_% UPDATE @@ -84,6 +85,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE ''@'%' def test\_% CREATE ROUTINE ''@'%' def test\_% EVENT ''@'%' def test\_% TRIGGER +''@'%' def test\_% DELETE VERSIONING ROWS ############################################################################### # Testcase 3.2.15.2-3.2.15.4 INFORMATION_SCHEMA.SCHEMA_PRIVILEGES accessibility ############################################################################### diff --git a/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result b/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result index 38257899a4b..528a770e0eb 100644 --- a/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result +++ b/mysql-test/suite/funcs_1/r/is_schema_privileges_is_mysql_test.result @@ -16,6 +16,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE ''@'%' def test CREATE TEMPORARY TABLES NO ''@'%' def test CREATE VIEW NO ''@'%' def test DELETE NO +''@'%' def test DELETE VERSIONING ROWS NO ''@'%' def test DROP NO ''@'%' def test EVENT NO ''@'%' def test INDEX NO diff --git a/mysql-test/suite/funcs_1/r/is_statistics.result b/mysql-test/suite/funcs_1/r/is_statistics.result index 749b09fa87d..8f82c04e3da 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics.result +++ b/mysql-test/suite/funcs_1/r/is_statistics.result @@ -154,6 +154,7 @@ def mysql user mysql PRIMARY Warnings: Warning 1286 Unknown storage engine 'InnoDB' Warning 1286 Unknown storage engine 'InnoDB' +Warning 1286 Unknown storage engine 'InnoDB' #################################################################################### # Testcase 3.2.14.2 + 3.2.14.3: INFORMATION_SCHEMA.STATISTICS accessible information #################################################################################### diff --git a/mysql-test/suite/funcs_1/r/is_statistics_mysql.result b/mysql-test/suite/funcs_1/r/is_statistics_mysql.result index dc3ed5f9839..b5f9096aa47 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_statistics_mysql.result @@ -79,6 +79,8 @@ def mysql time_zone_transition_type 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL def mysql time_zone_transition_type 0 mysql PRIMARY 2 Transition_type_id A #CARD# NULL NULL BTREE def mysql user 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE def mysql user 0 mysql PRIMARY 2 User A #CARD# NULL NULL BTREE +def mysql vtmd_template 1 mysql archive_name 1 archive_name A #CARD# NULL NULL YES BTREE +def mysql vtmd_template 0 mysql PRIMARY 1 end A #CARD# NULL NULL BTREE connect testuser1,localhost,testuser1,,db_datadict; SELECT * FROM information_schema.statistics WHERE table_schema = 'mysql' diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints.result b/mysql-test/suite/funcs_1/r/is_table_constraints.result index 0553b4344c8..bd55e1c0b10 100644 --- a/mysql-test/suite/funcs_1/r/is_table_constraints.result +++ b/mysql-test/suite/funcs_1/r/is_table_constraints.result @@ -88,6 +88,7 @@ def mysql PRIMARY mysql time_zone_name def mysql PRIMARY mysql time_zone_transition def mysql PRIMARY mysql time_zone_transition_type def mysql PRIMARY mysql user +def mysql PRIMARY mysql vtmd_template ######################################################################################### # Testcase 3.2.7.2 + 3.2.7.3: INFORMATION_SCHEMA.TABLE_CONSTRAINTS accessible information ######################################################################################### diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result b/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result index e54de0671a2..9998f99ab1b 100644 --- a/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result @@ -38,6 +38,7 @@ def mysql PRIMARY mysql time_zone_name PRIMARY KEY def mysql PRIMARY mysql time_zone_transition PRIMARY KEY def mysql PRIMARY mysql time_zone_transition_type PRIMARY KEY def mysql PRIMARY mysql user PRIMARY KEY +def mysql PRIMARY mysql vtmd_template PRIMARY KEY connect testuser1,localhost,testuser1,,db_datadict; SELECT * FROM information_schema.table_constraints WHERE table_schema = 'mysql' diff --git a/mysql-test/suite/funcs_1/r/is_table_privileges.result b/mysql-test/suite/funcs_1/r/is_table_privileges.result index 340aead9aba..c448241e14e 100644 --- a/mysql-test/suite/funcs_1/r/is_table_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_table_privileges.result @@ -96,6 +96,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'testuser2'@'localhost' def db_datadict tb1 CREATE YES 'testuser2'@'localhost' def db_datadict tb1 CREATE VIEW YES 'testuser2'@'localhost' def db_datadict tb1 DELETE YES +'testuser2'@'localhost' def db_datadict tb1 DELETE VERSIONING ROWS YES 'testuser2'@'localhost' def db_datadict tb1 DROP YES 'testuser2'@'localhost' def db_datadict tb1 INDEX YES 'testuser2'@'localhost' def db_datadict tb1 INSERT YES @@ -131,6 +132,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'testuser2'@'localhost' def db_datadict tb1 CREATE YES 'testuser2'@'localhost' def db_datadict tb1 CREATE VIEW YES 'testuser2'@'localhost' def db_datadict tb1 DELETE YES +'testuser2'@'localhost' def db_datadict tb1 DELETE VERSIONING ROWS YES 'testuser2'@'localhost' def db_datadict tb1 DROP YES 'testuser2'@'localhost' def db_datadict tb1 INDEX YES 'testuser2'@'localhost' def db_datadict tb1 INSERT YES @@ -184,6 +186,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'testuser1'@'localhost' def test t1_table CREATE NO 'testuser1'@'localhost' def test t1_table CREATE VIEW NO 'testuser1'@'localhost' def test t1_table DELETE NO +'testuser1'@'localhost' def test t1_table DELETE VERSIONING ROWS NO 'testuser1'@'localhost' def test t1_table DROP NO 'testuser1'@'localhost' def test t1_table INDEX NO 'testuser1'@'localhost' def test t1_table INSERT NO @@ -196,6 +199,7 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE 'testuser1'@'localhost' def test t1_view CREATE NO 'testuser1'@'localhost' def test t1_view CREATE VIEW NO 'testuser1'@'localhost' def test t1_view DELETE NO +'testuser1'@'localhost' def test t1_view DELETE VERSIONING ROWS NO 'testuser1'@'localhost' def test t1_view DROP NO 'testuser1'@'localhost' def test t1_view INDEX NO 'testuser1'@'localhost' def test t1_view INSERT NO diff --git a/mysql-test/suite/funcs_1/r/is_tables_mysql.result b/mysql-test/suite/funcs_1/r/is_tables_mysql.result index 8e0c9b64dab..704bb51f70a 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_tables_mysql.result @@ -700,6 +700,29 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Users and global privileges Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA mysql +TABLE_NAME vtmd_template +TABLE_TYPE BASE TABLE +ENGINE InnoDB +VERSION 10 +ROW_FORMAT DYNAMIC_OR_PAGE +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_bin +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- DROP USER testuser1@localhost; CREATE USER testuser1@localhost; GRANT SELECT ON test1.* TO testuser1@localhost; diff --git a/mysql-test/suite/funcs_1/r/is_triggers.result b/mysql-test/suite/funcs_1/r/is_triggers.result index 8e5842742cb..2eb352ceb07 100644 --- a/mysql-test/suite/funcs_1/r/is_triggers.result +++ b/mysql-test/suite/funcs_1/r/is_triggers.result @@ -144,7 +144,7 @@ connect testuser2, localhost, testuser2, , db_datadict; SHOW GRANTS FOR 'testuser2'@'localhost'; Grants for testuser2@localhost GRANT USAGE ON *.* TO 'testuser2'@'localhost' -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW ON `db_datadict`.`t1` TO 'testuser2'@'localhost' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, DELETE VERSIONING ROWS ON `db_datadict`.`t1` TO 'testuser2'@'localhost' # No TRIGGER Privilege --> no result for query SELECT * FROM information_schema.triggers WHERE trigger_name = 'trg1'; diff --git a/mysql-test/suite/funcs_1/r/is_user_privileges.result b/mysql-test/suite/funcs_1/r/is_user_privileges.result index a300a1f73e7..655b6d9e209 100644 --- a/mysql-test/suite/funcs_1/r/is_user_privileges.result +++ b/mysql-test/suite/funcs_1/r/is_user_privileges.result @@ -119,6 +119,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -165,6 +166,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -211,6 +213,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -281,6 +284,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -327,6 +331,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -373,6 +378,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -429,6 +435,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -475,6 +482,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -521,6 +529,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -599,6 +608,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -645,6 +655,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -691,6 +702,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -761,6 +773,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -807,6 +820,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -853,6 +867,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -909,6 +924,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -955,6 +971,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1001,6 +1018,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1109,6 +1127,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1155,6 +1174,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1201,6 +1221,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1304,6 +1325,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1350,6 +1372,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1396,6 +1419,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1452,6 +1476,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1498,6 +1523,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1544,6 +1570,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1607,6 +1634,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1653,6 +1681,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1699,6 +1728,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1777,6 +1807,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1823,6 +1854,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer @@ -1869,6 +1901,7 @@ Create_user_priv N Event_priv N Trigger_priv N Create_tablespace_priv N +Delete_versioning_rows_priv N ssl_type ssl_cipher x509_issuer diff --git a/mysql-test/suite/funcs_1/r/memory_trig_03.result b/mysql-test/suite/funcs_1/r/memory_trig_03.result index 8fd3e034735..b86315a1a7d 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_03.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_03.result @@ -78,7 +78,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke TRIGGER on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.t1 to test_yesprivs@localhost; @@ -168,7 +168,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke UPDATE on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER, UPDATE on *.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; @@ -183,7 +183,7 @@ test_noprivs@localhost use priv_db; show grants; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' select f1 from t1 order by f1; f1 insert 3.5.3.2-no @@ -248,7 +248,7 @@ connection no_privs_424b; show grants; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' use priv_db; create trigger trg4b_1 before UPDATE on t1 for each row set new.f1 = 'trig 3.5.3.7-1b'; @@ -329,7 +329,7 @@ connection no_privs_424c; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' use priv_db; create trigger trg4c_1 before INSERT on t1 for each row set new.f1 = 'trig 3.5.3.7-1c'; @@ -441,7 +441,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke SELECT on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER, SELECT on *.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; @@ -457,7 +457,7 @@ test_noprivs@localhost use priv_db; show grants; Grants for test_noprivs@localhost -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' create trigger trg5a_1 before INSERT on t1 for each row set @test_var = new.f1; connection default; @@ -503,7 +503,7 @@ revoke SELECT on priv_db.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.* to test_yesprivs@localhost; @@ -518,7 +518,7 @@ connection no_privs_425b; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' use priv_db; create trigger trg5b_1 before UPDATE on t1 for each row set @test_var= new.f1; @@ -565,7 +565,7 @@ revoke SELECT on priv_db.t1 from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.t1 to test_yesprivs@localhost; @@ -580,7 +580,7 @@ connection no_privs_425c; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' use priv_db; create trigger trg5c_1 before INSERT on t1 for each row set @test_var= new.f1; diff --git a/mysql-test/suite/funcs_1/r/memory_trig_03e.result b/mysql-test/suite/funcs_1/r/memory_trig_03e.result index 83c36c6294f..ea0aaf0c86f 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_03e.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_03e.result @@ -604,7 +604,7 @@ trig 1_1-yes revoke TRIGGER on *.* from test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' disconnect yes_privs; connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; select current_user; @@ -657,7 +657,7 @@ root@localhost grant TRIGGER on priv_db.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT TRIGGER ON `priv_db`.* TO 'test_yesprivs'@'localhost' trigger privilege on db level for create: @@ -930,7 +930,7 @@ grant TRIGGER on priv1_db.t1 to test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT USAGE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `priv1_db`.* TO 'test_yesprivs'@'localhost' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, DELETE VERSIONING ROWS ON `priv1_db`.* TO 'test_yesprivs'@'localhost' GRANT SELECT, UPDATE ON `priv2_db`.* TO 'test_yesprivs'@'localhost' GRANT TRIGGER ON `priv1_db`.`t1` TO 'test_yesprivs'@'localhost' diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result index a2af9082c72..4c422d600bf 100644 --- a/mysql-test/suite/funcs_1/r/memory_views.result +++ b/mysql-test/suite/funcs_1/r/memory_views.result @@ -3552,11 +3552,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3586,7 +3586,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3615,7 +3615,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_03.result b/mysql-test/suite/funcs_1/r/myisam_trig_03.result index 8fd3e034735..b86315a1a7d 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_03.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_03.result @@ -78,7 +78,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke TRIGGER on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.t1 to test_yesprivs@localhost; @@ -168,7 +168,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke UPDATE on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER, UPDATE on *.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; @@ -183,7 +183,7 @@ test_noprivs@localhost use priv_db; show grants; Grants for test_noprivs@localhost -GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' select f1 from t1 order by f1; f1 insert 3.5.3.2-no @@ -248,7 +248,7 @@ connection no_privs_424b; show grants; Grants for test_noprivs@localhost GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' use priv_db; create trigger trg4b_1 before UPDATE on t1 for each row set new.f1 = 'trig 3.5.3.7-1b'; @@ -329,7 +329,7 @@ connection no_privs_424c; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' use priv_db; create trigger trg4c_1 before INSERT on t1 for each row set new.f1 = 'trig 3.5.3.7-1c'; @@ -441,7 +441,7 @@ grant ALL on *.* to test_noprivs@localhost; revoke SELECT on *.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER, SELECT on *.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; @@ -457,7 +457,7 @@ test_noprivs@localhost use priv_db; show grants; Grants for test_noprivs@localhost -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' create trigger trg5a_1 before INSERT on t1 for each row set @test_var = new.f1; connection default; @@ -503,7 +503,7 @@ revoke SELECT on priv_db.* from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.* to test_yesprivs@localhost; @@ -518,7 +518,7 @@ connection no_privs_425b; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.* TO 'test_noprivs'@'localhost' use priv_db; create trigger trg5b_1 before UPDATE on t1 for each row set @test_var= new.f1; @@ -565,7 +565,7 @@ revoke SELECT on priv_db.t1 from test_noprivs@localhost; show grants for test_noprivs@localhost; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; grant TRIGGER on *.* to test_yesprivs@localhost; grant SELECT on priv_db.t1 to test_yesprivs@localhost; @@ -580,7 +580,7 @@ connection no_privs_425c; show grants; Grants for test_noprivs@localhost GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' +GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER, DELETE VERSIONING ROWS ON `priv_db`.`t1` TO 'test_noprivs'@'localhost' use priv_db; create trigger trg5c_1 before INSERT on t1 for each row set @test_var= new.f1; diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_03e.result b/mysql-test/suite/funcs_1/r/myisam_trig_03e.result index a4db9050c86..60e6031f0e2 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_03e.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_03e.result @@ -604,7 +604,7 @@ trig 1_1-yes revoke TRIGGER on *.* from test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' disconnect yes_privs; connect yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK; select current_user; @@ -657,7 +657,7 @@ root@localhost grant TRIGGER on priv_db.* to test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, CREATE TABLESPACE, DELETE VERSIONING ROWS ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' GRANT TRIGGER ON `priv_db`.* TO 'test_yesprivs'@'localhost' trigger privilege on db level for create: @@ -930,7 +930,7 @@ grant TRIGGER on priv1_db.t1 to test_yesprivs@localhost; show grants for test_yesprivs@localhost; Grants for test_yesprivs@localhost GRANT USAGE ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576' -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `priv1_db`.* TO 'test_yesprivs'@'localhost' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, DELETE VERSIONING ROWS ON `priv1_db`.* TO 'test_yesprivs'@'localhost' GRANT SELECT, UPDATE ON `priv2_db`.* TO 'test_yesprivs'@'localhost' GRANT TRIGGER ON `priv1_db`.`t1` TO 'test_yesprivs'@'localhost' diff --git a/mysql-test/suite/funcs_1/r/myisam_views-big.result b/mysql-test/suite/funcs_1/r/myisam_views-big.result index 3290b3dd36a..36c99148020 100644 --- a/mysql-test/suite/funcs_1/r/myisam_views-big.result +++ b/mysql-test/suite/funcs_1/r/myisam_views-big.result @@ -4054,11 +4054,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -4088,7 +4088,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -4117,7 +4117,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 2c86e6c3e73..29d3b23211b 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -2807,7 +2807,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE with() SELECT * from t1 where f2=f1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '() +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE write() SELECT * from t1 where f2=f1; @@ -9222,7 +9222,7 @@ CREATE PROCEDURE sp1() BEGIN declare with char; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'char; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with char; END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: @@ -11574,9 +11574,8 @@ BEGIN declare with condition for sqlstate '02000'; declare exit handler for with set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition for sqlstate '02000'; -declare exit handler for with set @var2 = 1; -END' at line 3 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with condition for sqlstate '02000'; +declare exit handler for with set @var2 = 1' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist @@ -13680,7 +13679,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare with handler for sqlstate '02000' set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'handler for sqlstate '02000' set @var2 = 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with handler for sqlstate '02000' set @var2 = 1; END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: diff --git a/mysql-test/suite/handler/disabled.def b/mysql-test/suite/handler/disabled.def index 888298bbb09..1f648e74b06 100644 --- a/mysql-test/suite/handler/disabled.def +++ b/mysql-test/suite/handler/disabled.def @@ -9,3 +9,6 @@ # Do not use any TAB characters for whitespace. # ############################################################################## + +wl6501_1: versioning branch +wl6501_crash_3: versioning branch diff --git a/mysql-test/suite/innodb/t/innodb_skip_innodb_is_tables.test b/mysql-test/suite/innodb/t/innodb_skip_innodb_is_tables.test index 01ced047302..4954191d74a 100644 --- a/mysql-test/suite/innodb/t/innodb_skip_innodb_is_tables.test +++ b/mysql-test/suite/innodb/t/innodb_skip_innodb_is_tables.test @@ -1,4 +1,5 @@ --source include/not_embedded.inc +--source include/have_xtradb.inc select * from information_schema.innodb_trx; select * from information_schema.innodb_locks; diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result index 42e294b3293..fcf196a0631 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext.result +++ b/mysql-test/suite/innodb_fts/r/fulltext.result @@ -56,7 +56,7 @@ Only MyISAM tables support collections MySQL has now support for full-text search Full-text search in MySQL implements vector space model select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'QUERY EXPANSION)' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH QUERY EXPANSION)' at line 1 explain select * from t1 where MATCH(a,b) AGAINST ("collections"); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 fulltext a a 0 1 Using where diff --git a/mysql-test/suite/parts/r/partition_syntax_innodb.result b/mysql-test/suite/parts/r/partition_syntax_innodb.result index a5d257f64e0..cc53aaff426 100644 --- a/mysql-test/suite/parts/r/partition_syntax_innodb.result +++ b/mysql-test/suite/parts/r/partition_syntax_innodb.result @@ -510,7 +510,7 @@ f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11)); -ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning #------------------------------------------------------------------------ # 2.2 Every partition must have the same number of subpartitions. # This is a limitation of MySQL 5.1, which could be removed in diff --git a/mysql-test/suite/parts/r/partition_syntax_myisam.result b/mysql-test/suite/parts/r/partition_syntax_myisam.result index 765280f35c6..58d3a6f593e 100644 --- a/mysql-test/suite/parts/r/partition_syntax_myisam.result +++ b/mysql-test/suite/parts/r/partition_syntax_myisam.result @@ -510,7 +510,7 @@ f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11)); -ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +ERROR HY000: It is only possible to mix RANGE/LIST/SYSTEM_TIME partitioning with HASH/KEY partitioning for subpartitioning #------------------------------------------------------------------------ # 2.2 Every partition must have the same number of subpartitions. # This is a limitation of MySQL 5.1, which could be removed in diff --git a/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.result b/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.result index 1a269d72eb7..afe00ed7729 100644 --- a/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.result +++ b/mysql-test/suite/roles/create_and_drop_role_invalid_user_table.result @@ -5,7 +5,7 @@ alter table user drop column default_role; alter table user drop column max_statement_time; flush privileges; create role test_role; -ERROR HY000: Column count of mysql.user is wrong. Expected 44, found 43. Created with MariaDB MYSQL_VERSION_ID, now running MYSQL_VERSION_ID. Please use mysql_upgrade to fix this error +ERROR HY000: Column count of mysql.user is wrong. Expected 45, found 44. Created with MariaDB MYSQL_VERSION_ID, now running MYSQL_VERSION_ID. Please use mysql_upgrade to fix this error drop role test_role; ERROR HY000: Operation DROP ROLE failed for 'test_role' alter table user add column is_role enum('N', 'Y') default 'N' not null @@ -15,7 +15,7 @@ create role test_role; create user test_user@localhost; grant test_role to test_user@localhost; set default role test_role for root@localhost; -ERROR HY000: Column count of mysql.user is wrong. Expected 45, found 44. Created with MariaDB MYSQL_VERSION_ID, now running MYSQL_VERSION_ID. Please use mysql_upgrade to fix this error +ERROR HY000: Column count of mysql.user is wrong. Expected 46, found 45. Created with MariaDB MYSQL_VERSION_ID, now running MYSQL_VERSION_ID. Please use mysql_upgrade to fix this error drop role test_role; drop user test_user@localhost; alter table user add column default_role char(80) binary default '' not null diff --git a/mysql-test/suite/roles/set_role-recursive.result b/mysql-test/suite/roles/set_role-recursive.result index 53b28a25261..9cea63de3bf 100644 --- a/mysql-test/suite/roles/set_role-recursive.result +++ b/mysql-test/suite/roles/set_role-recursive.result @@ -16,11 +16,11 @@ Host User Role Admin_option test_role1 test_role2 N grant select on *.* to test_role2; select * from mysql.user where user like 'test_role1'; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time - test_role1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N Y 0.000000 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_versioning_rows_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time + test_role1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N Y 0.000000 select * from mysql.user where user like 'test_role2'; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time - test_role2 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N Y 0.000000 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_versioning_rows_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time + test_role2 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N Y 0.000000 select * from mysql.roles_mapping; ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping' show grants; diff --git a/mysql-test/suite/roles/set_role-simple.result b/mysql-test/suite/roles/set_role-simple.result index 29b176776e7..c26f06d1bfe 100644 --- a/mysql-test/suite/roles/set_role-simple.result +++ b/mysql-test/suite/roles/set_role-simple.result @@ -11,8 +11,8 @@ localhost root test_role1 Y localhost test_user test_role1 N grant select on *.* to test_role1; select * from mysql.user where user='test_role1'; -Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time - test_role1 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N Y 0.000000 +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_versioning_rows_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time + test_role1 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N Y 0.000000 select * from mysql.roles_mapping; ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping' show grants; diff --git a/mysql-test/suite/sys_vars/r/delay_key_write_basic.result b/mysql-test/suite/sys_vars/r/delay_key_write_basic.result index 2258d7af078..7299737f63b 100644 --- a/mysql-test/suite/sys_vars/r/delay_key_write_basic.result +++ b/mysql-test/suite/sys_vars/r/delay_key_write_basic.result @@ -37,8 +37,8 @@ SET @@global.delay_key_write = FALSE0; ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'FALSE0' SET @@global.delay_key_write = ONN; ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'ONN' -SET @@global.delay_key_write = OF; -ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'OF' +SET @@global.delay_key_write = OFFF; +ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'OFFF' SET @@global.delay_key_write = ' '; ERROR 42000: Variable 'delay_key_write' can't be set to the value of ' ' SET @@global.delay_key_write = ""; diff --git a/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result b/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result index 834d693edb8..f33ef34a62a 100644 --- a/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result +++ b/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result @@ -43,8 +43,8 @@ SET @@session.foreign_key_checks = TRÜE; ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'TRÜE' SET @@session.foreign_key_checks = ÕN; ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'ÕN' -SET @@session.foreign_key_checks = OF; -ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'OF' +SET @@session.foreign_key_checks = OFFF; +ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'OFFF' SET @@session.foreign_key_checks = ÓFF; ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'ÓFF' SET @@session.foreign_key_checks = '¹'; diff --git a/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result b/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result index 08dc5d7aaca..aec529aece2 100644 --- a/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result @@ -66,7 +66,7 @@ SET @@session.innodb_table_locks = TRÜE; ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'TRÜE' SET @@session.innodb_table_locks = ÕN; ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'ÕN' -SET @@session.innodb_table_locks = OF; +SET @@session.innodb_table_locks = OFF; SELECT @@session.innodb_table_locks; @@session.innodb_table_locks 0 @@ -84,7 +84,7 @@ SET @@global.innodb_table_locks = TRÜE; ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'TRÜE' SET @@global.innodb_table_locks = QN; ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'QN' -SET @@global.innodb_table_locks = OF; +SET @@global.innodb_table_locks = OFF; SELECT @@global.innodb_table_locks; @@global.innodb_table_locks 0 diff --git a/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result b/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result index b7deea88a9c..8e9f7308b73 100644 --- a/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result +++ b/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result @@ -101,8 +101,8 @@ SET @@session.keep_files_on_create = ONN; ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'ONN' SET @@session.keep_files_on_create = ONF; ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'ONF' -SET @@session.keep_files_on_create = OF; -ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'OF' +SET @@session.keep_files_on_create = OFFF; +ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'OFFF' SET @@session.keep_files_on_create = 'OFN'; ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'OFN' SET @@session.keep_files_on_create = -2; diff --git a/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result b/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result index 7ed1b689f5a..d3d2e97d249 100644 --- a/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result +++ b/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result @@ -50,8 +50,8 @@ SET @@global.log_bin_trust_function_creators = 'ONN'; ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'ONN' SET @@global.log_bin_trust_function_creators = "OFFF"; ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'OFFF' -SET @@global.log_bin_trust_function_creators = OF; -ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'OF' +SET @@global.log_bin_trust_function_creators = OFFF; +ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'OFFF' SET @@global.log_bin_trust_function_creators = TTRUE; ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'TTRUE' SET @@global.log_bin_trust_function_creators = FELSE; diff --git a/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result b/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result index 633dc274dec..9e514c8cb35 100644 --- a/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result +++ b/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result @@ -101,8 +101,8 @@ SET @@session.low_priority_updates = ONN; ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'ONN' SET @@session.low_priority_updates = ONF; ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'ONF' -SET @@session.low_priority_updates = OF; -ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'OF' +SET @@session.low_priority_updates = OFFF; +ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'OFFF' SET @@session.low_priority_updates = 'OFN'; ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'OFN' SET @@session.low_priority_updates = -2; diff --git a/mysql-test/suite/sys_vars/r/old_passwords_basic.result b/mysql-test/suite/sys_vars/r/old_passwords_basic.result index 26d0e79071b..dba84b18b11 100644 --- a/mysql-test/suite/sys_vars/r/old_passwords_basic.result +++ b/mysql-test/suite/sys_vars/r/old_passwords_basic.result @@ -97,8 +97,8 @@ SET @@session.old_passwords = ONN; ERROR 42000: Variable 'old_passwords' can't be set to the value of 'ONN' SET @@session.old_passwords = ONF; ERROR 42000: Variable 'old_passwords' can't be set to the value of 'ONF' -SET @@session.old_passwords = OF; -ERROR 42000: Variable 'old_passwords' can't be set to the value of 'OF' +SET @@session.old_passwords = OFFF; +ERROR 42000: Variable 'old_passwords' can't be set to the value of 'OFFF' SET @@session.old_passwords = 'OFN'; ERROR 42000: Variable 'old_passwords' can't be set to the value of 'OFN' SET @@session.old_passwords = -2; diff --git a/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result b/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result index 99843f0b93f..c22107292cd 100644 --- a/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result +++ b/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result @@ -104,7 +104,7 @@ SET @@session.optimizer_prune_level = ONF; ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level' SET @@session.optimizer_prune_level = ON; ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level' -SET @@session.optimizer_prune_level = OF; +SET @@session.optimizer_prune_level = OFFF; ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level' SET @@session.optimizer_prune_level = 'OFN'; ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level' diff --git a/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result b/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result index c98dd338909..cec880bf1d5 100644 --- a/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result +++ b/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result @@ -58,8 +58,8 @@ SET @@session.pseudo_slave_mode = TRÜE; ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'TRÜE' SET @@session.pseudo_slave_mode = ÕN; ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'ÕN' -SET @@session.pseudo_slave_mode = OF; -ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'OF' +SET @@session.pseudo_slave_mode = OFFF; +ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'OFFF' SET @@session.pseudo_slave_mode = ÓFF; ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'ÓFF' SET @@session.pseudo_slave_mode = '¹'; diff --git a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result index 96f42bbbda3..26169b4b979 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result +++ b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result @@ -66,8 +66,8 @@ SET @@session.query_cache_wlock_invalidate = TRÜE; ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'TRÜE' SET @@session.query_cache_wlock_invalidate = ÕN; ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÕN' -SET @@session.query_cache_wlock_invalidate = OF; -ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OF' +SET @@session.query_cache_wlock_invalidate = OFFF; +ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OFFF' SET @@session.query_cache_wlock_invalidate = ÓFF; ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÓFF' SET @@global.query_cache_wlock_invalidate = -1; @@ -82,8 +82,8 @@ SET @@global.query_cache_wlock_invalidate = TRÜE; ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'TRÜE' SET @@global.query_cache_wlock_invalidate = ÕN; ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÕN' -SET @@global.query_cache_wlock_invalidate = OF; -ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OF' +SET @@global.query_cache_wlock_invalidate = OFFF; +ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OFFF' SET @@global.query_cache_wlock_invalidate = ÓFF; ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÓFF' '#-------------------FN_DYNVARS_135_05----------------------------#' diff --git a/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result b/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result index 98f05bda488..fc16ecc06f2 100644 --- a/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result @@ -43,8 +43,8 @@ SET @@session.sql_big_selects = TRÜE; ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'TRÜE' SET @@session.sql_big_selects = ÕN; ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'ÕN' -SET @@session.sql_big_selects = OF; -ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'OF' +SET @@session.sql_big_selects = OFFF; +ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'OFFF' SET @@session.sql_big_selects = ÓFF; ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'ÓFF' SET @@session.sql_big_selects = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result b/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result index 09553ae7d57..91081a78328 100644 --- a/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result @@ -48,7 +48,7 @@ SET @@session.sql_big_tables = TRÜE; ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'TRÜE' SET @@session.sql_big_tables = ÕN; ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'ÕN' -SET @@session.sql_big_tables = OF; +SET @@session.sql_big_tables = OFFF; ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'OF' SET @@session.sql_big_tables = ÓFF; ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'ÓFF' diff --git a/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result b/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result index 2dfdcb26898..83597ef47cb 100644 --- a/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result @@ -48,8 +48,8 @@ SET @@session.sql_buffer_result = TRÜE; ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'TRÜE' SET @@session.sql_buffer_result = ÕN; ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'ÕN' -SET @@session.sql_buffer_result = OF; -ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'OF' +SET @@session.sql_buffer_result = OFFF; +ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'OFFF' SET @@session.sql_buffer_result = ÓFF; ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'ÓFF' SET @@session.sql_buffer_result = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result index 909c434340c..a909019fc50 100644 --- a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result @@ -48,8 +48,8 @@ SET @@session.sql_log_bin = TRÜE; ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'TRÜE' SET @@session.sql_log_bin = ÕN; ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'ÕN' -SET @@session.sql_log_bin = OF; -ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'OF' +SET @@session.sql_log_bin = OFFF; +ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'OFFF' SET @@session.sql_log_bin = ÓFF; ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'ÓFF' SET @@session.sql_log_bin = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_log_off_basic.result b/mysql-test/suite/sys_vars/r/sql_log_off_basic.result index c2ffa17c5fe..0cb5b576127 100644 --- a/mysql-test/suite/sys_vars/r/sql_log_off_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_log_off_basic.result @@ -48,8 +48,8 @@ SET @@session.sql_log_off = TRÜE; ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'TRÜE' SET @@session.sql_log_off = ÕN; ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'ÕN' -SET @@session.sql_log_off = OF; -ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'OF' +SET @@session.sql_log_off = OFFF; +ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'OFFF' SET @@session.sql_log_off = ÓFF; ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'ÓFF' SET @@session.sql_log_off = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result index 28bc53e5718..ed493e038ca 100644 --- a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result @@ -63,7 +63,7 @@ SET @@session.sql_low_priority_updates = TRÜE; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'TRÜE' SET @@session.sql_low_priority_updates = ÕN; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÕN' -SET @@session.sql_low_priority_updates = OF; +SET @@session.sql_low_priority_updates = OFFF; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'OF' SET @@session.sql_low_priority_updates = ÓFF; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÓFF' @@ -79,7 +79,7 @@ SET @@global.sql_low_priority_updates = TRÜE; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'TRÜE' SET @@global.sql_low_priority_updates = ÕN; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÕN' -SET @@global.sql_low_priority_updates = OF; +SET @@global.sql_low_priority_updates = OFFF; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'OF' SET @@global.sql_low_priority_updates = ÓFF; ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÓFF' diff --git a/mysql-test/suite/sys_vars/r/sql_notes_basic.result b/mysql-test/suite/sys_vars/r/sql_notes_basic.result index 7a54f90f8b7..18a846874ab 100644 --- a/mysql-test/suite/sys_vars/r/sql_notes_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_notes_basic.result @@ -48,8 +48,8 @@ SET @@session.sql_notes = TRÜE; ERROR 42000: Variable 'sql_notes' can't be set to the value of 'TRÜE' SET @@session.sql_notes = ÕN; ERROR 42000: Variable 'sql_notes' can't be set to the value of 'ÕN' -SET @@session.sql_notes = OF; -ERROR 42000: Variable 'sql_notes' can't be set to the value of 'OF' +SET @@session.sql_notes = OFFF; +ERROR 42000: Variable 'sql_notes' can't be set to the value of 'OFFF' SET @@session.sql_notes = ÓFF; ERROR 42000: Variable 'sql_notes' can't be set to the value of 'ÓFF' SET @@session.sql_notes = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result b/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result index 8cf99233ef9..97715ae2089 100644 --- a/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result @@ -48,8 +48,8 @@ SET @@session.sql_quote_show_create = TRÜE; ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'TRÜE' SET @@session.sql_quote_show_create = ÕN; ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'ÕN' -SET @@session.sql_quote_show_create = OF; -ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'OF' +SET @@session.sql_quote_show_create = OFFF; +ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'OFFF' SET @@session.sql_quote_show_create = ÓFF; ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'ÓFF' SET @@session.sql_quote_show_create = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result b/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result index 91bfcb2377e..4bdcc8f6b47 100644 --- a/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result @@ -48,8 +48,8 @@ SET @@session.sql_safe_updates = TRÜE; ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'TRÜE' SET @@session.sql_safe_updates = ÕN; ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'ÕN' -SET @@session.sql_safe_updates = OF; -ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'OF' +SET @@session.sql_safe_updates = OFFF; +ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'OFFF' SET @@session.sql_safe_updates = ÓFF; ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'ÓFF' SET @@session.sql_safe_updates = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sql_warnings_basic.result b/mysql-test/suite/sys_vars/r/sql_warnings_basic.result index 762182336c3..f9cae0c7f7a 100644 --- a/mysql-test/suite/sys_vars/r/sql_warnings_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_warnings_basic.result @@ -46,8 +46,8 @@ SET @@session.sql_warnings = TRÜE; ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'TRÜE' SET @@session.sql_warnings = ÕN; ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'ÕN' -SET @@session.sql_warnings = OF; -ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'OF' +SET @@session.sql_warnings = OFFF; +ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'OFFF' SET @@session.sql_warnings = ÓFF; ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'ÓFF' SET @@session.sql_warnings = '¹'; diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 69ecca3312f..65537aeaa55 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -5274,6 +5274,76 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NEVER,COMPLEMENTARY,PREFERABLY READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME VERSIONING_ALTER_HISTORY +SESSION_VALUE KEEP +GLOBAL_VALUE KEEP +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE KEEP +VARIABLE_SCOPE SESSION +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Versioning ALTER TABLE mode +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST KEEP,SURVIVE,DROP +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME VERSIONING_CURRENT_TIMESTAMP +SESSION_VALUE NOW +GLOBAL_VALUE NOW +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE now +VARIABLE_SCOPE SESSION +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT Default AS OF value for versioned tables +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME VERSIONING_FORCE +SESSION_VALUE OFF +GLOBAL_VALUE OFF +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE OFF +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Force system versioning for all created tables +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME VERSIONING_HIDE +SESSION_VALUE AUTO +GLOBAL_VALUE AUTO +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE AUTO +VARIABLE_SCOPE SESSION +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Hide system versioning from being displayed in table info. AUTO: hide implicit system fields only in non-versioned and AS OF queries; IMPLICIT: hide implicit system fields in all queries; FULL: hide any system fields in all queries and hide versioning info in SHOW commands; NEVER: don't hide system fields +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST AUTO,IMPLICIT,FULL,NEVER +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME VERSIONING_INNODB_ALGORITHM_SIMPLE +SESSION_VALUE ON +GLOBAL_VALUE ON +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE ON +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Use simple algorithm of timestamp handling in InnoDB instead of TRX_SEES +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME WAIT_TIMEOUT SESSION_VALUE 28800 GLOBAL_VALUE 28800 diff --git a/mysql-test/suite/sys_vars/r/tx_read_only_basic.result b/mysql-test/suite/sys_vars/r/tx_read_only_basic.result index 3750145083f..e8f5da31c5a 100644 --- a/mysql-test/suite/sys_vars/r/tx_read_only_basic.result +++ b/mysql-test/suite/sys_vars/r/tx_read_only_basic.result @@ -102,8 +102,8 @@ SET @@session.tx_read_only = ONN; ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'ONN' SET @@session.tx_read_only = ONF; ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'ONF' -SET @@session.tx_read_only = OF; -ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'OF' +SET @@session.tx_read_only = OFFF; +ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'OFFF' SET @@session.tx_read_only = 'OFN'; ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'OFN' SET @@session.tx_read_only = -2; diff --git a/mysql-test/suite/sys_vars/t/delay_key_write_basic.test b/mysql-test/suite/sys_vars/t/delay_key_write_basic.test index 25176879eb1..2856993cb6c 100644 --- a/mysql-test/suite/sys_vars/t/delay_key_write_basic.test +++ b/mysql-test/suite/sys_vars/t/delay_key_write_basic.test @@ -90,7 +90,7 @@ SET @@global.delay_key_write = FALSE0; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.delay_key_write = ONN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@global.delay_key_write = OF; +SET @@global.delay_key_write = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.delay_key_write = ' '; diff --git a/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test b/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test index 8a327ab699b..b1fc9997cfa 100644 --- a/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test +++ b/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test @@ -94,7 +94,7 @@ SET @@session.foreign_key_checks = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.foreign_key_checks = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.foreign_key_checks = OF; +SET @@session.foreign_key_checks = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.foreign_key_checks = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test b/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test index e3e4bda345e..25be5daa552 100644 --- a/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test @@ -119,7 +119,7 @@ SET @@session.innodb_table_locks = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.innodb_table_locks = ÕN; -SET @@session.innodb_table_locks = OF; +SET @@session.innodb_table_locks = OFF; SELECT @@session.innodb_table_locks; --Error ER_WRONG_VALUE_FOR_VAR @@ -141,7 +141,7 @@ SET @@global.innodb_table_locks = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.innodb_table_locks = QN; -SET @@global.innodb_table_locks = OF; +SET @@global.innodb_table_locks = OFF; SELECT @@global.innodb_table_locks; --Error ER_WRONG_TYPE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test b/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test index e6141af4bbe..cfa50e72146 100644 --- a/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test +++ b/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test @@ -132,7 +132,7 @@ SET @@session.keep_files_on_create = ONN; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.keep_files_on_create = ONF; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.keep_files_on_create = OF; +SET @@session.keep_files_on_create = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.keep_files_on_create = 'OFN'; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test b/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test index 15ffad2742a..1db6bf41e6f 100644 --- a/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test +++ b/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test @@ -96,7 +96,7 @@ SET @@global.log_bin_trust_function_creators = 'ONN'; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.log_bin_trust_function_creators = "OFFF"; --Error ER_WRONG_VALUE_FOR_VAR -SET @@global.log_bin_trust_function_creators = OF; +SET @@global.log_bin_trust_function_creators = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.log_bin_trust_function_creators = TTRUE; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test b/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test index e00688ef974..703036b8e36 100644 --- a/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test +++ b/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test @@ -132,7 +132,7 @@ SET @@session.low_priority_updates = ONN; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.low_priority_updates = ONF; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.low_priority_updates = OF; +SET @@session.low_priority_updates = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.low_priority_updates = 'OFN'; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/old_passwords_basic.test b/mysql-test/suite/sys_vars/t/old_passwords_basic.test index f4965ad7528..038a77edf8f 100644 --- a/mysql-test/suite/sys_vars/t/old_passwords_basic.test +++ b/mysql-test/suite/sys_vars/t/old_passwords_basic.test @@ -131,7 +131,7 @@ SET @@session.old_passwords = ONN; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.old_passwords = ONF; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.old_passwords = OF; +SET @@session.old_passwords = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.old_passwords = 'OFN'; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test b/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test index 1e3a8bc3d7f..374be2db6ae 100644 --- a/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test +++ b/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test @@ -140,7 +140,7 @@ SET @@session.optimizer_prune_level = ONF; --Error ER_WRONG_TYPE_FOR_VAR SET @@session.optimizer_prune_level = ON; --Error ER_WRONG_TYPE_FOR_VAR -SET @@session.optimizer_prune_level = OF; +SET @@session.optimizer_prune_level = OFFF; --Error ER_WRONG_TYPE_FOR_VAR SET @@session.optimizer_prune_level = 'OFN'; diff --git a/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test b/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test index 3ef39bb8667..6d1dca299c6 100644 --- a/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test +++ b/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test @@ -97,7 +97,7 @@ SET @@session.pseudo_slave_mode = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.pseudo_slave_mode = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.pseudo_slave_mode = OF; +SET @@session.pseudo_slave_mode = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.pseudo_slave_mode = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test index 055c3629d15..c883d9b789a 100644 --- a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test +++ b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test @@ -116,7 +116,7 @@ SET @@session.query_cache_wlock_invalidate = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.query_cache_wlock_invalidate = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.query_cache_wlock_invalidate = OF; +SET @@session.query_cache_wlock_invalidate = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.query_cache_wlock_invalidate = ÓFF; @@ -135,7 +135,7 @@ SET @@global.query_cache_wlock_invalidate = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.query_cache_wlock_invalidate = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@global.query_cache_wlock_invalidate = OF; +SET @@global.query_cache_wlock_invalidate = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@global.query_cache_wlock_invalidate = ÓFF; diff --git a/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test b/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test index 42331d766be..52345b71144 100644 --- a/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test @@ -94,7 +94,7 @@ SET @@session.sql_big_selects = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_big_selects = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_big_selects = OF; +SET @@session.sql_big_selects = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_big_selects = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test b/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test index f5f99efeb0a..2475bd9cd8a 100644 --- a/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test @@ -100,7 +100,7 @@ SET @@session.sql_buffer_result = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_buffer_result = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_buffer_result = OF; +SET @@session.sql_buffer_result = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_buffer_result = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test index 5f5e3920862..7e133200d5f 100644 --- a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test @@ -98,7 +98,7 @@ SET @@session.sql_log_bin = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_log_bin = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_log_bin = OF; +SET @@session.sql_log_bin = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_log_bin = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_log_off_basic.test b/mysql-test/suite/sys_vars/t/sql_log_off_basic.test index 38549ac35d2..a48d3bbfda6 100644 --- a/mysql-test/suite/sys_vars/t/sql_log_off_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_log_off_basic.test @@ -97,7 +97,7 @@ SET @@session.sql_log_off = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_log_off = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_log_off = OF; +SET @@session.sql_log_off = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_log_off = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_notes_basic.test b/mysql-test/suite/sys_vars/t/sql_notes_basic.test index 9af5fa35ea2..204ebe3fe84 100644 --- a/mysql-test/suite/sys_vars/t/sql_notes_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_notes_basic.test @@ -99,7 +99,7 @@ SET @@session.sql_notes = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_notes = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_notes = OF; +SET @@session.sql_notes = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_notes = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test b/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test index 020b5f51e9f..8e8118b998b 100644 --- a/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test @@ -98,7 +98,7 @@ SET @@session.sql_quote_show_create = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_quote_show_create = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_quote_show_create = OF; +SET @@session.sql_quote_show_create = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_quote_show_create = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test b/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test index 66148b65aaf..89208cae0ef 100644 --- a/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test @@ -97,7 +97,7 @@ SET @@session.sql_safe_updates = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_safe_updates = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_safe_updates = OF; +SET @@session.sql_safe_updates = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_safe_updates = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sql_warnings_basic.test b/mysql-test/suite/sys_vars/t/sql_warnings_basic.test index ced58f96e15..f32b6f33f89 100644 --- a/mysql-test/suite/sys_vars/t/sql_warnings_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_warnings_basic.test @@ -98,7 +98,7 @@ SET @@session.sql_warnings = TRÜE; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_warnings = ÕN; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.sql_warnings = OF; +SET @@session.sql_warnings = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.sql_warnings = ÓFF; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/tx_read_only_basic.test b/mysql-test/suite/sys_vars/t/tx_read_only_basic.test index 0ebfcc31a89..8c6ab0e3d59 100644 --- a/mysql-test/suite/sys_vars/t/tx_read_only_basic.test +++ b/mysql-test/suite/sys_vars/t/tx_read_only_basic.test @@ -116,7 +116,7 @@ SET @@session.tx_read_only = ONN; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.tx_read_only = ONF; --Error ER_WRONG_VALUE_FOR_VAR -SET @@session.tx_read_only = OF; +SET @@session.tx_read_only = OFFF; --Error ER_WRONG_VALUE_FOR_VAR SET @@session.tx_read_only = 'OFN'; --Error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/versioning/common.inc b/mysql-test/suite/versioning/common.inc new file mode 100644 index 00000000000..ca3ccd41752 --- /dev/null +++ b/mysql-test/suite/versioning/common.inc @@ -0,0 +1,87 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); + +delimiter ~~; +create procedure if not exists verify_vtq() +begin + set @i= 0; + select + @i:= @i + 1 as No, + transaction_id > 0 as A, + commit_id > transaction_id as B, + begin_timestamp > @test_start as C, + commit_timestamp >= begin_timestamp as D + from information_schema.innodb_vtq + where transaction_id > @start_trx_id; + select ifnull(max(transaction_id), 0) + into @start_trx_id + from information_schema.innodb_vtq; +end~~ + +create function if not exists default_engine() +returns varchar(255) +deterministic +begin + declare e varchar(255); + select lower(engine) from information_schema.engines where support='DEFAULT' into e; + return e; +end~~ + +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin + if default_engine() = 'innodb' then + return 'bigint unsigned'; + elseif default_engine() = 'myisam' then + return 'timestamp(6)'; + end if; + return NULL; +end~~ + +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin + if default_engine() = 'innodb' then + return concat('vtq_commit_ts(', sys_field, ')'); + elseif default_engine() = 'myisam' then + return sys_field; + end if; + return NULL; +end~~ + +create procedure if not exists innodb_verify_vtq(recs int) +begin + declare i int default 1; + if default_engine() = 'innodb' then + call verify_vtq; + elseif default_engine() = 'myisam' then + create temporary table tmp (No int, A bool, B bool, C bool, D bool); + while i <= recs do + insert into tmp values (i, 1, 1, 1, 1); + set i= i + 1; + end while; + select * from tmp; + drop table tmp; + end if; +end~~ + +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin + prepare stmt from concat(a, b); + execute stmt; + deallocate prepare stmt; +end~~ + +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin + prepare stmt from concat(a, b, c); + execute stmt; + deallocate prepare stmt; +end~~ +delimiter ;~~ + +let $default_engine= `select default_engine()`; +let sys_datatype= `select sys_datatype()`; diff --git a/mysql-test/suite/versioning/common.opt b/mysql-test/suite/versioning/common.opt new file mode 100644 index 00000000000..132aab2d0ec --- /dev/null +++ b/mysql-test/suite/versioning/common.opt @@ -0,0 +1,19 @@ +--innodb +--innodb-cmpmem +--innodb-cmp-per-index +--innodb-trx +--innodb-locks +--innodb-metrics +--innodb-buffer-pool-stats +--innodb-buffer-page +--innodb-buffer-page-lru +--innodb-sys-columns +--innodb-sys-fields +--innodb-sys-foreign +--innodb-sys-foreign-cols +--innodb-sys-indexes +--innodb-sys-tables +--innodb-sys-virtual +--innodb-vtq +--versioning-hide=implicit +--plugin-load=versioning diff --git a/mysql-test/suite/versioning/common_finish.inc b/mysql-test/suite/versioning/common_finish.inc new file mode 100644 index 00000000000..9a746f5a98c --- /dev/null +++ b/mysql-test/suite/versioning/common_finish.inc @@ -0,0 +1,7 @@ +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result new file mode 100644 index 00000000000..d6cbaf96b73 --- /dev/null +++ b/mysql-test/suite/versioning/r/alter.result @@ -0,0 +1,595 @@ +create table t( +a int +); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t without system versioning; +ERROR HY000: Wrong parameters for `t`: table is not versioned +alter table t with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t without system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t +add column trx_start bigint(20) unsigned generated always as row start, +add column trx_end bigint(20) unsigned generated always as row end, +add period for system_time(trx_start, trx_end), +with system versioning; +ERROR HY000: `trx_start` must be of type `TIMESTAMP(6)` for versioned table `t` +alter table t +add column trx_start timestamp generated always as row start, +add column trx_end timestamp generated always as row end, +add period for system_time(trx_start, trx_end), +with system versioning; +ERROR HY000: `trx_start` must be of type `TIMESTAMP(6)` for versioned table `t` +alter table t +add column trx_start timestamp(6) not null generated always as row start, +add column trx_end timestamp(6) not null generated always as row end, +add period for system_time(trx_start, trx_end), +with system versioning; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'generated always as row start, +add column trx_end timestamp(6) not null generate' at line 2 +alter table t +add column trx_start timestamp(6) generated always as row start, +add column trx_end timestamp(6) generated always as row end, +add period for system_time(trx_start, trx_end), +with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t drop column trx_start, drop column trx_end; +alter table t without system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t add column b int; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t add column c int; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t add column d int first; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `d` int(11) DEFAULT NULL, + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t add column e int after d; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `d` int(11) DEFAULT NULL, + `e` int(11) DEFAULT NULL, + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t drop column a; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `d` int(11) DEFAULT NULL, + `e` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t ( +a int, +sys_trx_start timestamp(6) generated always as row start, +sys_trx_end timestamp(6) generated always as row end, +period for system_time(sys_trx_start, sys_trx_end)) +with system versioning; +select * from t for system_time all; +a sys_trx_start sys_trx_end +alter table t drop column sys_trx_start; +alter table t drop column sys_trx_end; +select * from t for system_time all; +a +alter table t drop column sys_trx_start; +ERROR 42000: Can't DROP COLUMN `sys_trx_start`; check that it exists +alter table t drop column sys_trx_end; +ERROR 42000: Can't DROP COLUMN `sys_trx_end`; check that it exists +create or replace table t ( +a int, +sys_trx_start timestamp(6) generated always as row start, +sys_trx_end timestamp(6) generated always as row end, +period for system_time(sys_trx_start, sys_trx_end)) +with system versioning; +select * from t for system_time all; +a sys_trx_start sys_trx_end +alter table t drop column sys_trx_start, drop column sys_trx_end; +select * from t for system_time all; +a +create or replace table t( +a int +); +insert into t values(1); +alter table t with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +insert into t values(2); +select * from t for system_time all; +a +1 +2 +select * from t; +a +1 +2 +update t set a=3 where a=1; +select * from t; +a +3 +2 +select * from t for system_time all; +a +3 +2 +1 +select sys_trx_start from t where a=3 into @tm; +alter table t add column b int; +select @tm=sys_trx_start from t where a=3; +@tm=sys_trx_start +1 +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t; +a b +3 NULL +2 NULL +select * from t for system_time all; +a b +3 NULL +2 NULL +1 NULL +alter table t without system versioning; +select * from t; +a b +3 NULL +2 NULL +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t modify a int with system versioning; +ERROR HY000: Wrong parameters for `t`: table is not versioned +alter table t modify a int without system versioning; +ERROR HY000: Wrong parameters for `t`: table is not versioned +alter table t with system versioning; +alter table t modify a int without system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING, + `b` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t modify a int with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create or replace table t( +a int +) engine=innodb; +insert into t values(1); +select * from t; +a +1 +alter table t +add column trx_start timestamp(6) generated always as row start, +add column trx_end timestamp(6) generated always as row end, +add period for system_time(trx_start, trx_end), +with system versioning; +ERROR HY000: `trx_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t` +alter table t +add column trx_start bigint(20) unsigned generated always as row start, +add column trx_end bigint(20) unsigned generated always as row end, +add period for system_time(trx_start, trx_end), +with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +alter table t drop column trx_start, drop column trx_end; +alter table t without system versioning; +alter table t with system versioning, algorithm=copy; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +update t set a=2; +select * from t for system_time all; +a +2 +1 +alter table t add column b int, algorithm=copy; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t; +a b +2 NULL +alter table t drop column b, algorithm=copy; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t for system_time all; +a +2 +1 +alter table t add column b int, algorithm=inplace; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t; +a b +2 NULL +alter table t drop column b, algorithm=inplace; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t for system_time all; +a +2 +1 +alter table t without system versioning, algorithm=copy; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +create or replace table t (a int) with system versioning engine=innodb; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b int auto_increment unique; +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +insert into t values (4, NULL); +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +4 2 +create or replace table t (a int) with system versioning; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b int auto_increment unique; +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +insert into t values (4, NULL); +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +4 2 +create or replace table t (a int) with system versioning engine=innodb; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b tinyint auto_increment unique; +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +insert into t values (4, NULL); +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +4 2 +create or replace table t (a int) with system versioning; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b tinyint auto_increment unique; +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +insert into t values (4, NULL); +select * from t for system_time all; +a b +1 -1 +2 -2 +3 1 +4 2 +create or replace table t (a int) engine innodb; +insert into t values (1); +alter table t with system versioning, algorithm=inplace; +select * from t for system_time all; +a +1 +update t set a=2; +select * from t for system_time all; +a +2 +1 +alter table t add column b int, algorithm=inplace; +select * from t for system_time all; +a b +2 NULL +1 NULL +alter table t without system versioning, algorithm=inplace; +select * from t; +a b +2 NULL +create or replace table t ( +a int, +sys_trx_start bigint(20) unsigned generated always as row start, +sys_trx_end bigint(20) unsigned generated always as row end, +period for system_time(sys_trx_start, sys_trx_end) +) with system versioning engine innodb; +alter table t change column sys_trx_start asdf bigint unsigned; +ERROR HY000: Can not change system versioning field 'sys_trx_start' +create or replace table t ( +a int, +sys_trx_start timestamp(6) generated always as row start, +sys_trx_end timestamp(6) generated always as row end, +period for system_time(sys_trx_start, sys_trx_end) +) with system versioning engine myisam; +alter table t change column sys_trx_start asdf timestamp(6); +ERROR HY000: Can not change system versioning field 'sys_trx_start' +create or replace table t ( +a int, +sys_trx_start timestamp(6) generated always as row start, +sys_trx_end timestamp(6) generated always as row end, +period for system_time(sys_trx_start, sys_trx_end) +) with system versioning; +select * from t; +a sys_trx_start sys_trx_end +alter table t without system versioning; +ERROR HY000: System versioning field 'sys_trx_start' is not hidden +alter table t drop column sys_trx_start; +select * from t; +a sys_trx_end +alter table t without system versioning; +ERROR HY000: System versioning field 'sys_trx_end' is not hidden +alter table t drop column sys_trx_end; +select * from t; +a +alter table t without system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +set versioning_alter_history = DROP; +create or replace table t (a int) with system versioning engine innodb; +insert into t values (1); +update t set a = 2; +select * from t for system_time all; +a +2 +1 +alter table t add column b int; +select * from t for system_time all; +a b +2 NULL +create or replace table t (a int) with system versioning engine myisam; +insert into t values (1); +update t set a = 2; +select * from t for system_time all; +a +2 +1 +alter table t add column b int; +select * from t for system_time all; +a b +2 NULL +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +13 1 1 1 1 +14 1 1 1 1 +drop table t; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/auto_increment.result b/mysql-test/suite/versioning/r/auto_increment.result new file mode 100644 index 00000000000..533a5cc45af --- /dev/null +++ b/mysql-test/suite/versioning/r/auto_increment.result @@ -0,0 +1,201 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure test_01( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + id int unsigned auto_increment primary key, + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +set @str= concat(' + create table t2( + id int unsigned auto_increment primary key, + x int unsigned, + y int unsigned) + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x, y) values(1, 11); +insert into t2(x, y) values(1, 11); +insert into t1(x, y) values(2, 12); +insert into t2(x, y) values(2, 12); +insert into t1(x, y) values(3, 13); +insert into t2(x, y) values(3, 13); +insert into t1(x, y) values(4, 14); +insert into t2(x, y) values(4, 14); +insert into t1(x, y) values(5, 15); +insert into t2(x, y) values(5, 15); +insert into t1(x, y) values(6, 16); +insert into t2(x, y) values(6, 16); +insert into t1(x, y) values(7, 17); +insert into t2(x, y) values(7, 17); +insert into t1(x, y) values(8, 18); +insert into t2(x, y) values(8, 18); +insert into t1(x, y) values(9, 19); +insert into t2(x, y) values(9, 19); +select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id; +delete from t1 where x = 2; +delete from t2 where x = 2; +select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id; +delete from t1 where x > 7; +delete from t2 where x > 7; +select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id; +drop table t1; +drop table t2; +end~~ +call test_01('timestamp(6)', 'myisam', 'sys_end'); +A x y x y +1 1 11 1 11 +1 2 12 2 12 +1 3 13 3 13 +1 4 14 4 14 +1 5 15 5 15 +1 6 16 6 16 +1 7 17 7 17 +1 8 18 8 18 +1 9 19 9 19 +A x y x y +1 1 11 1 11 +1 3 13 3 13 +1 4 14 4 14 +1 5 15 5 15 +1 6 16 6 16 +1 7 17 7 17 +1 8 18 8 18 +1 9 19 9 19 +A x y x y +1 1 11 1 11 +1 3 13 3 13 +1 4 14 4 14 +1 5 15 5 15 +1 6 16 6 16 +1 7 17 7 17 +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +A x y x y +1 1 11 1 11 +1 2 12 2 12 +1 3 13 3 13 +1 4 14 4 14 +1 5 15 5 15 +1 6 16 6 16 +1 7 17 7 17 +1 8 18 8 18 +1 9 19 9 19 +A x y x y +1 1 11 1 11 +1 3 13 3 13 +1 4 14 4 14 +1 5 15 5 15 +1 6 16 6 16 +1 7 17 7 17 +1 8 18 8 18 +1 9 19 9 19 +A x y x y +1 1 11 1 11 +1 3 13 3 13 +1 4 14 4 14 +1 5 15 5 15 +1 6 16 6 16 +1 7 17 7 17 +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +drop procedure test_01; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/commit_id.result b/mysql-test/suite/versioning/r/commit_id.result new file mode 100644 index 00000000000..56ca1f4bec3 --- /dev/null +++ b/mysql-test/suite/versioning/r/commit_id.result @@ -0,0 +1,173 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create table t1( +id int auto_increment primary key) +with system versioning +engine innodb; +insert into t1 values (); +set @ts0= now(6); +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx0; +select transaction_id = @tx0 from information_schema.innodb_vtq limit 1; +transaction_id = @tx0 +1 +set @ts1= now(6); +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx1; +select transaction_id = @tx1 from information_schema.innodb_vtq limit 1; +transaction_id = @tx1 +1 +set @ts2= now(6); +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx2; +select transaction_id = @tx2 from information_schema.innodb_vtq limit 1; +transaction_id = @tx2 +1 +set @ts3= now(6); +select +vtq_trx_id(@ts0) < @tx0 as A, +vtq_trx_id(@ts0, true) = @tx0 as B, +vtq_trx_id(@ts1) = @tx0 as C, +vtq_trx_id(@ts1, true) = @tx1 as D, +vtq_trx_id(@ts2) = @tx1 as E, +vtq_trx_id(@ts2, true) = @tx2 as F, +vtq_trx_id(@ts3) = @tx2 as G, +vtq_trx_id(@ts3, true) is null as H; +A B C D E F G H +1 1 1 1 1 1 1 1 +select +vtq_commit_id(@ts0) < @tx0 as A, +vtq_commit_id(@ts0, true) = vtq_commit_id(null, @tx0) as B, +vtq_commit_id(@ts1) = vtq_commit_id(null, @tx0) as C, +vtq_commit_id(@ts1, true) = vtq_commit_id(null, @tx1) as D, +vtq_commit_id(@ts2) = vtq_commit_id(null, @tx1) as E, +vtq_commit_id(@ts2, true) = vtq_commit_id(null, @tx2) as F, +vtq_commit_id(@ts3) = vtq_commit_id(null, @tx2) as G, +vtq_commit_id(@ts3, true) is null as H; +A B C D E F G H +1 1 1 1 1 1 1 1 +select +vtq_trx_sees(@tx1, @tx0) as A, +not vtq_trx_sees(@tx0, @tx1) as B, +vtq_trx_sees_eq(@tx1, @tx1) as C, +not vtq_trx_sees(@tx1, @tx1) as D, +vtq_trx_sees(@tx2, 0) as E, +vtq_trx_sees(0, @tx2) is null as F, +vtq_trx_sees(-1, @tx2) as H; +A B C D E F H +1 1 1 1 1 1 1 +set transaction isolation level read uncommitted; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx3; +select isolation_level = 'READ-UNCOMMITTED' from information_schema.innodb_vtq where transaction_id = @tx3; +isolation_level = 'READ-UNCOMMITTED' +1 +set transaction isolation level read committed; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx4; +select isolation_level = 'READ-COMMITTED' from information_schema.innodb_vtq where transaction_id = @tx4; +isolation_level = 'READ-COMMITTED' +1 +set transaction isolation level serializable; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx5; +select isolation_level = 'SERIALIZABLE' from information_schema.innodb_vtq where transaction_id = @tx5; +isolation_level = 'SERIALIZABLE' +1 +set transaction isolation level repeatable read; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx6; +select isolation_level = 'REPEATABLE-READ' from information_schema.innodb_vtq where transaction_id = @tx6; +isolation_level = 'REPEATABLE-READ' +1 +drop table t1; +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result new file mode 100644 index 00000000000..a190ac30fd9 --- /dev/null +++ b/mysql-test/suite/versioning/r/create.result @@ -0,0 +1,376 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +drop table if exists t1; +create function if not exists non_default_engine() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'myisam'; +end if; +return 'innodb'; +end~~ +create table t1 ( +x1 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start comment 'start', +Sys_end SYS_TRX_TYPE generated always as row end comment 'end', +period for system_time (Sys_start, Sys_end) +) with system versioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x1` int(10) unsigned DEFAULT NULL, + `Sys_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START COMMENT 'start', + `Sys_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END COMMENT 'end', + PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +# Implicit fields test +create or replace table t1 ( +x2 int unsigned +) with system versioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x2` int(10) unsigned DEFAULT NULL, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t1 ( +x3 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_start2 SYS_TRX_TYPE generated always as row start, +Sys_end SYS_TRX_TYPE generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning; +ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW START' +create or replace table t1 ( +x4 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_end2 SYS_TRX_TYPE generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning; +ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW END' +create or replace table t1 ( +x5 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_end SYS_TRX_TYPE generated always as row end, +Sys_end2 SYS_TRX_TYPE generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning; +ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW END' +create or replace table t1 ( +x6 int unsigned, +period for system_time (Sys_start, Sys_end) +) with system versioning; +ERROR HY000: Wrong parameters for `t1`: missing 'AS ROW START' +create or replace table t1 ( +x7 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_end SYS_TRX_TYPE generated always as row end, +Sys_end2 SYS_TRX_TYPE generated always as row end, +period for system_time (Sys_start, Sys_end) +); +ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING' +create or replace table t1 ( +x8 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_end SYS_TRX_TYPE generated always as row end, +period for system_time (sys_insert, sys_remove) +) with system versioning; +ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW START' +create or replace table t1 ( +x9 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_end SYS_TRX_TYPE generated always as row end, +period for system_time (Sys_start, Sys_end) +); +ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING' +create or replace table t1 ( +x10 int unsigned, +Sys_start SYS_TRX_TYPE generated always as row start, +Sys_end SYS_TRX_TYPE generated always as row end, +period for system_time (Sys_start, Sys_start) +); +ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING' +create or replace table t1 ( +x11 int unsigned, +Sys_start bigint unsigned generated always as row start, +Sys_end timestamp(6) generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning; +Got one of the listed errors +create or replace table t1 ( +x12 int unsigned, +Sys_start timestamp(6) generated always as row start, +Sys_end bigint unsigned generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning; +Got one of the listed errors +create or replace table t1 ( +x13 int unsigned, +Sys_start bigint generated always as row start, +Sys_end bigint unsigned generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning engine innodb; +ERROR HY000: `Sys_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1` +create or replace table t1 ( +x14 int unsigned, +Sys_start bigint unsigned generated always as row start, +Sys_end bigint generated always as row end, +period for system_time (Sys_start, Sys_end) +) with system versioning engine innodb; +ERROR HY000: `Sys_end` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1` +create or replace table t1 ( +A1 int with system versioning, +B int +); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A1` int(11) DEFAULT NULL, + `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t1 ( +A2 int with system versioning, +B int +) with system versioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A2` int(11) DEFAULT NULL, + `B` int(11) DEFAULT NULL, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t1 ( +A3 int, +B int without system versioning +); +create or replace table t1 ( +A4 int, +B int without system versioning +) with system versioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A4` int(11) DEFAULT NULL, + `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t1 ( +A5 int with system versioning, +B int without system versioning +); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A5` int(11) DEFAULT NULL, + `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t1 ( +A6 int with system versioning, +B int without system versioning +) with system versioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A6` int(11) DEFAULT NULL, + `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t1 ( +A7 int without system versioning +); +create or replace table t1 ( +A8 int without system versioning +) with system versioning; +ERROR HY000: Wrong parameters for `t1`: no columns defined 'WITH SYSTEM VERSIONING' +create table t( +a11 int +) without system versioning; +ERROR HY000: Wrong parameters for `t`: not allowed 'WITHOUT SYSTEM VERSIONING' +create or replace table t1 (a int) with system versioning; +create temporary table tmp with system versioning select * from t1; +create or replace table t1 (a int) with system versioning; +create table tt1 like t1; +show create table tt1; +Table Create Table +tt1 CREATE TABLE `tt1` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +drop table tt1; +create or replace table t1 (x int) with system versioning; +create or replace table t0( +y int, +st SYS_TRX_TYPE generated always as row start, +en SYS_TRX_TYPE generated always as row end, +period for system_time (st, en) +) with system versioning; +create or replace table t2 as select * from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `x` int(11) DEFAULT NULL +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 +create or replace table t3 as select * from t0; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `y` int(11) DEFAULT NULL +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 +insert into t1 values (1); +insert into t0 values (2); +create or replace table t2 with system versioning as select * from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `x` int(11) DEFAULT NULL, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t2; +x +1 +create or replace table t3 with system versioning as select * from t0; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `y` int(11) DEFAULT NULL, + `st` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `en` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`st`, `en`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t3 where y > 2; +y st en +delete from t0; +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int); +create or replace table t3 with system versioning select * from t1 for system_time all, t2; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `x` int(11) DEFAULT NULL, + `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START, + `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END, + `y` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +create or replace table t2 with system versioning as select * from t0; +create or replace table t3 with system versioning select x, y, t1.sys_trx_start, t2.en from t1, t2; +ERROR HY000: Wrong parameters for `t3`: system fields selected from different tables +insert into t2 values (1), (2); +delete from t2 where y = 2; +create or replace table t3 select * from t2 for system_time all; +select st, en from t2 where y = 1 into @st, @en; +select y from t2 for system_time all where st = @st and en = @en; +y +1 +select st, en from t2 for system_time all where y = 2 into @st, @en; +select y from t2 for system_time all where st = @st and en = @en; +y +2 +create or replace table t1 (a int) with system versioning engine INNODB_OR_MYISAM; +create or replace table t2 as select a, sys_trx_start, sys_trx_end from t1 for system_time all; +create or replace table t2 with system versioning engine INNODB_OR_MYISAM as select a, sys_trx_start, sys_trx_end from t1 for system_time all; +ERROR HY000: `sys_trx_start` must be of type `SYS_TRX_TYPE` for versioned table `t2` +create or replace table t1 (a int, id int) with system versioning engine INNODB_OR_MYISAM; +create or replace table t2 (b int, id int); +create or replace table t3 as +select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id; +create or replace table t (sys_trx_start int); +alter table t with system versioning; +ERROR 42S21: Duplicate column name 'sys_trx_start' +create or replace table t (sys_trx_end int); +alter table t with system versioning; +ERROR 42S21: Duplicate column name 'sys_trx_end' +drop database test; +create database test; diff --git a/mysql-test/suite/versioning/r/cte.result b/mysql-test/suite/versioning/r/cte.result new file mode 100644 index 00000000000..161255aeaa7 --- /dev/null +++ b/mysql-test/suite/versioning/r/cte.result @@ -0,0 +1,99 @@ +create or replace table dept ( +dept_id int(10) primary key, +name varchar(100) +) +with system versioning; +create or replace table emp ( +emp_id int(10) primary key, +dept_id int(10) not null, +name varchar(100) not null, +mgr int(10), +salary int(10) not null, +constraint `dept-emp-fk` + foreign key (dept_id) references dept (dept_id) +on delete cascade +on update restrict, +constraint `mgr-fk` + foreign key (mgr) references emp (emp_id) +on delete restrict +on update restrict +) +with system versioning; +insert into dept (dept_id, name) values (10, "accounting"); +insert into emp (emp_id, name, salary, dept_id, mgr) values +(1, "bill", 1000, 10, null), +(20, "john", 500, 10, 1), +(30, "jane", 750, 10,1 ); +select vtq_commit_ts(max(sys_trx_start)) into @ts_1 from emp; +update emp set mgr=30 where name ="john"; +select vtq_commit_ts(sys_trx_start) into @ts_2 from emp where name="john"; +/* All report to 'Bill' */ +with recursive +ancestors +as +( +select e.emp_id, e.name, e.mgr, e.salary +from emp for system_time as of timestamp @ts_1 as e +where name = 'bill' + union +select e.emp_id, e.name, e.mgr, e.salary +from emp for system_time as of timestamp @ts_1 as e, +ancestors as a +where e.mgr = a.emp_id +) +select * from ancestors for system_time as of now; +emp_id name mgr salary +1 bill NULL 1000 +30 jane 1 750 +/* Expected 3 rows */ +with recursive +ancestors +as +( +select e.emp_id, e.name, e.mgr, e.salary +from emp for system_time as of timestamp @ts_2 as e +where name = 'bill' + union +select e.emp_id, e.name, e.mgr, e.salary +from emp for system_time as of timestamp @ts_2 as e, +ancestors as a +where e.mgr = a.emp_id +) +select * from ancestors; +emp_id name mgr salary +1 bill NULL 1000 +30 jane 1 750 +20 john 30 500 +create or replace table emp ( emp_id int, name varchar(127), mgr int) with system versioning; +create or replace table addr ( emp_id int, address varchar(100)) with system versioning; +insert emp values (1, 'bill', 0), (2, 'bill', 1), (3, 'kate', 1); +insert addr values (1, 'Moscow'), (2, 'New York'), (3, 'London'); +set @ts=now(6); +delete from emp; +delete from addr; +insert emp values (4, 'john', 1); +insert addr values (4, 'Paris'); +with ancestors as (select * from emp natural join addr) select * from ancestors; +emp_id name mgr address +4 john 1 Paris +with ancestors as (select * from emp natural join addr) select * from ancestors for system_time all; +emp_id name mgr address +1 bill 0 Moscow +2 bill 1 New York +3 kate 1 London +4 john 1 Paris +with ancestors as (select * from emp natural join addr system_time all) select * from ancestors; +emp_id name mgr address +1 bill 0 Moscow +2 bill 1 New York +3 kate 1 London +4 john 1 Paris +select * from emp natural join addr system_time all; +emp_id name mgr address +1 bill 0 Moscow +2 bill 1 New York +3 kate 1 London +4 john 1 Paris +drop table emp; +drop table dept; +drop table addr; diff --git a/mysql-test/suite/versioning/r/ddl.result b/mysql-test/suite/versioning/r/ddl.result new file mode 100644 index 00000000000..759cb5f449a --- /dev/null +++ b/mysql-test/suite/versioning/r/ddl.result @@ -0,0 +1,211 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create function get_archive_table_name() +returns varchar(255) +begin +return (select archive_name from t_vtmd for system_time all where archive_name is not NULL +order by start desc limit 1); +end~~ +create procedure drop_last_archive() +begin +call concat_exec2('drop table ', get_archive_table_name()); +end~~ +set versioning_alter_history= survive; +create or replace table t (a int) with system versioning; +insert into t values (1); +update t set a=2 where a=1; +select sys_trx_start from t where a=2 into @tm; +alter table t add column b int; +select * from t; +a b +2 NULL +call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all'); +a +2 +1 +call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2'); +@tm=sys_trx_start +1 +select @tm<sys_trx_start from t where a=2; +@tm<sys_trx_start +1 +select sys_trx_start from t where a=2 into @tm; +call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2'); +@tm=sys_trx_end +1 +call drop_last_archive(); +set versioning_alter_history= keep; +drop table t_vtmd; +drop table t; +set versioning_alter_history= survive; +create or replace table t (a int) with system versioning; +insert into t values (1); +update t set a=2 where a=1; +select sys_trx_start from t where a=2 into @tm; +alter table t add column b int; +select * from t; +a b +2 NULL +call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all'); +a +2 +1 +call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2'); +@tm=sys_trx_start +1 +select @tm<sys_trx_start from t where a=2; +@tm<sys_trx_start +1 +select sys_trx_start from t where a=2 into @tm; +call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2'); +@tm=sys_trx_end +1 +call drop_last_archive(); +set versioning_alter_history= keep; +drop table t_vtmd; +drop table t; +set versioning_alter_history= survive; +create or replace table t (a int) with system versioning engine innodb; +insert into t values (1); +update t set a=2 where a=1; +select sys_trx_start from t where a=2 into @tm; +alter table t add column b int; +select * from t; +a b +2 NULL +call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all'); +a +2 +1 +call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2'); +@tm=sys_trx_start +1 +select @tm<sys_trx_start from t where a=2; +@tm<sys_trx_start +1 +select sys_trx_start from t where a=2 into @tm; +call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2'); +@tm=sys_trx_end +1 +call drop_last_archive(); +set versioning_alter_history= keep; +drop table t_vtmd; +drop table t; +set versioning_alter_history= survive; +create or replace table t (a int) with system versioning engine innodb; +insert into t values (1); +update t set a=2 where a=1; +alter table t add column b int, algorithm=inplace; +set versioning_alter_history = keep; +drop function get_archive_table_name; +drop procedure drop_last_archive; +select * from mysql.vtmd_template; +start end name archive_name col_renames +show create table mysql.vtmd_template; +Table Create Table +vtmd_template CREATE TABLE `vtmd_template` ( + `start` bigint(20) unsigned GENERATED ALWAYS AS ROW START COMMENT 'TRX_ID of table lifetime start', + `end` bigint(20) unsigned GENERATED ALWAYS AS ROW END NOT NULL COMMENT 'TRX_ID of table lifetime end', + `name` varchar(64) COLLATE utf8_bin NOT NULL COMMENT 'Table name during period [start, end)', + `archive_name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT 'Name of archive table', + `col_renames` blob DEFAULT NULL COMMENT 'Column name mappings from previous lifetime', + PRIMARY KEY (`end`), + KEY `archive_name` (`archive_name`), + PERIOD FOR SYSTEM_TIME (`start`, `end`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0 WITH SYSTEM VERSIONING +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +drop table t; +drop table t_vtmd; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/delete.result b/mysql-test/suite/versioning/r/delete.result new file mode 100644 index 00000000000..910d99c8643 --- /dev/null +++ b/mysql-test/suite/versioning/r/delete.result @@ -0,0 +1,374 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create or replace procedure test_01( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create or replace table t1( + XNo int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(XNo) values(0); +insert into t1(XNo) values(1); +insert into t1(XNo) values(2); +insert into t1(XNo) values(3); +insert into t1(XNo) values(4); +insert into t1(XNo) values(5); +insert into t1(XNo) values(6); +insert into t1(XNo) values(7); +insert into t1(XNo) values(8); +insert into t1(XNo) values(9); +set @str= concat('select XNo, ', +fields, " < '2038-01-19 03:14:07' + from t1 for system_time + between timestamp '0000-0-0 0:0:0' + and timestamp '2038-01-19 04:14:07'"); +prepare stmt from @str; execute stmt; +delete from t1 where XNo = 0; +execute stmt; +delete from t1 where XNo = 1; +execute stmt; +delete from t1 where XNo > 5; +create view vt1 as select XNo from t1; +select XNo from vt1; +delete from vt1 where XNo = 3; +select XNo from vt1; +execute stmt; drop prepare stmt; +drop view vt1; +drop table t1; +end~~ +create or replace procedure test_02( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat('create or replace table t1 ( + x int, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x) values (1); +select sys_start into @sys_start from t1; +delete from t1; +select * from t1; +select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C +from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07'; +drop table t1; +end~~ +create or replace procedure test_03( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str0= concat('( + x int, + y int, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +set @str= concat('create or replace table t1', @str0); +prepare stmt from @str; execute stmt; drop prepare stmt; +set @str= concat('create or replace table t2', @str0); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x, y) values (1, 1), (2, 2), (3, 3), (14, 4); +insert into t2(x, y) values (11, 1), (12, 2), (13, 32), (14, 4); +delete t1, t2 from t1 join t2 where t1.y = 3 and t2.y = 32; +select x as t1_x from t1; +select x as t2_x from t2; +delete t1, t2 from t1 join t2 where t1.x = t2.x; +select x as t1_x from t1; +select x as t2_x from t2; +select x as t1_x_all from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07'; +select x as t2_x_all from t2 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07'; +drop table t1; +drop table t2; +end~~ +# Basic + delete from view +call test_01('timestamp(6)', 'myisam', 'sys_end'); +XNo sys_end < '2038-01-19 03:14:07' +0 0 +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +XNo sys_end < '2038-01-19 03:14:07' +0 1 +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +XNo sys_end < '2038-01-19 03:14:07' +0 1 +1 1 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +XNo +2 +3 +4 +5 +XNo +2 +4 +5 +XNo sys_end < '2038-01-19 03:14:07' +0 1 +1 1 +2 0 +3 1 +4 0 +5 0 +6 1 +7 1 +8 1 +9 1 +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07' +0 0 +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07' +0 1 +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07' +0 1 +1 1 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +XNo +2 +3 +4 +5 +XNo +2 +4 +5 +XNo vtq_commit_ts(sys_end) < '2038-01-19 03:14:07' +0 1 +1 1 +2 0 +3 1 +4 0 +5 0 +6 1 +7 1 +8 1 +9 1 +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +13 1 1 1 1 +14 1 1 1 1 +# Check sys_start, sys_end +call test_02('timestamp(6)', 'myisam', 'sys_end'); +x sys_start sys_end +A B C +1 1 1 +call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x sys_start sys_end +A B C +1 1 1 +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +# Multi-delete +call test_03('timestamp(6)', 'myisam', 'sys_end'); +t1_x +1 +2 +14 +t2_x +11 +12 +14 +t1_x +1 +2 +t2_x +11 +12 +t1_x_all +1 +2 +3 +14 +t2_x_all +11 +12 +13 +14 +call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +t1_x +1 +2 +14 +t2_x +11 +12 +14 +t1_x +1 +2 +t2_x +11 +12 +t1_x_all +1 +2 +3 +14 +t2_x_all +11 +12 +13 +14 +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +drop procedure test_01; +drop procedure test_02; +drop procedure test_03; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/derived.result b/mysql-test/suite/versioning/r/derived.result new file mode 100644 index 00000000000..04a237f6428 --- /dev/null +++ b/mysql-test/suite/versioning/r/derived.result @@ -0,0 +1,181 @@ +create table emp +( +emp_id int, +name varchar(127), +mgr int +) with system versioning; +insert into emp values (1, 'bill', 0), +(2, 'bill', 1), +(3, 'kate', 1); +set @ts=now(6); +delete from emp; +insert into emp values (4, 'john', 1); +with ancestors as (select * from emp) select * from ancestors; +emp_id name mgr +4 john 1 +set @tmp= "with ancestors as (select * from emp) select * from ancestors"; +prepare stmt from @tmp; +execute stmt; +emp_id name mgr +4 john 1 +drop prepare stmt; +with ancestors as (select * from emp for system_time all) select * from ancestors; +emp_id name mgr +1 bill 0 +2 bill 1 +3 kate 1 +4 john 1 +set @tmp= "with ancestors as (select * from emp for system_time all) select * from ancestors"; +prepare stmt from @tmp; +execute stmt; +emp_id name mgr +1 bill 0 +2 bill 1 +3 kate 1 +4 john 1 +drop prepare stmt; +with recursive ancestors as (select * from emp) select * from ancestors; +emp_id name mgr +4 john 1 +set @tmp= "with recursive ancestors as (select * from emp) select * from ancestors"; +prepare stmt from @tmp; +execute stmt; +emp_id name mgr +4 john 1 +drop prepare stmt; +select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp; +emp_id +4 +set @tmp= "select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp"; +prepare stmt from @tmp; +execute stmt; +emp_id +4 +drop prepare stmt; +with recursive +ancestors +as +( +select e.emp_id, e.name, e.mgr +from emp as e +where name = 'john' + union +select ee.emp_id, ee.name, ee.mgr +from emp as ee, ancestors as a +where ee.mgr = a.emp_id +) +select * from ancestors; +emp_id name mgr +4 john 1 +set @tmp= " +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr + from emp as e + where name = 'john' + union + select ee.emp_id, ee.name, ee.mgr + from emp as ee, ancestors as a + where ee.mgr = a.emp_id +) +select * from ancestors"; +prepare stmt from @tmp; +execute stmt; +emp_id name mgr +4 john 1 +drop prepare stmt; +with recursive +ancestors +as +( +select e.emp_id, e.name, e.mgr +from emp as e +where name = 'bill' + system_time as of timestamp @ts +union +select ee.emp_id, ee.name, ee.mgr +from emp as ee, ancestors as a +where ee.mgr = a.emp_id +system_time as of timestamp @ts +) +select * from ancestors; +emp_id name mgr +1 bill 0 +2 bill 1 +3 kate 1 +set @tmp= " +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr + from emp as e + where name = 'bill' + system_time as of timestamp @ts + union + select ee.emp_id, ee.name, ee.mgr + from emp as ee, ancestors as a + where ee.mgr = a.emp_id + system_time as of timestamp @ts +) +select * from ancestors"; +prepare stmt from @tmp; +execute stmt; +emp_id name mgr +1 bill 0 +2 bill 1 +3 kate 1 +drop prepare stmt; +drop table emp; +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int) with system versioning; +insert into t1 values (1); +set @t0= now(6); +insert into t1 values (2); +delete from t1 where x = 1; +insert into t2 values (10); +select * from (select *, t1.sys_trx_end, t1.sys_trx_end as endo from t1) as s0; +ERROR HY000: Derived table is prohibited: multiple end system fields `t1.sys_trx_end`, `t1.sys_trx_end` in query! +select * from (select *, t1.sys_trx_end, t2.sys_trx_start from t1, t2) as s0; +ERROR HY000: Derived table is prohibited: system fields from multiple tables `t1`, `t2` in query! +select * from (select * from t1 for system_time as of timestamp @t0, t2) as s0; +x y +1 10 +with s1 as (select * from t1 for system_time as of timestamp @t0, t2) select * from s1; +x y +1 10 +select * from (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) as s2; +y x +10 1 +with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3; +y x +10 1 +select * from (select *, t1.sys_trx_start from t2 for system_time as of now, t1) as s4 system_time as of timestamp @t0; +y x +10 1 +with s5 as (select *, t1.sys_trx_start from t2 for system_time as of now, t1) select * from s5 for system_time as of timestamp @t0; +y x +10 1 +with s6 as (select *, t1.sys_trx_start from t2 for system_time as of now, t1) select * from s6 system_time as of timestamp @t0; +y x +10 1 +set @q= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t0, "'"); +prepare q from @q; +execute q; +drop prepare q; +select * from vt1; +x +1 +select * from (select * from vt1, t2) as s0; +x y +1 10 +select * from (select *, vt1.sys_trx_end from t2, vt1) as s0; +y x +10 1 +select * from (select *, vt1.sys_trx_start from t2 for system_time as of now, vt1) as s0 system_time as of timestamp @t0; +y x +10 1 +drop table t1, t2; +drop view vt1; diff --git a/mysql-test/suite/versioning/r/foreign.result b/mysql-test/suite/versioning/r/foreign.result new file mode 100644 index 00000000000..3903bee2f00 --- /dev/null +++ b/mysql-test/suite/versioning/r/foreign.result @@ -0,0 +1,172 @@ +create table parent( +id int unique key +) engine innodb; +create table child( +parent_id int, +foreign key(parent_id) references parent(id) +on delete restrict +on update restrict +) engine innodb with system versioning; +insert into parent values(1); +insert into child values(1); +delete from parent where id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +delete from child where parent_id = 1; +delete from parent where id = 1; +insert into parent values(1); +insert into child values(1); +update parent set id=id+1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +delete from child; +update parent set id=id+1; +select * from child for system_time from timestamp '1-1-1' to timestamp now(6); +parent_id +1 +1 +drop table child; +drop table parent; +create table parent( +id int(10) unsigned unique key +) engine innodb; +create table child( +parent_id int(10) unsigned primary key, +foreign key(parent_id) references parent(id) +) engine innodb with system versioning; +insert into parent values(1); +insert into child values(1); +delete from parent where id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +drop table child; +drop table parent; +create table parent( +id int unique key +) engine innodb; +create table child( +parent_id int, +foreign key(parent_id) references parent(id) +on delete cascade +on update cascade +) engine innodb with system versioning; +insert into parent values(1); +insert into child values(1); +delete from parent where id = 1; +select * from child; +parent_id +select * from child for system_time all; +parent_id +1 +insert into parent values(1); +insert into child values(1); +update parent set id = id + 1; +select * from child; +parent_id +2 +select * from child for system_time all; +parent_id +1 +2 +drop table child; +drop table parent; +create or replace table parent ( +id int primary key +) with system versioning +engine innodb; +create or replace table child ( +x int, +parent_id int not null, +constraint `parent-fk` + foreign key (parent_id) references parent (id) +on delete cascade +on update restrict +) +engine innodb; +insert into parent (id) values (2); +insert into child (x, parent_id) values (2, 2); +delete from parent; +select * from child; +x parent_id +drop table child; +drop table parent; +create or replace table parent ( +id int primary key +) +engine innodb; +create or replace table child ( +id int primary key, +parent_id int not null, +constraint `parent-fk` + foreign key (parent_id) references parent (id) +on delete cascade +on update restrict +) with system versioning +engine innodb; +insert into parent (id) values (3); +insert into child (id, parent_id) values (3, 3); +delete from parent; +select * from child; +id parent_id +select * from child for system_time all; +id parent_id +3 3 +drop table child; +drop table parent; +create table parent( +id int unique key +) engine innodb; +create table child( +parent_id int, +foreign key(parent_id) references parent(id) +on delete set null +on update set null +) engine innodb with system versioning; +insert into parent values(1); +insert into child values(1); +delete from child; +insert into child values(1); +delete from parent where id = 1; +select * from child; +parent_id +NULL +select * from child for system_time from timestamp '1-1-1' to timestamp now(6); +parent_id +1 +NULL +delete from child; +insert into parent values(1); +insert into child values(1); +update parent set id=id+1; +select * from child; +parent_id +NULL +select * from child for system_time from timestamp '1-1-1' to timestamp now(6); +parent_id +1 +NULL +NULL +drop table child; +drop table parent; +create or replace table parent( +id int unique key +) engine innodb with system versioning; +create or replace table child( +parent_id int, +foreign key(parent_id) references parent(id) +) engine innodb; +insert into parent values(1); +insert into child values(1); +delete from parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +update parent set id=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +delete from child; +delete from parent; +insert into child values(1); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +insert into parent values(1); +insert into child values(1); +delete from parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +update parent set id=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) +drop table child; +drop table parent; diff --git a/mysql-test/suite/versioning/r/insert.result b/mysql-test/suite/versioning/r/insert.result new file mode 100644 index 00000000000..4bfa4fe0720 --- /dev/null +++ b/mysql-test/suite/versioning/r/insert.result @@ -0,0 +1,371 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure test_01( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x, y) values(3, 4); +insert into t1(x, y) values(2, 3); +insert into t1 values(40, 33); +set @str= concat('select x, y, ', fields, ' from t1'); +prepare stmt from @str; execute stmt; drop prepare stmt; +drop table t1; +end~~ +create procedure test_02( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + id int unsigned auto_increment primary key, + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x, y) values(33, 44); +insert into t1(id, x, y) values(20, 33, 44); +insert into t1 values(40, 33, 44); +set @str= concat('select id, x, y, ', fields, ' from t1'); +prepare stmt from @str; execute stmt; drop prepare stmt; +drop table t1; +end~~ +create procedure test_03( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +create view vt1_1 as select x, y from t1; +insert into t1(x, y) values(8001, 9001); +insert into vt1_1(x, y) values(1001, 2001); +insert into vt1_1 values(1002, 2002); +set @str= concat('select x, y, ', fields, ' from t1'); +prepare stmt from @str; execute stmt; drop prepare stmt; +select x, y from vt1_1; +end~~ +create procedure test_04( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + id bigint primary key, + a int, + b int) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1 values(1, 1, 1); +select sys_trx_start, sys_trx_end from t1 into @sys_start, @sys_end; +select id, a, b from t1; +insert into t1 values(2, 2, 2); +select id, a, b, sys_trx_start > @sys_start as C, sys_trx_end = @sys_end as D from t1 where id = 2; +drop table t1; +end~~ +create procedure test_05( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat('( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +set @str2= concat('create table t1', @str); +prepare stmt from @str2; execute stmt; drop prepare stmt; +set @str2= concat('create table t2', @str); +prepare stmt from @str2; execute stmt; drop prepare stmt; +insert into t1(x, y) values +(1, 1000), +(2, 2000), +(3, 3000), +(4, 4000), +(5, 5000), +(6, 6000), +(7, 7000), +(8, 8000), +(9, 9000); +delete from t1 where x >= 1; +insert into t1(x, y) values +(1, 1001), +(2, 2001), +(3, 3001), +(4, 4001), +(5, 5001), +(6, 6001), +(7, 7001), +(8, 8001), +(9, 9001); +insert into t2 select x, y from t1 for system_time between timestamp '0000-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; +select x, y from t1; +select x, y from t2; +drop table t1; +drop table t2; +end~~ +call test_01('timestamp(6)', 'myisam', 'sys_end'); +x y sys_end +3 4 2038-01-19 03:14:07.999999 +2 3 2038-01-19 03:14:07.999999 +40 33 2038-01-19 03:14:07.999999 +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y vtq_commit_ts(sys_end) +3 4 2038-01-19 03:14:07.999999 +2 3 2038-01-19 03:14:07.999999 +40 33 2038-01-19 03:14:07.999999 +call test_02('timestamp(6)', 'myisam', 'sys_end'); +id x y sys_end +1 33 44 2038-01-19 03:14:07.999999 +20 33 44 2038-01-19 03:14:07.999999 +40 33 44 2038-01-19 03:14:07.999999 +call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +id x y vtq_commit_ts(sys_end) +1 33 44 2038-01-19 03:14:07.999999 +20 33 44 2038-01-19 03:14:07.999999 +40 33 44 2038-01-19 03:14:07.999999 +call test_03('timestamp(6)', 'myisam', 'sys_end'); +x y sys_end +8001 9001 2038-01-19 03:14:07.999999 +1001 2001 2038-01-19 03:14:07.999999 +1002 2002 2038-01-19 03:14:07.999999 +x y +8001 9001 +1001 2001 +1002 2002 +drop table t1; +drop view vt1_1; +call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y vtq_commit_ts(sys_end) +8001 9001 2038-01-19 03:14:07.999999 +1001 2001 2038-01-19 03:14:07.999999 +1002 2002 2038-01-19 03:14:07.999999 +x y +8001 9001 +1001 2001 +1002 2002 +drop table t1; +drop view vt1_1; +call test_04('timestamp(6)', 'myisam', 'sys_end'); +id a b +1 1 1 +id a b C D +2 2 2 1 1 +call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +id a b +1 1 1 +id a b C D +2 2 2 1 1 +call test_05('timestamp(6)', 'myisam', 'sys_end'); +x y +1 1001 +2 2001 +3 3001 +4 4001 +5 5001 +6 6001 +7 7001 +8 8001 +9 9001 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +1 1001 +2 2001 +3 3001 +4 4001 +5 5001 +6 6001 +7 7001 +8 8001 +9 9001 +call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y +1 1001 +2 2001 +3 3001 +4 4001 +5 5001 +6 6001 +7 7001 +8 8001 +9 9001 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +1 1001 +2 2001 +3 3001 +4 4001 +5 5001 +6 6001 +7 7001 +8 8001 +9 9001 +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +13 1 1 1 1 +14 1 1 1 1 +15 1 1 1 1 +create table t1( +x int unsigned, +sys_start bigint unsigned generated always as row start, +sys_end bigint unsigned generated always as row end, +period for system_time (sys_start, sys_end)) +with system versioning engine=innodb; +create table t2(x int unsigned) engine=innodb; +start transaction; +insert into t1(x) values(1); +commit; +call verify_vtq; +No A B C D +1 1 1 1 1 +start transaction; +insert into t2(x) values(1); +savepoint a; +insert into t1(x) values(1); +rollback to a; +commit; +call verify_vtq; +No A B C D +drop table t1; +drop table t2; +drop procedure test_01; +drop procedure test_02; +drop procedure test_03; +drop procedure test_04; +drop procedure test_05; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/optimized.result b/mysql-test/suite/versioning/r/optimized.result new file mode 100644 index 00000000000..a89180bbabd --- /dev/null +++ b/mysql-test/suite/versioning/r/optimized.result @@ -0,0 +1,126 @@ +create table t ( +a int, +b int without system versioning +) with system versioning; +insert into t values(1, 2); +insert into t values(3, 4); +select * from t; +a b +1 2 +3 4 +select a from t for system_time as of timestamp now(6); +a +1 +3 +select a, b, b+0 from t for system_time as of timestamp now(6); +a b b+0 +1 NULL NULL +3 NULL NULL +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t for system_time as of timestamp now(6); +a b +1 NULL +3 NULL +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select count(*) from t group by b system_time as of timestamp now(6); +count(*) +2 +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t for system_time as of timestamp now(6) order by b asc; +a b +1 NULL +3 NULL +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t for system_time as of timestamp now(6) order by b desc; +a b +1 NULL +3 NULL +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t group by a having a=2 system_time as of timestamp now(6); +a b +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t group by b having b=2 system_time as of timestamp now(6); +a b +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +select a from t where b=2 system_time as of timestamp now(6); +a +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select a from t where b=NULL system_time as of timestamp now(6); +a +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select a from t where b is NULL system_time as of timestamp now(6); +a +1 +3 +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select count(*), b from t group by b having b=NULL system_time as of timestamp now(6); +count(*) b +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +select a, b from t; +a b +1 2 +3 4 +select count(*) from t for system_time as of timestamp now(6) group by b; +count(*) +2 +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t for system_time as of timestamp now(6) group by b having b=2; +a b +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +select a from t for system_time as of timestamp now(6) where b=2; +a +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select a from t for system_time as of timestamp now(6) where b=NULL; +a +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select a from t for system_time as of timestamp now(6) where b is NULL; +a +1 +3 +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select count(*), b from t for system_time as of timestamp now(6) group by b having b=NULL; +count(*) b +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +create or replace table t ( +a int, +b int not null without system versioning +) with system versioning; +insert into t values (1, 2), (3, 4); +select * from t for system_time as of timestamp now(6); +a b +1 NULL +3 NULL +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +select * from t for system_time as of timestamp now(6) where b is NULL; +a b +1 NULL +3 NULL +Warnings: +Warning 4102 Attempt to read unversioned field `b` in historical query +Warning 4102 Attempt to read unversioned field `b` in historical query +drop table t; diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result new file mode 100644 index 00000000000..2ba2b870ae9 --- /dev/null +++ b/mysql-test/suite/versioning/r/partition.result @@ -0,0 +1,378 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create table t1 (x int) +with system versioning +partition by range columns (x) ( +partition p0 values less than (100), +partition p1 values less than (1000)); +insert into t1 values (3), (300); +select * from t1; +x +3 +300 +select * from t1 partition (p0); +x +3 +select * from t1 partition (p1); +x +300 +delete from t1; +select * from t1; +x +select * from t1 for system_time all; +x +3 +300 +select * from t1 partition (p0) for system_time all; +x +3 +select * from t1 partition (p1) for system_time all; +x +300 +create or replace table t1 (x int) +partition by system_time ( +partition p0 versioning, +partition pn as of now); +ERROR HY000: System Versioning required: t1 +create or replace table t1 (x int); +alter table t1 +partition by system_time ( +partition p0 versioning, +partition pn as of now); +Got one of the listed errors +create or replace table t1 (x int) +with system versioning +partition by system_time ( +partition p0 as of now); +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +create or replace table t1 (x int) +with system versioning +partition by system_time ( +partition p0 as of now, +partition p1 as of now); +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +create or replace table t1 (x int) +with system versioning +partition by system_time ( +partition p0 versioning, +partition p1 versioning); +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +create or replace table t1 (x int) +with system versioning +partition by system_time ( +partition pn as of now, +partition p0 versioning); +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +create or replace table t1 (x int) +with system versioning +partition by system_time ( +partition p0 versioning, +partition pn as of now); +alter table t1 add partition ( +partition p1 as of now); +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +alter table t1 add partition ( +partition p1 versioning); +Warnings: +Warning 4078 Maybe missing parameters: no rotation condition for multiple `VERSIONING` partitions. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL, + `sys_trx_start` ${SYS_TRX_TYPE} GENERATED ALWAYS AS ROW START, + `sys_trx_end` ${SYS_TRX_TYPE} GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING + PARTITION BY SYSTEM_TIME +(PARTITION p0 VERSIONING ENGINE = ${INNODB_OR_MYISAM}, + PARTITION p1 VERSIONING ENGINE = ${INNODB_OR_MYISAM}, + PARTITION pn AS OF NOW ENGINE = ${INNODB_OR_MYISAM}) +insert into t1 values (1), (2); +alter table t1 drop partition pn; +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +alter table t1 drop partition p1; +alter table t1 drop partition p0; +ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW' +select x from t1; +x +1 +2 +create or replace table t1 (x int) +with system versioning +partition by system_time limit 1 ( +partition p0 versioning, +partition pn as of now); +alter table t1 change x big int; +create or replace table t1 (x int) +with system versioning +partition by system_time ( +partition p0 versioning, +partition pn as of now); +set @now= now(6); +insert into t1 values (1); +set @ts_start= sys_commit_ts('sys_trx_start'); +set @ts_end= sys_commit_ts('sys_trx_end'); +set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all'); +prepare select_p0 from @str; +set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn) for system_time all'); +prepare select_pn from @str; +execute select_p0; +x A B +execute select_pn; +x C D +1 1 1 +explain partitions select * from t1; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t1 pn system NULL NULL NULL NULL 1 +set @str= concat('select ', @ts_start, ' from t1 partition (pn) into @ts0'); +prepare stmt from @str; +execute stmt; +drop prepare stmt; +set @now= now(6); +delete from t1; +execute select_p0; +x A B +1 1 1 +execute select_pn; +x C D +set @str= concat('select ', @ts_start, ' from t1 partition (p0) for system_time all into @ts1'); +prepare stmt from @str; +execute stmt; +drop prepare stmt; +select @ts0 = @ts1; +@ts0 = @ts1 +1 +set @now= now(6); +insert into t1 values (2); +execute select_p0; +x A B +1 1 0 +execute select_pn; +x C D +2 1 1 +set @str= concat('select ', @ts_start, ' from t1 partition (pn) into @ts0'); +prepare stmt from @str; +execute stmt; +drop prepare stmt; +set @now= now(6); +update t1 set x = x + 1; +execute select_p0; +x A B +1 1 0 +2 1 1 +execute select_pn; +x C D +3 1 1 +drop prepare select_p0; +drop prepare select_pn; +set @str= concat('select ', @ts_start, ' from t1 partition (p0) for system_time all where x = 2 into @ts1'); +prepare stmt from @str; +execute stmt; +drop prepare stmt; +set @str= concat('select ', @ts_end, ' from t1 partition (p0) for system_time all where x = 2 into @ts2'); +prepare stmt from @str; +execute stmt; +drop prepare stmt; +set @str= concat('select ', @ts_start, ' from t1 partition (pn) into @ts3'); +prepare stmt from @str; +execute stmt; +drop prepare stmt; +select @ts0 = @ts1; +@ts0 = @ts1 +1 +select @ts2 = @ts3; +@ts2 = @ts3 +1 +create or replace table t1 (x int) +with system versioning +partition by system_time limit 0 ( +partition p0 versioning, +partition p1 versioning, +partition pn as of now); +ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT' +create or replace table t1 (x int) +with system versioning +partition by system_time limit 1 ( +partition p0 versioning, +partition p1 versioning, +partition pn as of now); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL, + `sys_trx_start` ${SYS_TRX_TYPE} GENERATED ALWAYS AS ROW START, + `sys_trx_end` ${SYS_TRX_TYPE} GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING + PARTITION BY SYSTEM_TIME LIMIT 1 +(PARTITION p0 VERSIONING ENGINE = ${INNODB_OR_MYISAM}, + PARTITION p1 VERSIONING ENGINE = ${INNODB_OR_MYISAM}, + PARTITION pn AS OF NOW ENGINE = ${INNODB_OR_MYISAM}) +alter table t1 drop partition non_existent; +ERROR HY000: Error in list of partitions to DROP +insert into t1 values (1), (2); +select * from t1 partition (pn); +x +1 +2 +delete from t1; +Warnings: +Note 4079 Switching from partition `p0` to `p1` +select * from t1 partition (p0) for system_time all; +x +1 +select * from t1 partition (p1) for system_time all; +x +2 +insert into t1 values (3); +delete from t1; +Warnings: +Warning 4077 Using full partition `p1`, need more VERSIONING partitions! +select * from t1 partition (p1) for system_time all; +x +2 +3 +create or replace table t1 (x int) +with system versioning +partition by system_time interval 0 second ( +partition p0 versioning, +partition p1 versioning, +partition pn as of now); +ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL' +create or replace table t1 (x int) +with system versioning +partition by system_time interval 1 second ( +partition p0 versioning, +partition p1 versioning, +partition pn as of now); +insert into t1 values (1), (2), (3); +select * from t1 partition (pn); +x +1 +2 +3 +delete from t1; +select * from t1 partition (p0) for system_time all; +x +1 +2 +3 +insert into t1 values (4); +delete from t1; +Warnings: +Note 4079 Switching from partition `p0` to `p1` +select * from t1 partition (p1) for system_time all; +x +4 +create or replace table t1 (x int) +with system versioning +partition by system_time limit 1 +subpartition by key (x) +subpartitions 2 ( +partition p0 versioning, +partition p1 versioning, +partition pn as of now); +insert into t1 (x) values (1), (2), (3); +select * from t1 partition (pnsp0); +x +1 +3 +select * from t1 partition (pnsp1); +x +2 +delete from t1; +Warnings: +Note 4079 Switching from partition `p0` to `p1` +Warning 4077 Using full partition `p1`, need more VERSIONING partitions! +select * from t1 partition (p0sp0) for system_time all; +x +1 +select * from t1 partition (p0sp1) for system_time all; +x +select * from t1 partition (p1sp0) for system_time all; +x +3 +select * from t1 partition (p1sp1) for system_time all; +x +2 +drop table t1; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/rpl_mixed.result b/mysql-test/suite/versioning/r/rpl_mixed.result new file mode 100644 index 00000000000..b91c8fd33c8 --- /dev/null +++ b/mysql-test/suite/versioning/r/rpl_mixed.result @@ -0,0 +1,118 @@ +include/master-slave.inc +[connection master] +connection slave; +connection master; +CREATE TABLE t1 (x int) with system versioning; +insert into t1 values (1); +SELECT * FROM t1; +x +1 +delete from t1; +select * from t1; +x +select * from t1 for system_time all; +x +1 +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +1 +connection master; +insert into t1 values (2); +connection slave; +select * from t1; +x +2 +connection master; +update t1 set x = 3; +connection slave; +select * from t1; +x +3 +select * from t1 for system_time all; +x +1 +3 +2 +connection master; +create or replace table t1 (x int primary key); +connection slave; +alter table t1 with system versioning; +connection master; +insert into t1 values (1); +connection slave; +select * from t1; +x +1 +select * from t1 for system_time all; +x +1 +connection master; +update t1 set x= 2 where x = 1; +connection slave; +select * from t1; +x +2 +select * from t1 for system_time all; +x +1 +2 +connection master; +delete from t1; +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +1 +2 +connection master; +create or replace table t1 (x int); +connection slave; +alter table t1 with system versioning; +connection master; +insert into t1 values (1); +update t1 set x= 2 where x = 1; +connection slave; +select * from t1; +x +2 +select * from t1 for system_time all; +x +2 +1 +connection master; +delete from t1; +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +2 +1 +connection master; +create or replace table t1 (x int) with system versioning; +create or replace table t2 (x int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +update t1, t2 set t1.x=11, t2.x=22; +connection slave; +select * from t1; +x +11 +select * from t2; +x +22 +select * from t1 for system_time all; +x +11 +1 +select * from t2 for system_time all; +x +22 +2 +connection master; +drop table t1, t2; +include/rpl_end.inc diff --git a/mysql-test/suite/versioning/r/rpl_row.result b/mysql-test/suite/versioning/r/rpl_row.result new file mode 100644 index 00000000000..b91c8fd33c8 --- /dev/null +++ b/mysql-test/suite/versioning/r/rpl_row.result @@ -0,0 +1,118 @@ +include/master-slave.inc +[connection master] +connection slave; +connection master; +CREATE TABLE t1 (x int) with system versioning; +insert into t1 values (1); +SELECT * FROM t1; +x +1 +delete from t1; +select * from t1; +x +select * from t1 for system_time all; +x +1 +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +1 +connection master; +insert into t1 values (2); +connection slave; +select * from t1; +x +2 +connection master; +update t1 set x = 3; +connection slave; +select * from t1; +x +3 +select * from t1 for system_time all; +x +1 +3 +2 +connection master; +create or replace table t1 (x int primary key); +connection slave; +alter table t1 with system versioning; +connection master; +insert into t1 values (1); +connection slave; +select * from t1; +x +1 +select * from t1 for system_time all; +x +1 +connection master; +update t1 set x= 2 where x = 1; +connection slave; +select * from t1; +x +2 +select * from t1 for system_time all; +x +1 +2 +connection master; +delete from t1; +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +1 +2 +connection master; +create or replace table t1 (x int); +connection slave; +alter table t1 with system versioning; +connection master; +insert into t1 values (1); +update t1 set x= 2 where x = 1; +connection slave; +select * from t1; +x +2 +select * from t1 for system_time all; +x +2 +1 +connection master; +delete from t1; +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +2 +1 +connection master; +create or replace table t1 (x int) with system versioning; +create or replace table t2 (x int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +update t1, t2 set t1.x=11, t2.x=22; +connection slave; +select * from t1; +x +11 +select * from t2; +x +22 +select * from t1 for system_time all; +x +11 +1 +select * from t2 for system_time all; +x +22 +2 +connection master; +drop table t1, t2; +include/rpl_end.inc diff --git a/mysql-test/suite/versioning/r/rpl_stmt.result b/mysql-test/suite/versioning/r/rpl_stmt.result new file mode 100644 index 00000000000..b91c8fd33c8 --- /dev/null +++ b/mysql-test/suite/versioning/r/rpl_stmt.result @@ -0,0 +1,118 @@ +include/master-slave.inc +[connection master] +connection slave; +connection master; +CREATE TABLE t1 (x int) with system versioning; +insert into t1 values (1); +SELECT * FROM t1; +x +1 +delete from t1; +select * from t1; +x +select * from t1 for system_time all; +x +1 +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +1 +connection master; +insert into t1 values (2); +connection slave; +select * from t1; +x +2 +connection master; +update t1 set x = 3; +connection slave; +select * from t1; +x +3 +select * from t1 for system_time all; +x +1 +3 +2 +connection master; +create or replace table t1 (x int primary key); +connection slave; +alter table t1 with system versioning; +connection master; +insert into t1 values (1); +connection slave; +select * from t1; +x +1 +select * from t1 for system_time all; +x +1 +connection master; +update t1 set x= 2 where x = 1; +connection slave; +select * from t1; +x +2 +select * from t1 for system_time all; +x +1 +2 +connection master; +delete from t1; +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +1 +2 +connection master; +create or replace table t1 (x int); +connection slave; +alter table t1 with system versioning; +connection master; +insert into t1 values (1); +update t1 set x= 2 where x = 1; +connection slave; +select * from t1; +x +2 +select * from t1 for system_time all; +x +2 +1 +connection master; +delete from t1; +connection slave; +select * from t1; +x +select * from t1 for system_time all; +x +2 +1 +connection master; +create or replace table t1 (x int) with system versioning; +create or replace table t2 (x int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +update t1, t2 set t1.x=11, t2.x=22; +connection slave; +select * from t1; +x +11 +select * from t2; +x +22 +select * from t1 for system_time all; +x +11 +1 +select * from t2 for system_time all; +x +22 +2 +connection master; +drop table t1, t2; +include/rpl_end.inc diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result new file mode 100644 index 00000000000..6c179d2e166 --- /dev/null +++ b/mysql-test/suite/versioning/r/select.result @@ -0,0 +1,398 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create or replace table t1 ( +x int unsigned, +y int unsigned +) with system versioning; +insert into t1 (x, y) values +(0, 100), +(1, 101), +(2, 102), +(3, 103), +(4, 104), +(5, 105), +(6, 106), +(7, 107), +(8, 108), +(9, 109); +set @t0= now(6); +delete from t1 where x = 3; +delete from t1 where x > 7; +insert into t1(x, y) values(3, 33); +select sys_trx_start from t1 where x = 3 and y = 33 into @t1; +select x, y from t1; +x y +0 100 +1 101 +2 102 +4 104 +5 105 +6 106 +7 107 +3 33 +select x as ASOF_x, y from t1 for system_time as of timestamp @t0; +ASOF_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1; +FROMTO_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1; +BETWAND_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +3 33 +select x as ALL_x, y from t1 for system_time all; +ALL_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +3 33 +ASOF2_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +FROMTO2_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +BETWAND2_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +3 33 +create or replace table t1 ( +x int unsigned, +y int unsigned +) with system versioning; +create or replace table t2 ( +x int unsigned, +y int unsigned +) with system versioning; +insert into t1 values (1, 1), (1, 2), (1, 3), (4, 4), (5, 5); +insert into t2 values (1, 2), (2, 1), (3, 1); +set @t0= now(6); +select t1.x as IJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x; +IJ1_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x; +LJ1_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +4 4 NULL NULL +5 5 NULL NULL +select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x; +RJ1_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +NULL NULL 2 1 +NULL NULL 3 1 +delete from t1; +delete from t2; +select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x +system_time as of timestamp @t0; +IJ2_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x +system_time as of timestamp @t0; +LJ2_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +4 4 NULL NULL +5 5 NULL NULL +select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x +system_time as of timestamp @t0; +RJ2_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +NULL NULL 2 1 +NULL NULL 3 1 +drop table t1; +drop table t2; +create table t1( +A int +) with system versioning; +insert into t1 values(1); +select * from t1; +A +1 +create or replace table t1 (x int); +insert into t1 values (1); +select * from t1 for system_time all; +ERROR HY000: System Versioning required: t1 +create or replace table t1 (x int) with system versioning; +insert into t1 values (1); +select * from t1 for system_time all for update; +ERROR HY000: Versioned SELECT write-locking of history rows +create or replace table t1 (a int not null auto_increment primary key) with system versioning; +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +create or replace table t1 (a int) with system versioning; +create or replace table t2 (a int) with system versioning; +insert into t1 values(1); +insert into t2 values(1); +create view v1 as select * from t2 inner join t1 using (a); +select * from v1; +a +1 +drop view v1; +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create view vt1 as select a from t1; +select * from t1 natural join vt1; +a +1 +drop view vt1; +create or replace table t1(x int) with system versioning; +select * from (t1 as r left join t1 as u using (x)), t1; +x x +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create trigger read_end after update on t1 +for each row set @end = old.sys_trx_end; +update t1 set a=2; +select @end; +@end +MAX_RESULT +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +select * from (select * from t1 cross join t2) as tmp; +a b +1 2 +select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2; +a b +1 2 +select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp; +a b +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +select * from t1 for system_time all natural left join t2 for system_time all; +a1 a2 +1 1 +2 1 +1 2 +2 2 +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create or replace view v1 as select a1 from t1; +select * from v1 natural join t2; +a1 a2 +1 1 +2 1 +1 2 +2 2 +select * from v1 natural left join t2; +a1 a2 +1 1 +2 1 +1 2 +2 2 +select * from v1 natural right join t2; +a2 a1 +1 1 +2 1 +1 2 +2 2 +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +3 1 +2 2 +3 2 +2 3 +3 3 +1 NULL +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int) with system versioning; +insert into t1 values (1), (2), (3); +delete from t1 where x = 3; +insert into t2 values (1); +select * from t1, t2 system_time all; +x y +1 1 +2 1 +3 1 +select * from t1 for system_time all, t2 for system_time all system_time all; +ERROR HY000: Unused clause: 'SYSTEM_TIME' +drop view v1; +drop table t1, t2; +call innodb_verify_vtq(27); +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +13 1 1 1 1 +14 1 1 1 1 +15 1 1 1 1 +16 1 1 1 1 +17 1 1 1 1 +18 1 1 1 1 +19 1 1 1 1 +20 1 1 1 1 +21 1 1 1 1 +22 1 1 1 1 +23 1 1 1 1 +24 1 1 1 1 +25 1 1 1 1 +26 1 1 1 1 +27 1 1 1 1 +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/select_sp.result b/mysql-test/suite/versioning/r/select_sp.result new file mode 100644 index 00000000000..44b7d4e25b4 --- /dev/null +++ b/mysql-test/suite/versioning/r/select_sp.result @@ -0,0 +1,441 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure test_01() +begin +declare engine varchar(255) default default_engine(); +declare sys_type varchar(255) default sys_datatype(); +declare fields varchar(255) default sys_commit_ts('sys_start'); +set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1 (x, y) values +(0, 100), +(1, 101), +(2, 102), +(3, 103), +(4, 104), +(5, 105), +(6, 106), +(7, 107), +(8, 108), +(9, 109); +set @t0= now(6); +if engine = 'innodb' then +select sys_start from t1 limit 1 into @x0; +end if; +delete from t1 where x = 3; +delete from t1 where x > 7; +insert into t1(x, y) values(3, 33); +select sys_start from t1 where x = 3 and y = 33 into @t1; +if engine = 'innodb' then +set @x1= @t1; +select vtq_commit_ts(@x1) into @t1; +end if; +select x, y from t1; +select x as ASOF_x, y from t1 for system_time as of timestamp @t0; +select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1; +select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1; +select x as ALL_x, y from t1 for system_time all; +if engine = 'innodb' then +select x as ASOF2_x, y from t1 for system_time as of @x0; +select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1; +select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1; +else +select x as ASOF2_x, y from t1 for system_time as of @t0; +select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1; +select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1; +end if; +drop table t1; +end~~ +create or replace procedure test_02() +begin +declare engine varchar(255) default default_engine(); +declare sys_type varchar(255) default sys_datatype(); +declare fields varchar(255) default sys_commit_ts('sys_start'); +set @str0= concat('( + x int, + y int, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +set @str= concat('create or replace table t1', @str0); +prepare stmt from @str; execute stmt; drop prepare stmt; +set @str= concat('create or replace table t2', @str0); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1 values (1, 1), (1, 2), (1, 3), (4, 4), (5, 5); +insert into t2 values (1, 2), (2, 1), (3, 1); +set @t0= now(6); +select t1.x as IJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x; +select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x; +select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x; +delete from t1; +delete from t2; +select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x +system_time as of timestamp @t0; +select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x +system_time as of timestamp @t0; +select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x +system_time as of timestamp @t0; +drop table t1; +drop table t2; +end~~ +call test_01(); +x y +0 100 +1 101 +2 102 +4 104 +5 105 +6 106 +7 107 +3 33 +ASOF_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +FROMTO_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +BETWAND_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +3 33 +ALL_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +3 33 +ASOF2_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +FROMTO2_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +BETWAND2_x y +0 100 +1 101 +2 102 +3 103 +4 104 +5 105 +6 106 +7 107 +8 108 +9 109 +3 33 +call test_02(); +IJ1_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +LJ1_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +4 4 NULL NULL +5 5 NULL NULL +RJ1_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +NULL NULL 2 1 +NULL NULL 3 1 +IJ2_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +LJ2_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +4 4 NULL NULL +5 5 NULL NULL +RJ2_x1 y1 x2 y2 +1 1 1 2 +1 2 1 2 +1 3 1 2 +NULL NULL 2 1 +NULL NULL 3 1 +create table t1( +A int +) with system versioning; +insert into t1 values(1); +select * from t1; +A +1 +create or replace table t1 (x int); +insert into t1 values (1); +select * from t1 for system_time all; +ERROR HY000: System Versioning required: t1 +create or replace table t1 (x int) with system versioning; +insert into t1 values (1); +select * from t1 for system_time all for update; +ERROR HY000: Versioned SELECT write-locking of history rows +create or replace table t1 (a int not null auto_increment primary key) with system versioning; +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +create or replace table t1 (a int) with system versioning; +create or replace table t2 (a int) with system versioning; +insert into t1 values(1); +insert into t2 values(1); +create view v1 as select * from t2 inner join t1 using (a); +select * from v1; +a +1 +drop view v1; +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create view vt1 as select a from t1; +select * from t1 natural join vt1; +a +1 +drop view vt1; +create or replace table t1(x int) with system versioning; +select * from (t1 as r left join t1 as u using (x)), t1; +x x +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create trigger read_end after update on t1 +for each row set @end = old.sys_trx_end; +update t1 set a=2; +select @end; +@end +MAX_RESULT +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +select * from (select * from t1 cross join t2) as tmp; +a b +1 2 +select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2; +a b +1 2 +select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp; +a b +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +select * from t1 for system_time all natural left join t2 for system_time all; +a1 a2 +1 1 +2 1 +1 2 +2 2 +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create or replace view v1 as select a1 from t1; +select * from v1 natural join t2; +a1 a2 +1 1 +2 1 +1 2 +2 2 +select * from v1 natural left join t2; +a1 a2 +1 1 +2 1 +1 2 +2 2 +select * from v1 natural right join t2; +a2 a1 +1 1 +2 1 +1 2 +2 2 +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +3 1 +2 2 +3 2 +2 3 +3 3 +1 NULL +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int) with system versioning; +insert into t1 values (1), (2), (3); +delete from t1 where x = 3; +insert into t2 values (1); +select * from t1, t2 system_time all; +x y +1 1 +2 1 +3 1 +select * from t1 for system_time all, t2 for system_time all system_time all; +ERROR HY000: Unused clause: 'SYSTEM_TIME' +drop view v1; +drop table t1, t2; +call innodb_verify_vtq(27); +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +13 1 1 1 1 +14 1 1 1 1 +15 1 1 1 1 +16 1 1 1 1 +17 1 1 1 1 +18 1 1 1 1 +19 1 1 1 1 +20 1 1 1 1 +21 1 1 1 1 +22 1 1 1 1 +23 1 1 1 1 +24 1 1 1 1 +25 1 1 1 1 +26 1 1 1 1 +27 1 1 1 1 +drop procedure test_01; +drop procedure test_02; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/simple.result b/mysql-test/suite/versioning/r/simple.result new file mode 100644 index 00000000000..e0af556f073 --- /dev/null +++ b/mysql-test/suite/versioning/r/simple.result @@ -0,0 +1,71 @@ +create or replace table dept ( +dept_id int(10) primary key, +name varchar(100) +) +with system versioning; +create or replace table emp ( +emp_id int(10) primary key, +dept_id int(10), +name varchar(100), +salary int(10), +constraint `dept-emp-fk` + foreign key (dept_id) references dept (dept_id) +on delete cascade +on update restrict +) +with system versioning; +select now() into @ts_0; +insert into dept (dept_id, name) values (10, "accounting"); +commit; +select vtq_commit_ts(sys_trx_start) into @ts_1 from dept where dept_id=10; +insert into emp (emp_id, name, salary, dept_id) values (1, "bill", 1000, 10); +commit; +select vtq_commit_ts(sys_trx_start) into @ts_2 from emp where name="bill"; +select * from emp; +emp_id dept_id name salary +1 10 bill 1000 +update emp set salary=2000 where name="bill"; +commit; +select vtq_commit_ts(sys_trx_start) into @ts_3 from emp where name="bill"; +select * from emp; +emp_id dept_id name salary +1 10 bill 2000 +select * from emp for system_time as of timestamp @ts_2; +emp_id dept_id name salary +1 10 bill 1000 +select * from emp for system_time as of timestamp @ts_3; +emp_id dept_id name salary +1 10 bill 2000 +select * from emp e, dept d +where d.dept_id = 10 +and d.dept_id = e.dept_id; +emp_id dept_id name salary dept_id name +1 10 bill 2000 10 accounting +select * from emp e, dept d +where d.dept_id = 10 +and d.dept_id = e.dept_id +system_time from timestamp @ts_1 to timestamp @ts_2; +emp_id dept_id name salary sys_trx_start sys_trx_end dept_id name sys_trx_start sys_trx_end +select * from emp e, dept d +where d.dept_id = 10 +and d.dept_id = e.dept_id +system_time as of timestamp @ts_0; +emp_id dept_id name salary dept_id name +select * from emp e, dept d +where d.dept_id = 10 +and d.dept_id = e.dept_id +system_time as of timestamp @ts_1; +emp_id dept_id name salary dept_id name +select * from emp e, dept d +where d.dept_id = 10 +and d.dept_id = e.dept_id +system_time as of timestamp @ts_2; +emp_id dept_id name salary dept_id name +1 10 bill 1000 10 accounting +select * from emp e, dept d +where d.dept_id = 10 +and d.dept_id = e.dept_id +system_time as of timestamp @ts_3; +emp_id dept_id name salary dept_id name +1 10 bill 2000 10 accounting +drop table emp, dept; diff --git a/mysql-test/suite/versioning/r/sysvars.result b/mysql-test/suite/versioning/r/sysvars.result new file mode 100644 index 00000000000..a9cc7d3aec3 --- /dev/null +++ b/mysql-test/suite/versioning/r/sysvars.result @@ -0,0 +1,150 @@ +create table t (a int) with system versioning; +insert into t values (1); +update t set a= 2; +show global variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp NOW +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp NOW +select * from t; +a +2 +set versioning_current_timestamp = '2031-1-1 0:0:0'; +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 2031-01-01 00:00:00.000000 +select * from t; +a +2 +set versioning_current_timestamp = '2011-1-1 0:0:0'; +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 2011-01-01 00:00:00.000000 +select * from t; +a +set versioning_current_timestamp = 'all'; +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp ALL +select * from t; +a +2 +1 +create view vt as select * from t; +select * from t; +a +2 +1 +drop view vt; +select * from (select * from t) as tt; +a +2 +1 +set global versioning_current_timestamp= 'alley'; +ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'alley' +set global versioning_current_timestamp= null; +ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'NULL' +set global versioning_current_timestamp= 1; +ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp' +set global versioning_current_timestamp= 1.1; +ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp' +set versioning_current_timestamp= 'alley'; +ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'alley' +set versioning_current_timestamp= null; +ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'NULL' +set versioning_current_timestamp= 1; +ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp' +set versioning_current_timestamp= 1.1; +ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp' +set global versioning_current_timestamp= '1911-11-11 11:11:11.1111119'; +show global variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1911-11-11 11:11:11.111111 +set global versioning_current_timestamp= '1900-01-01 00:00:00'; +show global variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1900-01-01 00:00:00.000000 +set global versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119'; +Warnings: +Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119' +show global variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1911-11-11 11:11:11.111111 +set @ts= timestamp'1900-01-01 00:00:00'; +set global versioning_current_timestamp= @ts; +show global variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1900-01-01 00:00:00.000000 +set versioning_current_timestamp= '1911-11-11 11:11:11.1111119'; +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1911-11-11 11:11:11.111111 +set versioning_current_timestamp= '1900-01-01 00:00:00'; +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1900-01-01 00:00:00.000000 +set versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119'; +Warnings: +Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119' +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1911-11-11 11:11:11.111111 +set @ts= timestamp'1900-01-01 00:00:00'; +set versioning_current_timestamp= @ts; +show variables like 'versioning_current_timestamp'; +Variable_name Value +versioning_current_timestamp 1900-01-01 00:00:00.000000 +set global versioning_current_timestamp= 'now'; +set versioning_current_timestamp= 'now'; +show variables where variable_name = "versioning_hide"; +Variable_name Value +versioning_hide IMPLICIT +select * from t for system_time all; +a +2 +1 +set versioning_hide= AUTO; +select * from t; +a +2 +select * from t for system_time as of timestamp current_timestamp(6); +a +2 +select * from t for system_time all; +a sys_trx_start sys_trx_end +2 TIMESTAMP TIMESTAMP +1 TIMESTAMP TIMESTAMP +select * from t for system_time from '0-0-0' to current_timestamp(6); +a sys_trx_start sys_trx_end +2 TIMESTAMP TIMESTAMP +1 TIMESTAMP TIMESTAMP +select * from t for system_time between '0-0-0' and current_timestamp(6); +a sys_trx_start sys_trx_end +2 TIMESTAMP TIMESTAMP +1 TIMESTAMP TIMESTAMP +set versioning_hide= NEVER; +select * from t; +a sys_trx_start sys_trx_end +2 TIMESTAMP TIMESTAMP +set versioning_hide= FULL; +create or replace table t ( +x int, +st timestamp(6) generated always as row start, +en timestamp(6) generated always as row end, +period for system_time (st, en)) +with system versioning; +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `x` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t values (2); +delete from t; +select * from t; +x +select * from t for system_time all; +x +2 +drop table t; +set versioning_hide= IMPLICIT; diff --git a/mysql-test/suite/versioning/r/truncate.result b/mysql-test/suite/versioning/r/truncate.result new file mode 100644 index 00000000000..47647ade900 --- /dev/null +++ b/mysql-test/suite/versioning/r/truncate.result @@ -0,0 +1,37 @@ +create table t (a int); +truncate t to system_time now(); +ERROR HY000: System Versioning required: t +create or replace table t (a int) with system versioning; +insert into t values (1); +update t set a=2; +set @test = 'correct'; +create trigger trg_before before delete on t for each row set @test = 'incorrect'; +create trigger trg_after after delete on t for each row set @test = 'incorrect'; +truncate t to system_time now(6); +select @test from t; +@test +correct +drop table t; +create table t (a int) with system versioning; +insert into t values (1), (2); +update t set a=11 where a=1; +set @ts1=now(6); +update t set a=22 where a=2; +select * from t for system_time all; +a +11 +22 +1 +2 +truncate t to system_time timestamp @ts1; +select * from t for system_time all; +a +11 +22 +2 +truncate table t to system_time timestamp now(6); +select * from t for system_time all; +a +11 +22 +drop table t; diff --git a/mysql-test/suite/versioning/r/truncate_privilege.result b/mysql-test/suite/versioning/r/truncate_privilege.result new file mode 100644 index 00000000000..69a43ba8830 --- /dev/null +++ b/mysql-test/suite/versioning/r/truncate_privilege.result @@ -0,0 +1,33 @@ +connect root,localhost,root,,test; +connection root; +create database mysqltest; +create user mysqltest_1@localhost; +connect user1,localhost,mysqltest_1,,test; +connection user1; +connection root; +create table mysqltest.t (a int) with system versioning; +connection user1; +show grants; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +truncate mysqltest.t to system_time now(); +ERROR 42000: DELETE VERSIONING ROWS command denied to user 'mysqltest_1'@'localhost' for table 't' +connection root; +grant delete versioning rows on mysqltest.* to mysqltest_1@localhost; +grant delete versioning rows on mysqltest.t to mysqltest_1@localhost; +connection user1; +show grants; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT DELETE VERSIONING ROWS ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +GRANT DELETE VERSIONING ROWS ON `mysqltest`.`t` TO 'mysqltest_1'@'localhost' +truncate mysqltest.t to system_time now(); +connection root; +grant all on *.* to mysqltest_1@localhost; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT ALL PRIVILEGES ON *.* TO 'mysqltest_1'@'localhost' +GRANT DELETE VERSIONING ROWS ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +GRANT DELETE VERSIONING ROWS ON `mysqltest`.`t` TO 'mysqltest_1'@'localhost' +drop user mysqltest_1@localhost; +drop database mysqltest; diff --git a/mysql-test/suite/versioning/r/update.result b/mysql-test/suite/versioning/r/update.result new file mode 100644 index 00000000000..d54add35def --- /dev/null +++ b/mysql-test/suite/versioning/r/update.result @@ -0,0 +1,594 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure test_01( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x, y) values +(1, 1000), +(2, 2000), +(3, 3000), +(4, 4000), +(5, 5000), +(6, 6000), +(7, 7000), +(8, 8000), +(9, 9000); +select x, y from t1; +update t1 set y = y + 1 where x > 7; +select x, y from t1; +select x, y from t1 for system_time +between timestamp '0000-0-0 0:0:0' + and timestamp '2038-01-19 04:14:07'; +drop table t1; +end~~ +create procedure test_02( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1 ( + id bigint primary key, + x int, + y int without system versioning) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1 values(1, 1, 1); +set @ins_t= now(6); +select sys_trx_start into @tmp1 from t1; +update t1 set x= 11, y= 11 where id = 1; +select @tmp1 < sys_trx_start as A1, x, y from t1; +select sys_trx_start into @tmp1 from t1; +update t1 set y= 1 where id = 1; +select @tmp1 = sys_trx_start as A2, x from t1; +drop table t1; +end~~ +create procedure test_03( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1 ( + x int, + y int) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1 (x, y) values (1, 1), (2, 1), (3, 1); +start transaction; +update t1 set y= y + 1 where x = 3; +update t1 set y= y + 1 where x = 3; +commit; +select x, y from t1 for system_time +between timestamp '0000-0-0 0:0:0' + and timestamp '2038-01-19 04:14:07'; +drop table t1; +end~~ +create procedure test_04( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1 ( + id int primary key auto_increment, + x int) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +set @t0= now(6); +insert into t1 (x) values (1); +set @t1= now(6); +update t1 set x= 2 where id = 1; +set @t2= now(6); +update t1 set x= 3 where id = 1; +select x from t1 for system_time as of timestamp @t0; +select x from t1 for system_time as of timestamp @t1; +select x from t1 for system_time as of timestamp @t2; +select x from t1 for system_time as of timestamp now(6); +drop table t1; +end~~ +create procedure test_05( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat(' + create table t1( + x int unsigned, + sys_end ', sys_type, ' generated always as row end, + sys_start ', sys_type, ' generated always as row start, + y int unsigned, + period for system_time (sys_start, sys_end), + primary key(x, y)) + with system versioning + engine ', engine); +prepare stmt from @str; execute stmt; drop prepare stmt; +insert into t1(x, y) values +(1, 1000), +(2, 2000), +(3, 3000), +(4, 4000), +(5, 5000), +(6, 6000), +(7, 7000), +(8, 8000), +(9, 9000); +insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1; +insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1; +insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1; +insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1; +select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; +select x, y from t1; +drop table t1; +end~~ +create procedure test_06( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat('( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); +set @str2= concat('create table t1', @str); +prepare stmt from @str2; execute stmt; drop prepare stmt; +set @str2= concat('create table t2', @str); +prepare stmt from @str2; execute stmt; drop prepare stmt; +insert into t1(x, y) values +(1, 1000), +(2, 2000), +(3, 3000), +(4, 4000), +(5, 5000), +(6, 6000), +(7, 7000), +(8, 8000), +(9, 9000); +insert into t2(x, y) values +(1, 1010), +(2, 2010), +(3, 3010), +(4, 4010), +(5, 5010), +(6, 6010), +(7, 7010), +(8, 8010), +(9, 9010); +update t1, t2 set t1.y = t1.x + t1.y, t2.y = t2.x + t2.y where t1.x > 7 and t2.x < 7; +select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; +select x, y from t1; +select x, y from t2 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; +select x, y from t2; +drop table t1; +drop table t2; +end~~ +create procedure test_07( +sys_type varchar(255), +engine varchar(255), +fields varchar(255)) +begin +set @str= concat('( + id bigint primary key, + name varchar(128) with system versioning, + salary bigint) + engine ', engine); +set @str2= concat('create table t1', @str); +prepare stmt from @str2; execute stmt; drop prepare stmt; +set @str2= concat('create table t2', @str); +prepare stmt from @str2; execute stmt; drop prepare stmt; +insert into t1 values (1, "Jeremy", 3000); +insert into t2 values (1, "Jeremy", 4000); +select sys_trx_start into @tmp1 from t1; +select sys_trx_start into @tmp2 from t2; +update t1, t2 set t1.name= "Jerry", t2.name= "Jerry" where t1.id = t2.id and t1.name = "Jeremy"; +select @tmp1 < sys_trx_start as A1, name from t1; +select @tmp2 < sys_trx_start as A2, name from t2; +select sys_trx_start into @tmp1 from t1; +select sys_trx_start into @tmp2 from t2; +update t1, t2 set t1.salary= 2500, t2.salary= 2500 where t1.id = t2.id and t1.name = "Jerry"; +select @tmp1 = sys_trx_start as B1, salary from t1; +select @tmp2 = sys_trx_start as B2, salary from t2; +drop table t1; +drop table t2; +end~~ +call test_01('timestamp(6)', 'myisam', 'sys_end'); +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8001 +9 9001 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8001 +9 9001 +8 8000 +9 9000 +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8001 +9 9001 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8001 +9 9001 +8 8000 +9 9000 +call test_02('timestamp(6)', 'myisam', 'sys_end'); +A1 x y +1 11 11 +A2 x +1 11 +call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +A1 x y +1 11 11 +A2 x +1 11 +call test_03('timestamp(6)', 'myisam', 'sys_end'); +x y +1 1 +2 1 +3 3 +3 1 +3 2 +call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y +1 1 +2 1 +3 3 +3 1 +call test_04('timestamp(6)', 'myisam', 'sys_end'); +x +x +1 +x +2 +x +3 +call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x +x +1 +x +2 +x +3 +call test_05('timestamp(6)', 'myisam', 'sys_end'); +x y +1 1000 +2 2000 +3 3001 +4 4002 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +3 3000 +4 4000 +4 4001 +4 4444 +x y +1 1000 +2 2000 +3 3001 +4 4002 +4 4444 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y +1 1000 +2 2000 +3 3000 +3 3001 +4 4000 +4 4001 +4 4002 +4 4444 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +x y +1 1000 +2 2000 +3 3001 +4 4002 +4 4444 +5 5000 +6 6000 +7 7000 +8 8000 +9 9000 +call test_06('timestamp(6)', 'myisam', 'sys_end'); +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8008 +9 9009 +8 8000 +9 9000 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8008 +9 9009 +x y +1 1011 +2 2012 +3 3013 +4 4014 +5 5015 +6 6016 +7 7010 +8 8010 +9 9010 +1 1010 +2 2010 +3 3010 +4 4010 +5 5010 +6 6010 +x y +1 1011 +2 2012 +3 3013 +4 4014 +5 5015 +6 6016 +7 7010 +8 8010 +9 9010 +call test_06('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8008 +9 9009 +8 8000 +9 9000 +x y +1 1000 +2 2000 +3 3000 +4 4000 +5 5000 +6 6000 +7 7000 +8 8008 +9 9009 +x y +1 1011 +2 2012 +3 3013 +4 4014 +5 5015 +6 6016 +7 7010 +8 8010 +9 9010 +1 1010 +2 2010 +3 3010 +4 4010 +5 5010 +6 6010 +x y +1 1011 +2 2012 +3 3013 +4 4014 +5 5015 +6 6016 +7 7010 +8 8010 +9 9010 +call test_07('timestamp(6)', 'myisam', 'sys_end'); +A1 name +1 Jerry +A2 name +1 Jerry +B1 salary +1 2500 +B2 salary +1 2500 +call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +A1 name +1 Jerry +A2 name +1 Jerry +B1 salary +1 2500 +B2 salary +1 2500 +call verify_vtq; +No A B C D +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 +9 1 1 1 1 +10 1 1 1 1 +11 1 1 1 1 +12 1 1 1 1 +13 1 1 1 1 +14 1 1 1 1 +15 1 1 1 1 +16 1 1 1 1 +17 1 1 1 1 +18 1 1 1 1 +19 1 1 1 1 +20 1 1 1 1 +drop procedure test_01; +drop procedure test_02; +drop procedure test_03; +drop procedure test_04; +drop procedure test_05; +drop procedure test_06; +drop procedure test_07; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/view.result b/mysql-test/suite/versioning/r/view.result new file mode 100644 index 00000000000..ff009be57f5 --- /dev/null +++ b/mysql-test/suite/versioning/r/view.result @@ -0,0 +1,217 @@ +set @@session.time_zone='+00:00'; +select ifnull(max(transaction_id), 0) into @start_trx_id from information_schema.innodb_vtq; +set @test_start=now(6); +create procedure if not exists verify_vtq() +begin +set @i= 0; +select +@i:= @i + 1 as No, +transaction_id > 0 as A, +commit_id > transaction_id as B, +begin_timestamp > @test_start as C, +commit_timestamp >= begin_timestamp as D +from information_schema.innodb_vtq +where transaction_id > @start_trx_id; +select ifnull(max(transaction_id), 0) +into @start_trx_id +from information_schema.innodb_vtq; +end~~ +create function if not exists default_engine() +returns varchar(255) +deterministic +begin +declare e varchar(255); +select lower(engine) from information_schema.engines where support='DEFAULT' into e; +return e; +end~~ +create function if not exists sys_datatype() +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return 'bigint unsigned'; +elseif default_engine() = 'myisam' then +return 'timestamp(6)'; +end if; +return NULL; +end~~ +create function if not exists sys_commit_ts(sys_field varchar(255)) +returns varchar(255) +deterministic +begin +if default_engine() = 'innodb' then +return concat('vtq_commit_ts(', sys_field, ')'); +elseif default_engine() = 'myisam' then +return sys_field; +end if; +return NULL; +end~~ +create procedure if not exists innodb_verify_vtq(recs int) +begin +declare i int default 1; +if default_engine() = 'innodb' then +call verify_vtq; +elseif default_engine() = 'myisam' then +create temporary table tmp (No int, A bool, B bool, C bool, D bool); +while i <= recs do +insert into tmp values (i, 1, 1, 1, 1); +set i= i + 1; +end while; +select * from tmp; +drop table tmp; +end if; +end~~ +create procedure concat_exec2(a varchar(255), b varchar(255)) +begin +prepare stmt from concat(a, b); +execute stmt; +deallocate prepare stmt; +end~~ +create procedure concat_exec3(a varchar(255), b varchar(255), c varchar(255)) +begin +prepare stmt from concat(a, b, c); +execute stmt; +deallocate prepare stmt; +end~~ +create table t1 (x int) with system versioning engine innodb; +insert into t1 values (1); +select now(6) into @t1; +update t1 set x= 2; +select now(6) into @t2; +delete from t1; +set @vt1= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'"); +prepare stmt from @vt1; +execute stmt; +drop prepare stmt; +set @vt2= concat("create view vt2 as select *, sys_trx_end from t1 for system_time as of timestamp '", @t2, "'"); +prepare stmt from @vt2; +execute stmt; +drop prepare stmt; +select * from vt1 for system_time all; +x +1 +select * from vt2 for system_time all; +x +2 +select * from t1; +x +create or replace view vt1 as select * from t1; +show create view vt1; +View Create View character_set_client collation_connection +vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `x`,`t1`.`sys_trx_start` AS `sys_trx_start`,`t1`.`sys_trx_end` AS `sys_trx_end` from `t1` FOR SYSTEM_TIME ALL where `t1`.`sys_trx_end` = 18446744073709551615 latin1 latin1_swedish_ci +drop view vt1; +drop view vt2; +create view vt1 as select * from t1 for system_time all; +select * from vt1 for system_time all; +x +2 +1 +prepare stmt from 'select * from vt1 for system_time all'; +execute stmt; +x +2 +1 +drop prepare stmt; +select * from vt1; +x +2 +1 +prepare stmt from 'select * from vt1'; +execute stmt; +x +2 +1 +drop prepare stmt; +select * from t1 for system_time as of timestamp @t1; +x +1 +select * from vt1 for system_time as of timestamp @t1; +x +1 +prepare stmt from 'select * from vt1 for system_time as of timestamp @t1'; +execute stmt; +x +1 +drop prepare stmt; +create or replace view vt1 as select * from t1; +select * from vt1 for system_time all; +x +prepare stmt from 'select * from vt1 for system_time all'; +execute stmt; +x +drop prepare stmt; +insert into vt1 values (3); +select * from t1; +x +3 +select * from vt1; +x +3 +select * from t1 for system_time all; +x +2 +1 +3 +select * from vt1 for system_time all; +x +3 +create or replace table t1 (x int) with system versioning; +insert into t1 values (1), (2); +set @t1=now(6); +delete from t1 where x=2; +set @t2=now(6); +delete from t1 where x=1; +set @t3=now(6); +set @tmp= concat("create or replace view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'"); +prepare stmt from @tmp; +execute stmt; +drop prepare stmt; +select * from vt1 for system_time all; +x +1 +2 +create or replace table t1 (x int) with system versioning; +create or replace view vt1(c) as select x from t1; +create or replace table t1 (a int) with system versioning engine innodb; +create or replace table t2 (b int) with system versioning engine innodb; +insert into t1 values (1); +insert into t2 values (2); +create or replace view vt12 as select * from t1 cross join t2; +select * from vt12; +a b +1 2 +create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2; +select * from vt12; +a b +create or replace view vt1 as select a, t1.sys_trx_start, t2.sys_trx_end from t1, t2; +ERROR HY000: Creating VIEW `vt1` is prohibited: system fields from multiple tables `t1`, `t2` in query! +create or replace view vt1 as select a, t1.sys_trx_end, t2.sys_trx_end from t1, t2; +ERROR HY000: Creating VIEW `vt1` is prohibited: multiple end system fields `t1.sys_trx_end`, `t2.sys_trx_end` in query! +create or replace table t3 (x int); +create or replace view vt1 as select * from t1, t2, t3; +show create view vt1; +View Create View character_set_client collation_connection +vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,`t3`.`x` AS `x`,`t1`.`sys_trx_start` AS `sys_trx_start`,`t1`.`sys_trx_end` AS `sys_trx_end` from ((`t1` FOR SYSTEM_TIME ALL join `t2` FOR SYSTEM_TIME ALL) join `t3`) where `t1`.`sys_trx_end` = 18446744073709551615 and `t2`.`sys_trx_end` = 18446744073709551615 latin1 latin1_swedish_ci +create or replace view vt1 as select * from t3, t2, t1; +show create view vt1; +View Create View character_set_client collation_connection +vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t3`.`x` AS `x`,`t2`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`sys_trx_start` AS `sys_trx_start`,`t2`.`sys_trx_end` AS `sys_trx_end` from ((`t3` join `t2` FOR SYSTEM_TIME ALL) join `t1` FOR SYSTEM_TIME ALL) where `t2`.`sys_trx_end` = 18446744073709551615 and `t1`.`sys_trx_end` = 18446744073709551615 latin1 latin1_swedish_ci +create or replace view vt1 as select a, t2.sys_trx_end as endo from t3, t1, t2; +show create view vt1; +View Create View character_set_client collation_connection +vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`sys_trx_end` AS `endo`,`t2`.`sys_trx_start` AS `sys_trx_start` from ((`t3` join `t1` FOR SYSTEM_TIME ALL) join `t2` FOR SYSTEM_TIME ALL) where `t1`.`sys_trx_end` = 18446744073709551615 and `t2`.`sys_trx_end` = 18446744073709551615 latin1 latin1_swedish_ci +create or replace view vt1 as select * from t1 union select * from t1; +select * from vt1; +a +1 +create or replace view vvt1 as select * from t1, t2, vt1; +ERROR HY000: Creating VIEW `vvt1` is prohibited: versioned VIEW `vt1` in query! +drop view vt1, vt12; +drop table t1, t2, t3; +drop procedure verify_vtq; +drop procedure innodb_verify_vtq; +drop function default_engine; +drop function sys_commit_ts; +drop function sys_datatype; +drop procedure concat_exec2; +drop procedure concat_exec3; diff --git a/mysql-test/suite/versioning/r/vtmd.result b/mysql-test/suite/versioning/r/vtmd.result new file mode 100644 index 00000000000..47f0dfd3491 --- /dev/null +++ b/mysql-test/suite/versioning/r/vtmd.result @@ -0,0 +1,364 @@ +create or replace procedure drop_archives (in vtmd_name varchar(64)) +begin +declare archive_name varchar(64); +declare cur_done bool default false; +declare cur cursor for +select cur_tmp.archive_name from cur_tmp; +declare continue handler for not found set cur_done = true; +set @tmp= concat(' + create or replace temporary table + cur_tmp as + select vtmd.archive_name from ', vtmd_name, ' + for system_time all as vtmd + where vtmd.archive_name is not null + group by vtmd.archive_name'); +prepare stmt from @tmp; execute stmt; drop prepare stmt; +open cur; +fetch_loop: loop +fetch cur into archive_name; +if cur_done then +leave fetch_loop; +end if; +set @tmp= concat('drop table ', archive_name); +prepare stmt from @tmp; execute stmt; drop prepare stmt; +end loop; +drop table cur_tmp; +end~~ +create or replace procedure check_vtmd (in vtmd_name varchar(64)) +begin +set @tmp= concat(' + create or replace temporary table + tmp_vtmd with system versioning as + select * from ', vtmd_name, ' + for system_time all as vtmd'); +prepare stmt from @tmp; execute stmt; drop prepare stmt; +set @inf= 0xFFFFFFFFFFFFFFFF + 0; +set @start= null; +select start from tmp_vtmd for system_time all order by start limit 1 into @start; +select @start > 0 and @start < @inf; +select +start >= @start as A_start, +(@start:= end) and end = @inf as B_end, +name, +substr(archive_name, 1, instr(archive_name, '_')) as C_archive_name +from tmp_vtmd for system_time all; +drop table tmp_vtmd; +end~~ +create or replace procedure show_tables() +begin +show tables; +select table_name, table_schema from information_schema.tables +where table_schema not in ('mysql', 'performance_schema', 'information_schema', 'mtr'); +end~~ +set versioning_alter_history= keep; +create table t0 (z int) with system versioning; +show tables; +Tables_in_test +t0 +set versioning_alter_history= survive; +create or replace table t0 (y int) with system versioning; +show tables; +Tables_in_test +t0 +t0_vtmd +show create table t0_vtmd; +Table Create Table +t0_vtmd CREATE TABLE `t0_vtmd` ( + `start` bigint(20) unsigned GENERATED ALWAYS AS ROW START COMMENT 'TRX_ID of table lifetime start', + `end` bigint(20) unsigned GENERATED ALWAYS AS ROW END NOT NULL COMMENT 'TRX_ID of table lifetime end', + `name` varchar(64) COLLATE utf8_bin NOT NULL COMMENT 'Table name during period [start, end)', + `archive_name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT 'Name of archive table', + `col_renames` blob DEFAULT NULL COMMENT 'Column name mappings from previous lifetime', + PRIMARY KEY (`end`), + KEY `archive_name` (`archive_name`), + PERIOD FOR SYSTEM_TIME (`start`, `end`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0 WITH SYSTEM VERSIONING +call check_vtmd('t0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 1 t0 NULL +set versioning_alter_history= keep; +drop table t0; +set versioning_alter_history= survive; +create table t0 (x int) with system versioning; +ERROR HY000: VTMD error: `test.t0_vtmd` exists and not empty! +drop table t0_vtmd; +create table t0 (y int) with system versioning; +create or replace table t0 (x int) with system versioning; +insert into t0 values (1); +set @t0= now(6); +alter table t0 add column (y int); +select * from t0 for system_time as of @t0; +x +1 +select * from t0; +x y +1 NULL +call check_vtmd('t0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 t0 t0_ +1 0 t0 t0_ +1 1 t0 NULL +call drop_archives('t0_vtmd'); +drop table t0_vtmd; +alter table t0 drop column y; +call check_vtmd('t0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 1 t0 t0_ +call drop_archives('t0_vtmd'); +set versioning_alter_history= keep; +drop tables t0, t0_vtmd; +set versioning_alter_history= survive; +set versioning_alter_history= keep; +create or replace table x0 (x int) with system versioning; +set versioning_alter_history= survive; +rename table x0 to d0; +show tables; +Tables_in_test +d0 +set versioning_alter_history= keep; +drop table d0; +set versioning_alter_history= survive; +create or replace table x0 (x int) with system versioning; +rename table x0 to d0; +show tables; +Tables_in_test +d0 +d0_vtmd +call check_vtmd('d0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 NULL +1 1 d0 NULL +set versioning_alter_history= keep; +drop table d0; +set versioning_alter_history= survive; +create or replace table x0 (x int) with system versioning; +rename table x0 to d0; +ERROR HY000: VTMD error: `test.d0_vtmd` table already exists! +show tables; +Tables_in_test +d0_vtmd +x0 +x0_vtmd +drop table x0_vtmd; +rename table x0 to d0; +Warnings: +Warning 4088 `test.d0_vtmd` table already exists! +show tables; +Tables_in_test +d0 +d0_vtmd +rename table d0 to duck; +rename table duck to bay; +rename table bay to sheer; +rename table sheer to t0; +call check_vtmd('t0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 NULL +1 0 d0 NULL +1 0 duck NULL +1 0 bay NULL +1 0 sheer NULL +1 1 t0 NULL +alter table t0 add column (y int); +call check_vtmd('t0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 t0_ +1 0 d0 t0_ +1 0 duck t0_ +1 0 bay t0_ +1 0 sheer t0_ +1 0 t0 t0_ +1 1 t0 NULL +alter table t0 add column (z int); +alter table t0 drop column y; +alter table t0 drop column z; +create database db0; +rename table t0 to db0.t0; +show tables; +Tables_in_test +use db0; +show tables; +Tables_in_db0 +t0 +t0_vtmd +call test.check_vtmd('db0.t0_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 t0_ +1 0 d0 t0_ +1 0 duck t0_ +1 0 bay t0_ +1 0 sheer t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 1 t0 NULL +create database db1; +rename table t0 to db1.other_name; +show tables; +Tables_in_db0 +use db1; +show tables; +Tables_in_db1 +other_name +other_name_vtmd +call test.check_vtmd('db1.other_name_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 t0_ +1 0 d0 t0_ +1 0 duck t0_ +1 0 bay t0_ +1 0 sheer t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 NULL +1 1 other_name NULL +alter table other_name rename to t1; +call test.check_vtmd('db1.t1_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 t0_ +1 0 d0 t0_ +1 0 duck t0_ +1 0 bay t0_ +1 0 sheer t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 NULL +1 0 other_name NULL +1 1 t1 NULL +alter table t1 rename to test.t2, add column (y int); +use test; +show tables; +Tables_in_test +t2 +t2_vtmd +call check_vtmd('t2_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 x0 t0_ +1 0 d0 t0_ +1 0 duck t0_ +1 0 bay t0_ +1 0 sheer t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t0_ +1 0 t0 t1_ +1 0 other_name t1_ +1 0 t1 t1_ +1 1 t2 NULL +create or replace table t3 (x int) with system versioning; +alter table t3 change x x bigint; +alter table t3 change x x bigint after sys_trx_start; +call check_vtmd('t3_vtmd'); +@start > 0 and @start < @inf +1 +A_start B_end name C_archive_name +1 0 t3 t3_ +1 0 t3 t3_ +1 1 t3 NULL +set versioning_hide= auto; +call show_tables(); +Tables_in_test +t2 +t2_vtmd +t3 +t3_vtmd +table_name table_schema +t2 test +t2_vtmd test +t3 test +t3_vtmd test +set versioning_hide= implicit; +call show_tables(); +Tables_in_test +t2 +t2_vtmd +t3 +t3_vtmd +table_name table_schema +t2 test +t2_vtmd test +t3 test +t3_vtmd test +set versioning_hide= full; +call show_tables(); +Tables_in_test +t2 +t2_vtmd +t3 +t3_vtmd +table_name table_schema +t2 test +t2_vtmd test +t3 test +t3_vtmd test +set versioning_hide= never; +call show_tables(); +Tables_in_test +t0_TIMESTAMP_SUFFIX +t0_TIMESTAMP_SUFFIX +t0_TIMESTAMP_SUFFIX +t0_TIMESTAMP_SUFFIX +t2 +t2_vtmd +t3 +t3_TIMESTAMP_SUFFIX +t3_TIMESTAMP_SUFFIX +t3_vtmd +table_name table_schema +t1_TIMESTAMP_SUFFIX db1 +t0_TIMESTAMP_SUFFIX test +t0_TIMESTAMP_SUFFIX test +t0_TIMESTAMP_SUFFIX test +t0_TIMESTAMP_SUFFIX test +t2 test +t2_vtmd test +t3 test +t3_TIMESTAMP_SUFFIX test +t3_TIMESTAMP_SUFFIX test +t3_vtmd test +set versioning_hide= auto; +create or replace table u0_vtmd (x int) with system versioning; +show tables; +Tables_in_test +t2 +t2_vtmd +t3 +t3_vtmd +u0_vtmd +u0_vtmd_vtmd +Warnings: +Warning 4088 Table `test.u0_vtmd` is not a VTMD table +set versioning_alter_history= survive; +create or replace table t (x int) with system versioning; +select * from t for system_time all; +x sys_trx_start sys_trx_end +drop database db0; +drop database db1; +drop database test; +create database test; diff --git a/mysql-test/suite/versioning/r/vtmd_show.result b/mysql-test/suite/versioning/r/vtmd_show.result new file mode 100644 index 00000000000..4c77182c5de --- /dev/null +++ b/mysql-test/suite/versioning/r/vtmd_show.result @@ -0,0 +1,229 @@ +create or replace procedure drop_archives (in vtmd_name varchar(64)) +begin +declare archive_name varchar(64); +declare cur_done bool default false; +declare cur cursor for +select cur_tmp.archive_name from cur_tmp; +declare continue handler for not found set cur_done = true; +set @tmp= concat(' + create or replace temporary table + cur_tmp as + select vtmd.archive_name from ', vtmd_name, ' + for system_time all as vtmd + where vtmd.archive_name is not null + group by vtmd.archive_name'); +prepare stmt from @tmp; execute stmt; drop prepare stmt; +open cur; +fetch_loop: loop +fetch cur into archive_name; +if cur_done then +leave fetch_loop; +end if; +set @tmp= concat('drop table ', archive_name); +prepare stmt from @tmp; execute stmt; drop prepare stmt; +end loop; +drop table cur_tmp; +end~~ +create procedure test_01(in engine varchar(64)) +begin +set @tmp = concat('create table t (a int) with system versioning engine ', engine); +prepare stmt from @tmp; execute stmt; drop prepare stmt; +set @tm1 = now(6); +alter table t add column b int; +set @tm2 = now(6); +alter table t add column c int; +show create table t for system_time as of timestamp @tm1; +show create table t for system_time as of timestamp @tm2; +show create table t for system_time as of now; +show create table t for system_time as of timestamp now(6); +show create table t; +set @tm3 = now(6); +rename table t to tt; +show create table tt for system_time as of timestamp @tm3; +set @tm4 = now(6); +alter table tt add column d int; +show create table tt for system_time as of timestamp @tm3; +show create table tt for system_time as of timestamp @tm4; +show create table tt; +drop table tt; +call drop_archives('tt_vtmd'); +drop table tt_vtmd; +end~~ +create table t (a int) with system versioning; +show create table t for system_time as of now; +ERROR HY000: VTMD error: Table 'test.t_vtmd' doesn't exist +set versioning_alter_history=survive; +create or replace table t (a int) with system versioning; +show create table t for system_time between timestamp @tm1 and timestamp @tm1; +ERROR HY000: SYSTEM_TIME range selector is prohibited +show create table t for system_time from timestamp @tm1 to timestamp @tm1; +ERROR HY000: SYSTEM_TIME range selector is prohibited +show create table t for system_time as of timestamp '01-01-1990'; +ERROR HY000: VTMD error: Table 'test.t' doesn't exist +show create table t for system_time as of timestamp '01-01-2020'; +ERROR HY000: VTMD error: Table 'test.t' doesn't exist +drop table t; +call drop_archives('t_vtmd'); +drop table t_vtmd; +call test_01('myisam'); +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +call test_01('innodb'); +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +Table Create Table +tt CREATE TABLE `tt` ( + `a` int(11) DEFAULT NULL, + `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, + `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +drop procedure test_01; +drop procedure drop_archives; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test new file mode 100644 index 00000000000..7020439d86e --- /dev/null +++ b/mysql-test/suite/versioning/t/alter.test @@ -0,0 +1,279 @@ +create table t( + a int +); +show create table t; +--error ER_VERS_WRONG_PARAMS +alter table t without system versioning; + +alter table t with system versioning; +show create table t; + +alter table t without system versioning; +show create table t; + +--error ER_VERS_FIELD_WRONG_TYPE +alter table t + add column trx_start bigint(20) unsigned generated always as row start, + add column trx_end bigint(20) unsigned generated always as row end, + add period for system_time(trx_start, trx_end), + with system versioning; + +--error ER_VERS_FIELD_WRONG_TYPE +alter table t + add column trx_start timestamp generated always as row start, + add column trx_end timestamp generated always as row end, + add period for system_time(trx_start, trx_end), + with system versioning; + +--error ER_PARSE_ERROR +alter table t + add column trx_start timestamp(6) not null generated always as row start, + add column trx_end timestamp(6) not null generated always as row end, + add period for system_time(trx_start, trx_end), + with system versioning; + +alter table t + add column trx_start timestamp(6) generated always as row start, + add column trx_end timestamp(6) generated always as row end, + add period for system_time(trx_start, trx_end), + with system versioning; +show create table t; + +alter table t drop column trx_start, drop column trx_end; +alter table t without system versioning; +show create table t; + +alter table t with system versioning; +show create table t; + +alter table t add column b int; +show create table t; + +alter table t add column c int; +show create table t; + +alter table t add column d int first; +show create table t; + +alter table t add column e int after d; +show create table t; + +alter table t drop column a; +show create table t; + +create or replace table t ( + a int, + sys_trx_start timestamp(6) generated always as row start, + sys_trx_end timestamp(6) generated always as row end, + period for system_time(sys_trx_start, sys_trx_end)) +with system versioning; + +select * from t for system_time all; +alter table t drop column sys_trx_start; +alter table t drop column sys_trx_end; +select * from t for system_time all; + +--error ER_CANT_DROP_FIELD_OR_KEY +alter table t drop column sys_trx_start; +--error ER_CANT_DROP_FIELD_OR_KEY +alter table t drop column sys_trx_end; + +create or replace table t ( + a int, + sys_trx_start timestamp(6) generated always as row start, + sys_trx_end timestamp(6) generated always as row end, + period for system_time(sys_trx_start, sys_trx_end)) +with system versioning; + +select * from t for system_time all; +alter table t drop column sys_trx_start, drop column sys_trx_end; +select * from t for system_time all; + +create or replace table t( + a int +); +insert into t values(1); +alter table t with system versioning; +show create table t; +insert into t values(2); +select * from t for system_time all; +select * from t; + +update t set a=3 where a=1; +select * from t; +select * from t for system_time all; +select sys_trx_start from t where a=3 into @tm; +alter table t add column b int; +select @tm=sys_trx_start from t where a=3; +show create table t; +select * from t; +select * from t for system_time all; + +alter table t without system versioning; +select * from t; +show create table t; + +--error ER_VERS_WRONG_PARAMS +alter table t modify a int with system versioning; +--error ER_VERS_WRONG_PARAMS +alter table t modify a int without system versioning; + +alter table t with system versioning; + +alter table t modify a int without system versioning; +show create table t; + +alter table t modify a int with system versioning; +show create table t; + +-- source suite/versioning/common.inc +create or replace table t( + a int +) engine=innodb; + +insert into t values(1); +select * from t; + +--error ER_VERS_FIELD_WRONG_TYPE +alter table t + add column trx_start timestamp(6) generated always as row start, + add column trx_end timestamp(6) generated always as row end, + add period for system_time(trx_start, trx_end), + with system versioning; + +alter table t + add column trx_start bigint(20) unsigned generated always as row start, + add column trx_end bigint(20) unsigned generated always as row end, + add period for system_time(trx_start, trx_end), + with system versioning; +show create table t; +alter table t drop column trx_start, drop column trx_end; +alter table t without system versioning; + +alter table t with system versioning, algorithm=copy; +show create table t; + +update t set a=2; +select * from t for system_time all; + +alter table t add column b int, algorithm=copy; +show create table t; +select * from t; + +alter table t drop column b, algorithm=copy; +show create table t; +select * from t for system_time all; + +alter table t add column b int, algorithm=inplace; +show create table t; +select * from t; + +alter table t drop column b, algorithm=inplace; +show create table t; +select * from t for system_time all; + +alter table t without system versioning, algorithm=copy; +show create table t; + +create or replace table t (a int) with system versioning engine=innodb; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b int auto_increment unique; +select * from t for system_time all; +insert into t values (4, NULL); +select * from t for system_time all; + +create or replace table t (a int) with system versioning; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b int auto_increment unique; +select * from t for system_time all; +insert into t values (4, NULL); +select * from t for system_time all; + +create or replace table t (a int) with system versioning engine=innodb; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b tinyint auto_increment unique; +select * from t for system_time all; +insert into t values (4, NULL); +select * from t for system_time all; + +create or replace table t (a int) with system versioning; +insert into t values (1), (2), (3); +delete from t where a<3; +alter table t add b tinyint auto_increment unique; +select * from t for system_time all; +insert into t values (4, NULL); +select * from t for system_time all; + +create or replace table t (a int) engine innodb; +insert into t values (1); +alter table t with system versioning, algorithm=inplace; +select * from t for system_time all; +update t set a=2; +select * from t for system_time all; +alter table t add column b int, algorithm=inplace; +select * from t for system_time all; +alter table t without system versioning, algorithm=inplace; +select * from t; + +create or replace table t ( + a int, + sys_trx_start bigint(20) unsigned generated always as row start, + sys_trx_end bigint(20) unsigned generated always as row end, + period for system_time(sys_trx_start, sys_trx_end) +) with system versioning engine innodb; +--error ER_VERS_ALTER_SYSTEM_FIELD +alter table t change column sys_trx_start asdf bigint unsigned; + +create or replace table t ( + a int, + sys_trx_start timestamp(6) generated always as row start, + sys_trx_end timestamp(6) generated always as row end, + period for system_time(sys_trx_start, sys_trx_end) +) with system versioning engine myisam; +--error ER_VERS_ALTER_SYSTEM_FIELD +alter table t change column sys_trx_start asdf timestamp(6); + +create or replace table t ( + a int, + sys_trx_start timestamp(6) generated always as row start, + sys_trx_end timestamp(6) generated always as row end, + period for system_time(sys_trx_start, sys_trx_end) +) with system versioning; +select * from t; + +--error ER_VERS_SYS_FIELD_NOT_HIDDEN +alter table t without system versioning; +alter table t drop column sys_trx_start; +select * from t; + +--error ER_VERS_SYS_FIELD_NOT_HIDDEN +alter table t without system versioning; +alter table t drop column sys_trx_end; +select * from t; + +alter table t without system versioning; +show create table t; + +set versioning_alter_history = DROP; + +create or replace table t (a int) with system versioning engine innodb; +insert into t values (1); +update t set a = 2; +select * from t for system_time all; +alter table t add column b int; +select * from t for system_time all; + +create or replace table t (a int) with system versioning engine myisam; +insert into t values (1); +update t set a = 2; +select * from t for system_time all; +alter table t add column b int; +select * from t for system_time all; + +call verify_vtq; +drop table t; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/auto_increment.test b/mysql-test/suite/versioning/t/auto_increment.test new file mode 100644 index 00000000000..7b79be575d1 --- /dev/null +++ b/mysql-test/suite/versioning/t/auto_increment.test @@ -0,0 +1,68 @@ +-- source suite/versioning/common.inc + +delimiter ~~; +create procedure test_01( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + id int unsigned auto_increment primary key, + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + + set @str= concat(' + create table t2( + id int unsigned auto_increment primary key, + x int unsigned, + y int unsigned) + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + + insert into t1(x, y) values(1, 11); + insert into t2(x, y) values(1, 11); + insert into t1(x, y) values(2, 12); + insert into t2(x, y) values(2, 12); + insert into t1(x, y) values(3, 13); + insert into t2(x, y) values(3, 13); + insert into t1(x, y) values(4, 14); + insert into t2(x, y) values(4, 14); + insert into t1(x, y) values(5, 15); + insert into t2(x, y) values(5, 15); + insert into t1(x, y) values(6, 16); + insert into t2(x, y) values(6, 16); + insert into t1(x, y) values(7, 17); + insert into t2(x, y) values(7, 17); + insert into t1(x, y) values(8, 18); + insert into t2(x, y) values(8, 18); + insert into t1(x, y) values(9, 19); + insert into t2(x, y) values(9, 19); + + select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id; + delete from t1 where x = 2; + delete from t2 where x = 2; + + select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id; + delete from t1 where x > 7; + delete from t2 where x > 7; + + select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner join t2 on t1.id = t2.id; + drop table t1; + drop table t2; +end~~ +delimiter ;~~ + +call test_01('timestamp(6)', 'myisam', 'sys_end'); +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +call verify_vtq; + +drop procedure test_01; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/commit_id.test b/mysql-test/suite/versioning/t/commit_id.test new file mode 100644 index 00000000000..fa44958470c --- /dev/null +++ b/mysql-test/suite/versioning/t/commit_id.test @@ -0,0 +1,86 @@ +-- source suite/versioning/common.inc + +create table t1( + id int auto_increment primary key) +with system versioning +engine innodb; + + +# VTQ_TRX_ID, VTQ_COMMIT_ID, VTQ_TRX_SEES # + +insert into t1 values (); + +set @ts0= now(6); +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx0; +select transaction_id = @tx0 from information_schema.innodb_vtq limit 1; + +set @ts1= now(6); +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx1; +select transaction_id = @tx1 from information_schema.innodb_vtq limit 1; + +set @ts2= now(6); +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx2; +select transaction_id = @tx2 from information_schema.innodb_vtq limit 1; + +set @ts3= now(6); + +select + vtq_trx_id(@ts0) < @tx0 as A, + vtq_trx_id(@ts0, true) = @tx0 as B, + vtq_trx_id(@ts1) = @tx0 as C, + vtq_trx_id(@ts1, true) = @tx1 as D, + vtq_trx_id(@ts2) = @tx1 as E, + vtq_trx_id(@ts2, true) = @tx2 as F, + vtq_trx_id(@ts3) = @tx2 as G, + vtq_trx_id(@ts3, true) is null as H; + +select + vtq_commit_id(@ts0) < @tx0 as A, + vtq_commit_id(@ts0, true) = vtq_commit_id(null, @tx0) as B, + vtq_commit_id(@ts1) = vtq_commit_id(null, @tx0) as C, + vtq_commit_id(@ts1, true) = vtq_commit_id(null, @tx1) as D, + vtq_commit_id(@ts2) = vtq_commit_id(null, @tx1) as E, + vtq_commit_id(@ts2, true) = vtq_commit_id(null, @tx2) as F, + vtq_commit_id(@ts3) = vtq_commit_id(null, @tx2) as G, + vtq_commit_id(@ts3, true) is null as H; + +select + vtq_trx_sees(@tx1, @tx0) as A, + not vtq_trx_sees(@tx0, @tx1) as B, + vtq_trx_sees_eq(@tx1, @tx1) as C, + not vtq_trx_sees(@tx1, @tx1) as D, + vtq_trx_sees(@tx2, 0) as E, + vtq_trx_sees(0, @tx2) is null as F, + vtq_trx_sees(-1, @tx2) as H; + + +# VTQ_ISO_LEVEL # + +set transaction isolation level read uncommitted; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx3; +select isolation_level = 'READ-UNCOMMITTED' from information_schema.innodb_vtq where transaction_id = @tx3; + +set transaction isolation level read committed; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx4; +select isolation_level = 'READ-COMMITTED' from information_schema.innodb_vtq where transaction_id = @tx4; + +set transaction isolation level serializable; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx5; +select isolation_level = 'SERIALIZABLE' from information_schema.innodb_vtq where transaction_id = @tx5; + +set transaction isolation level repeatable read; +insert into t1 values (); +select sys_trx_start from t1 where id = last_insert_id() into @tx6; +select isolation_level = 'REPEATABLE-READ' from information_schema.innodb_vtq where transaction_id = @tx6; + + +drop table t1; +call verify_vtq; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/create.combinations b/mysql-test/suite/versioning/t/create.combinations new file mode 100644 index 00000000000..75fb20d9f5e --- /dev/null +++ b/mysql-test/suite/versioning/t/create.combinations @@ -0,0 +1,5 @@ +[innodb] +default-storage-engine=innodb + +[myisam] +default-storage-engine=myisam diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test new file mode 100644 index 00000000000..815030255df --- /dev/null +++ b/mysql-test/suite/versioning/t/create.test @@ -0,0 +1,295 @@ +-- source suite/versioning/common.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +delimiter ~~; +create function if not exists non_default_engine() +returns varchar(255) +deterministic +begin + if default_engine() = 'innodb' then + return 'myisam'; + end if; + return 'innodb'; +end~~ +delimiter ;~~ + +--let $sys_datatype= `select sys_datatype()` +--let $default_engine= `select default_engine()` +--let $non_default_engine= `select non_default_engine()` + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +eval create table t1 ( + x1 int unsigned, + Sys_start $sys_datatype generated always as row start comment 'start', + Sys_end $sys_datatype generated always as row end comment 'end', + period for system_time (Sys_start, Sys_end) +) with system versioning; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +--echo # Implicit fields test +create or replace table t1 ( + x2 int unsigned +) with system versioning; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x3 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_start2 $sys_datatype generated always as row start, + Sys_end $sys_datatype generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning; + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x4 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_end2 $sys_datatype generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning; + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x5 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_end $sys_datatype generated always as row end, + Sys_end2 $sys_datatype generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning; + +--error ER_VERS_WRONG_PARAMS +create or replace table t1 ( + x6 int unsigned, + period for system_time (Sys_start, Sys_end) +) with system versioning; + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x7 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_end $sys_datatype generated always as row end, + Sys_end2 $sys_datatype generated always as row end, + period for system_time (Sys_start, Sys_end) +); + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x8 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_end $sys_datatype generated always as row end, + period for system_time (sys_insert, sys_remove) +) with system versioning; + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x9 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_end $sys_datatype generated always as row end, + period for system_time (Sys_start, Sys_end) +); + +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +--error ER_VERS_WRONG_PARAMS +eval create or replace table t1 ( + x10 int unsigned, + Sys_start $sys_datatype generated always as row start, + Sys_end $sys_datatype generated always as row end, + period for system_time (Sys_start, Sys_start) +); + +--error ER_VERS_FIELD_WRONG_TYPE, ER_VERS_FIELD_WRONG_TYPE +create or replace table t1 ( + x11 int unsigned, + Sys_start bigint unsigned generated always as row start, + Sys_end timestamp(6) generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning; + +--error ER_VERS_FIELD_WRONG_TYPE, ER_VERS_FIELD_WRONG_TYPE +create or replace table t1 ( + x12 int unsigned, + Sys_start timestamp(6) generated always as row start, + Sys_end bigint unsigned generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning; + +--error ER_VERS_FIELD_WRONG_TYPE +create or replace table t1 ( + x13 int unsigned, + Sys_start bigint generated always as row start, + Sys_end bigint unsigned generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning engine innodb; + +--error ER_VERS_FIELD_WRONG_TYPE +create or replace table t1 ( + x14 int unsigned, + Sys_start bigint unsigned generated always as row start, + Sys_end bigint generated always as row end, + period for system_time (Sys_start, Sys_end) +) with system versioning engine innodb; + +# columns with/without system versioning + +create or replace table t1 ( + A1 int with system versioning, + B int +); +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +create or replace table t1 ( + A2 int with system versioning, + B int +) with system versioning; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +create or replace table t1 ( + A3 int, + B int without system versioning +); + +create or replace table t1 ( + A4 int, + B int without system versioning +) with system versioning; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +create or replace table t1 ( + A5 int with system versioning, + B int without system versioning +); +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +create or replace table t1 ( + A6 int with system versioning, + B int without system versioning +) with system versioning; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t1; + +create or replace table t1 ( + A7 int without system versioning +); + +--error ER_VERS_WRONG_PARAMS +create or replace table t1 ( + A8 int without system versioning +) with system versioning; + +# table with/without system versioning + +--error ER_VERS_WRONG_PARAMS +create table t( + a11 int +) without system versioning; + +create or replace table t1 (a int) with system versioning; +create temporary table tmp with system versioning select * from t1; + +# CREATE TABLE ... LIKE +create or replace table t1 (a int) with system versioning; +create table tt1 like t1; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table tt1; +drop table tt1; + +# CREATE TABLE ... SELECT +create or replace table t1 (x int) with system versioning; +--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +eval create or replace table t0( + y int, + st $sys_datatype generated always as row start, + en $sys_datatype generated always as row end, + period for system_time (st, en) +) with system versioning; + +## For non-versioned table: +### 1. system fields are not inherited (hidden and not hidden) +create or replace table t2 as select * from t1; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM +show create table t2; + +create or replace table t3 as select * from t0; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM +show create table t3; + +### 2. hidden fields are inherited as hidden +### TODO: non-system hidden fields + +## For versioned table system fields are inherited as is. +insert into t1 values (1); +insert into t0 values (2); + +create or replace table t2 with system versioning as select * from t1; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t2; +# implicit system fields are hidden +select * from t2; + +create or replace table t3 with system versioning as select * from t0; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t3; +# explicit system fields are not hidden +select * from t3 where y > 2; + +delete from t0; + +## Combinations of versioned + non-versioned +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int); +create or replace table t3 with system versioning select * from t1 for system_time all, t2; +--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE +show create table t3; + +create or replace table t2 with system versioning as select * from t0; +--error ER_VERS_WRONG_PARAMS +create or replace table t3 with system versioning select x, y, t1.sys_trx_start, t2.en from t1, t2; + +insert into t2 values (1), (2); +delete from t2 where y = 2; + +create or replace table t3 select * from t2 for system_time all; +select st, en from t2 where y = 1 into @st, @en; +select y from t2 for system_time all where st = @st and en = @en; +select st, en from t2 for system_time all where y = 2 into @st, @en; +select y from t2 for system_time all where st = @st and en = @en; + +--replace_result innodb INNODB_OR_MYISAM myisam INNODB_OR_MYISAM +eval create or replace table t1 (a int) with system versioning engine $non_default_engine; +create or replace table t2 as select a, sys_trx_start, sys_trx_end from t1 for system_time all; +--replace_result innodb INNODB_OR_MYISAM myisam INNODB_OR_MYISAM "BIGINT(20) UNSIGNED" SYS_TRX_TYPE "TIMESTAMP(6)" SYS_TRX_TYPE +--error ER_VERS_FIELD_WRONG_TYPE +eval create or replace table t2 with system versioning engine $default_engine as select a, sys_trx_start, sys_trx_end from t1 for system_time all; + +--replace_result innodb INNODB_OR_MYISAM myisam INNODB_OR_MYISAM +eval create or replace table t1 (a int, id int) with system versioning engine $non_default_engine; +create or replace table t2 (b int, id int); +create or replace table t3 as + select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id; + +create or replace table t (sys_trx_start int); +--error ER_DUP_FIELDNAME +alter table t with system versioning; + +create or replace table t (sys_trx_end int); +--error ER_DUP_FIELDNAME +alter table t with system versioning; + +drop database test; +create database test; diff --git a/mysql-test/suite/versioning/t/cte.opt b/mysql-test/suite/versioning/t/cte.opt new file mode 100644 index 00000000000..36f683f4f5b --- /dev/null +++ b/mysql-test/suite/versioning/t/cte.opt @@ -0,0 +1,3 @@ +--innodb --default-storage-engine=innodb +--plugin-load=versioning +--versioning-hide=implicit diff --git a/mysql-test/suite/versioning/t/cte.test b/mysql-test/suite/versioning/t/cte.test new file mode 100644 index 00000000000..7a35352f7c8 --- /dev/null +++ b/mysql-test/suite/versioning/t/cte.test @@ -0,0 +1,84 @@ +create or replace table dept ( + dept_id int(10) primary key, + name varchar(100) +) +with system versioning; + +create or replace table emp ( + emp_id int(10) primary key, + dept_id int(10) not null, + name varchar(100) not null, + mgr int(10), + salary int(10) not null, + constraint `dept-emp-fk` + foreign key (dept_id) references dept (dept_id) + on delete cascade + on update restrict, + constraint `mgr-fk` + foreign key (mgr) references emp (emp_id) + on delete restrict + on update restrict +) +with system versioning; + +insert into dept (dept_id, name) values (10, "accounting"); + +insert into emp (emp_id, name, salary, dept_id, mgr) values +(1, "bill", 1000, 10, null), +(20, "john", 500, 10, 1), +(30, "jane", 750, 10,1 ); + +select vtq_commit_ts(max(sys_trx_start)) into @ts_1 from emp; + +update emp set mgr=30 where name ="john"; +select vtq_commit_ts(sys_trx_start) into @ts_2 from emp where name="john"; + +/* All report to 'Bill' */ +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr, e.salary + from emp for system_time as of timestamp @ts_1 as e + where name = 'bill' + union + select e.emp_id, e.name, e.mgr, e.salary + from emp for system_time as of timestamp @ts_1 as e, + ancestors as a + where e.mgr = a.emp_id +) +select * from ancestors for system_time as of now; + +/* Expected 3 rows */ +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr, e.salary + from emp for system_time as of timestamp @ts_2 as e + where name = 'bill' + union + select e.emp_id, e.name, e.mgr, e.salary + from emp for system_time as of timestamp @ts_2 as e, + ancestors as a + where e.mgr = a.emp_id +) +select * from ancestors; + +create or replace table emp ( emp_id int, name varchar(127), mgr int) with system versioning; +create or replace table addr ( emp_id int, address varchar(100)) with system versioning; +insert emp values (1, 'bill', 0), (2, 'bill', 1), (3, 'kate', 1); +insert addr values (1, 'Moscow'), (2, 'New York'), (3, 'London'); +set @ts=now(6); +delete from emp; +delete from addr; +insert emp values (4, 'john', 1); +insert addr values (4, 'Paris'); +with ancestors as (select * from emp natural join addr) select * from ancestors; +with ancestors as (select * from emp natural join addr) select * from ancestors for system_time all; +with ancestors as (select * from emp natural join addr system_time all) select * from ancestors; +select * from emp natural join addr system_time all; + +drop table emp; +drop table dept; +drop table addr; diff --git a/mysql-test/suite/versioning/t/ddl.test b/mysql-test/suite/versioning/t/ddl.test new file mode 100644 index 00000000000..5be62281a6d --- /dev/null +++ b/mysql-test/suite/versioning/t/ddl.test @@ -0,0 +1,105 @@ +-- source suite/versioning/common.inc + +delimiter ~~; +create function get_archive_table_name() +returns varchar(255) +begin + return (select archive_name from t_vtmd for system_time all where archive_name is not NULL + order by start desc limit 1); +end~~ + +create procedure drop_last_archive() +begin + call concat_exec2('drop table ', get_archive_table_name()); +end~~ +delimiter ;~~ + +set versioning_alter_history= survive; + +create or replace table t (a int) with system versioning; +insert into t values (1); +update t set a=2 where a=1; +select sys_trx_start from t where a=2 into @tm; +alter table t add column b int; + +select * from t; +call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all'); + +call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2'); +select @tm<sys_trx_start from t where a=2; +select sys_trx_start from t where a=2 into @tm; +call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2'); + +call drop_last_archive(); + + +set versioning_alter_history= keep; +drop table t_vtmd; +drop table t; +set versioning_alter_history= survive; + +# same for INNODB ALGORITHM=COPY +create or replace table t (a int) with system versioning; +insert into t values (1); +update t set a=2 where a=1; +select sys_trx_start from t where a=2 into @tm; +alter table t add column b int; + +select * from t; +call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all'); + +call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2'); +select @tm<sys_trx_start from t where a=2; +select sys_trx_start from t where a=2 into @tm; +call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2'); + +call drop_last_archive(); + + +set versioning_alter_history= keep; +drop table t_vtmd; +drop table t; +set versioning_alter_history= survive; + +# same for INNODB default ALGORITHM +create or replace table t (a int) with system versioning engine innodb; +insert into t values (1); +update t set a=2 where a=1; +select sys_trx_start from t where a=2 into @tm; +alter table t add column b int; + +select * from t; +call concat_exec3('select * from ', get_archive_table_name(), ' for system_time all'); + +call concat_exec3('select @tm=sys_trx_start from ', get_archive_table_name(), ' for system_time all where a=2'); +select @tm<sys_trx_start from t where a=2; +select sys_trx_start from t where a=2 into @tm; +call concat_exec3('select @tm=sys_trx_end from ', get_archive_table_name(), ' for system_time all where a=2'); + +call drop_last_archive(); + + +set versioning_alter_history= keep; +drop table t_vtmd; +drop table t; +set versioning_alter_history= survive; + +# no DDL for INNODB explicit ALGORITHM=INPLACE +create or replace table t (a int) with system versioning engine innodb; +insert into t values (1); +update t set a=2 where a=1; +alter table t add column b int, algorithm=inplace; + +set versioning_alter_history = keep; + +drop function get_archive_table_name; +drop procedure drop_last_archive; + +select * from mysql.vtmd_template; +show create table mysql.vtmd_template; + +call verify_vtq; +drop table t; +drop table t_vtmd; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/delete.test b/mysql-test/suite/versioning/t/delete.test new file mode 100644 index 00000000000..1830f512b88 --- /dev/null +++ b/mysql-test/suite/versioning/t/delete.test @@ -0,0 +1,121 @@ +-- source suite/versioning/common.inc + +delimiter ~~; +create or replace procedure test_01( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create or replace table t1( + XNo int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(XNo) values(0); + insert into t1(XNo) values(1); + insert into t1(XNo) values(2); + insert into t1(XNo) values(3); + insert into t1(XNo) values(4); + insert into t1(XNo) values(5); + insert into t1(XNo) values(6); + insert into t1(XNo) values(7); + insert into t1(XNo) values(8); + insert into t1(XNo) values(9); + set @str= concat('select XNo, ', + fields, " < '2038-01-19 03:14:07' + from t1 for system_time + between timestamp '0000-0-0 0:0:0' + and timestamp '2038-01-19 04:14:07'"); + prepare stmt from @str; execute stmt; + delete from t1 where XNo = 0; + execute stmt; + delete from t1 where XNo = 1; + execute stmt; + delete from t1 where XNo > 5; + create view vt1 as select XNo from t1; + select XNo from vt1; + delete from vt1 where XNo = 3; + select XNo from vt1; + execute stmt; drop prepare stmt; + drop view vt1; + drop table t1; +end~~ + +create or replace procedure test_02( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat('create or replace table t1 ( + x int, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(x) values (1); + select sys_start into @sys_start from t1; + delete from t1; + select * from t1; + select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C + from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07'; + drop table t1; +end~~ + +create or replace procedure test_03( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str0= concat('( + x int, + y int, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + set @str= concat('create or replace table t1', @str0); + prepare stmt from @str; execute stmt; drop prepare stmt; + set @str= concat('create or replace table t2', @str0); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(x, y) values (1, 1), (2, 2), (3, 3), (14, 4); + insert into t2(x, y) values (11, 1), (12, 2), (13, 32), (14, 4); + delete t1, t2 from t1 join t2 where t1.y = 3 and t2.y = 32; + select x as t1_x from t1; + select x as t2_x from t2; + delete t1, t2 from t1 join t2 where t1.x = t2.x; + select x as t1_x from t1; + select x as t2_x from t2; + select x as t1_x_all from t1 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07'; + select x as t2_x_all from t2 for system_time between timestamp '0-0-0' and timestamp '2038-01-19 04:14:07'; + drop table t1; + drop table t2; +end~~ +delimiter ;~~ + +--echo # Basic + delete from view +call test_01('timestamp(6)', 'myisam', 'sys_end'); +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +call verify_vtq; + +--echo # Check sys_start, sys_end +call test_02('timestamp(6)', 'myisam', 'sys_end'); +call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +call verify_vtq; + +--echo # Multi-delete +call test_03('timestamp(6)', 'myisam', 'sys_end'); +call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +call verify_vtq; + +drop procedure test_01; +drop procedure test_02; +drop procedure test_03; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/derived.test b/mysql-test/suite/versioning/t/derived.test new file mode 100644 index 00000000000..63683e251c9 --- /dev/null +++ b/mysql-test/suite/versioning/t/derived.test @@ -0,0 +1,133 @@ +create table emp +( + emp_id int, + name varchar(127), + mgr int +) with system versioning; + +insert into emp values (1, 'bill', 0), + (2, 'bill', 1), + (3, 'kate', 1); +set @ts=now(6); +delete from emp; +insert into emp values (4, 'john', 1); + +with ancestors as (select * from emp) select * from ancestors; +set @tmp= "with ancestors as (select * from emp) select * from ancestors"; +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +with ancestors as (select * from emp for system_time all) select * from ancestors; +set @tmp= "with ancestors as (select * from emp for system_time all) select * from ancestors"; +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +with recursive ancestors as (select * from emp) select * from ancestors; +set @tmp= "with recursive ancestors as (select * from emp) select * from ancestors"; +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp; +set @tmp= "select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp"; +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr + from emp as e + where name = 'john' + union + select ee.emp_id, ee.name, ee.mgr + from emp as ee, ancestors as a + where ee.mgr = a.emp_id +) +select * from ancestors; +set @tmp= " +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr + from emp as e + where name = 'john' + union + select ee.emp_id, ee.name, ee.mgr + from emp as ee, ancestors as a + where ee.mgr = a.emp_id +) +select * from ancestors"; +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr + from emp as e + where name = 'bill' + system_time as of timestamp @ts + union + select ee.emp_id, ee.name, ee.mgr + from emp as ee, ancestors as a + where ee.mgr = a.emp_id + system_time as of timestamp @ts +) +select * from ancestors; +set @tmp= " +with recursive +ancestors +as +( + select e.emp_id, e.name, e.mgr + from emp as e + where name = 'bill' + system_time as of timestamp @ts + union + select ee.emp_id, ee.name, ee.mgr + from emp as ee, ancestors as a + where ee.mgr = a.emp_id + system_time as of timestamp @ts +) +select * from ancestors"; +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +drop table emp; + +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int) with system versioning; +insert into t1 values (1); +set @t0= now(6); +insert into t1 values (2); +delete from t1 where x = 1; +insert into t2 values (10); + +--error ER_VERS_DERIVED_PROHIBITED +select * from (select *, t1.sys_trx_end, t1.sys_trx_end as endo from t1) as s0; +--error ER_VERS_DERIVED_PROHIBITED +select * from (select *, t1.sys_trx_end, t2.sys_trx_start from t1, t2) as s0; + +# system_time propagation from inner to outer +select * from (select * from t1 for system_time as of timestamp @t0, t2) as s0; +with s1 as (select * from t1 for system_time as of timestamp @t0, t2) select * from s1; +# leading table selection +select * from (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) as s2; +with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3; +# system_time propagation from outer to inner +select * from (select *, t1.sys_trx_start from t2 for system_time as of now, t1) as s4 system_time as of timestamp @t0; +with s5 as (select *, t1.sys_trx_start from t2 for system_time as of now, t1) select * from s5 for system_time as of timestamp @t0; +with s6 as (select *, t1.sys_trx_start from t2 for system_time as of now, t1) select * from s6 system_time as of timestamp @t0; + +# VIEW instead of t1 +set @q= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t0, "'"); +prepare q from @q; execute q; drop prepare q; + +# system_time propagation from view +select * from vt1; +# system_time propagation from inner to outer +select * from (select * from vt1, t2) as s0; +# leading table selection +select * from (select *, vt1.sys_trx_end from t2, vt1) as s0; +# system_time propagation from outer to inner +select * from (select *, vt1.sys_trx_start from t2 for system_time as of now, vt1) as s0 system_time as of timestamp @t0; + +drop table t1, t2; +drop view vt1; diff --git a/mysql-test/suite/versioning/t/foreign.opt b/mysql-test/suite/versioning/t/foreign.opt new file mode 100644 index 00000000000..c1a585b67eb --- /dev/null +++ b/mysql-test/suite/versioning/t/foreign.opt @@ -0,0 +1 @@ +--versioning-hide=implicit diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test new file mode 100644 index 00000000000..ec23abac460 --- /dev/null +++ b/mysql-test/suite/versioning/t/foreign.test @@ -0,0 +1,205 @@ +-- source include/have_innodb.inc + +################# +# Test RESTRICT # +################# + +create table parent( + id int unique key +) engine innodb; + +create table child( + parent_id int, + foreign key(parent_id) references parent(id) + on delete restrict + on update restrict +) engine innodb with system versioning; + +insert into parent values(1); +insert into child values(1); + +-- error ER_ROW_IS_REFERENCED_2 +delete from parent where id = 1; +delete from child where parent_id = 1; +delete from parent where id = 1; + +insert into parent values(1); +insert into child values(1); +-- error ER_ROW_IS_REFERENCED_2 +update parent set id=id+1; +delete from child; +update parent set id=id+1; +select * from child for system_time from timestamp '1-1-1' to timestamp now(6); + +drop table child; +drop table parent; + +############################################## +# Test when clustered index is a foreign key # +############################################## + +create table parent( + id int(10) unsigned unique key +) engine innodb; + +create table child( + parent_id int(10) unsigned primary key, + foreign key(parent_id) references parent(id) +) engine innodb with system versioning; + +insert into parent values(1); +insert into child values(1); + +-- error ER_ROW_IS_REFERENCED_2 +delete from parent where id = 1; + +drop table child; +drop table parent; + +################ +# Test CASCADE # +################ + +create table parent( + id int unique key +) engine innodb; + +create table child( + parent_id int, + foreign key(parent_id) references parent(id) + on delete cascade + on update cascade +) engine innodb with system versioning; + +insert into parent values(1); +insert into child values(1); + +delete from parent where id = 1; +select * from child; +select * from child for system_time all; + +insert into parent values(1); +insert into child values(1); +update parent set id = id + 1; +select * from child; +select * from child for system_time all; + +drop table child; +drop table parent; + +create or replace table parent ( + id int primary key +) with system versioning +engine innodb; + +create or replace table child ( + x int, + parent_id int not null, + constraint `parent-fk` + foreign key (parent_id) references parent (id) + on delete cascade + on update restrict +) +engine innodb; + +insert into parent (id) values (2); +insert into child (x, parent_id) values (2, 2); +delete from parent; +select * from child; + +drop table child; +drop table parent; + +create or replace table parent ( + id int primary key +) +engine innodb; + +create or replace table child ( + id int primary key, + parent_id int not null, + constraint `parent-fk` + foreign key (parent_id) references parent (id) + on delete cascade + on update restrict +) with system versioning +engine innodb; + +insert into parent (id) values (3); +insert into child (id, parent_id) values (3, 3); +delete from parent; +select * from child; +select * from child for system_time all; + +drop table child; +drop table parent; + +################# +# Test SET NULL # +################# + +create table parent( + id int unique key +) engine innodb; + +create table child( + parent_id int, + foreign key(parent_id) references parent(id) + on delete set null + on update set null +) engine innodb with system versioning; + +insert into parent values(1); +insert into child values(1); +delete from child; +insert into child values(1); + +delete from parent where id = 1; +select * from child; +select * from child for system_time from timestamp '1-1-1' to timestamp now(6); +delete from child; + +insert into parent values(1); +insert into child values(1); +update parent set id=id+1; +select * from child; +select * from child for system_time from timestamp '1-1-1' to timestamp now(6); + +drop table child; +drop table parent; + +########################### +# Parent table is foreign # +########################### + +create or replace table parent( + id int unique key +) engine innodb with system versioning; + +create or replace table child( + parent_id int, + foreign key(parent_id) references parent(id) +) engine innodb; + +insert into parent values(1); +insert into child values(1); +-- error ER_ROW_IS_REFERENCED_2 +delete from parent; +-- error ER_ROW_IS_REFERENCED_2 +update parent set id=2; + +delete from child; +delete from parent; + +-- error ER_NO_REFERENCED_ROW_2 +insert into child values(1); + +insert into parent values(1); +insert into child values(1); +-- error ER_ROW_IS_REFERENCED_2 +delete from parent; +-- error ER_ROW_IS_REFERENCED_2 +update parent set id=2; + +drop table child; +drop table parent; diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test new file mode 100644 index 00000000000..730c5478841 --- /dev/null +++ b/mysql-test/suite/versioning/t/insert.test @@ -0,0 +1,197 @@ +-- source suite/versioning/common.inc + +delimiter ~~; +create procedure test_01( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(x, y) values(3, 4); + insert into t1(x, y) values(2, 3); + insert into t1 values(40, 33); + set @str= concat('select x, y, ', fields, ' from t1'); + prepare stmt from @str; execute stmt; drop prepare stmt; + drop table t1; +end~~ + +create procedure test_02( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + id int unsigned auto_increment primary key, + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(x, y) values(33, 44); + insert into t1(id, x, y) values(20, 33, 44); + insert into t1 values(40, 33, 44); + set @str= concat('select id, x, y, ', fields, ' from t1'); + prepare stmt from @str; execute stmt; drop prepare stmt; + drop table t1; +end~~ + +create procedure test_03( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + create view vt1_1 as select x, y from t1; + insert into t1(x, y) values(8001, 9001); + insert into vt1_1(x, y) values(1001, 2001); + insert into vt1_1 values(1002, 2002); + set @str= concat('select x, y, ', fields, ' from t1'); + prepare stmt from @str; execute stmt; drop prepare stmt; + select x, y from vt1_1; +end~~ + +create procedure test_04( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + id bigint primary key, + a int, + b int) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1 values(1, 1, 1); + select sys_trx_start, sys_trx_end from t1 into @sys_start, @sys_end; + select id, a, b from t1; + insert into t1 values(2, 2, 2); + select id, a, b, sys_trx_start > @sys_start as C, sys_trx_end = @sys_end as D from t1 where id = 2; + drop table t1; +end~~ + +create procedure test_05( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat('( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + set @str2= concat('create table t1', @str); + prepare stmt from @str2; execute stmt; drop prepare stmt; + set @str2= concat('create table t2', @str); + prepare stmt from @str2; execute stmt; drop prepare stmt; + insert into t1(x, y) values + (1, 1000), + (2, 2000), + (3, 3000), + (4, 4000), + (5, 5000), + (6, 6000), + (7, 7000), + (8, 8000), + (9, 9000); + delete from t1 where x >= 1; + insert into t1(x, y) values + (1, 1001), + (2, 2001), + (3, 3001), + (4, 4001), + (5, 5001), + (6, 6001), + (7, 7001), + (8, 8001), + (9, 9001); + insert into t2 select x, y from t1 for system_time between timestamp '0000-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; + select x, y from t1; + select x, y from t2; + drop table t1; + drop table t2; +end~~ +delimiter ;~~ + +call test_01('timestamp(6)', 'myisam', 'sys_end'); +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_02('timestamp(6)', 'myisam', 'sys_end'); +call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_03('timestamp(6)', 'myisam', 'sys_end'); +drop table t1; +drop view vt1_1; + +call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); +drop table t1; +drop view vt1_1; + +call test_04('timestamp(6)', 'myisam', 'sys_end'); +call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_05('timestamp(6)', 'myisam', 'sys_end'); +call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +# VTQ test + +call verify_vtq; + +create table t1( + x int unsigned, + sys_start bigint unsigned generated always as row start, + sys_end bigint unsigned generated always as row end, + period for system_time (sys_start, sys_end)) +with system versioning engine=innodb; + +create table t2(x int unsigned) engine=innodb; + +start transaction; +insert into t1(x) values(1); +commit; +call verify_vtq; + +start transaction; +insert into t2(x) values(1); +savepoint a; +insert into t1(x) values(1); +rollback to a; +commit; +call verify_vtq; + +drop table t1; +drop table t2; + +drop procedure test_01; +drop procedure test_02; +drop procedure test_03; +drop procedure test_04; +drop procedure test_05; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/optimized.test b/mysql-test/suite/versioning/t/optimized.test new file mode 100644 index 00000000000..6c508d04508 --- /dev/null +++ b/mysql-test/suite/versioning/t/optimized.test @@ -0,0 +1,40 @@ +create table t ( + a int, + b int without system versioning +) with system versioning; + +insert into t values(1, 2); +insert into t values(3, 4); +select * from t; +select a from t for system_time as of timestamp now(6); +select a, b, b+0 from t for system_time as of timestamp now(6); +select * from t for system_time as of timestamp now(6); +select count(*) from t group by b system_time as of timestamp now(6); +select * from t for system_time as of timestamp now(6) order by b asc; +select * from t for system_time as of timestamp now(6) order by b desc; +select * from t group by a having a=2 system_time as of timestamp now(6); +select * from t group by b having b=2 system_time as of timestamp now(6); +select a from t where b=2 system_time as of timestamp now(6); +select a from t where b=NULL system_time as of timestamp now(6); +select a from t where b is NULL system_time as of timestamp now(6); +select count(*), b from t group by b having b=NULL system_time as of timestamp now(6); +select a, b from t; + +select count(*) from t for system_time as of timestamp now(6) group by b; +select * from t for system_time as of timestamp now(6) group by b having b=2; +select a from t for system_time as of timestamp now(6) where b=2; +select a from t for system_time as of timestamp now(6) where b=NULL; +select a from t for system_time as of timestamp now(6) where b is NULL; +select count(*), b from t for system_time as of timestamp now(6) group by b having b=NULL; + +create or replace table t ( + a int, + b int not null without system versioning +) with system versioning; + +insert into t values (1, 2), (3, 4); + +select * from t for system_time as of timestamp now(6); +select * from t for system_time as of timestamp now(6) where b is NULL; + +drop table t; diff --git a/mysql-test/suite/versioning/t/partition.combinations b/mysql-test/suite/versioning/t/partition.combinations new file mode 100644 index 00000000000..d79429f34f7 --- /dev/null +++ b/mysql-test/suite/versioning/t/partition.combinations @@ -0,0 +1,7 @@ +[innodb] +partition +default-storage-engine=innodb + +[myisam] +partition +default-storage-engine=myisam diff --git a/mysql-test/suite/versioning/t/partition.opt b/mysql-test/suite/versioning/t/partition.opt new file mode 100644 index 00000000000..c1a585b67eb --- /dev/null +++ b/mysql-test/suite/versioning/t/partition.opt @@ -0,0 +1 @@ +--versioning-hide=implicit diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test new file mode 100644 index 00000000000..479b63399bf --- /dev/null +++ b/mysql-test/suite/versioning/t/partition.test @@ -0,0 +1,242 @@ +-- source suite/versioning/common.inc + +### check System Versioning and conventional partitioning + +create table t1 (x int) +with system versioning +partition by range columns (x) ( + partition p0 values less than (100), + partition p1 values less than (1000)); + +insert into t1 values (3), (300); +select * from t1; +select * from t1 partition (p0); +select * from t1 partition (p1); + +delete from t1; +select * from t1; +select * from t1 for system_time all; +select * from t1 partition (p0) for system_time all; +select * from t1 partition (p1) for system_time all; + +### check server-level partitioning + +# create errors +--error ER_VERSIONING_REQUIRED +create or replace table t1 (x int) +partition by system_time ( + partition p0 versioning, + partition pn as of now); + +create or replace table t1 (x int); +--error ER_VERSIONING_REQUIRED,ER_VERSIONING_REQUIRED +alter table t1 +partition by system_time ( + partition p0 versioning, + partition pn as of now); + +--error ER_VERS_WRONG_PARTS +create or replace table t1 (x int) +with system versioning +partition by system_time ( + partition p0 as of now); + +--error ER_VERS_WRONG_PARTS +create or replace table t1 (x int) +with system versioning +partition by system_time ( + partition p0 as of now, + partition p1 as of now); + +--error ER_VERS_WRONG_PARTS +create or replace table t1 (x int) +with system versioning +partition by system_time ( + partition p0 versioning, + partition p1 versioning); + +--error ER_VERS_WRONG_PARTS +create or replace table t1 (x int) +with system versioning +partition by system_time ( + partition pn as of now, + partition p0 versioning); + +create or replace table t1 (x int) +with system versioning +partition by system_time ( + partition p0 versioning, + partition pn as of now); + +# alter table +--error ER_VERS_WRONG_PARTS +alter table t1 add partition ( + partition p1 as of now); + +alter table t1 add partition ( + partition p1 versioning); + +--replace_result InnoDB ${INNODB_OR_MYISAM} MyISAM ${INNODB_OR_MYISAM} "bigint(20) unsigned" ${SYS_TRX_TYPE} timestamp(6) ${SYS_TRX_TYPE} +show create table t1; + +insert into t1 values (1), (2); + +--error ER_VERS_WRONG_PARTS +alter table t1 drop partition pn; +alter table t1 drop partition p1; +--error ER_VERS_WRONG_PARTS +alter table t1 drop partition p0; + +select x from t1; + +# Bug #260: incorrect IB partitioning warning +create or replace table t1 (x int) +with system versioning +partition by system_time limit 1 ( + partition p0 versioning, + partition pn as of now); +alter table t1 change x big int; + +# insert, delete, update +create or replace table t1 (x int) +with system versioning +partition by system_time ( + partition p0 versioning, + partition pn as of now); + +set @now= now(6); +insert into t1 values (1); +set @ts_start= sys_commit_ts('sys_trx_start'); +set @ts_end= sys_commit_ts('sys_trx_end'); +set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all'); +prepare select_p0 from @str; +set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn) for system_time all'); +prepare select_pn from @str; + +execute select_p0; +execute select_pn; + +# pruning check +--replace_result ALL system "Using where" "" +explain partitions select * from t1; + +set @str= concat('select ', @ts_start, ' from t1 partition (pn) into @ts0'); +prepare stmt from @str; execute stmt; drop prepare stmt; + +set @now= now(6); +delete from t1; +execute select_p0; +execute select_pn; + +set @str= concat('select ', @ts_start, ' from t1 partition (p0) for system_time all into @ts1'); +prepare stmt from @str; execute stmt; drop prepare stmt; + +select @ts0 = @ts1; + +set @now= now(6); +insert into t1 values (2); +execute select_p0; +execute select_pn; + +set @str= concat('select ', @ts_start, ' from t1 partition (pn) into @ts0'); +prepare stmt from @str; execute stmt; drop prepare stmt; + +set @now= now(6); +update t1 set x = x + 1; +execute select_p0; +execute select_pn; + +drop prepare select_p0; +drop prepare select_pn; + +set @str= concat('select ', @ts_start, ' from t1 partition (p0) for system_time all where x = 2 into @ts1'); +prepare stmt from @str; execute stmt; drop prepare stmt; +set @str= concat('select ', @ts_end, ' from t1 partition (p0) for system_time all where x = 2 into @ts2'); +prepare stmt from @str; execute stmt; drop prepare stmt; +set @str= concat('select ', @ts_start, ' from t1 partition (pn) into @ts3'); +prepare stmt from @str; execute stmt; drop prepare stmt; + +select @ts0 = @ts1; +select @ts2 = @ts3; + +# rotation by LIMIT +--error ER_VERS_WRONG_PARAMS +create or replace table t1 (x int) +with system versioning +partition by system_time limit 0 ( + partition p0 versioning, + partition p1 versioning, + partition pn as of now); + +create or replace table t1 (x int) +with system versioning +partition by system_time limit 1 ( + partition p0 versioning, + partition p1 versioning, + partition pn as of now); + +--replace_result InnoDB ${INNODB_OR_MYISAM} MyISAM ${INNODB_OR_MYISAM} "bigint(20) unsigned" ${SYS_TRX_TYPE} timestamp(6) ${SYS_TRX_TYPE} +show create table t1; + +--error ER_DROP_PARTITION_NON_EXISTENT +alter table t1 drop partition non_existent; + +insert into t1 values (1), (2); +select * from t1 partition (pn); +delete from t1; +select * from t1 partition (p0) for system_time all; +select * from t1 partition (p1) for system_time all; + +insert into t1 values (3); +delete from t1; +select * from t1 partition (p1) for system_time all; + +# rotation by INTERVAL +--error ER_VERS_WRONG_PARAMS +create or replace table t1 (x int) +with system versioning +partition by system_time interval 0 second ( + partition p0 versioning, + partition p1 versioning, + partition pn as of now); + +create or replace table t1 (x int) +with system versioning +partition by system_time interval 1 second ( + partition p0 versioning, + partition p1 versioning, + partition pn as of now); + +insert into t1 values (1), (2), (3); +select * from t1 partition (pn); +delete from t1; +select * from t1 partition (p0) for system_time all; + +--sleep 2 +insert into t1 values (4); +delete from t1; +select * from t1 partition (p1) for system_time all; + +# Subpartitions +create or replace table t1 (x int) +with system versioning +partition by system_time limit 1 +subpartition by key (x) +subpartitions 2 ( + partition p0 versioning, + partition p1 versioning, + partition pn as of now); + +insert into t1 (x) values (1), (2), (3); +select * from t1 partition (pnsp0); +select * from t1 partition (pnsp1); + +delete from t1; +select * from t1 partition (p0sp0) for system_time all; +select * from t1 partition (p0sp1) for system_time all; +select * from t1 partition (p1sp0) for system_time all; +select * from t1 partition (p1sp1) for system_time all; + +drop table t1; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/rpl_mixed.combinations b/mysql-test/suite/versioning/t/rpl_mixed.combinations new file mode 100644 index 00000000000..9a1c771672c --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_mixed.combinations @@ -0,0 +1,5 @@ +[myisam] +default-storage-engine=myisam + +[innodb] +default-storage-engine=innodb diff --git a/mysql-test/suite/versioning/t/rpl_mixed.test b/mysql-test/suite/versioning/t/rpl_mixed.test new file mode 100644 index 00000000000..09612e664dc --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_mixed.test @@ -0,0 +1,7 @@ +-- source include/have_binlog_format_mixed.inc +-- source include/master-slave.inc +-- source include/have_innodb.inc + +-- source rpl_test.inc + +-- source include/rpl_end.inc diff --git a/mysql-test/suite/versioning/t/rpl_row.combinations b/mysql-test/suite/versioning/t/rpl_row.combinations new file mode 100644 index 00000000000..9a1c771672c --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_row.combinations @@ -0,0 +1,5 @@ +[myisam] +default-storage-engine=myisam + +[innodb] +default-storage-engine=innodb diff --git a/mysql-test/suite/versioning/t/rpl_row.test b/mysql-test/suite/versioning/t/rpl_row.test new file mode 100644 index 00000000000..cf04c52dd16 --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_row.test @@ -0,0 +1,7 @@ +-- source include/have_binlog_format_row.inc +-- source include/master-slave.inc +-- source include/have_innodb.inc + +-- source rpl_test.inc + +-- source include/rpl_end.inc diff --git a/mysql-test/suite/versioning/t/rpl_stmt.combinations b/mysql-test/suite/versioning/t/rpl_stmt.combinations new file mode 100644 index 00000000000..75fb20d9f5e --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_stmt.combinations @@ -0,0 +1,5 @@ +[innodb] +default-storage-engine=innodb + +[myisam] +default-storage-engine=myisam diff --git a/mysql-test/suite/versioning/t/rpl_stmt.test b/mysql-test/suite/versioning/t/rpl_stmt.test new file mode 100644 index 00000000000..bc4e76cdf5d --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_stmt.test @@ -0,0 +1,7 @@ +-- source include/have_binlog_format_statement.inc +-- source include/master-slave.inc +-- source include/have_innodb.inc + +-- source rpl_test.inc + +-- source include/rpl_end.inc diff --git a/mysql-test/suite/versioning/t/rpl_test.inc b/mysql-test/suite/versioning/t/rpl_test.inc new file mode 100644 index 00000000000..5beee9f9dc6 --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_test.inc @@ -0,0 +1,90 @@ +#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS +#Testing command counters -BEFORE. +#Storing the before counts of Slave +connection slave; +let $slave_com_commit_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1); +let $slave_com_insert_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1); +let $slave_com_delete_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1); +let $slave_com_update_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1); + +connection master; +CREATE TABLE t1 (x int) with system versioning; +insert into t1 values (1); +SELECT * FROM t1; +delete from t1; +select * from t1; +select * from t1 for system_time all; +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +connection master; +insert into t1 values (2); +sync_slave_with_master; +select * from t1; + +connection master; +update t1 set x = 3; +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +# check unversioned -> versioned replication +connection master; +create or replace table t1 (x int primary key); +sync_slave_with_master; +alter table t1 with system versioning; + +connection master; +insert into t1 values (1); +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +connection master; +update t1 set x= 2 where x = 1; +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +connection master; +delete from t1; +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +# same thing (UPDATE, DELETE), but without PK +connection master; +create or replace table t1 (x int); +sync_slave_with_master; +alter table t1 with system versioning; + +connection master; +insert into t1 values (1); +update t1 set x= 2 where x = 1; +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +connection master; +delete from t1; +sync_slave_with_master; +select * from t1; +select * from t1 for system_time all; + +# multi-update +connection master; +create or replace table t1 (x int) with system versioning; +create or replace table t2 (x int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +update t1, t2 set t1.x=11, t2.x=22; +sync_slave_with_master; +select * from t1; +select * from t2; +select * from t1 for system_time all; +select * from t2 for system_time all; + + +connection master; +drop table t1, t2; diff --git a/mysql-test/suite/versioning/t/rpl_test.opt b/mysql-test/suite/versioning/t/rpl_test.opt new file mode 100644 index 00000000000..c1a585b67eb --- /dev/null +++ b/mysql-test/suite/versioning/t/rpl_test.opt @@ -0,0 +1 @@ +--versioning-hide=implicit diff --git a/mysql-test/suite/versioning/t/select.combinations b/mysql-test/suite/versioning/t/select.combinations new file mode 100644 index 00000000000..75fb20d9f5e --- /dev/null +++ b/mysql-test/suite/versioning/t/select.combinations @@ -0,0 +1,5 @@ +[innodb] +default-storage-engine=innodb + +[myisam] +default-storage-engine=myisam diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test new file mode 100644 index 00000000000..6ec45db6c08 --- /dev/null +++ b/mysql-test/suite/versioning/t/select.test @@ -0,0 +1,189 @@ +-- source suite/versioning/common.inc + +# test_01 + +create or replace table t1 ( + x int unsigned, + y int unsigned +) with system versioning; + +insert into t1 (x, y) values + (0, 100), + (1, 101), + (2, 102), + (3, 103), + (4, 104), + (5, 105), + (6, 106), + (7, 107), + (8, 108), + (9, 109); + +set @t0= now(6); +if ($default_engine == 'innodb') +{ +--disable_query_log + select sys_trx_start from t1 limit 1 into @x0; +--enable_query_log +} + +delete from t1 where x = 3; +delete from t1 where x > 7; + +insert into t1(x, y) values(3, 33); +select sys_trx_start from t1 where x = 3 and y = 33 into @t1; +if ($default_engine == 'innodb') +{ +--disable_query_log + set @x1= @t1; + select vtq_commit_ts(@x1) into @t1; +--enable_query_log +} + +select x, y from t1; +select x as ASOF_x, y from t1 for system_time as of timestamp @t0; +select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1; +select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1; +select x as ALL_x, y from t1 for system_time all; + +--disable_query_log +if ($default_engine == 'innodb') +{ + select x as ASOF2_x, y from t1 for system_time as of @x0; + select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1; + select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1; +} +if ($default_engine != 'innodb') +{ + select x as ASOF2_x, y from t1 for system_time as of @t0; + select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1; + select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1; +} +--enable_query_log + +# test_02 + +create or replace table t1 ( + x int unsigned, + y int unsigned +) with system versioning; +create or replace table t2 ( + x int unsigned, + y int unsigned +) with system versioning; + +insert into t1 values (1, 1), (1, 2), (1, 3), (4, 4), (5, 5); +insert into t2 values (1, 2), (2, 1), (3, 1); +set @t0= now(6); + +select t1.x as IJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x; +select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x; +select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x; + +delete from t1; +delete from t2; + +select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x +system_time as of timestamp @t0; +select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x +system_time as of timestamp @t0; +select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x +system_time as of timestamp @t0; + +drop table t1; +drop table t2; + +# Wildcard expansion on hidden fields + +create table t1( + A int +) with system versioning; +insert into t1 values(1); +select * from t1; + +create or replace table t1 (x int); +insert into t1 values (1); +--error ER_VERSIONING_REQUIRED +select * from t1 for system_time all; + +create or replace table t1 (x int) with system versioning; +insert into t1 values (1); +--error ER_VERS_HISTORY_LOCK +select * from t1 for system_time all for update; + +create or replace table t1 (a int not null auto_increment primary key) with system versioning; +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; + +create or replace table t1 (a int) with system versioning; +create or replace table t2 (a int) with system versioning; +insert into t1 values(1); +insert into t2 values(1); +create view v1 as select * from t2 inner join t1 using (a); +select * from v1; +drop view v1; + +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create view vt1 as select a from t1; +select * from t1 natural join vt1; +drop view vt1; + +create or replace table t1(x int) with system versioning; +select * from (t1 as r left join t1 as u using (x)), t1; + +# @end should be max +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create trigger read_end after update on t1 + for each row set @end = old.sys_trx_end; +update t1 set a=2; +--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.999999" MAX_RESULT +select @end; + +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +select * from (select * from t1 cross join t2) as tmp; +select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2; +select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp; + +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +select * from t1 for system_time all natural left join t2 for system_time all; + +# natural join of a view and table +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create or replace view v1 as select a1 from t1; + +select * from v1 natural join t2; +select * from v1 natural left join t2; +select * from v1 natural right join t2; + +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; + +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int) with system versioning; +insert into t1 values (1), (2), (3); +delete from t1 where x = 3; +insert into t2 values (1); +select * from t1, t2 system_time all; + +--error ER_VERS_UNUSED_CLAUSE +select * from t1 for system_time all, t2 for system_time all system_time all; + +drop view v1; +drop table t1, t2; + +call innodb_verify_vtq(27); + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/select_sp.combinations b/mysql-test/suite/versioning/t/select_sp.combinations new file mode 100644 index 00000000000..75fb20d9f5e --- /dev/null +++ b/mysql-test/suite/versioning/t/select_sp.combinations @@ -0,0 +1,5 @@ +[innodb] +default-storage-engine=innodb + +[myisam] +default-storage-engine=myisam diff --git a/mysql-test/suite/versioning/t/select_sp.test b/mysql-test/suite/versioning/t/select_sp.test new file mode 100644 index 00000000000..bd165c3bd16 --- /dev/null +++ b/mysql-test/suite/versioning/t/select_sp.test @@ -0,0 +1,205 @@ +-- source suite/versioning/common.inc + +delimiter ~~; +create procedure test_01() +begin + declare engine varchar(255) default default_engine(); + declare sys_type varchar(255) default sys_datatype(); + declare fields varchar(255) default sys_commit_ts('sys_start'); + + set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1 (x, y) values + (0, 100), + (1, 101), + (2, 102), + (3, 103), + (4, 104), + (5, 105), + (6, 106), + (7, 107), + (8, 108), + (9, 109); + set @t0= now(6); + if engine = 'innodb' then + select sys_start from t1 limit 1 into @x0; + end if; + + delete from t1 where x = 3; + delete from t1 where x > 7; + + insert into t1(x, y) values(3, 33); + select sys_start from t1 where x = 3 and y = 33 into @t1; + if engine = 'innodb' then + set @x1= @t1; + select vtq_commit_ts(@x1) into @t1; + end if; + + select x, y from t1; + select x as ASOF_x, y from t1 for system_time as of timestamp @t0; + select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1; + select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1; + select x as ALL_x, y from t1 for system_time all; + + if engine = 'innodb' then + select x as ASOF2_x, y from t1 for system_time as of @x0; + select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1; + select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1; + else + select x as ASOF2_x, y from t1 for system_time as of @t0; + select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1; + select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1; + end if; + + drop table t1; +end~~ + +create or replace procedure test_02() +begin + declare engine varchar(255) default default_engine(); + declare sys_type varchar(255) default sys_datatype(); + declare fields varchar(255) default sys_commit_ts('sys_start'); + + set @str0= concat('( + x int, + y int, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + set @str= concat('create or replace table t1', @str0); + prepare stmt from @str; execute stmt; drop prepare stmt; + set @str= concat('create or replace table t2', @str0); + prepare stmt from @str; execute stmt; drop prepare stmt; + + insert into t1 values (1, 1), (1, 2), (1, 3), (4, 4), (5, 5); + insert into t2 values (1, 2), (2, 1), (3, 1); + set @t0= now(6); + + select t1.x as IJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x; + select t1.x as LJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x; + select t1.x as RJ1_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x; + + delete from t1; + delete from t2; + + select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x + system_time as of timestamp @t0; + select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x + system_time as of timestamp @t0; + select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x + system_time as of timestamp @t0; + + drop table t1; + drop table t2; +end~~ +delimiter ;~~ + +call test_01(); +call test_02(); + +# wildcard expansion on hidden fields. +create table t1( + A int +) with system versioning; +insert into t1 values(1); +select * from t1; + +create or replace table t1 (x int); +insert into t1 values (1); +--error ER_VERSIONING_REQUIRED +select * from t1 for system_time all; + +create or replace table t1 (x int) with system versioning; +insert into t1 values (1); +--error ER_VERS_HISTORY_LOCK +select * from t1 for system_time all for update; + +create or replace table t1 (a int not null auto_increment primary key) with system versioning; +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; + +create or replace table t1 (a int) with system versioning; +create or replace table t2 (a int) with system versioning; +insert into t1 values(1); +insert into t2 values(1); +create view v1 as select * from t2 inner join t1 using (a); +select * from v1; +drop view v1; + +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create view vt1 as select a from t1; +select * from t1 natural join vt1; +drop view vt1; + +create or replace table t1(x int) with system versioning; +select * from (t1 as r left join t1 as u using (x)), t1; + +# @end should be max +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +create trigger read_end after update on t1 + for each row set @end = old.sys_trx_end; +update t1 set a=2; +--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.999999" MAX_RESULT +select @end; + +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +select * from (select * from t1 cross join t2) as tmp; +select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2; +select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp; + +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +select * from t1 for system_time all natural left join t2 for system_time all; + +# natural join of a view and table +create or replace table t1(a1 int) with system versioning; +create or replace table t2(a2 int) with system versioning; +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create or replace view v1 as select a1 from t1; + +select * from v1 natural join t2; +select * from v1 natural left join t2; +select * from v1 natural right join t2; + +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; + +create or replace table t1 (x int) with system versioning; +create or replace table t2 (y int) with system versioning; +insert into t1 values (1), (2), (3); +delete from t1 where x = 3; +insert into t2 values (1); +select * from t1, t2 system_time all; + +--error ER_VERS_UNUSED_CLAUSE +select * from t1 for system_time all, t2 for system_time all system_time all; + +drop view v1; +drop table t1, t2; + +call innodb_verify_vtq(27); + +drop procedure test_01; +drop procedure test_02; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/simple.opt b/mysql-test/suite/versioning/t/simple.opt new file mode 100644 index 00000000000..993df05011e --- /dev/null +++ b/mysql-test/suite/versioning/t/simple.opt @@ -0,0 +1,2 @@ +--innodb --default-storage-engine=innodb +--plugin-load=versioning diff --git a/mysql-test/suite/versioning/t/simple.test b/mysql-test/suite/versioning/t/simple.test new file mode 100644 index 00000000000..d32ea939279 --- /dev/null +++ b/mysql-test/suite/versioning/t/simple.test @@ -0,0 +1,70 @@ +create or replace table dept ( + dept_id int(10) primary key, + name varchar(100) +) +with system versioning; + +create or replace table emp ( + emp_id int(10) primary key, + dept_id int(10), + name varchar(100), + salary int(10), + constraint `dept-emp-fk` + foreign key (dept_id) references dept (dept_id) + on delete cascade + on update restrict +) +with system versioning; + +select now() into @ts_0; + +insert into dept (dept_id, name) values (10, "accounting"); +commit; + +select vtq_commit_ts(sys_trx_start) into @ts_1 from dept where dept_id=10; + +insert into emp (emp_id, name, salary, dept_id) values (1, "bill", 1000, 10); +commit; + +select vtq_commit_ts(sys_trx_start) into @ts_2 from emp where name="bill"; + +select * from emp; + +update emp set salary=2000 where name="bill"; +commit; + +select vtq_commit_ts(sys_trx_start) into @ts_3 from emp where name="bill"; + +select * from emp; +select * from emp for system_time as of timestamp @ts_2; +select * from emp for system_time as of timestamp @ts_3; +select * from emp e, dept d +where d.dept_id = 10 + and d.dept_id = e.dept_id; + +select * from emp e, dept d +where d.dept_id = 10 + and d.dept_id = e.dept_id +system_time from timestamp @ts_1 to timestamp @ts_2; + +select * from emp e, dept d +where d.dept_id = 10 + and d.dept_id = e.dept_id +system_time as of timestamp @ts_0; + +select * from emp e, dept d +where d.dept_id = 10 + and d.dept_id = e.dept_id +system_time as of timestamp @ts_1; + +select * from emp e, dept d +where d.dept_id = 10 + and d.dept_id = e.dept_id +system_time as of timestamp @ts_2; + +select * from emp e, dept d +where d.dept_id = 10 + and d.dept_id = e.dept_id +system_time as of timestamp @ts_3; + +drop table emp, dept; diff --git a/mysql-test/suite/versioning/t/sysvars.opt b/mysql-test/suite/versioning/t/sysvars.opt new file mode 100644 index 00000000000..c1a585b67eb --- /dev/null +++ b/mysql-test/suite/versioning/t/sysvars.opt @@ -0,0 +1 @@ +--versioning-hide=implicit diff --git a/mysql-test/suite/versioning/t/sysvars.test b/mysql-test/suite/versioning/t/sysvars.test new file mode 100644 index 00000000000..6b713c29239 --- /dev/null +++ b/mysql-test/suite/versioning/t/sysvars.test @@ -0,0 +1,111 @@ +create table t (a int) with system versioning; +insert into t values (1); +update t set a= 2; + +show global variables like 'versioning_current_timestamp'; +show variables like 'versioning_current_timestamp'; +select * from t; + +set versioning_current_timestamp = '2031-1-1 0:0:0'; +show variables like 'versioning_current_timestamp'; +select * from t; + +set versioning_current_timestamp = '2011-1-1 0:0:0'; +show variables like 'versioning_current_timestamp'; +select * from t; + +set versioning_current_timestamp = 'all'; +show variables like 'versioning_current_timestamp'; +select * from t; + +create view vt as select * from t; +select * from t; +drop view vt; + +select * from (select * from t) as tt; + +# global +--error ER_WRONG_VALUE_FOR_VAR +set global versioning_current_timestamp= 'alley'; +--error ER_WRONG_VALUE_FOR_VAR +set global versioning_current_timestamp= null; +--error ER_WRONG_TYPE_FOR_VAR +set global versioning_current_timestamp= 1; +--error ER_WRONG_TYPE_FOR_VAR +set global versioning_current_timestamp= 1.1; + +# session +--error ER_WRONG_VALUE_FOR_VAR +set versioning_current_timestamp= 'alley'; +--error ER_WRONG_VALUE_FOR_VAR +set versioning_current_timestamp= null; +--error ER_WRONG_TYPE_FOR_VAR +set versioning_current_timestamp= 1; +--error ER_WRONG_TYPE_FOR_VAR +set versioning_current_timestamp= 1.1; + +# global +set global versioning_current_timestamp= '1911-11-11 11:11:11.1111119'; +show global variables like 'versioning_current_timestamp'; + +set global versioning_current_timestamp= '1900-01-01 00:00:00'; +show global variables like 'versioning_current_timestamp'; + +set global versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119'; +show global variables like 'versioning_current_timestamp'; + +set @ts= timestamp'1900-01-01 00:00:00'; +set global versioning_current_timestamp= @ts; +show global variables like 'versioning_current_timestamp'; + +# session +set versioning_current_timestamp= '1911-11-11 11:11:11.1111119'; +show variables like 'versioning_current_timestamp'; + +set versioning_current_timestamp= '1900-01-01 00:00:00'; +show variables like 'versioning_current_timestamp'; + +set versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119'; +show variables like 'versioning_current_timestamp'; + +set @ts= timestamp'1900-01-01 00:00:00'; +set versioning_current_timestamp= @ts; +show variables like 'versioning_current_timestamp'; + +set global versioning_current_timestamp= 'now'; +set versioning_current_timestamp= 'now'; + +show variables where variable_name = "versioning_hide"; +select * from t for system_time all; + +set versioning_hide= AUTO; +select * from t; +select * from t for system_time as of timestamp current_timestamp(6); +--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/ +select * from t for system_time all; +--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/ +select * from t for system_time from '0-0-0' to current_timestamp(6); +--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/ +select * from t for system_time between '0-0-0' and current_timestamp(6); + +set versioning_hide= NEVER; +--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/ +select * from t; + +set versioning_hide= FULL; +create or replace table t ( + x int, + st timestamp(6) generated always as row start, + en timestamp(6) generated always as row end, + period for system_time (st, en)) +with system versioning; + +show create table t; +insert into t values (2); +delete from t; + +select * from t; +select * from t for system_time all; + +drop table t; +set versioning_hide= IMPLICIT; diff --git a/mysql-test/suite/versioning/t/truncate.combinations b/mysql-test/suite/versioning/t/truncate.combinations new file mode 100644 index 00000000000..75fb20d9f5e --- /dev/null +++ b/mysql-test/suite/versioning/t/truncate.combinations @@ -0,0 +1,5 @@ +[innodb] +default-storage-engine=innodb + +[myisam] +default-storage-engine=myisam diff --git a/mysql-test/suite/versioning/t/truncate.opt b/mysql-test/suite/versioning/t/truncate.opt new file mode 100644 index 00000000000..c1a585b67eb --- /dev/null +++ b/mysql-test/suite/versioning/t/truncate.opt @@ -0,0 +1 @@ +--versioning-hide=implicit diff --git a/mysql-test/suite/versioning/t/truncate.test b/mysql-test/suite/versioning/t/truncate.test new file mode 100644 index 00000000000..1de94487570 --- /dev/null +++ b/mysql-test/suite/versioning/t/truncate.test @@ -0,0 +1,29 @@ +-- source include/have_innodb.inc + +create table t (a int); +--error ER_VERSIONING_REQUIRED +truncate t to system_time now(); + +# TRUNCATE is not DELETE and trigger must not be called. +create or replace table t (a int) with system versioning; +insert into t values (1); +update t set a=2; +set @test = 'correct'; +create trigger trg_before before delete on t for each row set @test = 'incorrect'; +create trigger trg_after after delete on t for each row set @test = 'incorrect'; +truncate t to system_time now(6); +select @test from t; +drop table t; + +create table t (a int) with system versioning; +insert into t values (1), (2); +update t set a=11 where a=1; +set @ts1=now(6); +update t set a=22 where a=2; +select * from t for system_time all; +truncate t to system_time timestamp @ts1; +select * from t for system_time all; +truncate table t to system_time timestamp now(6); +select * from t for system_time all; + +drop table t; diff --git a/mysql-test/suite/versioning/t/truncate_privilege.test b/mysql-test/suite/versioning/t/truncate_privilege.test new file mode 100644 index 00000000000..7042f359e13 --- /dev/null +++ b/mysql-test/suite/versioning/t/truncate_privilege.test @@ -0,0 +1,41 @@ +# Can't test with embedded server +-- source include/not_embedded.inc + +--source include/have_innodb.inc + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + +connect (root,localhost,root,,test); +connection root; + +--disable_warnings +create database mysqltest; +--enable_warnings + +create user mysqltest_1@localhost; +connect (user1,localhost,mysqltest_1,,test); +connection user1; + +connection root; +create table mysqltest.t (a int) with system versioning; + +connection user1; +show grants; +--error ER_TABLEACCESS_DENIED_ERROR +truncate mysqltest.t to system_time now(); + +connection root; +grant delete versioning rows on mysqltest.* to mysqltest_1@localhost; +grant delete versioning rows on mysqltest.t to mysqltest_1@localhost; + +connection user1; +show grants; +truncate mysqltest.t to system_time now(); + +connection root; +grant all on *.* to mysqltest_1@localhost; +show grants for mysqltest_1@localhost; + +drop user mysqltest_1@localhost; +drop database mysqltest; diff --git a/mysql-test/suite/versioning/t/update.test b/mysql-test/suite/versioning/t/update.test new file mode 100644 index 00000000000..b7e0c1fc85f --- /dev/null +++ b/mysql-test/suite/versioning/t/update.test @@ -0,0 +1,267 @@ +-- source suite/versioning/common.inc + +delimiter ~~; +create procedure test_01( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(x, y) values + (1, 1000), + (2, 2000), + (3, 3000), + (4, 4000), + (5, 5000), + (6, 6000), + (7, 7000), + (8, 8000), + (9, 9000); + select x, y from t1; + update t1 set y = y + 1 where x > 7; + select x, y from t1; + select x, y from t1 for system_time + between timestamp '0000-0-0 0:0:0' + and timestamp '2038-01-19 04:14:07'; + drop table t1; +end~~ + +create procedure test_02( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1 ( + id bigint primary key, + x int, + y int without system versioning) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1 values(1, 1, 1); + set @ins_t= now(6); + select sys_trx_start into @tmp1 from t1; + update t1 set x= 11, y= 11 where id = 1; + select @tmp1 < sys_trx_start as A1, x, y from t1; + + select sys_trx_start into @tmp1 from t1; + update t1 set y= 1 where id = 1; + select @tmp1 = sys_trx_start as A2, x from t1; + + drop table t1; +end~~ + +create procedure test_03( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1 ( + x int, + y int) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + + insert into t1 (x, y) values (1, 1), (2, 1), (3, 1); + + start transaction; + update t1 set y= y + 1 where x = 3; + update t1 set y= y + 1 where x = 3; + commit; + + select x, y from t1 for system_time + between timestamp '0000-0-0 0:0:0' + and timestamp '2038-01-19 04:14:07'; + + drop table t1; +end~~ + +create procedure test_04( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1 ( + id int primary key auto_increment, + x int) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + + set @t0= now(6); + insert into t1 (x) values (1); + set @t1= now(6); + update t1 set x= 2 where id = 1; + set @t2= now(6); + update t1 set x= 3 where id = 1; + + select x from t1 for system_time as of timestamp @t0; + select x from t1 for system_time as of timestamp @t1; + select x from t1 for system_time as of timestamp @t2; + select x from t1 for system_time as of timestamp now(6); + + drop table t1; +end~~ + +create procedure test_05( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat(' + create table t1( + x int unsigned, + sys_end ', sys_type, ' generated always as row end, + sys_start ', sys_type, ' generated always as row start, + y int unsigned, + period for system_time (sys_start, sys_end), + primary key(x, y)) + with system versioning + engine ', engine); + prepare stmt from @str; execute stmt; drop prepare stmt; + insert into t1(x, y) values + (1, 1000), + (2, 2000), + (3, 3000), + (4, 4000), + (5, 5000), + (6, 6000), + (7, 7000), + (8, 8000), + (9, 9000); + insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1; + insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1; + insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1; + insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1; + select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; + select x, y from t1; + drop table t1; +end~~ + +create procedure test_06( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat('( + x int unsigned, + y int unsigned, + sys_start ', sys_type, ' generated always as row start, + sys_end ', sys_type, ' generated always as row end, + period for system_time (sys_start, sys_end)) + with system versioning + engine ', engine); + set @str2= concat('create table t1', @str); + prepare stmt from @str2; execute stmt; drop prepare stmt; + set @str2= concat('create table t2', @str); + prepare stmt from @str2; execute stmt; drop prepare stmt; + insert into t1(x, y) values + (1, 1000), + (2, 2000), + (3, 3000), + (4, 4000), + (5, 5000), + (6, 6000), + (7, 7000), + (8, 8000), + (9, 9000); + insert into t2(x, y) values + (1, 1010), + (2, 2010), + (3, 3010), + (4, 4010), + (5, 5010), + (6, 6010), + (7, 7010), + (8, 8010), + (9, 9010); + update t1, t2 set t1.y = t1.x + t1.y, t2.y = t2.x + t2.y where t1.x > 7 and t2.x < 7; + select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; + select x, y from t1; + select x, y from t2 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0'; + select x, y from t2; + drop table t1; + drop table t2; +end~~ + +create procedure test_07( + sys_type varchar(255), + engine varchar(255), + fields varchar(255)) +begin + set @str= concat('( + id bigint primary key, + name varchar(128) with system versioning, + salary bigint) + engine ', engine); + + set @str2= concat('create table t1', @str); + prepare stmt from @str2; execute stmt; drop prepare stmt; + set @str2= concat('create table t2', @str); + prepare stmt from @str2; execute stmt; drop prepare stmt; + + insert into t1 values (1, "Jeremy", 3000); + insert into t2 values (1, "Jeremy", 4000); + + select sys_trx_start into @tmp1 from t1; + select sys_trx_start into @tmp2 from t2; + update t1, t2 set t1.name= "Jerry", t2.name= "Jerry" where t1.id = t2.id and t1.name = "Jeremy"; + select @tmp1 < sys_trx_start as A1, name from t1; + select @tmp2 < sys_trx_start as A2, name from t2; + + select sys_trx_start into @tmp1 from t1; + select sys_trx_start into @tmp2 from t2; + update t1, t2 set t1.salary= 2500, t2.salary= 2500 where t1.id = t2.id and t1.name = "Jerry"; + select @tmp1 = sys_trx_start as B1, salary from t1; + select @tmp2 = sys_trx_start as B2, salary from t2; + + drop table t1; + drop table t2; +end~~ +delimiter ;~~ + +call test_01('timestamp(6)', 'myisam', 'sys_end'); +call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_02('timestamp(6)', 'myisam', 'sys_end'); +call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_03('timestamp(6)', 'myisam', 'sys_end'); +call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_04('timestamp(6)', 'myisam', 'sys_end'); +call test_04('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_05('timestamp(6)', 'myisam', 'sys_end'); +call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_06('timestamp(6)', 'myisam', 'sys_end'); +call test_06('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call test_07('timestamp(6)', 'myisam', 'sys_end'); +call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)'); + +call verify_vtq; + +drop procedure test_01; +drop procedure test_02; +drop procedure test_03; +drop procedure test_04; +drop procedure test_05; +drop procedure test_06; +drop procedure test_07; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/view.opt b/mysql-test/suite/versioning/t/view.opt new file mode 100644 index 00000000000..9baff80804d --- /dev/null +++ b/mysql-test/suite/versioning/t/view.opt @@ -0,0 +1,2 @@ +--versioning-hide=implicit +--plugin-load=versioning diff --git a/mysql-test/suite/versioning/t/view.test b/mysql-test/suite/versioning/t/view.test new file mode 100644 index 00000000000..bd95d0fdfd3 --- /dev/null +++ b/mysql-test/suite/versioning/t/view.test @@ -0,0 +1,97 @@ +-- source include/have_innodb.inc +-- source suite/versioning/common.inc + +create table t1 (x int) with system versioning engine innodb; +insert into t1 values (1); + +select now(6) into @t1; +update t1 set x= 2; + +select now(6) into @t2; +delete from t1; + +set @vt1= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'"); +prepare stmt from @vt1; execute stmt; drop prepare stmt; + +set @vt2= concat("create view vt2 as select *, sys_trx_end from t1 for system_time as of timestamp '", @t2, "'"); +prepare stmt from @vt2; execute stmt; drop prepare stmt; + +select * from vt1 for system_time all; +select * from vt2 for system_time all; +select * from t1; + +create or replace view vt1 as select * from t1; +show create view vt1; + +drop view vt1; +drop view vt2; + +create view vt1 as select * from t1 for system_time all; +select * from vt1 for system_time all; +prepare stmt from 'select * from vt1 for system_time all'; execute stmt; drop prepare stmt; + +select * from vt1; +prepare stmt from 'select * from vt1'; execute stmt; drop prepare stmt; + +select * from t1 for system_time as of timestamp @t1; +select * from vt1 for system_time as of timestamp @t1; +prepare stmt from 'select * from vt1 for system_time as of timestamp @t1'; execute stmt; drop prepare stmt; + +create or replace view vt1 as select * from t1; +select * from vt1 for system_time all; +prepare stmt from 'select * from vt1 for system_time all'; execute stmt; drop prepare stmt; + +insert into vt1 values (3); +select * from t1; +select * from vt1; +select * from t1 for system_time all; +select * from vt1 for system_time all; + +create or replace table t1 (x int) with system versioning; +insert into t1 values (1), (2); +set @t1=now(6); +delete from t1 where x=2; +set @t2=now(6); +delete from t1 where x=1; +set @t3=now(6); + +set @tmp= concat("create or replace view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'"); +prepare stmt from @tmp; execute stmt; drop prepare stmt; + +select * from vt1 for system_time all; + +create or replace table t1 (x int) with system versioning; +create or replace view vt1(c) as select x from t1; + +create or replace table t1 (a int) with system versioning engine innodb; +create or replace table t2 (b int) with system versioning engine innodb; +insert into t1 values (1); +insert into t2 values (2); +create or replace view vt12 as select * from t1 cross join t2; +select * from vt12; +create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2; +select * from vt12; + +--error ER_VERS_VIEW_PROHIBITED +create or replace view vt1 as select a, t1.sys_trx_start, t2.sys_trx_end from t1, t2; +--error ER_VERS_VIEW_PROHIBITED +create or replace view vt1 as select a, t1.sys_trx_end, t2.sys_trx_end from t1, t2; + +create or replace table t3 (x int); +create or replace view vt1 as select * from t1, t2, t3; +show create view vt1; +create or replace view vt1 as select * from t3, t2, t1; +show create view vt1; +create or replace view vt1 as select a, t2.sys_trx_end as endo from t3, t1, t2; +show create view vt1; + +create or replace view vt1 as select * from t1 union select * from t1; +select * from vt1; + +--error ER_VERS_VIEW_PROHIBITED +create or replace view vvt1 as select * from t1, t2, vt1; + +drop view vt1, vt12; +drop table t1, t2, t3; + +-- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/vtmd.opt b/mysql-test/suite/versioning/t/vtmd.opt new file mode 100644 index 00000000000..3596fc4d3bd --- /dev/null +++ b/mysql-test/suite/versioning/t/vtmd.opt @@ -0,0 +1 @@ +--innodb --default-storage-engine=innodb diff --git a/mysql-test/suite/versioning/t/vtmd.test b/mysql-test/suite/versioning/t/vtmd.test new file mode 100644 index 00000000000..c5483c182cc --- /dev/null +++ b/mysql-test/suite/versioning/t/vtmd.test @@ -0,0 +1,203 @@ +-- source include/have_innodb.inc +delimiter ~~; +create or replace procedure drop_archives (in vtmd_name varchar(64)) +begin + declare archive_name varchar(64); + declare cur_done bool default false; + declare cur cursor for + select cur_tmp.archive_name from cur_tmp; + declare continue handler for not found set cur_done = true; + + set @tmp= concat(' + create or replace temporary table + cur_tmp as + select vtmd.archive_name from ', vtmd_name, ' + for system_time all as vtmd + where vtmd.archive_name is not null + group by vtmd.archive_name'); + prepare stmt from @tmp; execute stmt; drop prepare stmt; + + open cur; + fetch_loop: loop + fetch cur into archive_name; + if cur_done then + leave fetch_loop; + end if; + set @tmp= concat('drop table ', archive_name); + prepare stmt from @tmp; execute stmt; drop prepare stmt; + end loop; + + drop table cur_tmp; +end~~ +delimiter ;~~ + +delimiter ~~; +create or replace procedure check_vtmd (in vtmd_name varchar(64)) +begin + set @tmp= concat(' + create or replace temporary table + tmp_vtmd with system versioning as + select * from ', vtmd_name, ' + for system_time all as vtmd'); + prepare stmt from @tmp; execute stmt; drop prepare stmt; + + set @inf= 0xFFFFFFFFFFFFFFFF + 0; + set @start= null; + select start from tmp_vtmd for system_time all order by start limit 1 into @start; + select @start > 0 and @start < @inf; + select + start >= @start as A_start, + (@start:= end) and end = @inf as B_end, + name, + substr(archive_name, 1, instr(archive_name, '_')) as C_archive_name + from tmp_vtmd for system_time all; + + drop table tmp_vtmd; +end~~ +delimiter ;~~ + +delimiter ~~; +create or replace procedure show_tables() +begin + show tables; + select table_name, table_schema from information_schema.tables + where table_schema not in ('mysql', 'performance_schema', 'information_schema', 'mtr'); +end~~ +delimiter ;~~ + +# create +set versioning_alter_history= keep; +create table t0 (z int) with system versioning; +show tables; +set versioning_alter_history= survive; +create or replace table t0 (y int) with system versioning; +show tables; +show create table t0_vtmd; +call check_vtmd('t0_vtmd'); + +set versioning_alter_history= keep; +drop table t0; +set versioning_alter_history= survive; +--error ER_VERS_VTMD_ERROR +create table t0 (x int) with system versioning; + +drop table t0_vtmd; +create table t0 (y int) with system versioning; +create or replace table t0 (x int) with system versioning; + +# alter +insert into t0 values (1); +set @t0= now(6); +alter table t0 add column (y int); +select * from t0 for system_time as of @t0; +select * from t0; +call check_vtmd('t0_vtmd'); + +call drop_archives('t0_vtmd'); +drop table t0_vtmd; +alter table t0 drop column y; +call check_vtmd('t0_vtmd'); + +call drop_archives('t0_vtmd'); +set versioning_alter_history= keep; +drop tables t0, t0_vtmd; +set versioning_alter_history= survive; + +# rename +set versioning_alter_history= keep; +create or replace table x0 (x int) with system versioning; +set versioning_alter_history= survive; +rename table x0 to d0; +show tables; + +set versioning_alter_history= keep; +drop table d0; +set versioning_alter_history= survive; +create or replace table x0 (x int) with system versioning; +rename table x0 to d0; +show tables; +call check_vtmd('d0_vtmd'); + +set versioning_alter_history= keep; +drop table d0; +set versioning_alter_history= survive; +create or replace table x0 (x int) with system versioning; + +--error ER_VERS_VTMD_ERROR +rename table x0 to d0; +show tables; + +drop table x0_vtmd; +rename table x0 to d0; +show tables; + +rename table d0 to duck; +rename table duck to bay; +rename table bay to sheer; +rename table sheer to t0; +call check_vtmd('t0_vtmd'); + +alter table t0 add column (y int); +call check_vtmd('t0_vtmd'); + +# rename to different schema +alter table t0 add column (z int); +alter table t0 drop column y; +alter table t0 drop column z; + +create database db0; +rename table t0 to db0.t0; +show tables; +use db0; +show tables; +call test.check_vtmd('db0.t0_vtmd'); + +create database db1; +rename table t0 to db1.other_name; +show tables; +use db1; +show tables; +call test.check_vtmd('db1.other_name_vtmd'); + +# alter rename +alter table other_name rename to t1; +call test.check_vtmd('db1.t1_vtmd'); + +# alter rename and modify to different schema +alter table t1 rename to test.t2, add column (y int); +use test; +show tables; +call check_vtmd('t2_vtmd'); + +create or replace table t3 (x int) with system versioning; +alter table t3 change x x bigint; +alter table t3 change x x bigint after sys_trx_start; +call check_vtmd('t3_vtmd'); + +# hide archive tables +set versioning_hide= auto; +call show_tables(); + +set versioning_hide= implicit; +call show_tables(); + +set versioning_hide= full; +call show_tables(); + +set versioning_hide= never; +--replace_regex /\d{8}_\d{6}_\d{6}/TIMESTAMP_SUFFIX/ +call show_tables(); + +# wrong VTMD handling +set versioning_hide= auto; +create or replace table u0_vtmd (x int) with system versioning; +show tables; + +set versioning_alter_history= survive; +create or replace table t (x int) with system versioning; +select * from t for system_time all; + +drop database db0; +drop database db1; +drop database test; +create database test; diff --git a/mysql-test/suite/versioning/t/vtmd_show.opt b/mysql-test/suite/versioning/t/vtmd_show.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/suite/versioning/t/vtmd_show.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/suite/versioning/t/vtmd_show.test b/mysql-test/suite/versioning/t/vtmd_show.test new file mode 100644 index 00000000000..4397198c839 --- /dev/null +++ b/mysql-test/suite/versioning/t/vtmd_show.test @@ -0,0 +1,90 @@ +delimiter ~~; +create or replace procedure drop_archives (in vtmd_name varchar(64)) +begin + declare archive_name varchar(64); + declare cur_done bool default false; + declare cur cursor for + select cur_tmp.archive_name from cur_tmp; + declare continue handler for not found set cur_done = true; + + set @tmp= concat(' + create or replace temporary table + cur_tmp as + select vtmd.archive_name from ', vtmd_name, ' + for system_time all as vtmd + where vtmd.archive_name is not null + group by vtmd.archive_name'); + prepare stmt from @tmp; execute stmt; drop prepare stmt; + + open cur; + fetch_loop: loop + fetch cur into archive_name; + if cur_done then + leave fetch_loop; + end if; + set @tmp= concat('drop table ', archive_name); + prepare stmt from @tmp; execute stmt; drop prepare stmt; + end loop; + + drop table cur_tmp; +end~~ +delimiter ;~~ + +delimiter ~~; +create procedure test_01(in engine varchar(64)) +begin + set @tmp = concat('create table t (a int) with system versioning engine ', engine); + prepare stmt from @tmp; execute stmt; drop prepare stmt; + + set @tm1 = now(6); + alter table t add column b int; + + set @tm2 = now(6); + alter table t add column c int; + + show create table t for system_time as of timestamp @tm1; + show create table t for system_time as of timestamp @tm2; + show create table t for system_time as of now; + show create table t for system_time as of timestamp now(6); + show create table t; + + set @tm3 = now(6); + rename table t to tt; + show create table tt for system_time as of timestamp @tm3; + + set @tm4 = now(6); + alter table tt add column d int; + show create table tt for system_time as of timestamp @tm3; + show create table tt for system_time as of timestamp @tm4; + show create table tt; + + drop table tt; + call drop_archives('tt_vtmd'); + drop table tt_vtmd; +end~~ +delimiter ;~~ + +create table t (a int) with system versioning; +--error ER_VERS_VTMD_ERROR +show create table t for system_time as of now; + +set versioning_alter_history=survive; + +create or replace table t (a int) with system versioning; +--error ER_VERS_RANGE_PROHIBITED +show create table t for system_time between timestamp @tm1 and timestamp @tm1; +--error ER_VERS_RANGE_PROHIBITED +show create table t for system_time from timestamp @tm1 to timestamp @tm1; +--error ER_VERS_VTMD_ERROR +show create table t for system_time as of timestamp '01-01-1990'; +--error ER_VERS_VTMD_ERROR +show create table t for system_time as of timestamp '01-01-2020'; +drop table t; +call drop_archives('t_vtmd'); +drop table t_vtmd; + +call test_01('myisam'); +call test_01('innodb'); + +drop procedure test_01; +drop procedure drop_archives; |