summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/partial-index.spec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
commit311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch)
tree0ec307299b1dada3701e42f4ca6eda57d708261e /src/test/isolation/specs/partial-index.spec
parentInitial commit. (diff)
downloadpostgresql-15-upstream.tar.xz
postgresql-15-upstream.zip
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/isolation/specs/partial-index.spec')
-rw-r--r--src/test/isolation/specs/partial-index.spec32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/isolation/specs/partial-index.spec b/src/test/isolation/specs/partial-index.spec
new file mode 100644
index 0000000..c033841
--- /dev/null
+++ b/src/test/isolation/specs/partial-index.spec
@@ -0,0 +1,32 @@
+# Partial Index test
+#
+# Make sure that an update which moves a row out of a partial index
+# is handled correctly. In early versions, an attempt at optimization
+# broke this behavior, allowing anomalies.
+#
+# Any overlap between the transactions must cause a serialization failure.
+
+setup
+{
+ create table test_t (id integer, val1 text, val2 integer);
+ create index test_idx on test_t(id) where val2 = 1;
+ insert into test_t (select generate_series(0, 10000), 'a', 2);
+ insert into test_t (select generate_series(0, 10), 'a', 1);
+}
+
+teardown
+{
+ DROP TABLE test_t;
+}
+
+session s1
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step rxy1 { select * from test_t where val2 = 1; }
+step wx1 { update test_t set val2 = 2 where val2 = 1 and id = 10; }
+step c1 { COMMIT; }
+
+session s2
+setup { BEGIN ISOLATION LEVEL SERIALIZABLE; }
+step wy2 { update test_t set val2 = 2 where val2 = 1 and id = 9; }
+step rxy2 { select * from test_t where val2 = 1; }
+step c2 { COMMIT; }