Skip to content

Commit 148e632

Browse files
committed
Fix parent of WCO qual.
The parent of some WCO expressions was, apparently by accident, set to the the source of DML queries, rather than the target table. This causes problems for the upcoming pluggable storage work, because the target and source table might be of different storage types. It's possible that this is already problematic, but neither experimenting nor inquiries on -hackers have found them. So don't backpatch for now. Author: Andres Freund Discussion: https://postgr.es/m/[email protected]
1 parent 1c53c4d commit 148e632

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/backend/executor/nodeModifyTable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
22702270
{
22712271
WithCheckOption *wco = (WithCheckOption *) lfirst(ll);
22722272
ExprState *wcoExpr = ExecInitQual((List *) wco->qual,
2273-
mtstate->mt_plans[i]);
2273+
&mtstate->ps);
22742274

22752275
wcoExprs = lappend(wcoExprs, wcoExpr);
22762276
}

src/test/regress/expected/updatable_views.out

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,31 +1782,31 @@ UPDATE rw_view1 SET a = a + 5; -- should fail
17821782
ERROR: new row violates check option for view "rw_view1"
17831783
DETAIL: Failing row contains (15).
17841784
EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (5);
1785-
QUERY PLAN
1786-
---------------------------------------------------------------
1785+
QUERY PLAN
1786+
---------------------------------------------------------
17871787
Insert on base_tbl b
17881788
-> Result
1789-
SubPlan 1
1790-
-> Index Only Scan using ref_tbl_pkey on ref_tbl r
1791-
Index Cond: (a = b.a)
1792-
SubPlan 2
1793-
-> Seq Scan on ref_tbl r_1
1789+
SubPlan 1
1790+
-> Index Only Scan using ref_tbl_pkey on ref_tbl r
1791+
Index Cond: (a = b.a)
1792+
SubPlan 2
1793+
-> Seq Scan on ref_tbl r_1
17941794
(7 rows)
17951795

17961796
EXPLAIN (costs off) UPDATE rw_view1 SET a = a + 5;
1797-
QUERY PLAN
1798-
-----------------------------------------------------------------
1797+
QUERY PLAN
1798+
-----------------------------------------------------------
17991799
Update on base_tbl b
18001800
-> Hash Join
18011801
Hash Cond: (b.a = r.a)
18021802
-> Seq Scan on base_tbl b
18031803
-> Hash
18041804
-> Seq Scan on ref_tbl r
1805-
SubPlan 1
1806-
-> Index Only Scan using ref_tbl_pkey on ref_tbl r_1
1807-
Index Cond: (a = b.a)
1808-
SubPlan 2
1809-
-> Seq Scan on ref_tbl r_2
1805+
SubPlan 1
1806+
-> Index Only Scan using ref_tbl_pkey on ref_tbl r_1
1807+
Index Cond: (a = b.a)
1808+
SubPlan 2
1809+
-> Seq Scan on ref_tbl r_2
18101810
(11 rows)
18111811

18121812
DROP TABLE base_tbl, ref_tbl CASCADE;

0 commit comments

Comments
 (0)