From 61eb670518c395b49dedfb5892dc5a16255671ef Mon Sep 17 00:00:00 2001
From: Dean Rasheed <dean.a.rasheed@gmail.com>
Date: Sat, 21 Nov 2026 12:56:49 +0000
Subject: [PATCH v1 2/2] Test inline isolation test steps.

Not intended to be pushed.
---
 .../expected/inline-alter-domain-validate.out | 23 ++++++
 .../expected/inline-deadlock-hard.out         | 36 +++++++++
 src/test/isolation/isolation_schedule         |  2 +
 .../specs/inline-alter-domain-validate.spec   | 28 +++++++
 .../isolation/specs/inline-deadlock-hard.spec | 76 +++++++++++++++++++
 5 files changed, 165 insertions(+)
 create mode 100644 src/test/isolation/expected/inline-alter-domain-validate.out
 create mode 100644 src/test/isolation/expected/inline-deadlock-hard.out
 create mode 100644 src/test/isolation/specs/inline-alter-domain-validate.spec
 create mode 100644 src/test/isolation/specs/inline-deadlock-hard.spec

diff --git a/src/test/isolation/expected/inline-alter-domain-validate.out b/src/test/isolation/expected/inline-alter-domain-validate.out
new file mode 100644
index 00000000000..7356dee4ff0
--- /dev/null
+++ b/src/test/isolation/expected/inline-alter-domain-validate.out
@@ -0,0 +1,23 @@
+Parsed test spec with 3 sessions
+
+starting permutation: s1[1] s2[1] s3[1] s3[2] s1[2] s3[3] s3[4]
+step s1[1]: DO $$ BEGIN PERFORM pg_advisory_lock(8888); END $$;
+step s2[1]: WITH wait AS MATERIALIZED (SELECT pg_advisory_lock(8888)) INSERT INTO alter_domain_validate_t SELECT (-1)::alter_domain_validate_d FROM wait; <waiting ...>
+step s3[1]: ALTER DOMAIN alter_domain_validate_d ADD CONSTRAINT alter_domain_validate_d_pos CHECK (VALUE > 0) NOT VALID;
+step s3[2]: ALTER DOMAIN alter_domain_validate_d VALIDATE CONSTRAINT alter_domain_validate_d_pos; <waiting ...>
+step s1[2]: DO $$ BEGIN PERFORM pg_advisory_unlock(8888); END $$;
+step s2[1]: <... completed>
+step s3[2]: <... completed>
+ERROR:  column "a" of table "alter_domain_validate_t" contains values that violate the new constraint
+step s3[3]: SELECT convalidated FROM pg_constraint WHERE conname = 'alter_domain_validate_d_pos';
+convalidated
+------------
+f           
+(1 row)
+
+step s3[4]: SELECT count(*) FROM alter_domain_validate_t;
+count
+-----
+    1
+(1 row)
+
diff --git a/src/test/isolation/expected/inline-deadlock-hard.out b/src/test/isolation/expected/inline-deadlock-hard.out
new file mode 100644
index 00000000000..19d6bfe5a37
--- /dev/null
+++ b/src/test/isolation/expected/inline-deadlock-hard.out
@@ -0,0 +1,36 @@
+Parsed test spec with 8 sessions
+
+starting permutation: s1[1] s2[1] s3[1] s4[1] s5[1] s6[1] s7[1] s8[1] s1[2] s2[2] s3[2] s4[2] s5[2] s6[2] s7[2] s8[2] s8[3] s7[3] s6[3] s5[3] s4[3] s3[3] s2[3] s1[3]
+step s1[1]: LOCK TABLE a1;
+step s2[1]: LOCK TABLE a2;
+step s3[1]: LOCK TABLE a3;
+step s4[1]: LOCK TABLE a4;
+step s5[1]: LOCK TABLE a5;
+step s6[1]: LOCK TABLE a6;
+step s7[1]: LOCK TABLE a7;
+step s8[1]: LOCK TABLE a8;
+step s1[2]: LOCK TABLE a2; <waiting ...>
+step s2[2]: LOCK TABLE a3; <waiting ...>
+step s3[2]: LOCK TABLE a4; <waiting ...>
+step s4[2]: LOCK TABLE a5; <waiting ...>
+step s5[2]: LOCK TABLE a6; <waiting ...>
+step s6[2]: LOCK TABLE a7; <waiting ...>
+step s7[2]: LOCK TABLE a8; <waiting ...>
+step s8[2]: LOCK TABLE a1; <waiting ...>
+step s8[2]: <... completed>
+ERROR:  deadlock detected
+step s7[2]: <... completed>
+step s8[3]: COMMIT;
+step s7[3]: COMMIT;
+step s6[2]: <... completed>
+step s6[3]: COMMIT;
+step s5[2]: <... completed>
+step s5[3]: COMMIT;
+step s4[2]: <... completed>
+step s4[3]: COMMIT;
+step s3[2]: <... completed>
+step s3[3]: COMMIT;
+step s2[2]: <... completed>
+step s2[3]: COMMIT;
+step s1[2]: <... completed>
+step s1[3]: COMMIT;
diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule
index 3831004b74d..6acf7697fe4 100644
--- a/src/test/isolation/isolation_schedule
+++ b/src/test/isolation/isolation_schedule
@@ -1,3 +1,5 @@
+test: inline-alter-domain-validate
+test: inline-deadlock-hard
 test: read-only-anomaly
 test: read-only-anomaly-2
 test: read-only-anomaly-3
diff --git a/src/test/isolation/specs/inline-alter-domain-validate.spec b/src/test/isolation/specs/inline-alter-domain-validate.spec
new file mode 100644
index 00000000000..ed71c5d5417
--- /dev/null
+++ b/src/test/isolation/specs/inline-alter-domain-validate.spec
@@ -0,0 +1,28 @@
+# Test inline permutation steps from alter-domain-validate.spec
+
+setup
+{
+	CREATE DOMAIN alter_domain_validate_d AS int;
+	CREATE TABLE alter_domain_validate_t (a alter_domain_validate_d);
+}
+
+teardown
+{
+	DROP TABLE alter_domain_validate_t;
+	DROP DOMAIN alter_domain_validate_d;
+}
+
+session s1
+session s2
+session s3
+
+permutation
+  s1 { DO $$ BEGIN PERFORM pg_advisory_lock(8888); END $$; }
+  # CoerceToDomain initializes the domain constraint list during executor
+  # startup, before this CTE waits on the advisory lock.
+  s2 { WITH wait AS MATERIALIZED (SELECT pg_advisory_lock(8888)) INSERT INTO alter_domain_validate_t SELECT (-1)::alter_domain_validate_d FROM wait; }
+  s3 { ALTER DOMAIN alter_domain_validate_d ADD CONSTRAINT alter_domain_validate_d_pos CHECK (VALUE > 0) NOT VALID; }
+  s3 { ALTER DOMAIN alter_domain_validate_d VALIDATE CONSTRAINT alter_domain_validate_d_pos; }
+  s1 { DO $$ BEGIN PERFORM pg_advisory_unlock(8888); END $$; }
+  s3 { SELECT convalidated FROM pg_constraint WHERE conname = 'alter_domain_validate_d_pos'; }
+  s3 { SELECT count(*) FROM alter_domain_validate_t; }
diff --git a/src/test/isolation/specs/inline-deadlock-hard.spec b/src/test/isolation/specs/inline-deadlock-hard.spec
new file mode 100644
index 00000000000..f3c27788155
--- /dev/null
+++ b/src/test/isolation/specs/inline-deadlock-hard.spec
@@ -0,0 +1,76 @@
+# Test inline permutation steps from deadlock-hard.spec
+
+setup
+{
+  CREATE TABLE a1 ();
+  CREATE TABLE a2 ();
+  CREATE TABLE a3 ();
+  CREATE TABLE a4 ();
+  CREATE TABLE a5 ();
+  CREATE TABLE a6 ();
+  CREATE TABLE a7 ();
+  CREATE TABLE a8 ();
+}
+
+teardown
+{
+  DROP TABLE a1, a2, a3, a4, a5, a6, a7, a8;
+}
+
+session s1
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s2
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s3
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s4
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s5
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s6
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s7
+setup		{ BEGIN; SET deadlock_timeout = '100s'; }
+
+session s8
+setup		{ BEGIN; SET deadlock_timeout = '10ms'; }
+
+# Note: when s8[2] detects the deadlock and fails, s7[2] is released, making
+# it timing-dependent which query completion is received first by the tester.
+# To ensure output stability, add a blocking mark to force s8[2]'s completion
+# to be reported first.  There is a second timing dependency, too: the tester
+# might or might not observe s8[2] during its short lock wait state.  Apply a
+# dummy blocking mark to s8[2] to ensure it will be reported as "waiting"
+# regardless of that.
+
+permutation
+  s1 { LOCK TABLE a1; }
+  s2 { LOCK TABLE a2; }
+  s3 { LOCK TABLE a3; }
+  s4 { LOCK TABLE a4; }
+  s5 { LOCK TABLE a5; }
+  s6 { LOCK TABLE a6; }
+  s7 { LOCK TABLE a7; }
+  s8 { LOCK TABLE a8; }
+  s1 { LOCK TABLE a2; }
+  s2 { LOCK TABLE a3; }
+  s3 { LOCK TABLE a4; }
+  s4 { LOCK TABLE a5; }
+  s5 { LOCK TABLE a6; }
+  s6 { LOCK TABLE a7; }
+  s7("s8[2]") { LOCK TABLE a8; }
+  s8(*) { LOCK TABLE a1; }
+  s8 { COMMIT; }
+  s7 { COMMIT; }
+  s6 { COMMIT; }
+  s5 { COMMIT; }
+  s4 { COMMIT; }
+  s3 { COMMIT; }
+  s2 { COMMIT; }
+  s1 { COMMIT; }
-- 
2.51.0

