1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
|
set default_storage_engine= innodb;
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning;
# No history inside the transaction
start transaction;
insert into t1 (x) values (1);
update t1 set x= x + 1;
update t1 set x= x + 1;
commit;
select *, sys_trx_start > 1, sys_trx_end from t1 for system_time all;
x sys_trx_start > 1 sys_trx_end
3 1 18446744073709551615
# ALTER ADD SYSTEM VERSIONING should write to mysql.transaction_registry
set @@system_versioning_alter_history=keep;
create or replace table t1 (x int);
insert into t1 values (1);
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=inplace;
select s from t1 into @trx_start;
select count(*) = 1 from mysql.transaction_registry where transaction_id = @trx_start;
count(*) = 1
1
create or replace table t1 (x int);
select count(*) from mysql.transaction_registry into @tmp;
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=inplace;
select count(*) = @tmp from mysql.transaction_registry;
count(*) = @tmp
1
create or replace table t1 (x int);
insert into t1 values (1);
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=copy;
select s from t1 into @trx_start;
select count(*) = 1 from mysql.transaction_registry where transaction_id = @trx_start;
count(*) = 1
1
create or replace table t1 (x int);
select count(*) from mysql.transaction_registry into @tmp;
alter table t1
add column s bigint unsigned as row start,
add column e bigint unsigned as row end,
add period for system_time(s, e),
add system versioning,
algorithm=copy;
select count(*) = @tmp + 1 from mysql.transaction_registry;
count(*) = @tmp + 1
1
# TRX_ID to TIMESTAMP versioning switch
create or replace table t1 (
x int,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
period for system_time (sys_start, sys_end)
) with system versioning;
insert into t1 values (1);
alter table t1 drop column sys_start, drop column sys_end;
select row_end = 18446744073709551615 as transaction_based from t1 for system_time all;
transaction_based
1
# Simple vs SEES algorithms
create or replace table t1 (
x int,
sys_start bigint(20) unsigned as row start invisible,
sys_end bigint(20) unsigned as row end invisible,
period for system_time (sys_start, sys_end)
) with system versioning;
INSERT INTO t1 VALUES(100);
set transaction isolation level read committed;
start transaction;
insert into t1 values (1);
connect con1,localhost,root,,test;
set transaction isolation level read committed;
start transaction;
insert into t1 values (2);
connect con2,localhost,root,,test;
set transaction isolation level read committed;
start transaction;
insert into t1 values (3);
commit;
disconnect con2;
connection default;
set @ts1= sysdate(6);
connection con1;
commit;
disconnect con1;
connection default;
set @ts2= sysdate(6);
commit;
set @ts3= sysdate(6);
select sys_start from t1 where x = 1 into @trx_id1;
select sys_start from t1 where x = 2 into @trx_id2;
select sys_start from t1 where x = 3 into @trx_id3;
select @trx_id1 < @trx_id2, @trx_id2 < @trx_id3;
@trx_id1 < @trx_id2 @trx_id2 < @trx_id3
1 1
select @ts1 < @ts2, @ts2 < @ts3;
@ts1 < @ts2 @ts2 < @ts3
1 1
# MVCC is resolved
select * from t1 for system_time as of transaction @trx_id1;
x
100
1
2
3
select * from t1 for system_time as of timestamp @ts1;
x
100
3
select * from t1 for system_time as of transaction @trx_id2;
x
100
2
3
select * from t1 for system_time as of timestamp @ts2;
x
100
2
3
select * from t1 for system_time as of transaction @trx_id3;
x
100
3
select * from t1 for system_time as of timestamp @ts3;
x
100
1
2
3
#
# MDEV-15427 IB: TRX_ID based operations inside transaction generate history
#
create or replace table t1(
x int(10),
row_start bigint(20) unsigned as row start,
row_end bigint(20) unsigned as row end,
period for system_time(row_start, row_end)
) with system versioning;
begin;
insert into t1 (x) values (1);
delete from t1;
commit;
select x from t1 for system_time all;
x
insert into t1 (x) values (2);
begin;
update t1 set x= 3;
update t1 set x= 4;
commit;
select x, row_start < row_end from t1 for system_time all;
x row_start < row_end
4 1
2 1
#
# MDEV-15951 system versioning by trx id doesn't work with partitioning
# currently trx_id does not support partitioning by system_time
#
create or replace table t1(
i int,
row_start bigint unsigned generated always as row start,
row_end bigint unsigned generated always as row end,
period for system_time(row_start, row_end)
) engine=InnoDB with system versioning partition by system_time (
partition p0 history,
partition pn current
);
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
create or replace table t1(
i int,
row_start bigint unsigned generated always as row start,
row_end bigint unsigned generated always as row end,
period for system_time(row_start, row_end)
) engine=InnoDB with system versioning;
alter table t1 partition by system_time (
partition p0 history,
partition pn current
);
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
drop table t1;
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by key() (
partition p1,
partition p2
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by key(a, row_start) (
partition p1,
partition p2
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by hash(a + row_end * 2) (
partition p1,
partition p2
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by range columns (a, row_start) (
partition p1 values less than (100, 100)
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
#
# MDEV-16010 Too many rows with AS OF point_in_the_past_or_NULL
#
create or replace table t1 (
x int,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time (row_start, row_end)
) with system versioning engine innodb;
insert into t1 (x) values (1);
delete from t1;
select * from t1 for system_time as of timestamp'1990-1-1 00:00';
x
select * from t1 for system_time as of NULL;
x
# MDEV-16024 transaction_registry.begin_timestamp is wrong for explicit transactions
create or replace table t1 (
x int(11) default null,
row_start bigint(20) unsigned generated always as row start invisible,
row_end bigint(20) unsigned generated always as row end invisible,
period for system_time (row_start, row_end)
) engine=innodb with system versioning;
begin;
set @ts1= now(6);
insert into t1 values (1);
commit;
select row_start from t1 into @trx_id;
select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD;
BEGIN_TS_GOOD
1
drop table t1;
#
# 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 AS OF TRANSACTION @`ts` 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 AS OF TIMESTAMP @`ts` 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 AS OF TIMESTAMP @`ts` 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 TRANSACTION RAND();
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
SELECT * FROM t1 FOR SYSTEM_TIME AS OF TRANSACTION (RAND());
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
SELECT * FROM t1 FOR SYSTEM_TIME AS OF TRANSACTION COALESCE(RAND());
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
SELECT * FROM t2 FOR SYSTEM_TIME AS OF TRANSACTION RAND();
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
SELECT * FROM t2 FOR SYSTEM_TIME AS OF TRANSACTION (RAND());
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
SELECT * FROM t2 FOR SYSTEM_TIME AS OF TRANSACTION 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 TRANSACTION 10.1;
ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME'
SELECT * FROM t1 FOR SYSTEM_TIME AS OF TRANSACTION COALESCE(10.1);
ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME'
SELECT * FROM t2 FOR SYSTEM_TIME AS OF TRANSACTION 10.1;
ERROR HY000: Illegal parameter data type decimal for operation 'FOR SYSTEM_TIME'
SELECT * FROM t2 FOR SYSTEM_TIME AS OF TRANSACTION 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 TRANSACTION 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 TRANSACTION 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 TRANSACTION 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 TRANSACTION 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 TRANSACTION 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 TRANSACTION var;
END;
$$
ERROR HY000: Illegal parameter data type set for operation 'FOR SYSTEM_TIME'
BEGIN NOT ATOMIC
DECLARE var BIT(10);
SELECT * FROM t2 FOR SYSTEM_TIME AS OF TRANSACTION var;
END;
$$
ERROR HY000: Transaction-precise system versioning for `t2` is not supported
#
# String literals resolve to TIMESTAMP
#
SELECT * FROM t1 FOR SYSTEM_TIME AS OF '2107-12-30 00:00:00';
x
1
SELECT * FROM t2 FOR SYSTEM_TIME AS OF '2107-12-30 00:00:00';
x
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 TRANSACTION ftx();
ERROR HY000: Transaction-precise 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 TRANSACTION ftx();
x start_timestamp end_timestamp
DROP TABLE tts;
DROP TABLE ttx;
DROP FUNCTION fts;
DROP FUNCTION ftx;
#
# MDEV-16330 Allow instant change of WITH SYSTEM VERSIONING column attribute
#
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=KEEP;
CREATE TABLE t (
a INT,
b INT,
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME(row_start, row_end)
) WITH SYSTEM VERSIONING ENGINE=INNODB;
INSERT INTO t VALUES (1,1);
# without table rebuild
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id
WHERE t.name='test/t' AND c.name='a';
prtype
50179
ALTER TABLE t
CHANGE a a INT WITHOUT SYSTEM VERSIONING;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id
WHERE t.name='test/t' AND c.name='a';
prtype
1027
UPDATE t SET a=11;
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
COUNT(*)
1
# with table rebuild
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id
WHERE t.name='test/t' AND c.name='a';
prtype
1027
ALTER TABLE t
CHANGE a a INT WITH SYSTEM VERSIONING,
ADD PRIMARY KEY pk(a);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1280 Name 'pk' ignored for PRIMARY key.
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id
WHERE t.name='test/t' AND c.name='a';
prtype
50435
UPDATE t SET a=1;
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
COUNT(*)
2
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
`row_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START INVISIBLE,
`row_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END INVISIBLE,
PRIMARY KEY (`a`,`row_end`),
PERIOD FOR SYSTEM_TIME (`row_start`, `row_end`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci WITH SYSTEM VERSIONING
# handles VIRTUAL columns too
CREATE OR REPLACE TABLE t (
a INT AS (b + 1),
b INT,
row_start BIGINT UNSIGNED AS ROW START INVISIBLE,
row_end BIGINT UNSIGNED AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME(row_start, row_end)
) WITH SYSTEM VERSIONING ENGINE=INNODB;
INSERT INTO t VALUES (DEFAULT, 1);
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id
WHERE t.name='test/t' AND c.name='b';
prtype
50179
ALTER TABLE t
CHANGE b b INT WITHOUT SYSTEM VERSIONING;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT c.prtype FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS AS c
INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES AS t
ON c.table_id=t.table_id
WHERE t.name='test/t' AND c.name='b';
prtype
1027
UPDATE t SET b=11;
SELECT COUNT(*) FROM t FOR SYSTEM_TIME ALL;
COUNT(*)
1
DROP TABLE t;
SET @@SYSTEM_VERSIONING_ALTER_HISTORY=ERROR;
SELECT count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp;
count(*)
0
# MDEV-18875 Assertion `thd->transaction.stmt.ha_list == __null ||
# trans == &thd->transaction.stmt' failed or bogus ER_DUP_ENTRY upon
# ALTER TABLE with versioning
create or replace table t (x int) engine=innodb;
set autocommit= 0;
alter table t
algorithm=copy,
add column row_start bigint unsigned as row start,
add column row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning;
set autocommit= 1;
# MDEV-18865 Assertion `t->first->versioned_by_id()'
# failed in innodb_prepare_commit_versioned
create or replace table t (x int) engine=innodb;
insert into t values (0);
alter table t add `row_start` bigint unsigned as row start,
add `row_end` bigint unsigned as row end,
add period for system_time(`row_start`,`row_end`),
modify x int after row_start,
with system versioning;
drop table t;
#
# MDEV-20842 Crash using versioning plugin functions after plugin was removed from server
#
uninstall plugin test_versioning;
select trt_begin_ts(0);
ERROR 42000: FUNCTION test.trt_begin_ts does not exist
#
# MDEV-21650 Non-empty statement transaction on global rollback after TRT update error
#
create table t1 (s date, e date, period for app(s,e)) engine=innodb;
alter table t1
add row_start bigint unsigned as row start,
add row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning,
add period if not exists for app(x,y);
Warnings:
Note 1060 Duplicate column name 'app'
set transaction isolation level serializable;
start transaction;
insert into t1 (s,e) values ('2021-07-04','2024-08-18');
connect con1,localhost,root,,test;
start transaction;
insert into t1 (s,e) values ('2018-06-01','2021-09-15');
connection default;
select * from t1 for system_time as of now();
ERROR HY000: TRX_ID ... not found in `mysql.transaction_registry`
connection con1;
set innodb_lock_wait_timeout= 1, lock_wait_timeout= 1;
alter table xx;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con1;
connection default;
drop table t1;
# End of 10.4 tests
#
# MDEV-37005 Unexpected ER_TABLE_EXISTS_ERROR on primary or replica upon CREATE OR REPLACE for partitioned table
#
create table t1 (
a int,
row_start bigint unsigned generated always as row start,
row_end bigint unsigned generated always as row end,
period for system_time (row_start, row_end)
) engine=innodb with system versioning
partition by hash (a);
create or replace table t1 (b int) engine=innodb with system versioning partition by system_time;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
PARTITIONS 2
drop table t1;
# End of 11.8 tests
|