mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-23644 Assertion on evaluating foreign referential action for self-reference in system versioned table
First part of the fix (row0mysql.cc) addresses external columns when adding history row on referential action. The full data must be retrieved before the row is inserted. Second part of the fix (the rest) avoids duplicate primary key error between the history row generated on referential action and the history row generated by SQL command. Both command and referential action can happen on same table since foreign key can be self-reference (parent and child tables are same). Moreover, the self-reference can refer multiple rows when the key is non-unique. In such case history is generated by referential action occured on first row but processed all rows by a matched key. The second round is when the next row is processed by a command but history already exists. In such case we check TRX_ID of existing history row and if it is the same we assume the above situation and skip adding one more history row or failing the command.
This commit is contained in:
@ -138,13 +138,13 @@ 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(row_start, row_end) from t1;
|
||||
f1 f3 check_row(row_start, row_end)
|
||||
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(row_start, row_end) from t1 for system_time all;
|
||||
f1 f3 check_row(row_start, row_end)
|
||||
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 NULL ERROR: row_end == row_start
|
||||
1 1 HISTORICAL ROW
|
||||
|
Reference in New Issue
Block a user