|
I believe this issue can be simplified to the following test case:
CREATE TABLE accounts_svt (
|
id SERIAL PRIMARY KEY,
|
name VARCHAR(255),
|
amount INT
|
) WITH SYSTEM VERSIONING;
|
|
CREATE TABLE accounts_tp (
|
id SERIAL PRIMARY KEY,
|
name VARCHAR(255),
|
amount INT,
|
start_trxid BIGINT UNSIGNED GENERATED ALWAYS AS ROW START INVISIBLE,
|
end_trxid BIGINT UNSIGNED GENERATED ALWAYS AS ROW END INVISIBLE,
|
PERIOD FOR SYSTEM_TIME(start_trxid, end_trxid)
|
) WITH SYSTEM VERSIONING;
|
|
BEGIN;
|
INSERT INTO accounts_svt (name, amount)
|
VALUES ("Smith", 400),
|
("Orson", 300),
|
("Serio", 500),
|
("Wallace", 200),
|
("March", 600),
|
("Douglas", 100);
|
INSERT INTO accounts_tp (name, amount)
|
VALUES ("Smith", 400),
|
("Orson", 300),
|
("Serio", 500),
|
("Wallace", 200),
|
("March", 600),
|
("Douglas", 100);
|
COMMIT;
|
|
BEGIN;
|
UPDATE accounts_svt
|
SET amount = 1000
|
WHERE id = 1
|
OR id = 3;
|
UPDATE accounts_tp
|
SET amount = 1000
|
WHERE id = 1
|
OR id = 3;
|
COMMIT;
|
|
SELECT * FROM mysql.transaction_registry;
|
|
SELECT *
|
FROM accounts_svt
|
FOR SYSTEM_TIME
|
FROM '2021-10-27 20:10'
|
TO '2038-01-19 03:14:07.999999';
|
|
SELECT *
|
FROM accounts_tp
|
FOR SYSTEM_TIME
|
FROM '2021-10-27 20:10'
|
TO '2038-01-19 03:14:07.999999';
|
The final queries using FROM .. TO .. return different results for system-versioned tables and transaction-precise tables:
MariaDB [test]> SELECT *
|
-> FROM accounts_svt
|
-> FOR SYSTEM_TIME
|
-> FROM '2021-10-27 20:10'
|
-> TO '2038-01-19 03:14:07.999999';
|
+----+---------+--------+
|
| id | name | amount |
|
+----+---------+--------+
|
| 1 | Smith | 400 |
|
| 1 | Smith | 1000 |
|
| 2 | Orson | 300 |
|
| 3 | Serio | 500 |
|
| 3 | Serio | 1000 |
|
| 4 | Wallace | 200 |
|
| 5 | March | 600 |
|
| 6 | Douglas | 100 |
|
+----+---------+--------+
|
8 rows in set (0.000 sec)
|
|
MariaDB [test]> SELECT *
|
-> FROM accounts_tp
|
-> FOR SYSTEM_TIME
|
-> FROM '2021-10-27 20:10'
|
-> TO '2038-01-19 03:14:07.999999';
|
+----+---------+--------+
|
| id | name | amount |
|
+----+---------+--------+
|
| 1 | Smith | 400 |
|
| 2 | Orson | 300 |
|
| 3 | Serio | 500 |
|
| 4 | Wallace | 200 |
|
| 5 | March | 600 |
|
| 6 | Douglas | 100 |
|
+----+---------+--------+
|
6 rows in set (0.001 sec)
|
|
|
Yes, it seems that transactional and timestamp-based versioning produce different results.
I have created the test to show the result differences
source suite/versioning/engines.inc;
|
source suite/versioning/common.inc;
|
|
SELECT TIMESTAMP '9999-12-31 23:59:59';
|
CREATE TABLE t(
|
x INT,
|
start_timestamp TIMESTAMP(6) NOT NULL,
|
end_timestamp TIMESTAMP(6) NOT NULL DEFAULT now()
|
);
|
insert into t values (1, TIMESTAMP '2021-10-27 20:10', TIMESTAMP '2038-01-19 03:14:07.999999');
|
select * from t;
|
select * from t WHERE start_timestamp >= TIMESTAMP '0001-01-01 00:00:00' and end_timestamp < TIMESTAMP '9999-12-31 23:59:59';
|
drop table t;
|
|
replace_result $sys_datatype_expl SYS_DATATYPE;
|
eval create or replace table t(
|
id SERIAL PRIMARY KEY,
|
x INT,
|
start_timestamp $sys_datatype_expl AS ROW START,
|
end_timestamp $sys_datatype_expl AS ROW END,
|
PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp)
|
) WITH SYSTEM VERSIONING;
|
INSERT INTO t(x)
|
VALUES (400),
|
(300),
|
(500),
|
(200),
|
(600),
|
(100);
|
|
UPDATE t
|
SET x = 999
|
WHERE id = 1
|
OR id = 3;
|
|
select id,x from t;
|
|
--sorted_result
|
SELECT id, x
|
FROM t
|
FOR SYSTEM_TIME
|
FROM '2021-10-27 20:10'
|
TO '2038-01-19 03:14:07.999999';
|
|
--sorted_result
|
SELECT id,x
|
FROM t
|
FOR SYSTEM_TIME
|
BETWEEN '2021-10-27 20:10'
|
AND '2038-01-19 03:14:07.999999';
|
#select * from mysql.transaction_registry;
|
|
drop table t;
|
|
--source suite/versioning/common_finish.inc
|
produces:
versioning.bug 'innodb,timestamp' [ pass ] 16
|
versioning.bug 'innodb,trx_id' [ fail ]
|
Test ended at 2021-11-02 00:16:31
|
|
CURRENT_TEST: versioning.bug
|
--- /home/nik/mariadb/mysql-test/suite/versioning/r/bug.result 2021-11-02 00:16:24.799553838 +0300
|
+++ /home/nik/mariadb/mysql-test/suite/versioning/r/bug.reject 2021-11-02 00:16:31.282928508 +0300
|
@@ -47,10 +47,8 @@
|
TO '2038-01-19 03:14:07.999999';
|
id x
|
1 400
|
-1 999
|
2 300
|
3 500
|
-3 999
|
4 200
|
5 600
|
6 100
|
|
mysqltest: Result length mismatch
|
|