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_fts/r/foreign_key_update.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

47 lines
1.1 KiB
Plaintext

CREATE TABLE t1 (
a varchar(40),
KEY a(a)
) ENGINE=InnoDB;
CREATE TABLE t1_fk (
a varchar(40),
KEY a(a),
FULLTEXT KEY (a),
CONSTRAINT fk FOREIGN KEY (a) REFERENCES t1 (a) ON UPDATE CASCADE
) ENGINE=InnoDB;
INSERT INTO t1 VALUES('mysql');
INSERT INTO t1_fk VALUES('mysql');
INSERT INTO t1_fk VALUES('mysql');
SELECT * FROM t1_fk;
a
mysql
mysql
SELECT * FROM t1_fk WHERE MATCH(a) AGAINST('mysql');
a
mysql
mysql
UPDATE t1 SET a = 'database' WHERE a = 'mysql';
SELECT * FROM t1_fk;
a
database
database
SELECT * FROM t1_fk WHERE MATCH(a) AGAINST('mysql');
a
SELECT * FROM t1_fk WHERE MATCH(a) AGAINST('database');
a
database
database
DROP TABLE t1_fk;
DROP TABLE t1;
#
# MDEV-32346 Assertion failure sym_node->table != NULL
# in pars_retrieve_table_def on UPDATE
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT, b TEXT, FOREIGN KEY(a) REFERENCES t1(a),
FULLTEXT (b))ENGINE=InnoDB;
INSERT INTO t1 SET a=1;
ALTER TABLE t2 DISCARD TABLESPACE;
UPDATE t1 SET a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
DROP TABLE t2,t1;