1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
Files
mariadb/mysql-test/suite/innodb/r/xa_recovery.result
Marko Mäkelä cffbb17480 MDEV-28933: Per-table unique FOREIGN KEY constraint names
Before MySQL 4.0.18, user-specified constraint names were ignored.
Starting with MySQL 4.0.18, the specified constraint name was
prepended with the schema name and '/'.  Now we are transforming
into a format where the constraint name is prepended with the
dict_table_t::name and the impossible UTF-8 sequence 0xff.
Generated constraint names will be ASCII decimal numbers.

On upgrade, old FOREIGN KEY constraint names will be displayed
without any schema name prefix. They will be updated to the new
format on DDL operations.

dict_foreign_t::sql_id(): Return the SQL constraint name
without any schemaname/tablename\377 or schemaname/ prefix.

row_rename_table_for_mysql(), dict_table_rename_in_cache():
Simplify the logic: Just rename constraints to the new format.

dict_table_get_foreign_id(): Replaces dict_table_get_highest_foreign_id().

innobase_get_foreign_key_info(): Let my_error() refer to erroneous
anonymous constraints as "(null)".

row_delete_constraint(): Try to drop all 3 constraint name variants.

Reviewed by: Thirunarayanan Balathandayuthapani
Tested by: Matthias Leich
2025-07-08 12:30:27 +03:00

51 lines
1.2 KiB
Plaintext

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connect con1,localhost,root;
XA START 'x';
UPDATE t1 set a=2;
XA END 'x';
XA PREPARE 'x';
connect con2,localhost,root;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
XA START 'y';
INSERT INTO t2 VALUES (1);
XA END 'y';
XA PREPARE 'y';
connection default;
# restart: --innodb-force-recovery=2
disconnect con1;
disconnect con2;
connect con1,localhost,root;
SELECT * FROM t1 LOCK IN SHARE MODE;
connection default;
SET innodb_lock_wait_timeout=1;
DROP TABLE t2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con1;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM t1;
a
2
XA ROLLBACK 'x';
SELECT * FROM t1;
a
1
DROP TABLE t2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
XA ROLLBACK 'y';
DROP TABLE t2;
CREATE TABLE t3(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB;
XA START 'a';
INSERT INTO t3 SET a=1;
INSERT INTO t3 SET a=42;
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
XA END 'a';
XA PREPARE 'a';
SET GLOBAL innodb_fast_shutdown=0;
# restart
XA COMMIT 'a';
SELECT * FROM t3;
a
1
DROP TABLE t3,t1;