summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/two-ids.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/two-ids.spec
parentInitial commit. (diff)
downloadpostgresql-14-46651ce6fe013220ed397add242004d764fc0153.tar.xz
postgresql-14-46651ce6fe013220ed397add242004d764fc0153.zip
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/isolation/specs/two-ids.spec')
-rw-r--r--src/test/isolation/specs/two-ids.spec40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/isolation/specs/two-ids.spec b/src/test/isolation/specs/two-ids.spec
new file mode 100644
index 0000000..fc0289f
--- /dev/null
+++ b/src/test/isolation/specs/two-ids.spec
@@ -0,0 +1,40 @@
+# Two IDs test
+#
+# Small, simple test showing read-only anomalies.
+#
+# There are only four permutations which must cause a serialization failure.
+# Required failure cases are where s2 overlaps both s1 and s3, but s1
+# commits before s3 executes its first SELECT.
+#
+# If s3 were declared READ ONLY there would be no false positives.
+# With s3 defaulting to READ WRITE, we currently expect 12 false
+# positives. Further work dealing with de facto READ ONLY transactions
+# may be able to reduce or eliminate those false positives.
+
+setup
+{
+ create table D1 (id int not null);
+ create table D2 (id int not null);
+ insert into D1 values (1);
+ insert into D2 values (1);
+}
+
+teardown
+{
+ DROP TABLE D1, D2;
+}
+
+session s1
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step wx1 { update D1 set id = id + 1; }
+step c1 { COMMIT; }
+
+session s2
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step rxwy2 { update D2 set id = (select id+1 from D1); }
+step c2 { COMMIT; }
+
+session s3
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step ry3 { select id from D2; }
+step c3 { COMMIT; }