mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
pgindent run for 9.4
This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
This commit is contained in:
@@ -116,7 +116,7 @@ static Node *find_jointree_node_for_rel(Node *jtnode, int relid);
|
||||
*
|
||||
* A clause "foo op ANY (sub-SELECT)" can be processed by pulling the
|
||||
* sub-SELECT up to become a rangetable entry and treating the implied
|
||||
* comparisons as quals of a semijoin. However, this optimization *only*
|
||||
* comparisons as quals of a semijoin. However, this optimization *only*
|
||||
* works at the top level of WHERE or a JOIN/ON clause, because we cannot
|
||||
* distinguish whether the ANY ought to return FALSE or NULL in cases
|
||||
* involving NULL inputs. Also, in an outer join's ON clause we can only
|
||||
@@ -133,7 +133,7 @@ static Node *find_jointree_node_for_rel(Node *jtnode, int relid);
|
||||
* transformations if any are found.
|
||||
*
|
||||
* This routine has to run before preprocess_expression(), so the quals
|
||||
* clauses are not yet reduced to implicit-AND format. That means we need
|
||||
* clauses are not yet reduced to implicit-AND format. That means we need
|
||||
* to recursively search through explicit AND clauses, which are
|
||||
* probably only binary ANDs. We stop as soon as we hit a non-AND item.
|
||||
*/
|
||||
@@ -287,7 +287,7 @@ pull_up_sublinks_jointree_recurse(PlannerInfo *root, Node *jtnode,
|
||||
/*
|
||||
* Although we could include the pulled-up subqueries in the returned
|
||||
* relids, there's no need since upper quals couldn't refer to their
|
||||
* outputs anyway. But we *do* need to include the join's own rtindex
|
||||
* outputs anyway. But we *do* need to include the join's own rtindex
|
||||
* because we haven't yet collapsed join alias variables, so upper
|
||||
* levels would mistakenly think they couldn't use references to this
|
||||
* join.
|
||||
@@ -609,7 +609,7 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode)
|
||||
*
|
||||
* If this jointree node is within either side of an outer join, then
|
||||
* lowest_outer_join references the lowest such JoinExpr node; otherwise
|
||||
* it is NULL. We use this to constrain the effects of LATERAL subqueries.
|
||||
* it is NULL. We use this to constrain the effects of LATERAL subqueries.
|
||||
*
|
||||
* If this jointree node is within the nullable side of an outer join, then
|
||||
* lowest_nulling_outer_join references the lowest such JoinExpr node;
|
||||
@@ -759,7 +759,7 @@ pull_up_subqueries_recurse(PlannerInfo *root, Node *jtnode,
|
||||
* Attempt to pull up a single simple subquery.
|
||||
*
|
||||
* jtnode is a RangeTblRef that has been tentatively identified as a simple
|
||||
* subquery by pull_up_subqueries. We return the replacement jointree node,
|
||||
* subquery by pull_up_subqueries. We return the replacement jointree node,
|
||||
* or jtnode itself if we determine that the subquery can't be pulled up after
|
||||
* all.
|
||||
*
|
||||
@@ -792,7 +792,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
||||
* Create a PlannerInfo data structure for this subquery.
|
||||
*
|
||||
* NOTE: the next few steps should match the first processing in
|
||||
* subquery_planner(). Can we refactor to avoid code duplication, or
|
||||
* subquery_planner(). Can we refactor to avoid code duplication, or
|
||||
* would that just make things uglier?
|
||||
*/
|
||||
subroot = makeNode(PlannerInfo);
|
||||
@@ -842,7 +842,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
||||
|
||||
/*
|
||||
* Now we must recheck whether the subquery is still simple enough to pull
|
||||
* up. If not, abandon processing it.
|
||||
* up. If not, abandon processing it.
|
||||
*
|
||||
* We don't really need to recheck all the conditions involved, but it's
|
||||
* easier just to keep this "if" looking the same as the one in
|
||||
@@ -859,7 +859,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
||||
* Give up, return unmodified RangeTblRef.
|
||||
*
|
||||
* Note: The work we just did will be redone when the subquery gets
|
||||
* planned on its own. Perhaps we could avoid that by storing the
|
||||
* planned on its own. Perhaps we could avoid that by storing the
|
||||
* modified subquery back into the rangetable, but I'm not gonna risk
|
||||
* it now.
|
||||
*/
|
||||
@@ -900,7 +900,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
||||
* non-nullable items and lateral references may have to be turned into
|
||||
* PlaceHolderVars. If we are dealing with an appendrel member then
|
||||
* anything that's not a simple Var has to be turned into a
|
||||
* PlaceHolderVar. Set up required context data for pullup_replace_vars.
|
||||
* PlaceHolderVar. Set up required context data for pullup_replace_vars.
|
||||
*/
|
||||
rvcontext.root = root;
|
||||
rvcontext.targetlist = subquery->targetList;
|
||||
@@ -925,7 +925,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
||||
* replace any of the jointree structure. (This'd be a lot cleaner if we
|
||||
* could use query_tree_mutator.) We have to use PHVs in the targetList,
|
||||
* returningList, and havingQual, since those are certainly above any
|
||||
* outer join. replace_vars_in_jointree tracks its location in the
|
||||
* outer join. replace_vars_in_jointree tracks its location in the
|
||||
* jointree and uses PHVs or not appropriately.
|
||||
*/
|
||||
parse->targetList = (List *)
|
||||
@@ -1084,7 +1084,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
||||
* Pull up a single simple UNION ALL subquery.
|
||||
*
|
||||
* jtnode is a RangeTblRef that has been identified as a simple UNION ALL
|
||||
* subquery by pull_up_subqueries. We pull up the leaf subqueries and
|
||||
* subquery by pull_up_subqueries. We pull up the leaf subqueries and
|
||||
* build an "append relation" for the union set. The result value is just
|
||||
* jtnode, since we don't actually need to change the query jointree.
|
||||
*/
|
||||
@@ -1098,7 +1098,7 @@ pull_up_simple_union_all(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte)
|
||||
|
||||
/*
|
||||
* Make a modifiable copy of the subquery's rtable, so we can adjust
|
||||
* upper-level Vars in it. There are no such Vars in the setOperations
|
||||
* upper-level Vars in it. There are no such Vars in the setOperations
|
||||
* tree proper, so fixing the rtable should be sufficient.
|
||||
*/
|
||||
rtable = copyObject(subquery->rtable);
|
||||
@@ -1370,7 +1370,7 @@ is_simple_subquery(Query *subquery, RangeTblEntry *rte,
|
||||
|
||||
/*
|
||||
* Don't pull up a subquery that has any set-returning functions in its
|
||||
* targetlist. Otherwise we might well wind up inserting set-returning
|
||||
* targetlist. Otherwise we might well wind up inserting set-returning
|
||||
* functions into places where they mustn't go, such as quals of higher
|
||||
* queries.
|
||||
*/
|
||||
@@ -1379,7 +1379,7 @@ is_simple_subquery(Query *subquery, RangeTblEntry *rte,
|
||||
|
||||
/*
|
||||
* Don't pull up a subquery that has any volatile functions in its
|
||||
* targetlist. Otherwise we might introduce multiple evaluations of these
|
||||
* targetlist. Otherwise we might introduce multiple evaluations of these
|
||||
* functions, if they get copied to multiple places in the upper query,
|
||||
* leading to surprising results. (Note: the PlaceHolderVar mechanism
|
||||
* doesn't quite guarantee single evaluation; else we could pull up anyway
|
||||
@@ -1609,7 +1609,7 @@ replace_vars_in_jointree(Node *jtnode,
|
||||
/*
|
||||
* If the RangeTblRef refers to a LATERAL subquery (that isn't the
|
||||
* same subquery we're pulling up), it might contain references to the
|
||||
* target subquery, which we must replace. We drive this from the
|
||||
* target subquery, which we must replace. We drive this from the
|
||||
* jointree scan, rather than a scan of the rtable, for a couple of
|
||||
* reasons: we can avoid processing no-longer-referenced RTEs, and we
|
||||
* can use the appropriate setting of need_phvs depending on whether
|
||||
@@ -1770,7 +1770,7 @@ pullup_replace_vars_callback(Var *var,
|
||||
/*
|
||||
* Insert PlaceHolderVar if needed. Notice that we are wrapping one
|
||||
* PlaceHolderVar around the whole RowExpr, rather than putting one
|
||||
* around each element of the row. This is because we need the
|
||||
* around each element of the row. This is because we need the
|
||||
* expression to yield NULL, not ROW(NULL,NULL,...) when it is forced
|
||||
* to null by an outer join.
|
||||
*/
|
||||
@@ -1872,7 +1872,7 @@ pullup_replace_vars_callback(Var *var,
|
||||
|
||||
/*
|
||||
* Cache it if possible (ie, if the attno is in range, which it
|
||||
* probably always should be). We can cache the value even if we
|
||||
* probably always should be). We can cache the value even if we
|
||||
* decided we didn't need a PHV, since this result will be
|
||||
* suitable for any request that has need_phvs.
|
||||
*/
|
||||
@@ -1915,7 +1915,7 @@ pullup_replace_vars_subquery(Query *query,
|
||||
*
|
||||
* If a query's setOperations tree consists entirely of simple UNION ALL
|
||||
* operations, flatten it into an append relation, which we can process more
|
||||
* intelligently than the general setops case. Otherwise, do nothing.
|
||||
* intelligently than the general setops case. Otherwise, do nothing.
|
||||
*
|
||||
* In most cases, this can succeed only for a top-level query, because for a
|
||||
* subquery in FROM, the parent query's invocation of pull_up_subqueries would
|
||||
@@ -2027,7 +2027,7 @@ flatten_simple_union_all(PlannerInfo *root)
|
||||
* SELECT ... FROM a LEFT JOIN b ON (a.x = b.y) WHERE b.y IS NULL;
|
||||
* If the join clause is strict for b.y, then only null-extended rows could
|
||||
* pass the upper WHERE, and we can conclude that what the query is really
|
||||
* specifying is an anti-semijoin. We change the join type from JOIN_LEFT
|
||||
* specifying is an anti-semijoin. We change the join type from JOIN_LEFT
|
||||
* to JOIN_ANTI. The IS NULL clause then becomes redundant, and must be
|
||||
* removed to prevent bogus selectivity calculations, but we leave it to
|
||||
* distribute_qual_to_rels to get rid of such clauses.
|
||||
@@ -2267,7 +2267,7 @@ reduce_outer_joins_pass2(Node *jtnode,
|
||||
/*
|
||||
* See if we can reduce JOIN_LEFT to JOIN_ANTI. This is the case if
|
||||
* the join's own quals are strict for any var that was forced null by
|
||||
* higher qual levels. NOTE: there are other ways that we could
|
||||
* higher qual levels. NOTE: there are other ways that we could
|
||||
* detect an anti-join, in particular if we were to check whether Vars
|
||||
* coming from the RHS must be non-null because of table constraints.
|
||||
* That seems complicated and expensive though (in particular, one
|
||||
@@ -2425,7 +2425,7 @@ reduce_outer_joins_pass2(Node *jtnode,
|
||||
* pulled-up relid, and change them to reference the replacement relid(s).
|
||||
*
|
||||
* NOTE: although this has the form of a walker, we cheat and modify the
|
||||
* nodes in-place. This should be OK since the tree was copied by
|
||||
* nodes in-place. This should be OK since the tree was copied by
|
||||
* pullup_replace_vars earlier. Avoid scribbling on the original values of
|
||||
* the bitmapsets, though, because expression_tree_mutator doesn't copy those.
|
||||
*/
|
||||
|
||||
@@ -54,12 +54,12 @@ static Expr *process_duplicate_ors(List *orlist);
|
||||
* Although this can be invoked on its own, it's mainly intended as a helper
|
||||
* for eval_const_expressions(), and that context drives several design
|
||||
* decisions. In particular, if the input is already AND/OR flat, we must
|
||||
* preserve that property. We also don't bother to recurse in situations
|
||||
* preserve that property. We also don't bother to recurse in situations
|
||||
* where we can assume that lower-level executions of eval_const_expressions
|
||||
* would already have simplified sub-clauses of the input.
|
||||
*
|
||||
* The difference between this and a simple make_notclause() is that this
|
||||
* tries to get rid of the NOT node by logical simplification. It's clearly
|
||||
* tries to get rid of the NOT node by logical simplification. It's clearly
|
||||
* always a win if the NOT node can be eliminated altogether. However, our
|
||||
* use of DeMorgan's laws could result in having more NOT nodes rather than
|
||||
* fewer. We do that unconditionally anyway, because in WHERE clauses it's
|
||||
@@ -152,7 +152,7 @@ negate_clause(Node *node)
|
||||
* those properties. For example, if no direct child of
|
||||
* the given AND clause is an AND or a NOT-above-OR, then
|
||||
* the recursive calls of negate_clause() can't return any
|
||||
* OR clauses. So we needn't call pull_ors() before
|
||||
* OR clauses. So we needn't call pull_ors() before
|
||||
* building a new OR clause. Similarly for the OR case.
|
||||
*--------------------
|
||||
*/
|
||||
@@ -293,7 +293,7 @@ canonicalize_qual(Expr *qual)
|
||||
/*
|
||||
* Pull up redundant subclauses in OR-of-AND trees. We do this only
|
||||
* within the top-level AND/OR structure; there's no point in looking
|
||||
* deeper. Also remove any NULL constants in the top-level structure.
|
||||
* deeper. Also remove any NULL constants in the top-level structure.
|
||||
*/
|
||||
newqual = find_duplicate_ors(qual);
|
||||
|
||||
@@ -374,7 +374,7 @@ pull_ors(List *orlist)
|
||||
*
|
||||
* This may seem like a fairly useless activity, but it turns out to be
|
||||
* applicable to many machine-generated queries, and there are also queries
|
||||
* in some of the TPC benchmarks that need it. This was in fact almost the
|
||||
* in some of the TPC benchmarks that need it. This was in fact almost the
|
||||
* sole useful side-effect of the old prepqual code that tried to force
|
||||
* the query into canonical AND-of-ORs form: the canonical equivalent of
|
||||
* ((A AND B) OR (A AND C))
|
||||
@@ -400,7 +400,7 @@ pull_ors(List *orlist)
|
||||
* results, so it's valid to treat NULL::boolean the same as FALSE and then
|
||||
* simplify AND/OR accordingly.
|
||||
*
|
||||
* Returns the modified qualification. AND/OR flatness is preserved.
|
||||
* Returns the modified qualification. AND/OR flatness is preserved.
|
||||
*/
|
||||
static Expr *
|
||||
find_duplicate_ors(Expr *qual)
|
||||
|
||||
@@ -33,7 +33,7 @@ typedef struct
|
||||
Relation rel; /* RTE relation at rt_index */
|
||||
List *targetlist; /* Targetlist for new subquery RTE */
|
||||
List *colnames; /* Column names in subquery RTE */
|
||||
List *vars_processed; /* List of Vars already processed */
|
||||
List *vars_processed; /* List of Vars already processed */
|
||||
} security_barrier_replace_vars_context;
|
||||
|
||||
static void expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
@@ -43,7 +43,7 @@ static void security_barrier_replace_vars(Node *node,
|
||||
security_barrier_replace_vars_context *context);
|
||||
|
||||
static bool security_barrier_replace_vars_walker(Node *node,
|
||||
security_barrier_replace_vars_context *context);
|
||||
security_barrier_replace_vars_context *context);
|
||||
|
||||
|
||||
/*
|
||||
@@ -97,6 +97,7 @@ expand_security_quals(PlannerInfo *root, List *tlist)
|
||||
if (rt_index == parse->resultRelation)
|
||||
{
|
||||
RangeTblEntry *newrte = copyObject(rte);
|
||||
|
||||
parse->rtable = lappend(parse->rtable, newrte);
|
||||
parse->resultRelation = list_length(parse->rtable);
|
||||
|
||||
@@ -117,11 +118,11 @@ expand_security_quals(PlannerInfo *root, List *tlist)
|
||||
rte->modifiedCols = NULL;
|
||||
|
||||
/*
|
||||
* For the most part, Vars referencing the original relation should
|
||||
* remain as they are, meaning that they pull OLD values from the
|
||||
* expanded RTE. But in the RETURNING list and in any WITH CHECK
|
||||
* OPTION quals, we want such Vars to represent NEW values, so
|
||||
* change them to reference the new RTE.
|
||||
* For the most part, Vars referencing the original relation
|
||||
* should remain as they are, meaning that they pull OLD values
|
||||
* from the expanded RTE. But in the RETURNING list and in any
|
||||
* WITH CHECK OPTION quals, we want such Vars to represent NEW
|
||||
* values, so change them to reference the new RTE.
|
||||
*/
|
||||
ChangeVarNodes((Node *) parse->returningList, rt_index,
|
||||
parse->resultRelation, 0);
|
||||
@@ -141,7 +142,8 @@ expand_security_quals(PlannerInfo *root, List *tlist)
|
||||
*/
|
||||
while (rte->securityQuals != NIL)
|
||||
{
|
||||
Node *qual = (Node *) linitial(rte->securityQuals);
|
||||
Node *qual = (Node *) linitial(rte->securityQuals);
|
||||
|
||||
rte->securityQuals = list_delete_first(rte->securityQuals);
|
||||
|
||||
ChangeVarNodes(qual, rt_index, 1, 0);
|
||||
@@ -160,14 +162,14 @@ static void
|
||||
expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
RangeTblEntry *rte, Node *qual)
|
||||
{
|
||||
Query *parse = root->parse;
|
||||
Oid relid = rte->relid;
|
||||
Query *subquery;
|
||||
RangeTblEntry *subrte;
|
||||
RangeTblRef *subrtr;
|
||||
PlanRowMark *rc;
|
||||
Query *parse = root->parse;
|
||||
Oid relid = rte->relid;
|
||||
Query *subquery;
|
||||
RangeTblEntry *subrte;
|
||||
RangeTblRef *subrtr;
|
||||
PlanRowMark *rc;
|
||||
security_barrier_replace_vars_context context;
|
||||
ListCell *cell;
|
||||
ListCell *cell;
|
||||
|
||||
/*
|
||||
* There should only be 2 possible cases:
|
||||
@@ -182,6 +184,7 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
switch (rte->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
|
||||
/*
|
||||
* Turn the relation RTE into a security barrier subquery RTE,
|
||||
* moving all permissions checks down into the subquery.
|
||||
@@ -204,7 +207,7 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
rte->relid = InvalidOid;
|
||||
rte->subquery = subquery;
|
||||
rte->security_barrier = true;
|
||||
rte->inh = false; /* must not be set for a subquery */
|
||||
rte->inh = false; /* must not be set for a subquery */
|
||||
|
||||
/* the permissions checks have now been moved down */
|
||||
rte->requiredPerms = 0;
|
||||
@@ -219,9 +222,9 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
* Note that we can't push the user-defined quals down since they
|
||||
* may included untrusted functions and that means that we will
|
||||
* end up locking all rows which pass the securityQuals, even if
|
||||
* those rows don't pass the user-defined quals. This is currently
|
||||
* documented behavior, but it'd be nice to come up with a better
|
||||
* solution some day.
|
||||
* those rows don't pass the user-defined quals. This is
|
||||
* currently documented behavior, but it'd be nice to come up with
|
||||
* a better solution some day.
|
||||
*/
|
||||
rc = get_plan_rowmark(root->rowMarks, rt_index);
|
||||
if (rc != NULL)
|
||||
@@ -277,6 +280,7 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
break;
|
||||
|
||||
case RTE_SUBQUERY:
|
||||
|
||||
/*
|
||||
* Build a new subquery that includes all the same columns as the
|
||||
* original subquery.
|
||||
@@ -288,8 +292,8 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
|
||||
foreach(cell, rte->subquery->targetList)
|
||||
{
|
||||
TargetEntry *tle;
|
||||
Var *var;
|
||||
TargetEntry *tle;
|
||||
Var *var;
|
||||
|
||||
tle = (TargetEntry *) lfirst(cell);
|
||||
var = makeVarFromTargetEntry(1, tle);
|
||||
@@ -333,7 +337,7 @@ expand_security_qual(PlannerInfo *root, List *tlist, int rt_index,
|
||||
* variable that needs to be exposed by the security barrier subquery RTE.
|
||||
*
|
||||
* NOTE: although this has the form of a walker, we cheat and modify the
|
||||
* nodes in-place. The given expression tree should have been copied
|
||||
* nodes in-place. The given expression tree should have been copied
|
||||
* earlier to ensure that no unwanted side-effects occur!
|
||||
*/
|
||||
static void
|
||||
@@ -355,7 +359,7 @@ security_barrier_replace_vars(Node *node,
|
||||
|
||||
static bool
|
||||
security_barrier_replace_vars_walker(Node *node,
|
||||
security_barrier_replace_vars_context *context)
|
||||
security_barrier_replace_vars_context *context)
|
||||
{
|
||||
if (node == NULL)
|
||||
return false;
|
||||
@@ -405,7 +409,7 @@ security_barrier_replace_vars_walker(Node *node,
|
||||
Form_pg_attribute att_tup;
|
||||
|
||||
att_tup = SystemAttributeDefinition(var->varattno,
|
||||
context->rel->rd_rel->relhasoids);
|
||||
context->rel->rd_rel->relhasoids);
|
||||
attname = NameStr(att_tup->attname);
|
||||
}
|
||||
else if (var->varattno == InvalidAttrNumber)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Routines to preprocess the parse tree target list
|
||||
*
|
||||
* For INSERT and UPDATE queries, the targetlist must contain an entry for
|
||||
* each attribute of the target relation in the correct order. For all query
|
||||
* each attribute of the target relation in the correct order. For all query
|
||||
* types, we may need to add junk tlist entries for Vars used in the RETURNING
|
||||
* list and row ID information needed for SELECT FOR UPDATE locking and/or
|
||||
* EvalPlanQual checking.
|
||||
@@ -79,7 +79,7 @@ preprocess_targetlist(PlannerInfo *root, List *tlist)
|
||||
/*
|
||||
* Add necessary junk columns for rowmarked rels. These values are needed
|
||||
* for locking of rels selected FOR UPDATE/SHARE, and to do EvalPlanQual
|
||||
* rechecking. See comments for PlanRowMark in plannodes.h.
|
||||
* rechecking. See comments for PlanRowMark in plannodes.h.
|
||||
*/
|
||||
foreach(lc, root->rowMarks)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ preprocess_targetlist(PlannerInfo *root, List *tlist)
|
||||
/*
|
||||
* If the query has a RETURNING list, add resjunk entries for any Vars
|
||||
* used in RETURNING that belong to other relations. We need to do this
|
||||
* to make these Vars available for the RETURNING calculation. Vars that
|
||||
* to make these Vars available for the RETURNING calculation. Vars that
|
||||
* belong to the result rel don't need to be added, because they will be
|
||||
* made to refer to the actual heap tuple.
|
||||
*/
|
||||
@@ -252,9 +252,9 @@ expand_targetlist(List *tlist, int command_type,
|
||||
* When generating a NULL constant for a dropped column, we label
|
||||
* it INT4 (any other guaranteed-to-exist datatype would do as
|
||||
* well). We can't label it with the dropped column's datatype
|
||||
* since that might not exist anymore. It does not really matter
|
||||
* since that might not exist anymore. It does not really matter
|
||||
* what we claim the type is, since NULL is NULL --- its
|
||||
* representation is datatype-independent. This could perhaps
|
||||
* representation is datatype-independent. This could perhaps
|
||||
* confuse code comparing the finished plan to the target
|
||||
* relation, however.
|
||||
*/
|
||||
@@ -336,7 +336,7 @@ expand_targetlist(List *tlist, int command_type,
|
||||
/*
|
||||
* The remaining tlist entries should be resjunk; append them all to the
|
||||
* end of the new tlist, making sure they have resnos higher than the last
|
||||
* real attribute. (Note: although the rewriter already did such
|
||||
* real attribute. (Note: although the rewriter already did such
|
||||
* renumbering, we have to do it again here in case we are doing an UPDATE
|
||||
* in a table with dropped columns, or an inheritance child table with
|
||||
* extra columns.)
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
*
|
||||
* There are two code paths in the planner for set-operation queries.
|
||||
* If a subquery consists entirely of simple UNION ALL operations, it
|
||||
* is converted into an "append relation". Otherwise, it is handled
|
||||
* is converted into an "append relation". Otherwise, it is handled
|
||||
* by the general code in this module (plan_set_operations and its
|
||||
* subroutines). There is some support code here for the append-relation
|
||||
* case, but most of the heavy lifting for that is done elsewhere,
|
||||
* notably in prepjointree.c and allpaths.c.
|
||||
*
|
||||
* There is also some code here to support planning of queries that use
|
||||
* inheritance (SELECT FROM foo*). Inheritance trees are converted into
|
||||
* inheritance (SELECT FROM foo*). Inheritance trees are converted into
|
||||
* append relations, and thenceforth share code with the UNION ALL case.
|
||||
*
|
||||
*
|
||||
@@ -577,7 +577,7 @@ generate_nonunion_plan(SetOperationStmt *op, PlannerInfo *root,
|
||||
*
|
||||
* The tlist for an Append plan isn't important as far as the Append is
|
||||
* concerned, but we must make it look real anyway for the benefit of the
|
||||
* next plan level up. In fact, it has to be real enough that the flag
|
||||
* next plan level up. In fact, it has to be real enough that the flag
|
||||
* column is shown as a variable not a constant, else setrefs.c will get
|
||||
* confused.
|
||||
*/
|
||||
@@ -970,7 +970,7 @@ generate_setop_tlist(List *colTypes, List *colCollations,
|
||||
* Ensure the tlist entry's exposed collation matches the set-op. This
|
||||
* is necessary because plan_set_operations() reports the result
|
||||
* ordering as a list of SortGroupClauses, which don't carry collation
|
||||
* themselves but just refer to tlist entries. If we don't show the
|
||||
* themselves but just refer to tlist entries. If we don't show the
|
||||
* right collation then planner.c might do the wrong thing in
|
||||
* higher-level queries.
|
||||
*
|
||||
@@ -1184,7 +1184,7 @@ generate_setop_grouplist(SetOperationStmt *op, List *targetlist)
|
||||
/*
|
||||
* expand_inherited_tables
|
||||
* Expand each rangetable entry that represents an inheritance set
|
||||
* into an "append relation". At the conclusion of this process,
|
||||
* into an "append relation". At the conclusion of this process,
|
||||
* the "inh" flag is set in all and only those RTEs that are append
|
||||
* relation parents.
|
||||
*/
|
||||
@@ -1216,7 +1216,7 @@ expand_inherited_tables(PlannerInfo *root)
|
||||
* Check whether a rangetable entry represents an inheritance set.
|
||||
* If so, add entries for all the child tables to the query's
|
||||
* rangetable, and build AppendRelInfo nodes for all the child tables
|
||||
* and add them to root->append_rel_list. If not, clear the entry's
|
||||
* and add them to root->append_rel_list. If not, clear the entry's
|
||||
* "inh" flag to prevent later code from looking for AppendRelInfos.
|
||||
*
|
||||
* Note that the original RTE is considered to represent the whole
|
||||
@@ -1527,7 +1527,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation,
|
||||
* parent rel's attribute numbering to the child's.
|
||||
*
|
||||
* The only surprise here is that we don't translate a parent whole-row
|
||||
* reference into a child whole-row reference. That would mean requiring
|
||||
* reference into a child whole-row reference. That would mean requiring
|
||||
* permissions on all child columns, which is overly strict, since the
|
||||
* query is really only going to reference the inherited columns. Instead
|
||||
* we set the per-column bits for all inherited columns.
|
||||
@@ -1708,6 +1708,7 @@ adjust_appendrel_attrs_mutator(Node *node,
|
||||
foreach(lc, fields)
|
||||
{
|
||||
Var *field = (Var *) lfirst(lc);
|
||||
|
||||
field->varlevelsup += context->sublevels_up;
|
||||
}
|
||||
rowexpr = makeNode(RowExpr);
|
||||
@@ -1887,7 +1888,7 @@ adjust_relid_set(Relids relids, Index oldrelid, Index newrelid)
|
||||
*
|
||||
* The expressions have already been fixed, but we have to make sure that
|
||||
* the target resnos match the child table (they may not, in the case of
|
||||
* a column that was added after-the-fact by ALTER TABLE). In some cases
|
||||
* a column that was added after-the-fact by ALTER TABLE). In some cases
|
||||
* this can force us to re-order the tlist to preserve resno ordering.
|
||||
* (We do all this work in special cases so that preptlist.c is fast for
|
||||
* the typical case.)
|
||||
|
||||
Reference in New Issue
Block a user