Fix parent node of WCO expressions in partitioned tables.
authorAndres Freund <andres@anarazel.de>
Tue, 6 Mar 2018 01:49:59 +0000 (17:49 -0800)
committerAndres Freund <andres@anarazel.de>
Tue, 6 Mar 2018 01:49:59 +0000 (17:49 -0800)
Since edd44738bc8814 WCO expressions of partitioned tables are
initialized with the first subplan as parent. That's not correct, as
the correct context is the ModifyTableState node. That's also what is
used for RETURNING processing, initialized nearby.

This appears not to cause any visible problems for in core code, but
is problematic for in development patch.

Discussion: https://postgr.es/m/20180303043818.tnvlo243bgy7una3@alap3.anarazel.de

src/backend/executor/execPartition.c

index 54efc9e5452cef67799069775abc30898822dd75..f6fe7cd61d9d1f72832b57993914c36dfa92550c 100644 (file)
@@ -413,7 +413,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate,
        {
            WithCheckOption *wco = castNode(WithCheckOption, lfirst(ll));
            ExprState  *wcoExpr = ExecInitQual(castNode(List, wco->qual),
-                                              mtstate->mt_plans[0]);
+                                              &mtstate->ps);
 
            wcoExprs = lappend(wcoExprs, wcoExpr);
        }