summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/read-write-unique-3.spec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
commit46651ce6fe013220ed397add242004d764fc0153 (patch)
tree6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/test/isolation/specs/read-write-unique-3.spec
parentInitial commit. (diff)
downloadpostgresql-14-upstream.tar.xz
postgresql-14-upstream.zip
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/test/isolation/specs/read-write-unique-3.spec33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/isolation/specs/read-write-unique-3.spec b/src/test/isolation/specs/read-write-unique-3.spec
new file mode 100644
index 0000000..cba2c4c
--- /dev/null
+++ b/src/test/isolation/specs/read-write-unique-3.spec
@@ -0,0 +1,33 @@
+# Read-write-unique test.
+# From bug report 9301.
+
+setup
+{
+ CREATE TABLE test (
+ key integer UNIQUE,
+ val text
+ );
+
+ CREATE OR REPLACE FUNCTION insert_unique(k integer, v text) RETURNS void
+ LANGUAGE SQL AS $$
+ INSERT INTO test (key, val) SELECT k, v WHERE NOT EXISTS (SELECT key FROM test WHERE key = k);
+ $$;
+}
+
+teardown
+{
+ DROP FUNCTION insert_unique(integer, text);
+ DROP TABLE test;
+}
+
+session s1
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step rw1 { SELECT insert_unique(1, '1'); }
+step c1 { COMMIT; }
+
+session s2
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step rw2 { SELECT insert_unique(1, '2'); }
+step c2 { COMMIT; }
+
+permutation rw1 rw2 c1 c2