aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/createplan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-05-08 16:59:09 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2013-05-08 16:59:58 -0400
commita7b965382cf0cb30aeacb112572718045e6d4be7 (patch)
tree067cbc56f7ccdf4c76715fdffd2e4a832c17f654 /src/backend/optimizer/plan/createplan.c
parent4b06c1820a1b96769ea7447a0fc8e0edabbf57f5 (diff)
downloadpostgresql-a7b965382cf0cb30aeacb112572718045e6d4be7.tar.gz
postgresql-a7b965382cf0cb30aeacb112572718045e6d4be7.zip
Better fix for permissions tests in excluded subqueries.
This reverts the code changes in 50c137487c96e629e0e5372bb3d1b5f1a2f71a88, which turned out to induce crashes and not completely fix the problem anyway. That commit only considered single subqueries that were excluded by constraint-exclusion logic, but actually the problem also exists for subqueries that are appendrel members (ie part of a UNION ALL list). In such cases we can't add a dummy subpath to the appendrel's AppendPath list without defeating the logic that recognizes when an appendrel is completely excluded. Instead, fix the problem by having setrefs.c scan the rangetable an extra time looking for subqueries that didn't get into the plan tree. (This approach depends on the 9.2 change that made set_subquery_pathlist generate dummy paths for excluded single subqueries, so that the exclusion behavior is the same for single subqueries and appendrel members.) Note: it turns out that the appendrel form of the missed-permissions-checks bug exists as far back as 8.4. However, since the practical effect of that bug seems pretty minimal, consensus is to not attempt to fix it in the back branches, at least not yet. Possibly we could back-port this patch once it's gotten a reasonable amount of testing in HEAD. For the moment I'm just going to revert the previous patch in 9.2.
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r--src/backend/optimizer/plan/createplan.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index e43ef3aa898..52bab79007e 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -678,8 +678,7 @@ static Plan *
create_append_plan(PlannerInfo *root, AppendPath *best_path)
{
Append *plan;
- RelOptInfo *rel = best_path->path.parent;
- List *tlist = build_relation_tlist(rel);
+ List *tlist = build_relation_tlist(best_path->path.parent);
List *subplans = NIL;
ListCell *subpaths;
@@ -694,30 +693,12 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path)
*/
if (best_path->subpaths == NIL)
{
- /*
- * If this is a dummy path for a subquery, we have to wrap the
- * subquery's original plan in a SubqueryScan so that setrefs.c will
- * do the right things. (In particular, it must pull up the
- * subquery's rangetable so that the executor will apply permissions
- * checks to those rels at runtime.)
- */
- if (rel->rtekind == RTE_SUBQUERY)
- {
- Assert(is_dummy_plan(rel->subplan));
- return (Plan *) make_subqueryscan(tlist,
- NIL,
- rel->relid,
- rel->subplan);
- }
- else
- {
- /* Generate a Result plan with constant-FALSE gating qual */
- return (Plan *) make_result(root,
- tlist,
- (Node *) list_make1(makeBoolConst(false,
- false)),
- NULL);
- }
+ /* Generate a Result plan with constant-FALSE gating qual */
+ return (Plan *) make_result(root,
+ tlist,
+ (Node *) list_make1(makeBoolConst(false,
+ false)),
+ NULL);
}
/* Build the plan for each child */