mirror of
https://github.com/MariaDB/server.git
synced 2025-07-21 21:22:27 +03:00
1. In case of system-versioned table add row_end into FTS_DOC_ID index in fts_create_common_tables() and innobase_create_key_defs(). fts_n_uniq() returns 1 or 2 depending on whether the table is system-versioned. After this patch recreate of FTS_DOC_ID index is required for existing system-versioned tables. If you see this message in error log or server warnings: "InnoDB: Table db/t1 contains 2 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB" use this command to fix the table: ALTER TABLE db.t1 FORCE; 2. Fix duplicate history for secondary unique index like it was done in MDEV-23644 for clustered index (932ec586aa
). In case of existing history row which conflicts with currently inseted row we check in row_ins_scan_sec_index_for_duplicate() whether that row was inserted as part of current transaction. In that case we indicate with DB_FOREIGN_DUPLICATE_KEY that new history row is not needed and should be silently skipped. 3. Some parts of MDEV-21138 (7410ff436e
) reverted. Skipping of FTS_DOC_ID index for history rows made problems with purge system. Now this is fixed differently by p.2. 4. wait_all_purged.inc checks that we didn't affect non-history rows so they are deleted and purged correctly. Additional FTS fixes fts_init_get_doc_id(): exclude history rows from max_doc_id calculation. fts_init_get_doc_id() callback is used only for crash recovery. fts_add_doc_by_id(): set max value for row_end field. fts_read_stopword(): stopwords table can be system-versioned too. We now read stopwords only for current data. row_insert_for_mysql(): exclude history rows from doc_id validation. row_merge_read_clustered_index(): exclude history_rows from doc_id processing. fts_load_user_stopword(): for versioned table retrieve row_end field and skip history rows. For non-versioned table we retrieve 'value' field twice (just for uniformity). FTS tests for System Versioning now include maybe_versioning.inc which adds 3 combinations: 'vers' for debug build sets sysvers_force and sysvers_hide. sysvers_force makes every created table system-versioned, sysvers_hide hides WITH SYSTEM VERSIONING for SHOW CREATE. Note: basic.test, stopword.test and versioning.test do not require debug for 'vers' combination. This is controlled by $modify_create_table in maybe_versioning.inc and these tests run WITH SYSTEM VERSIONING explicitly which allows to test 'vers' combination on non-debug builds. 'vers_trx' like 'vers' sets sysvers_force_trx and sysvers_hide. That tests FTS with trx_id-based System Versioning. 'orig' works like before: no System Versioning is added, no debug is required. Upgrade/downgrade test for System Versioning is done by innodb_fts.versioning. It has 2 combinations: 'prepare' makes binaries in std_data (requires old server and OLD_BINDIR). It tests upgrade/downgrade against old server as well. 'upgrade' tests upgrade against binaries in std_data. Cleanups: Removed innodb-fts-stopword.test as it duplicates stopword.test
151 lines
3.4 KiB
Plaintext
151 lines
3.4 KiB
Plaintext
# Basic + delete from view
|
|
create or replace table t1(
|
|
XNo int unsigned,
|
|
sys_start SYS_DATATYPE as row start invisible,
|
|
sys_end SYS_DATATYPE as row end invisible,
|
|
period for system_time (sys_start, sys_end))
|
|
with system versioning;
|
|
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);
|
|
select XNo, sys_end < MAXVAL from t1 for system_time all;
|
|
XNo sys_end < MAXVAL
|
|
0 0
|
|
1 0
|
|
2 0
|
|
3 0
|
|
4 0
|
|
5 0
|
|
6 0
|
|
7 0
|
|
8 0
|
|
9 0
|
|
delete from t1 where XNo = 0;
|
|
delete from t1 where XNo = 1;
|
|
delete from t1 where XNo > 5;
|
|
create view vt1 as select XNo from t1;
|
|
select XNo as XNo_vt1 from vt1;
|
|
XNo_vt1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
delete from vt1 where XNo = 3;
|
|
select XNo as XNo_vt1 from vt1;
|
|
XNo_vt1
|
|
2
|
|
4
|
|
5
|
|
drop view vt1;
|
|
drop table t1;
|
|
# Check sys_start, sys_end
|
|
create or replace table t1(
|
|
x int,
|
|
sys_start SYS_DATATYPE as row start invisible,
|
|
sys_end SYS_DATATYPE as row end invisible,
|
|
period for system_time (sys_start, sys_end))
|
|
with system versioning;
|
|
insert into t1(x) values (1);
|
|
select sys_start into @sys_start from t1;
|
|
delete from t1;
|
|
select * from t1;
|
|
x
|
|
select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C from t1 for system_time all;
|
|
A B C
|
|
1 1 1
|
|
drop table t1;
|
|
# Multi-delete
|
|
create or replace table t1(
|
|
x int,
|
|
y int,
|
|
sys_start SYS_DATATYPE as row start invisible,
|
|
sys_end SYS_DATATYPE as row end invisible,
|
|
period for system_time (sys_start, sys_end))
|
|
with system versioning;
|
|
create or replace table t2 like t1;
|
|
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;
|
|
t1_x
|
|
1
|
|
2
|
|
14
|
|
select x as t2_x from t2;
|
|
t2_x
|
|
11
|
|
12
|
|
14
|
|
delete t1, t2 from t1 join t2 where t1.x = t2.x;
|
|
select x as t1_x from t1;
|
|
t1_x
|
|
1
|
|
2
|
|
select x as t2_x from t2;
|
|
t2_x
|
|
11
|
|
12
|
|
select x as t1_x_all from t1 for system_time all;
|
|
t1_x_all
|
|
1
|
|
2
|
|
3
|
|
14
|
|
select x as t2_x_all from t2 for system_time all;
|
|
t2_x_all
|
|
11
|
|
12
|
|
13
|
|
14
|
|
drop table t1;
|
|
drop table t2;
|
|
# Update + delete
|
|
create or replace table t1 (x int) with system versioning;
|
|
insert into t1 values (1);
|
|
update t1 set x= 2;
|
|
delete from t1;
|
|
select x from t1 for system_time all;
|
|
x
|
|
2
|
|
1
|
|
drop table t1;
|
|
#
|
|
# MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED
|
|
#
|
|
create or replace table t1 (a int) with system versioning;
|
|
replace into t1 values (1), (2);
|
|
create or replace trigger tr before delete on t1 for each row delete from xx;
|
|
create or replace procedure pr() delete from t1;
|
|
call pr;
|
|
ERROR 42S02: Table 'test.xx' doesn't exist
|
|
call pr;
|
|
ERROR 42S02: Table 'test.xx' doesn't exist
|
|
drop procedure pr;
|
|
drop trigger tr;
|
|
drop table t1;
|
|
#
|
|
# MDEV-21138 Assertion `col->ord_part' or `f.col->ord_part' failed in row_build_index_entry_low
|
|
#
|
|
create table t1 (
|
|
f1 int, f2 text, f3 int, fulltext (f2), key(f1), key(f3),
|
|
foreign key r (f3) references t1 (f1) on delete set null)
|
|
with system versioning engine innodb;
|
|
insert into t1 values (1, repeat('a', 8193), 1), (1, repeat('b', 8193), 1);
|
|
select f1, f3, check_row_ts(row_start, row_end) from t1;
|
|
f1 f3 check_row_ts(row_start, row_end)
|
|
1 1 CURRENT ROW
|
|
1 1 CURRENT ROW
|
|
delete from t1;
|
|
select f1, f3, check_row_ts(row_start, row_end) from t1 for system_time all;
|
|
f1 f3 check_row_ts(row_start, row_end)
|
|
1 1 HISTORICAL ROW
|
|
1 1 HISTORICAL ROW
|
|
drop table t1;
|