-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic serializable testcase (#198)
Task: OSS-ONLY Signed-off-by: Kristian Lejao <[email protected]> (cherry picked from commit 8a276b6)
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
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,31 @@ | ||
CREATE TABLE serializable_tab1 ( | ||
id bigint NOT NULL | ||
); | ||
CREATE TABLE serializable_tab2 ( | ||
id bigint NOT NULL, | ||
user_id bigint | ||
); | ||
ALTER TABLE ONLY serializable_tab1 | ||
ADD CONSTRAINT user_constraint UNIQUE (id); | ||
ALTER TABLE ONLY serializable_tab2 | ||
ADD CONSTRAINT assignment_constraint UNIQUE (user_id); | ||
ALTER TABLE ONLY serializable_tab2 | ||
ADD CONSTRAINT user_assignments_user_id_fkey FOREIGN KEY (user_id) REFERENCES serializable_tab1(id) ON DELETE CASCADE; | ||
INSERT INTO serializable_tab1 (id) VALUES ('12345'); | ||
INSERT INTO serializable_tab2 (id, user_id) VALUES ('1', '12345'); | ||
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; | ||
DELETE FROM serializable_tab1 where id = '12345'; | ||
SELECT * FROM serializable_tab1; | ||
id | ||
---- | ||
(0 rows) | ||
|
||
ROLLBACK; | ||
SELECT * FROM serializable_tab1; | ||
id | ||
------- | ||
12345 | ||
(1 row) | ||
|
||
DROP TABLE serializable_tab2; | ||
DROP TABLE serializable_tab1; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CREATE TABLE serializable_tab1 ( | ||
id bigint NOT NULL | ||
); | ||
|
||
CREATE TABLE serializable_tab2 ( | ||
id bigint NOT NULL, | ||
user_id bigint | ||
); | ||
|
||
ALTER TABLE ONLY serializable_tab1 | ||
ADD CONSTRAINT user_constraint UNIQUE (id); | ||
|
||
ALTER TABLE ONLY serializable_tab2 | ||
ADD CONSTRAINT assignment_constraint UNIQUE (user_id); | ||
|
||
ALTER TABLE ONLY serializable_tab2 | ||
ADD CONSTRAINT user_assignments_user_id_fkey FOREIGN KEY (user_id) REFERENCES serializable_tab1(id) ON DELETE CASCADE; | ||
|
||
|
||
INSERT INTO serializable_tab1 (id) VALUES ('12345'); | ||
INSERT INTO serializable_tab2 (id, user_id) VALUES ('1', '12345'); | ||
|
||
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; | ||
DELETE FROM serializable_tab1 where id = '12345'; | ||
SELECT * FROM serializable_tab1; | ||
ROLLBACK; | ||
|
||
SELECT * FROM serializable_tab1; | ||
|
||
DROP TABLE serializable_tab2; | ||
DROP TABLE serializable_tab1; | ||
|