-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an error when attempting to create foreign keys
Summary: Currently if you attempt to create foreign keys when using the RocksDB engine no error is generated and the foreign key constraint is ignore (though a key is created). Add an error so that this will not be allowed - any create table (or alter table) that adds a constraint will generate an error. Issue 205 Test Plan: MTR Reviewers: yoshinorim, hermanlee4 Reviewed By: hermanlee4 Subscribers: webscalesql-eng Differential Revision: https://reviews.facebook.net/D56703
- Loading branch information
Showing
7 changed files
with
402 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
DROP TABLE IF EXISTS t1, t2; | ||
CREATE TABLE t1 (b INT PRIMARY KEY); | ||
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, FOREIGN KEY (b) REFERENCES t1(b)); | ||
ERROR 42000: MyRocks does not currently support foreign key constraints | ||
CREATE TABLE t2 (a INT NOT NULL, bforeign INT NOT NULL); | ||
DROP TABLE t2; | ||
CREATE TABLE t2 (a INT NOT NULL, foreignkey INT NOT NULL); | ||
DROP TABLE t2; | ||
CREATE TABLE t2 (a INT NOT NULL, bforeign INT not null, FOREIGN KEY (bforeign) REFERENCES t1(b)); | ||
ERROR 42000: MyRocks does not currently support foreign key constraints | ||
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL); | ||
ALTER TABLE t2 ADD FOREIGN KEY (b) REFERENCES t1(b); | ||
ERROR 42000: MyRocks does not currently support foreign key constraints | ||
DROP TABLE t2; | ||
CREATE TABLE t2 (a INT NOT NULL); | ||
ALTER TABLE t2 ADD bforeign INT NOT NULL; | ||
DROP TABLE t2; | ||
CREATE TABLE t2 (a INT NOT NULL); | ||
ALTER TABLE t2 ADD foreignkey INT NOT NULL; | ||
DROP TABLE t2; | ||
CREATE TABLE t2 (a INT NOT NULL); | ||
ALTER TABLE t2 ADD bforeign INT NOT NULL, ADD FOREIGN KEY (bforeign) REFERENCES t1(b); | ||
ERROR 42000: MyRocks does not currently support foreign key constraints | ||
DROP TABLE t2; | ||
DROP TABLE t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.