~drizzle-trunk/drizzle/development

1812.4.1 by Brian Aker
This fixes the IS key_column_usage table to correctly respond to FK.
1
CREATE TABLE `prim_key` (
2
`id` INT NOT NULL,
3
`val` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
4
PRIMARY KEY (`id`)
5
);
6
CREATE TABLE `fore_key0` (
7
`id` INT NOT NULL,
8
`id_ref0` INT DEFAULT NULL,
9
PRIMARY KEY (`id`),
10
KEY `id_ref0` (`id_ref0`),
11
CONSTRAINT `fore_key0_ibfk_1` FOREIGN KEY (`id_ref0`) REFERENCES
12
`prim_key` (`id`)
13
);
14
CREATE TABLE `fore_key1` (
15
`id` INT NOT NULL,
16
`id_ref1` INT DEFAULT NULL,
17
PRIMARY KEY (`id`),
18
KEY `id_ref1` (`id_ref1`),
19
CONSTRAINT `fore_key1_ibfk_1` FOREIGN KEY (`id_ref1`) REFERENCES
20
`prim_key` (`id`) ON UPDATE CASCADE
21
);
22
SELECT CONSTRAINT_NAME,TABLE_NAME,COLUMN_NAME,ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
23
CONSTRAINT_NAME	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION
1821.1.4 by lbieber
Add sort order for regression.654219
24
PRIMARY	fore_key0	id	1
25
PRIMARY	fore_key1	id	1
1812.4.1 by Brian Aker
This fixes the IS key_column_usage table to correctly respond to FK.
26
PRIMARY	prim_key	id	1
1821.1.4 by lbieber
Add sort order for regression.654219
27
fore_key0_ibfk_1	fore_key0	id_ref0	1
1812.4.1 by Brian Aker
This fixes the IS key_column_usage table to correctly respond to FK.
28
fore_key1_ibfk_1	fore_key1	id_ref1	1
29
DROP TABLE fore_key1;
30
DROP TABLE fore_key0;
31
DROP TABLE prim_key;
32
CREATE TABLE t1
33
(
34
s1 INT,
35
s2 INT,
36
s3 INT,
37
PRIMARY KEY(s3)
38
);
39
CREATE TABLE t3
40
(
41
s1 INT,
42
s2 INT,
43
s3 INT,
44
KEY(s1),
45
CONSTRAINT CO FOREIGN KEY (s2)
46
REFERENCES t1(s3)
47
);
48
SELECT CONSTRAINT_NAME,TABLE_NAME,COLUMN_NAME,ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
49
CONSTRAINT_NAME	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION
50
CO	t3	s2	1
51
PRIMARY	t1	s3	1
52
DROP TABLE t3;
53
DROP TABLE t1;
54
CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, c3 CHAR(5), c4 INT, c5 INT, constraint pk_t1 PRIMARY KEY (c5,c4));
55
CREATE TABLE T2 (tc1 INT NOT NULL, c1 INT NOT NULL, c2 INT NOT NULL, c5 CHAR(5), constraint fk_t2 FOREIGN KEY (c1,c2) REFERENCES t1 (c5,c4));
56
SELECT CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME IN ('t1', 't2');
57
CONSTRAINT_NAME	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION
1821.1.4 by lbieber
Add sort order for regression.654219
58
PRIMARY	t1	c4	2
1812.4.1 by Brian Aker
This fixes the IS key_column_usage table to correctly respond to FK.
59
PRIMARY	t1	c5	1
60
fk_t2	t2	c1	1
61
fk_t2	t2	c2	2
62
DROP TABLE t2;
63
DROP TABLE t1;