Skip to content

Commit 8ffc2aa

Browse files
committed
Add EvalPlanQual delete returning isolation test
Author: Andres Freund Reviewed-by: Pavel Borisov Discussion: https://www.postgresql.org/message-id/flat/CAPpHfdua-YFw3XTprfutzGp28xXLigFtzNbuFY8yPhqeq6X5kg%40mail.gmail.com
1 parent 87985cc commit 8ffc2aa

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/test/isolation/expected/eval-plan-qual.out

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,36 @@ savings | 600| 1200
746746
(2 rows)
747747

748748

749+
starting permutation: read wx2 wb1 c2 c1 read
750+
step read: SELECT * FROM accounts ORDER BY accountid;
751+
accountid|balance|balance2
752+
---------+-------+--------
753+
checking | 600| 1200
754+
savings | 600| 1200
755+
(2 rows)
756+
757+
step wx2: UPDATE accounts SET balance = balance + 450 WHERE accountid = 'checking' RETURNING balance;
758+
balance
759+
-------
760+
1050
761+
(1 row)
762+
763+
step wb1: DELETE FROM accounts WHERE balance = 600 RETURNING *; <waiting ...>
764+
step c2: COMMIT;
765+
step wb1: <... completed>
766+
accountid|balance|balance2
767+
---------+-------+--------
768+
savings | 600| 1200
769+
(1 row)
770+
771+
step c1: COMMIT;
772+
step read: SELECT * FROM accounts ORDER BY accountid;
773+
accountid|balance|balance2
774+
---------+-------+--------
775+
checking | 1050| 2100
776+
(1 row)
777+
778+
749779
starting permutation: upsert1 upsert2 c1 c2 read
750780
step upsert1:
751781
WITH upsert AS

src/test/isolation/specs/eval-plan-qual.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
7676
step wx1 { UPDATE accounts SET balance = balance - 200 WHERE accountid = 'checking' RETURNING balance; }
7777
# wy1 then wy2 checks the case where quals pass then fail
7878
step wy1 { UPDATE accounts SET balance = balance + 500 WHERE accountid = 'checking' RETURNING balance; }
79+
# wx2 then wb1 checks the case of re-fetching up-to-date values for DELETE ... RETURNING ...
80+
step wb1 { DELETE FROM accounts WHERE balance = 600 RETURNING *; }
7981

8082
step wxext1 { UPDATE accounts_ext SET balance = balance - 200 WHERE accountid = 'checking' RETURNING balance; }
8183
step tocds1 { UPDATE accounts SET accountid = 'cds' WHERE accountid = 'checking'; }
@@ -353,6 +355,8 @@ permutation wx1 delwcte c1 c2 read
353355
# test that a delete to a self-modified row throws error when
354356
# previously updated by a different cid
355357
permutation wx1 delwctefail c1 c2 read
358+
# test that a delete re-fetches up-to-date values for returning clause
359+
permutation read wx2 wb1 c2 c1 read
356360

357361
permutation upsert1 upsert2 c1 c2 read
358362
permutation readp1 writep1 readp2 c1 c2

0 commit comments

Comments
 (0)