Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46d0a9b

Browse files
committed
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.
1 parent c6fbe6d commit 46d0a9b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/backend/optimizer/plan/setrefs.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,11 @@ flatten_rtes_walker(Node *node, PlannerGlobal *glob)
372372
*
373373
* In the flat rangetable, we zero out substructure pointers that are not
374374
* needed by the executor; this reduces the storage space and copying cost
375-
* for cached plans. We keep only the alias and eref Alias fields, which are
376-
* needed by EXPLAIN, and the selectedCols, insertedCols and updatedCols
377-
* bitmaps, which are needed for executor-startup permissions checking and for
378-
* trigger event checking.
375+
* for cached plans. We keep only the tablesample field (which we'd otherwise
376+
* have to put in the plan tree, anyway); the ctename, alias and eref Alias
377+
* fields, which are needed by EXPLAIN; and the selectedCols, insertedCols and
378+
* updatedCols bitmaps, which are needed for executor-startup permissions
379+
* checking and for trigger event checking.
379380
*/
380381
static void
381382
add_rte_to_flat_rtable(PlannerGlobal *glob, RangeTblEntry *rte)
@@ -395,6 +396,7 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, RangeTblEntry *rte)
395396
newrte->ctecoltypes = NIL;
396397
newrte->ctecoltypmods = NIL;
397398
newrte->ctecolcollations = NIL;
399+
newrte->securityQuals = NIL;
398400

399401
glob->finalrtable = lappend(glob->finalrtable, newrte);
400402

@@ -1199,7 +1201,7 @@ set_customscan_references(PlannerInfo *root,
11991201
}
12001202

12011203
/* Adjust child plan-nodes recursively, if needed */
1202-
foreach (lc, cscan->custom_plans)
1204+
foreach(lc, cscan->custom_plans)
12031205
{
12041206
lfirst(lc) = set_plan_refs(root, (Plan *) lfirst(lc), rtoffset);
12051207
}

0 commit comments

Comments
 (0)