Skip to content

Commit

Permalink
Add basic serializable testcase (#198)
Browse files Browse the repository at this point in the history
Task: OSS-ONLY

Signed-off-by: Kristian Lejao <[email protected]>
(cherry picked from commit 8a276b6)
  • Loading branch information
lejaokri committed Oct 6, 2023
1 parent a21073f commit 2ada3e9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/test/regress/expected/serializable.out
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;
2 changes: 2 additions & 0 deletions src/test/regress/parallel_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ test: event_trigger oidjoins

# this test also uses event triggers, so likewise run it by itself
test: fast_default

test: serializable
32 changes: 32 additions & 0 deletions src/test/regress/sql/serializable.sql
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;

0 comments on commit 2ada3e9

Please sign in to comment.