summaryrefslogtreecommitdiff
path: root/src/test/isolation/specs
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2015-04-05 12:03:58 -0400
committerSimon Riggs <simon@2ndQuadrant.com>2015-04-05 12:03:58 -0400
commit35ecc244073a25cc99d76e42f99eb9476a2f8ab3 (patch)
tree07c45c7afba21cb2714464b43f95a8b2ed080e07 /src/test/isolation/specs
parentcf376a4adc0805b0960a5f8e8325fae7d4456926 (diff)
downloadpostgresql-35ecc244073a25cc99d76e42f99eb9476a2f8ab3.tar.gz
Add new test files for lock level patch
Diffstat (limited to 'src/test/isolation/specs')
-rw-r--r--src/test/isolation/specs/alter-table-2.spec30
-rw-r--r--src/test/isolation/specs/alter-table-3.spec30
-rw-r--r--src/test/isolation/specs/create-trigger.spec28
3 files changed, 88 insertions, 0 deletions
diff --git a/src/test/isolation/specs/alter-table-2.spec b/src/test/isolation/specs/alter-table-2.spec
new file mode 100644
index 0000000000..e6a02e01d6
--- /dev/null
+++ b/src/test/isolation/specs/alter-table-2.spec
@@ -0,0 +1,30 @@
+# ALTER TABLE - Add foreign keys with concurrent reads
+#
+# ADD CONSTRAINT uses ShareRowExclusiveLock so we mix writes with it
+# to see what works or waits.
+
+setup
+{
+ CREATE TABLE a (i int PRIMARY KEY);
+ CREATE TABLE b (a_id int);
+ INSERT INTO a VALUES (0), (1), (2), (3);
+ INSERT INTO b SELECT generate_series(1,1000) % 4;
+}
+
+teardown
+{
+ DROP TABLE a, b;
+}
+
+session "s1"
+step "s1a" { BEGIN; }
+step "s1b" { ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; }
+step "s1c" { COMMIT; }
+
+session "s2"
+step "s2a" { BEGIN; }
+step "s2b" { SELECT * FROM a WHERE i = 1 LIMIT 1 FOR UPDATE; }
+step "s2c" { SELECT * FROM b WHERE a_id = 3 LIMIT 1 FOR UPDATE; }
+step "s2d" { INSERT INTO b VALUES (0); }
+step "s2e" { INSERT INTO a VALUES (4); }
+step "s2f" { COMMIT; }
diff --git a/src/test/isolation/specs/alter-table-3.spec b/src/test/isolation/specs/alter-table-3.spec
new file mode 100644
index 0000000000..d252620313
--- /dev/null
+++ b/src/test/isolation/specs/alter-table-3.spec
@@ -0,0 +1,30 @@
+# ALTER TABLE - Enable and disable triggers with concurrent reads
+#
+# ENABLE/DISABLE TRIGGER uses ShareRowExclusiveLock so we mix writes with
+# it to see what works or waits.
+
+setup
+{
+ CREATE TABLE a (i int PRIMARY KEY);
+ INSERT INTO a VALUES (0), (1), (2), (3);
+ CREATE FUNCTION f() RETURNS TRIGGER LANGUAGE plpgsql AS 'BEGIN RETURN NULL; END;';
+ CREATE TRIGGER t AFTER UPDATE ON a EXECUTE PROCEDURE f();
+}
+
+teardown
+{
+ DROP TABLE a;
+ DROP FUNCTION f();
+}
+
+session "s1"
+step "s1a" { BEGIN; }
+step "s1b" { ALTER TABLE a DISABLE TRIGGER t; }
+step "s1c" { ALTER TABLE a ENABLE TRIGGER t; }
+step "s1d" { COMMIT; }
+
+session "s2"
+step "s2a" { BEGIN; }
+step "s2b" { SELECT * FROM a WHERE i = 1 LIMIT 1 FOR UPDATE; }
+step "s2c" { INSERT INTO a VALUES (0); }
+step "s2d" { COMMIT; }
diff --git a/src/test/isolation/specs/create-trigger.spec b/src/test/isolation/specs/create-trigger.spec
new file mode 100644
index 0000000000..34fad7521f
--- /dev/null
+++ b/src/test/isolation/specs/create-trigger.spec
@@ -0,0 +1,28 @@
+# CREATE TRIGGER - Add trigger with concurrent reads
+#
+# CREATE TRIGGER uses ShareRowExclusiveLock so we mix writes with it
+# to see what works or waits.
+
+setup
+{
+ CREATE TABLE a (i int);
+ CREATE FUNCTION f() RETURNS TRIGGER LANGUAGE plpgsql AS 'BEGIN RETURN NULL; END;';
+ INSERT INTO a VALUES (0), (1), (2), (3);
+}
+
+teardown
+{
+ DROP TABLE a;
+ DROP FUNCTION f();
+}
+
+session "s1"
+step "s1a" { BEGIN; }
+step "s1b" { CREATE TRIGGER t AFTER UPDATE ON a EXECUTE PROCEDURE f(); }
+step "s1c" { COMMIT; }
+
+session "s2"
+step "s2a" { BEGIN; }
+step "s2b" { SELECT * FROM a WHERE i = 1 FOR UPDATE; }
+step "s2c" { UPDATE a SET i = 4 WHERE i = 3; }
+step "s2d" { COMMIT; }