summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/sequence-ddl.spec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:17:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:17:33 +0000
commit5e45211a64149b3c659b90ff2de6fa982a5a93ed (patch)
tree739caf8c461053357daa9f162bef34516c7bf452 /src/test/isolation/specs/sequence-ddl.spec
parentInitial commit. (diff)
downloadpostgresql-15-5e45211a64149b3c659b90ff2de6fa982a5a93ed.tar.xz
postgresql-15-5e45211a64149b3c659b90ff2de6fa982a5a93ed.zip
Adding upstream version 15.5.upstream/15.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/isolation/specs/sequence-ddl.spec')
-rw-r--r--src/test/isolation/specs/sequence-ddl.spec41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/isolation/specs/sequence-ddl.spec b/src/test/isolation/specs/sequence-ddl.spec
new file mode 100644
index 0000000..7ead8af
--- /dev/null
+++ b/src/test/isolation/specs/sequence-ddl.spec
@@ -0,0 +1,41 @@
+# Test sequence usage and concurrent sequence DDL
+
+setup
+{
+ CREATE SEQUENCE seq1;
+}
+
+teardown
+{
+ DROP SEQUENCE seq1;
+}
+
+session s1
+setup { BEGIN; }
+step s1alter { ALTER SEQUENCE seq1 MAXVALUE 10; }
+step s1alter2 { ALTER SEQUENCE seq1 MAXVALUE 20; }
+step s1restart { ALTER SEQUENCE seq1 RESTART WITH 5; }
+step s1commit { COMMIT; }
+
+session s2
+step s2begin { BEGIN; }
+step s2nv { SELECT nextval('seq1') FROM generate_series(1, 15); }
+step s2commit { COMMIT; }
+
+permutation s1alter s1commit s2nv
+
+# Prior to PG10, the s2nv step would see the uncommitted s1alter
+# change, but now it waits.
+permutation s1alter s2nv s1commit
+
+# Prior to PG10, the s2nv step would see the uncommitted s1restart
+# change, but now it waits.
+permutation s1restart s2nv s1commit
+
+# In contrast to ALTER setval() is non-transactional, so it doesn't
+# have to wait.
+permutation s1restart s2nv s1commit
+
+# nextval doesn't release lock until transaction end, so s1alter2 has
+# to wait for s2commit.
+permutation s2begin s2nv s1alter2 s2commit s1commit