diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-05-15 09:33:29 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-05-15 09:33:29 +0400 |
commit | 46be31982a48e0456e9bee9918daf720c07be8b0 (patch) | |
tree | d61abd0f98d547f2f31257ce4540daa9a14e69ee /mysql-test | |
parent | 1b45ede6ab1981253041356f8f258bd98607fa6f (diff) | |
download | mariadb-git-46be31982a48e0456e9bee9918daf720c07be8b0.tar.gz |
MDEV-16094 Crash when using AS OF with a stored function
MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs
Problem:
Vers_history_point::resolve_unit() tested item->result_type() before
item->fix_fields() was called.
- Item_func_get_user_var::result_type() returned REAL_RESULT by default.
This caused MDEV-16100.
- Item_func_sp::result_type() crashed on assert.
This caused MDEV-16094
Changes:
1. Adding item->fix_fields() into Vers_history_point::resolve_unit()
before using data type specific properties of the history point
expression.
2. Adding a new virtual method Type_handler::Vers_history_point_resolve_unit()
3. Implementing type-specific
Type_handler_xxx::Type_handler::Vers_history_point_resolve_unit()
in the way to:
a. resolve temporal and general purpose string types to TIMESTAMP
b. resolve BIT and general purpose INT types to TRANSACTION
c. disallow use of non-relevant data type expressions in FOR SYSTEM_TIME
Note, DOUBLE and DECIMAL data types are disallowed intentionally.
- DOUBLE does not have enough precision to hold huge BIGINT UNSIGNED values
- DECIMAL rounds on conversion to INT
Both lack of precision and rounding might potentionally lead to
very unpredictable results when a wrong transaction ID would be chosen.
If one really wants dangerous use of DOUBLE and DECIMAL, explicit CAST
can be used:
FOR SYSTEM_TIME AS OF CAST(double_or_decimal AS UNSIGNED)
QQ: perhaps DECIMAL(N,0) could still be allowed.
4. Adding a new virtual method Item::type_handler_for_system_time(),
to make HEX hybrids and bit literals work as TRANSACTION rather
than TIMESTAMP.
5. sql_yacc.yy: replacing the rule temporal_literal to "TIMESTAMP TEXT_STRING".
Other temporal literals now resolve to TIMESTAMP through the new
Type_handler methods. No special grammar needed. This removed
a few shift/resolve conflicts.
(TIMESTAMP related conflicts in "history_point:" will be removed separately)
6. Removing the "timestamp_only" parameter from
vers_select_conds_t::resolve_units() and Vers_history_point::resolve_unit().
It was a hint telling that a table did not have any TRANSACTION-aware
system time columns, so it's OK to resolve to TIMESTAMP in case of uncertainty.
In the new reduction it works as follows:
- the decision between TIMESTAMP and TRANSACTION is first made
based only on the expression data type only
- then, in case if the expression resolved to TRANSACTION, the table
is checked if TRANSACTION-aware columns really exist.
This way is safer against possible ALTER TABLE statements changing
ROW START and ROW END columns from "BIGINT UNSIGNED" to "TIMESTAMP(x)"
or the other way around.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/suite/versioning/r/select.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/versioning/r/trx_id.result | 196 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/select.test | 2 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/trx_id.test | 240 |
4 files changed, 441 insertions, 1 deletions
diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result index 75f9fc25263..80c408980ec 100644 --- a/mysql-test/suite/versioning/r/select.result +++ b/mysql-test/suite/versioning/r/select.result @@ -339,6 +339,8 @@ select x from t1 for system_time as of timestamp @ts; x 1 set @ts= timestamp'1-1-1 0:0:0'; +select x from t1 for system_time as of timestamp @ts; +x ## TRANSACTION specifier select x from t1 for system_time as of transaction @trx_start; x @@ -390,7 +392,7 @@ create or replace table t1 (x int) with system versioning; select * from t1 for system_time as of current_timestamp; x select * from t1 for system_time as of now; -ERROR 42S22: Unknown column 'now' in 'on clause' +ERROR 42S22: Unknown column 'now' in 'FOR SYSTEM_TIME' ### Issue #405, NATURAL JOIN failure create or replace table t1 (a int) with system versioning; create or replace table t2 (b int); diff --git a/mysql-test/suite/versioning/r/trx_id.result b/mysql-test/suite/versioning/r/trx_id.result index 31989a30ebf..7b2ea04985d 100644 --- a/mysql-test/suite/versioning/r/trx_id.result +++ b/mysql-test/suite/versioning/r/trx_id.result @@ -183,3 +183,199 @@ BEGIN_TS_GOOD 1 drop database test; create database test; +use test; +# +# MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs +# +CREATE TABLE t1 ( +x INT, +sys_trx_start BIGINT UNSIGNED AS ROW START, +sys_trx_end BIGINT UNSIGNED AS ROW END, +PERIOD FOR SYSTEM_TIME (sys_trx_start, sys_trx_end) +) WITH SYSTEM VERSIONING ENGINE=INNODB; +INSERT INTO t1 (x) VALUES (1); +SET @ts= DATE_ADD(NOW(), INTERVAL 1 YEAR); +EXPLAIN EXTENDED SELECT x FROM t1 FOR SYSTEM_TIME AS OF TRANSACTION @ts; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`x` AS `x` from `test`.`t1` FOR SYSTEM_TIME ALL where trt_trx_sees(`test`.`t1`.`sys_trx_end`,@`ts`) and trt_trx_sees_eq(@`ts`,`test`.`t1`.`sys_trx_start`) +EXPLAIN EXTENDED SELECT x FROM t1 FOR SYSTEM_TIME AS OF TIMESTAMP @ts; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`x` AS `x` from `test`.`t1` FOR SYSTEM_TIME ALL where trt_trx_sees(`test`.`t1`.`sys_trx_end`,<cache>(trt_trx_id(@`ts`))) and trt_trx_sees_eq(<cache>(trt_trx_id(@`ts`)),`test`.`t1`.`sys_trx_start`) +EXPLAIN EXTENDED SELECT x FROM t1 FOR SYSTEM_TIME AS OF @ts; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`x` AS `x` from `test`.`t1` FOR SYSTEM_TIME ALL where trt_trx_sees(`test`.`t1`.`sys_trx_end`,<cache>(trt_trx_id(@`ts`))) and trt_trx_sees_eq(<cache>(trt_trx_id(@`ts`)),`test`.`t1`.`sys_trx_start`) +DROP TABLE t1; +# +# Testing AS OF with expressions of various kinds and data types +# +CREATE TABLE t1 +( +x INT, +sys_trx_start BIGINT UNSIGNED AS ROW START INVISIBLE, +sys_trx_end BIGINT UNSIGNED AS ROW END INVISIBLE, +PERIOD FOR SYSTEM_TIME (sys_trx_start, sys_trx_end) +) WITH SYSTEM VERSIONING; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 +( +x INT, +sys_trx_start TIMESTAMP(6) AS ROW START INVISIBLE, +sys_trx_end TIMESTAMP(6) AS ROW END INVISIBLE, +PERIOD FOR SYSTEM_TIME (sys_trx_start, sys_trx_end) +) WITH SYSTEM VERSIONING; +INSERT INTO t2 VALUES (1); +# +# ROW is not supported +# +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (1,1); +ERROR HY000: Illegal parameter data type row for operation 'FOR SYSTEM_TIME' +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (1,1); +ERROR HY000: Illegal parameter data type row for operation 'FOR SYSTEM_TIME' +# +# DOUBLE is not supported, use explicit CAST +# +SELECT * FROM t1 FOR SYSTEM_TIME AS OF RAND(); +ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME' +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (RAND()); +ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME' +SELECT * FROM t1 FOR SYSTEM_TIME AS OF COALESCE(RAND()); +ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME' +SELECT * FROM t2 FOR SYSTEM_TIME AS OF RAND(); +ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME' +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (RAND()); +ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME' +SELECT * FROM t2 FOR SYSTEM_TIME AS OF COALESCE(RAND()); +ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME' +# +# DECIMAL is not supported, use explicit CAST +# +SELECT * FROM t1 FOR SYSTEM_TIME AS OF 10.1; +ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME' +SELECT * FROM t1 FOR SYSTEM_TIME AS OF COALESCE(10.1); +ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME' +SELECT * FROM t2 FOR SYSTEM_TIME AS OF 10.1; +ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME' +SELECT * FROM t2 FOR SYSTEM_TIME AS OF COALESCE(10.1); +ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME' +# +# YEAR is not supported, use explicit CAST +# +BEGIN NOT ATOMIC +DECLARE var YEAR; +SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Illegal parameter data type year for operation 'FOR SYSTEM_TIME' +BEGIN NOT ATOMIC +DECLARE var YEAR; +SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Illegal parameter data type year for operation 'FOR SYSTEM_TIME' +# +# ENUM is not supported, use explicit CAST +# +BEGIN NOT ATOMIC +DECLARE var ENUM('xxx') DEFAULT 'xxx'; +SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Illegal parameter data type enum for operation 'FOR SYSTEM_TIME' +BEGIN NOT ATOMIC +DECLARE var ENUM('xxx') DEFAULT 'xxx'; +SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Illegal parameter data type enum for operation 'FOR SYSTEM_TIME' +# +# SET is not supported, use explicit CAST +# +BEGIN NOT ATOMIC +DECLARE var SET('xxx') DEFAULT 'xxx'; +SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Illegal parameter data type set for operation 'FOR SYSTEM_TIME' +BEGIN NOT ATOMIC +DECLARE var SET('xxx') DEFAULT 'xxx'; +SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Illegal parameter data type set for operation 'FOR SYSTEM_TIME' +# +# BIT is resolved to TRANSACTION +# +BEGIN NOT ATOMIC +DECLARE var BIT(10); +SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +x +BEGIN NOT ATOMIC +DECLARE var BIT(10); +SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +ERROR HY000: Transaction system versioning for `t2` is not supported +# +# String literals resolve to TIMESTAMP +# +SELECT * FROM t1 FOR SYSTEM_TIME AS OF '2038-12-30 00:00:00'; +x +1 +SELECT * FROM t2 FOR SYSTEM_TIME AS OF '2038-12-30 00:00:00'; +x +# +# HEX hybrids resolve to TRANSACTION +# +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (0x60); +x +1 +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (0x60); +ERROR HY000: Transaction system versioning for `t2` is not supported +# +# BIT literals resolve to TRANSACTION +# +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (b'1100000'); +x +1 +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (b'1100000'); +ERROR HY000: Transaction system versioning for `t2` is not supported +DROP TABLE t1, t2; +# +# MDEV-16094 Crash when using AS OF with a stored function +# +CREATE FUNCTION fts() RETURNS DATETIME RETURN '2001-01-01 10:20:30'; +CREATE FUNCTION ftx() RETURNS BIGINT UNSIGNED RETURN 1; +CREATE TABLE ttx +( +x INT, +start_timestamp BIGINT UNSIGNED GENERATED ALWAYS AS ROW START, +end_timestamp BIGINT UNSIGNED GENERATED ALWAYS AS ROW END, +PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp) +) ENGINE=InnoDB WITH SYSTEM VERSIONING; +CREATE TABLE tts +( +x INT, +start_timestamp TIMESTAMP(6) GENERATED ALWAYS AS ROW START, +end_timestamp TIMESTAMP(6) GENERATED ALWAYS AS ROW END, +PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp) +) ENGINE=InnoDB WITH SYSTEM VERSIONING; +SELECT * FROM tts FOR SYSTEM_TIME AS OF fts(); +x start_timestamp end_timestamp +SELECT * FROM tts FOR SYSTEM_TIME AS OF ftx(); +ERROR HY000: Transaction system versioning for `tts` is not supported +SELECT * FROM ttx FOR SYSTEM_TIME AS OF fts(); +x start_timestamp end_timestamp +SELECT * FROM ttx FOR SYSTEM_TIME AS OF ftx(); +x start_timestamp end_timestamp +DROP TABLE tts; +DROP TABLE ttx; +DROP FUNCTION fts; +DROP FUNCTION ftx; diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index 8d2c5f69e2c..bb154f0b248 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -221,6 +221,8 @@ select x from t1 for system_time as of timestamp @ts; set @ts= timestamp'1-1-1 0:0:0'; +select x from t1 for system_time as of timestamp @ts; + --echo ## TRANSACTION specifier select x from t1 for system_time as of transaction @trx_start; diff --git a/mysql-test/suite/versioning/t/trx_id.test b/mysql-test/suite/versioning/t/trx_id.test index 4fb15f35366..aab28d1057c 100644 --- a/mysql-test/suite/versioning/t/trx_id.test +++ b/mysql-test/suite/versioning/t/trx_id.test @@ -171,3 +171,243 @@ select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD; drop database test; create database test; +use test; + + +--echo # +--echo # MDEV-16100 FOR SYSTEM_TIME erroneously resolves string user variables as transaction IDs +--echo # + +CREATE TABLE t1 ( + x INT, + sys_trx_start BIGINT UNSIGNED AS ROW START, + sys_trx_end BIGINT UNSIGNED AS ROW END, + PERIOD FOR SYSTEM_TIME (sys_trx_start, sys_trx_end) +) WITH SYSTEM VERSIONING ENGINE=INNODB; +INSERT INTO t1 (x) VALUES (1); +SET @ts= DATE_ADD(NOW(), INTERVAL 1 YEAR); +EXPLAIN EXTENDED SELECT x FROM t1 FOR SYSTEM_TIME AS OF TRANSACTION @ts; +EXPLAIN EXTENDED SELECT x FROM t1 FOR SYSTEM_TIME AS OF TIMESTAMP @ts; +EXPLAIN EXTENDED SELECT x FROM t1 FOR SYSTEM_TIME AS OF @ts; +DROP TABLE t1; + + +--echo # +--echo # Testing AS OF with expressions of various kinds and data types +--echo # + +CREATE TABLE t1 +( + x INT, + sys_trx_start BIGINT UNSIGNED AS ROW START INVISIBLE, + sys_trx_end BIGINT UNSIGNED AS ROW END INVISIBLE, + PERIOD FOR SYSTEM_TIME (sys_trx_start, sys_trx_end) +) WITH SYSTEM VERSIONING; +INSERT INTO t1 VALUES (1); + +CREATE TABLE t2 +( + x INT, + sys_trx_start TIMESTAMP(6) AS ROW START INVISIBLE, + sys_trx_end TIMESTAMP(6) AS ROW END INVISIBLE, + PERIOD FOR SYSTEM_TIME (sys_trx_start, sys_trx_end) +) WITH SYSTEM VERSIONING; +INSERT INTO t2 VALUES (1); + +--echo # +--echo # ROW is not supported +--echo # + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (1,1); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (1,1); + + +--echo # +--echo # DOUBLE is not supported, use explicit CAST +--echo # + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t1 FOR SYSTEM_TIME AS OF RAND(); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (RAND()); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t1 FOR SYSTEM_TIME AS OF COALESCE(RAND()); + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t2 FOR SYSTEM_TIME AS OF RAND(); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (RAND()); +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t2 FOR SYSTEM_TIME AS OF COALESCE(RAND()); + + +--echo # +--echo # DECIMAL is not supported, use explicit CAST +--echo # + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t1 FOR SYSTEM_TIME AS OF 10.1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t1 FOR SYSTEM_TIME AS OF COALESCE(10.1); + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t2 FOR SYSTEM_TIME AS OF 10.1; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT * FROM t2 FOR SYSTEM_TIME AS OF COALESCE(10.1); + + +--echo # +--echo # YEAR is not supported, use explicit CAST +--echo # + +DELIMITER $$; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +BEGIN NOT ATOMIC + DECLARE var YEAR; + SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +BEGIN NOT ATOMIC + DECLARE var YEAR; + SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # ENUM is not supported, use explicit CAST +--echo # + +DELIMITER $$; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +BEGIN NOT ATOMIC + DECLARE var ENUM('xxx') DEFAULT 'xxx'; + SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +BEGIN NOT ATOMIC + DECLARE var ENUM('xxx') DEFAULT 'xxx'; + SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # SET is not supported, use explicit CAST +--echo # + +DELIMITER $$; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +BEGIN NOT ATOMIC + DECLARE var SET('xxx') DEFAULT 'xxx'; + SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +BEGIN NOT ATOMIC + DECLARE var SET('xxx') DEFAULT 'xxx'; + SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # BIT is resolved to TRANSACTION +--echo # + +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE var BIT(10); + SELECT * FROM t1 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_VERS_ENGINE_UNSUPPORTED +BEGIN NOT ATOMIC + DECLARE var BIT(10); + SELECT * FROM t2 FOR SYSTEM_TIME AS OF var; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # String literals resolve to TIMESTAMP +--echo # + +SELECT * FROM t1 FOR SYSTEM_TIME AS OF '2038-12-30 00:00:00'; +SELECT * FROM t2 FOR SYSTEM_TIME AS OF '2038-12-30 00:00:00'; + + +--echo # +--echo # HEX hybrids resolve to TRANSACTION +--echo # + +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (0x60); +--error ER_VERS_ENGINE_UNSUPPORTED +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (0x60); + + +--echo # +--echo # BIT literals resolve to TRANSACTION +--echo # + +SELECT * FROM t1 FOR SYSTEM_TIME AS OF (b'1100000'); +--error ER_VERS_ENGINE_UNSUPPORTED +SELECT * FROM t2 FOR SYSTEM_TIME AS OF (b'1100000'); + +DROP TABLE t1, t2; + + +--echo # +--echo # MDEV-16094 Crash when using AS OF with a stored function +--echo # + +CREATE FUNCTION fts() RETURNS DATETIME RETURN '2001-01-01 10:20:30'; +CREATE FUNCTION ftx() RETURNS BIGINT UNSIGNED RETURN 1; + +CREATE TABLE ttx +( + x INT, + start_timestamp BIGINT UNSIGNED GENERATED ALWAYS AS ROW START, + end_timestamp BIGINT UNSIGNED GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp) +) ENGINE=InnoDB WITH SYSTEM VERSIONING; + +CREATE TABLE tts +( + x INT, + start_timestamp TIMESTAMP(6) GENERATED ALWAYS AS ROW START, + end_timestamp TIMESTAMP(6) GENERATED ALWAYS AS ROW END, + PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp) +) ENGINE=InnoDB WITH SYSTEM VERSIONING; + +SELECT * FROM tts FOR SYSTEM_TIME AS OF fts(); +--error ER_VERS_ENGINE_UNSUPPORTED +SELECT * FROM tts FOR SYSTEM_TIME AS OF ftx(); +SELECT * FROM ttx FOR SYSTEM_TIME AS OF fts(); +SELECT * FROM ttx FOR SYSTEM_TIME AS OF ftx(); + +DROP TABLE tts; +DROP TABLE ttx; +DROP FUNCTION fts; +DROP FUNCTION ftx; |