Commit b39fd897 authored by Tom Lane's avatar Tom Lane

Improve regression test coverage of expand_tuple().

I was dissatisfied with the code coverage report for expand_tuple() in the
wake of commit 7c44c46d: 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
parent 50c6bb02
...@@ -145,6 +145,26 @@ accountid balance ...@@ -145,6 +145,26 @@ accountid balance
checking 1050 checking 1050
savings 600 savings 600
starting permutation: wx2_ext partiallock_ext c2 c1 read_ext
step wx2_ext: UPDATE accounts_ext SET balance = balance + 450;
step partiallock_ext:
SELECT * FROM accounts_ext a1, accounts_ext a2
WHERE a1.accountid = a2.accountid
FOR UPDATE OF a1;
<waiting ...>
step c2: COMMIT;
step partiallock_ext: <... completed>
accountid balance other newcol newcol2 accountid balance other newcol newcol2
checking 1050 other 42 checking 600 other 42
savings 1150 42 savings 700 42
step c1: COMMIT;
step read_ext: SELECT * FROM accounts_ext ORDER BY accountid;
accountid balance other newcol newcol2
checking 1050 other 42
savings 1150 42
starting permutation: updateforss readforss c1 c2 starting permutation: updateforss readforss c1 c2
step updateforss: step updateforss:
UPDATE table_a SET value = 'newTableAValue' WHERE id = 1; UPDATE table_a SET value = 'newTableAValue' WHERE id = 1;
......
...@@ -9,6 +9,11 @@ setup ...@@ -9,6 +9,11 @@ setup
CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null); CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null);
INSERT INTO accounts VALUES ('checking', 600), ('savings', 600); INSERT INTO accounts VALUES ('checking', 600), ('savings', 600);
CREATE TABLE accounts_ext (accountid text PRIMARY KEY, balance numeric not null, other text);
INSERT INTO accounts_ext VALUES ('checking', 600, 'other'), ('savings', 700, null);
ALTER TABLE accounts_ext ADD COLUMN newcol int DEFAULT 42;
ALTER TABLE accounts_ext ADD COLUMN newcol2 text DEFAULT NULL;
CREATE TABLE p (a int, b int, c int); CREATE TABLE p (a int, b int, c int);
CREATE TABLE c1 () INHERITS (p); CREATE TABLE c1 () INHERITS (p);
CREATE TABLE c2 () INHERITS (p); CREATE TABLE c2 () INHERITS (p);
...@@ -29,6 +34,7 @@ setup ...@@ -29,6 +34,7 @@ setup
teardown teardown
{ {
DROP TABLE accounts; DROP TABLE accounts;
DROP TABLE accounts_ext;
DROP TABLE p CASCADE; DROP TABLE p CASCADE;
DROP TABLE table_a, table_b, jointest; DROP TABLE table_a, table_b, jointest;
} }
...@@ -72,6 +78,11 @@ step "lockwithvalues" { ...@@ -72,6 +78,11 @@ step "lockwithvalues" {
WHERE a1.accountid = v.id WHERE a1.accountid = v.id
FOR UPDATE OF a1; FOR UPDATE OF a1;
} }
step "partiallock_ext" {
SELECT * FROM accounts_ext a1, accounts_ext a2
WHERE a1.accountid = a2.accountid
FOR UPDATE OF a1;
}
# these tests exercise EvalPlanQual with a SubLink sub-select (which should be # these tests exercise EvalPlanQual with a SubLink sub-select (which should be
# unaffected by any EPQ recheck behavior in the outer query); cf bug #14034 # unaffected by any EPQ recheck behavior in the outer query); cf bug #14034
...@@ -105,6 +116,7 @@ step "upsert2" { ...@@ -105,6 +116,7 @@ step "upsert2" {
INSERT INTO accounts SELECT 'savings', 1234 INSERT INTO accounts SELECT 'savings', 1234
WHERE NOT EXISTS (SELECT 1 FROM upsert); WHERE NOT EXISTS (SELECT 1 FROM upsert);
} }
step "wx2_ext" { UPDATE accounts_ext SET balance = balance + 450; }
step "readp2" { SELECT tableoid::regclass, ctid, * FROM p WHERE b IN (0, 1) AND c = 0 FOR UPDATE; } step "readp2" { SELECT tableoid::regclass, ctid, * FROM p WHERE b IN (0, 1) AND c = 0 FOR UPDATE; }
step "returningp1" { step "returningp1" {
WITH u AS ( UPDATE p SET b = b WHERE a > 0 RETURNING * ) WITH u AS ( UPDATE p SET b = b WHERE a > 0 RETURNING * )
...@@ -124,6 +136,7 @@ step "c2" { COMMIT; } ...@@ -124,6 +136,7 @@ step "c2" { COMMIT; }
session "s3" session "s3"
setup { BEGIN ISOLATION LEVEL READ COMMITTED; } setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
step "read" { SELECT * FROM accounts ORDER BY accountid; } step "read" { SELECT * FROM accounts ORDER BY accountid; }
step "read_ext" { SELECT * FROM accounts_ext ORDER BY accountid; }
# this test exercises EvalPlanQual with a CTE, cf bug #14328 # this test exercises EvalPlanQual with a CTE, cf bug #14328
step "readwcte" { step "readwcte" {
...@@ -156,6 +169,7 @@ permutation "readp1" "writep1" "readp2" "c1" "c2" ...@@ -156,6 +169,7 @@ permutation "readp1" "writep1" "readp2" "c1" "c2"
permutation "writep2" "returningp1" "c1" "c2" permutation "writep2" "returningp1" "c1" "c2"
permutation "wx2" "partiallock" "c2" "c1" "read" permutation "wx2" "partiallock" "c2" "c1" "read"
permutation "wx2" "lockwithvalues" "c2" "c1" "read" permutation "wx2" "lockwithvalues" "c2" "c1" "read"
permutation "wx2_ext" "partiallock_ext" "c2" "c1" "read_ext"
permutation "updateforss" "readforss" "c1" "c2" permutation "updateforss" "readforss" "c1" "c2"
permutation "wrtwcte" "readwcte" "c1" "c2" permutation "wrtwcte" "readwcte" "c1" "c2"
permutation "wrjt" "selectjoinforupdate" "c2" "c1" permutation "wrjt" "selectjoinforupdate" "c2" "c1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment