Skip to content

Commit b39fd89

Browse files
committed
Improve regression test coverage of expand_tuple().
I was dissatisfied with the code coverage report for expand_tuple() in the wake of commit 7c44c46: while better than no coverage at all, it was still not exercising the core function of inserting out-of-line default values, nor was the HeapTuple-output path covered. So far as I can find, the only code path that reaches the latter at present is EvalPlanQual fetches for non-locked tables. Hence, extend eval-plan-qual.spec to test cases where out-of-line defaults must be inserted into a tuple fetched from a non-locked table. Discussion: https://postgr.es/m/87woxi24uw.fsf@ansel.ydns.eu
1 parent 50c6bb0 commit b39fd89

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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,26 @@ accountid balance
145145
checking 1050
146146
savings 600
147147

148+
starting permutation: wx2_ext partiallock_ext c2 c1 read_ext
149+
step wx2_ext: UPDATE accounts_ext SET balance = balance + 450;
150+
step partiallock_ext:
151+
SELECT * FROM accounts_ext a1, accounts_ext a2
152+
WHERE a1.accountid = a2.accountid
153+
FOR UPDATE OF a1;
154+
<waiting ...>
155+
step c2: COMMIT;
156+
step partiallock_ext: <... completed>
157+
accountid balance other newcol newcol2 accountid balance other newcol newcol2
158+
159+
checking 1050 other 42 checking 600 other 42
160+
savings 1150 42 savings 700 42
161+
step c1: COMMIT;
162+
step read_ext: SELECT * FROM accounts_ext ORDER BY accountid;
163+
accountid balance other newcol newcol2
164+
165+
checking 1050 other 42
166+
savings 1150 42
167+
148168
starting permutation: updateforss readforss c1 c2
149169
step updateforss:
150170
UPDATE table_a SET value = 'newTableAValue' WHERE id = 1;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ setup
99
CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null);
1010
INSERT INTO accounts VALUES ('checking', 600), ('savings', 600);
1111

12+
CREATE TABLE accounts_ext (accountid text PRIMARY KEY, balance numeric not null, other text);
13+
INSERT INTO accounts_ext VALUES ('checking', 600, 'other'), ('savings', 700, null);
14+
ALTER TABLE accounts_ext ADD COLUMN newcol int DEFAULT 42;
15+
ALTER TABLE accounts_ext ADD COLUMN newcol2 text DEFAULT NULL;
16+
1217
CREATE TABLE p (a int, b int, c int);
1318
CREATE TABLE c1 () INHERITS (p);
1419
CREATE TABLE c2 () INHERITS (p);
@@ -29,6 +34,7 @@ setup
2934
teardown
3035
{
3136
DROP TABLE accounts;
37+
DROP TABLE accounts_ext;
3238
DROP TABLE p CASCADE;
3339
DROP TABLE table_a, table_b, jointest;
3440
}
@@ -72,6 +78,11 @@ step "lockwithvalues" {
7278
WHERE a1.accountid = v.id
7379
FOR UPDATE OF a1;
7480
}
81+
step "partiallock_ext" {
82+
SELECT * FROM accounts_ext a1, accounts_ext a2
83+
WHERE a1.accountid = a2.accountid
84+
FOR UPDATE OF a1;
85+
}
7586

7687
# these tests exercise EvalPlanQual with a SubLink sub-select (which should be
7788
# unaffected by any EPQ recheck behavior in the outer query); cf bug #14034
@@ -105,6 +116,7 @@ step "upsert2" {
105116
INSERT INTO accounts SELECT 'savings', 1234
106117
WHERE NOT EXISTS (SELECT 1 FROM upsert);
107118
}
119+
step "wx2_ext" { UPDATE accounts_ext SET balance = balance + 450; }
108120
step "readp2" { SELECT tableoid::regclass, ctid, * FROM p WHERE b IN (0, 1) AND c = 0 FOR UPDATE; }
109121
step "returningp1" {
110122
WITH u AS ( UPDATE p SET b = b WHERE a > 0 RETURNING * )
@@ -124,6 +136,7 @@ step "c2" { COMMIT; }
124136
session "s3"
125137
setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
126138
step "read" { SELECT * FROM accounts ORDER BY accountid; }
139+
step "read_ext" { SELECT * FROM accounts_ext ORDER BY accountid; }
127140

128141
# this test exercises EvalPlanQual with a CTE, cf bug #14328
129142
step "readwcte" {
@@ -156,6 +169,7 @@ permutation "readp1" "writep1" "readp2" "c1" "c2"
156169
permutation "writep2" "returningp1" "c1" "c2"
157170
permutation "wx2" "partiallock" "c2" "c1" "read"
158171
permutation "wx2" "lockwithvalues" "c2" "c1" "read"
172+
permutation "wx2_ext" "partiallock_ext" "c2" "c1" "read_ext"
159173
permutation "updateforss" "readforss" "c1" "c2"
160174
permutation "wrtwcte" "readwcte" "c1" "c2"
161175
permutation "wrjt" "selectjoinforupdate" "c2" "c1"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy