aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-07-21 20:03:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-07-21 20:03:58 -0400
commit46d0a9bfac3d5221702318cc1cf119221d729c84 (patch)
tree8ad95b8fad968f693e24f17d49969d19851d35d4 /src
parentc6fbe6d6fb828f50b9d67627588eb5ab8bd25e47 (diff)
downloadpostgresql-46d0a9bfac3d5221702318cc1cf119221d729c84.tar.gz
postgresql-46d0a9bfac3d5221702318cc1cf119221d729c84.zip
Fix add_rte_to_flat_rtable() for recent feature additions.
The TABLESAMPLE and row security patches each overlooked this function, though their errors of omission were opposite: RLS failed to zero out the securityQuals field, leading to wasteful copying of useless expression trees in finished plans, while TABLESAMPLE neglected to add a comment saying that it intentionally *isn't* deleting the tablesample subtree. There probably should be a similar comment about ctename, too. Back-patch as appropriate.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/setrefs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index 46d84d39a00..258e541754a 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -372,10 +372,11 @@ flatten_rtes_walker(Node *node, PlannerGlobal *glob)
*
* In the flat rangetable, we zero out substructure pointers that are not
* needed by the executor; this reduces the storage space and copying cost
- * for cached plans. We keep only the alias and eref Alias fields, which are
- * needed by EXPLAIN, and the selectedCols, insertedCols and updatedCols
- * bitmaps, which are needed for executor-startup permissions checking and for
- * trigger event checking.
+ * for cached plans. We keep only the tablesample field (which we'd otherwise
+ * have to put in the plan tree, anyway); the ctename, alias and eref Alias
+ * fields, which are needed by EXPLAIN; and the selectedCols, insertedCols and
+ * updatedCols bitmaps, which are needed for executor-startup permissions
+ * checking and for trigger event checking.
*/
static void
add_rte_to_flat_rtable(PlannerGlobal *glob, RangeTblEntry *rte)
@@ -395,6 +396,7 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, RangeTblEntry *rte)
newrte->ctecoltypes = NIL;
newrte->ctecoltypmods = NIL;
newrte->ctecolcollations = NIL;
+ newrte->securityQuals = NIL;
glob->finalrtable = lappend(glob->finalrtable, newrte);
@@ -1199,7 +1201,7 @@ set_customscan_references(PlannerInfo *root,
}
/* Adjust child plan-nodes recursively, if needed */
- foreach (lc, cscan->custom_plans)
+ foreach(lc, cscan->custom_plans)
{
lfirst(lc) = set_plan_refs(root, (Plan *) lfirst(lc), rtoffset);
}