| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Allow isolation test steps to be declared inline. |
| Date: | 2026-11-21 14:12:32 |
| Message-ID: | CAEZATCWg5_OXNrX=AbAHuJ25yeEbTrjX3Ku6ZvV38B8SsJsCAA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
One thing I find annoying when adding new isolation tests is finding
an appropriate place for the new tests, and figuring out whether any
currently defined steps can be reused. If new steps are needed, the
result often seems to be a confusing mess of cryptically named steps,
resulting in something that's not very readable, and only seems to get
worse as more tests are added.
The attached patch allows permutation steps to be written inline,
using the syntax "<session name> { <SQL> }". Thus, for example,
instead of writing this:
permutation "delete1" "insert1" "merge2" "c1" "select2" "c2"
where all the steps are defined elsewhere, the test can be written in
a fully self-contained form like this:
permutation
s1 { DELETE FROM target WHERE key = 1; }
s1 { INSERT INTO target VALUES (1, 'insert1'); }
s2 {
MERGE INTO target t
USING (SELECT 1 as key, 'merge2' as val) s ON s.key = t.key
WHEN NOT MATCHED THEN INSERT VALUES (s.key, s.val)
WHEN MATCHED THEN UPDATE set val = t.val || ' updated by merge2';
}
s1 { COMMIT; }
s2 { SELECT * FROM target; }
s2 { COMMIT; }
That won't be appropriate for all isolation tests (particularly when
there are a large number of permutations sharing the same steps), but
I do think it would be useful a lot of the time when adding new tests.
I'm not proposing to rewrite any existing tests. 0002 (not intended
for commit) does that for a couple of spec files, just to check that
the feature works.
IMO, the inline form is much easier to read, and it makes it easier to
add new tests to existing spec files. It also makes it easier to share
proposed new tests in email threads.
Thoughts?
Regards,
Dean
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-POC-Allow-isolation-test-steps-to-be-declared-inl.patch | text/x-patch | 9.6 KB |
| v1-0002-Test-inline-isolation-test-steps.patch | text/x-patch | 7.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-11-21 14:26:17 | Re: [PATCH] Fix two client-side NULL dereferences on malformed result sets (libpq, pg_receivewal) |
| Previous Message | Andrew Dunstan | 2026-11-21 13:42:48 | Re: Table AM callback for logical decoding support (REPACK CONCURRENTLY) |