summaryrefslogtreecommitdiffstats
path: root/storage/rocksdb/mysql-test/rocksdb/t/foreign_key.test
blob: 675a337c24d283e38b122acf08bd29a2631aa310 (plain)
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
--source include/have_rocksdb.inc

--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

CREATE TABLE t1 (b INT PRIMARY KEY);

# Try simple foreign key - should fail
--error ER_NOT_SUPPORTED_YET
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, FOREIGN KEY (b) REFERENCES t1(b));

# Try simple valid syntax with 'foreign' as part - should succeed
CREATE TABLE t2 (a INT NOT NULL, bforeign INT NOT NULL);
DROP TABLE t2;

# Try simple valid syntax with 'foreign' and 'key' as part (with no space) - should succeed
CREATE TABLE t2 (a INT NOT NULL, foreignkey INT NOT NULL);
DROP TABLE t2;

# Try with valid id containing 'foreign' and then a foreign key - should fail
--error ER_NOT_SUPPORTED_YET
CREATE TABLE t2 (a INT NOT NULL, bforeign INT not null, FOREIGN KEY (bforeign) REFERENCES t1(b));

CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL);
# Alter with foreign key - should fail
--error ER_NOT_SUPPORTED_YET
ALTER TABLE t2 ADD FOREIGN KEY (b) REFERENCES t1(b);
DROP TABLE t2;

# Alter with valid syntax that contains 'foreign' - should succeed
CREATE TABLE t2 (a INT NOT NULL);
ALTER TABLE t2 ADD bforeign INT NOT NULL;
DROP TABLE t2;

# Alter with valid syntax that contains 'foreign' and 'key' (no space) - should succeed
CREATE TABLE t2 (a INT NOT NULL);
ALTER TABLE t2 ADD foreignkey INT NOT NULL;
DROP TABLE t2;

# Alter with valid syntax that contains 'foreign' and then foreign key - should fail
CREATE TABLE t2 (a INT NOT NULL);
--error ER_NOT_SUPPORTED_YET
ALTER TABLE t2 ADD bforeign INT NOT NULL, ADD FOREIGN KEY (bforeign) REFERENCES t1(b);
DROP TABLE t2;

DROP TABLE t1;