File: rename_fk_1.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (51 lines) | stat: -rw-r--r-- 2,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# Bug #27453180 FOREIGN KEYS CONSTRAINTS IGNORED AFTER RENAME TABLE
#
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE child (fk INT, FOREIGN KEY (fk) REFERENCES parent(pk));
show create table child;
Table	Create Table
child	CREATE TABLE `child` (
  `fk` int DEFAULT NULL,
  KEY `fk` (`fk`),
  CONSTRAINT `child_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `parent` (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT * FROM INFORMATION_SCHEMA.INNODB_FOREIGN;
ID	FOR_NAME	REF_NAME	N_COLS	TYPE
test/child_ibfk_1	test/child	test/parent	1	48
SELECT * FROM INFORMATION_SCHEMA.INNODB_FOREIGN_COLS;
ID	FOR_COL_NAME	REF_COL_NAME	POS
test/child_ibfk_1	fk	pk	1
INSERT INTO child VALUES (1);
CREATE TABLE parent0 (pk INT PRIMARY KEY);
INSERT INTO parent0 VALUES (1);
RENAME TABLE parent0 TO parent;
SET FOREIGN_KEY_CHECKS=1;
DELETE FROM parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `parent` (`pk`))
DROP TABLE child;
DROP TABLE parent;
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE child (fk INT, FOREIGN KEY (fk) REFERENCES parent(pk));
show create table child;
Table	Create Table
child	CREATE TABLE `child` (
  `fk` int DEFAULT NULL,
  KEY `fk` (`fk`),
  CONSTRAINT `child_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `parent` (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT * FROM INFORMATION_SCHEMA.INNODB_FOREIGN;
ID	FOR_NAME	REF_NAME	N_COLS	TYPE
test/child_ibfk_1	test/child	test/parent	1	48
SELECT * FROM INFORMATION_SCHEMA.INNODB_FOREIGN_COLS;
ID	FOR_COL_NAME	REF_COL_NAME	POS
test/child_ibfk_1	fk	pk	1
INSERT INTO child VALUES (1);
CREATE TABLE parent0 (pk INT PRIMARY KEY);
INSERT INTO parent0 VALUES (1);
ALTER TABLE parent0 RENAME parent;
SET FOREIGN_KEY_CHECKS=1;
DELETE FROM parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `parent` (`pk`))
DROP TABLE child;
DROP TABLE parent;