mirror of
https://github.com/MariaDB/server.git
synced 2025-07-26 05:04:59 +02:00

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
39 lines
1.6 KiB
Text
39 lines
1.6 KiB
Text
--- foreign_sql_mode.result
|
|
+++ foreign_sql_mode,INPLACE,NON-STRICT.rdiff
|
|
@@ -3,14 +3,14 @@
|
|
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
|
|
CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB;
|
|
ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL;
|
|
-ERROR HY000: Column 'f1' cannot be NOT NULL: needed in a foreign key constraint '1' SET NULL
|
|
INSERT INTO t1 VALUES(1, 1);
|
|
INSERT INTO t2 VALUES(1);
|
|
UPDATE t1 SET f2= NULL;
|
|
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f2`) ON UPDATE CASCADE)
|
|
DELETE FROM t2;
|
|
SELECT * FROM t1;
|
|
f1 f2
|
|
-1 NULL
|
|
+1 1
|
|
UPDATE t1 SET f2 = NULL;
|
|
SELECT * FROM t1;
|
|
f1 f2
|
|
@@ -40,11 +40,10 @@
|
|
FOREIGN KEY(f1) REFERENCES `t#1`(f2)
|
|
ON UPDATE CASCADE)ENGINE=InnoDB;
|
|
ALTER TABLE `t#1` MODIFY COLUMN f2 INT;
|
|
-ERROR HY000: Cannot change column 'f2': used in a foreign key constraint '1' of table 'test.t#2'
|
|
INSERT INTO `t#1` VALUES(1, 1);
|
|
INSERT INTO `t#2` VALUES(1);
|
|
UPDATE `t#1` SET f2= NULL;
|
|
-ERROR 23000: Column 'f2' cannot be null
|
|
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t#2`, CONSTRAINT `1` FOREIGN KEY (`f1`) REFERENCES `t#1` (`f2`) ON UPDATE CASCADE)
|
|
DELETE FROM `t#2`;
|
|
SELECT * FROM `t#1`;
|
|
f1 f2
|
|
@@ -60,6 +59,5 @@
|
|
PRIMARY KEY(f1, f2),
|
|
FOREIGN KEY(f2, f3) REFERENCES t1(f2, f1)
|
|
ON UPDATE CASCADE)ENGINE=InnoDB;
|
|
-ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
|
DROP TABLE IF EXISTS t2;
|
|
DROP TABLE IF EXISTS t1;
|