mirror of
https://github.com/postgres/postgres.git
synced 2025-11-22 12:22:45 +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:
@@ -540,7 +540,7 @@ count_agg_clauses_walker(Node *node, count_agg_clauses_context *context)
|
||||
|
||||
/*
|
||||
* If the transition type is pass-by-value then it doesn't add
|
||||
* anything to the required size of the hashtable. If it is
|
||||
* anything to the required size of the hashtable. If it is
|
||||
* pass-by-reference then we have to add the estimated size of the
|
||||
* value itself, plus palloc overhead.
|
||||
*/
|
||||
@@ -835,7 +835,7 @@ contain_subplans_walker(Node *node, void *context)
|
||||
* Recursively search for mutable functions within a clause.
|
||||
*
|
||||
* Returns true if any mutable function (or operator implemented by a
|
||||
* mutable function) is found. This test is needed so that we don't
|
||||
* mutable function) is found. This test is needed so that we don't
|
||||
* mistakenly think that something like "WHERE random() < 0.5" can be treated
|
||||
* as a constant qualification.
|
||||
*
|
||||
@@ -962,7 +962,7 @@ contain_mutable_functions_walker(Node *node, void *context)
|
||||
* invalid conversions of volatile expressions into indexscan quals.
|
||||
*
|
||||
* We will recursively look into Query nodes (i.e., SubLink sub-selects)
|
||||
* but not into SubPlans. This is a bit odd, but intentional. If we are
|
||||
* but not into SubPlans. This is a bit odd, but intentional. If we are
|
||||
* looking at a SubLink, we are probably deciding whether a query tree
|
||||
* transformation is safe, and a contained sub-select should affect that;
|
||||
* for example, duplicating a sub-select containing a volatile function
|
||||
@@ -1207,7 +1207,7 @@ contain_volatile_functions_not_nextval_walker(Node *node, void *context)
|
||||
* The idea here is that the caller has verified that the expression contains
|
||||
* one or more Var or Param nodes (as appropriate for the caller's need), and
|
||||
* now wishes to prove that the expression result will be NULL if any of these
|
||||
* inputs is NULL. If we return false, then the proof succeeded.
|
||||
* inputs is NULL. If we return false, then the proof succeeded.
|
||||
*/
|
||||
bool
|
||||
contain_nonstrict_functions(Node *clause)
|
||||
@@ -1326,7 +1326,7 @@ contain_nonstrict_functions_walker(Node *node, void *context)
|
||||
* Recursively search for leaky functions within a clause.
|
||||
*
|
||||
* Returns true if any function call with side-effect may be present in the
|
||||
* clause. Qualifiers from outside the a security_barrier view should not
|
||||
* clause. Qualifiers from outside the a security_barrier view should not
|
||||
* be pushed down into the view, lest the contents of tuples intended to be
|
||||
* filtered out be revealed via side effects.
|
||||
*/
|
||||
@@ -1465,7 +1465,7 @@ contain_leaky_functions_walker(Node *node, void *context)
|
||||
*
|
||||
* Returns the set of all Relids that are referenced in the clause in such
|
||||
* a way that the clause cannot possibly return TRUE if any of these Relids
|
||||
* is an all-NULL row. (It is OK to err on the side of conservatism; hence
|
||||
* is an all-NULL row. (It is OK to err on the side of conservatism; hence
|
||||
* the analysis here is simplistic.)
|
||||
*
|
||||
* The semantics here are subtly different from contain_nonstrict_functions:
|
||||
@@ -1571,7 +1571,7 @@ find_nonnullable_rels_walker(Node *node, bool top_level)
|
||||
* could be FALSE (hence not NULL). However, if *all* the
|
||||
* arms produce NULL then the result is NULL, so we can take
|
||||
* the intersection of the sets of nonnullable rels, just as
|
||||
* for OR. Fall through to share code.
|
||||
* for OR. Fall through to share code.
|
||||
*/
|
||||
/* FALL THRU */
|
||||
case OR_EXPR:
|
||||
@@ -1779,7 +1779,7 @@ find_nonnullable_vars_walker(Node *node, bool top_level)
|
||||
* could be FALSE (hence not NULL). However, if *all* the
|
||||
* arms produce NULL then the result is NULL, so we can take
|
||||
* the intersection of the sets of nonnullable vars, just as
|
||||
* for OR. Fall through to share code.
|
||||
* for OR. Fall through to share code.
|
||||
*/
|
||||
/* FALL THRU */
|
||||
case OR_EXPR:
|
||||
@@ -2049,7 +2049,7 @@ is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK)
|
||||
* variables of the current query level and no uses of volatile functions.
|
||||
* Such an expr is not necessarily a true constant: it can still contain
|
||||
* Params and outer-level Vars, not to mention functions whose results
|
||||
* may vary from one statement to the next. However, the expr's value
|
||||
* may vary from one statement to the next. However, the expr's value
|
||||
* will be constant over any one scan of the current query, so it can be
|
||||
* used as, eg, an indexscan key.
|
||||
*
|
||||
@@ -2255,7 +2255,7 @@ rowtype_field_matches(Oid rowtypeid, int fieldnum,
|
||||
* expression tree, for example "2 + 2" => "4". More interestingly,
|
||||
* we can reduce certain boolean expressions even when they contain
|
||||
* non-constant subexpressions: "x OR true" => "true" no matter what
|
||||
* the subexpression x is. (XXX We assume that no such subexpression
|
||||
* the subexpression x is. (XXX We assume that no such subexpression
|
||||
* will have important side-effects, which is not necessarily a good
|
||||
* assumption in the presence of user-defined functions; do we need a
|
||||
* pg_proc flag that prevents discarding the execution of a function?)
|
||||
@@ -2268,7 +2268,7 @@ rowtype_field_matches(Oid rowtypeid, int fieldnum,
|
||||
*
|
||||
* Whenever a function is eliminated from the expression by means of
|
||||
* constant-expression evaluation or inlining, we add the function to
|
||||
* root->glob->invalItems. This ensures the plan is known to depend on
|
||||
* root->glob->invalItems. This ensures the plan is known to depend on
|
||||
* such functions, even though they aren't referenced anymore.
|
||||
*
|
||||
* We assume that the tree has already been type-checked and contains
|
||||
@@ -2451,7 +2451,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
|
||||
/*
|
||||
* Code for op/func reduction is pretty bulky, so split it out
|
||||
* as a separate function. Note: exprTypmod normally returns
|
||||
* as a separate function. Note: exprTypmod normally returns
|
||||
* -1 for a FuncExpr, but not when the node is recognizably a
|
||||
* length coercion; we want to preserve the typmod in the
|
||||
* eventual Const if so.
|
||||
@@ -2495,7 +2495,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
OpExpr *newexpr;
|
||||
|
||||
/*
|
||||
* Need to get OID of underlying function. Okay to scribble
|
||||
* Need to get OID of underlying function. Okay to scribble
|
||||
* on input to this extent.
|
||||
*/
|
||||
set_opfuncid(expr);
|
||||
@@ -2598,7 +2598,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
/* (NOT okay to try to inline it, though!) */
|
||||
|
||||
/*
|
||||
* Need to get OID of underlying function. Okay to
|
||||
* Need to get OID of underlying function. Okay to
|
||||
* scribble on input to this extent.
|
||||
*/
|
||||
set_opfuncid((OpExpr *) expr); /* rely on struct
|
||||
@@ -2963,13 +2963,13 @@ eval_const_expressions_mutator(Node *node,
|
||||
* TRUE: drop all remaining alternatives
|
||||
* If the first non-FALSE alternative is a constant TRUE,
|
||||
* we can simplify the entire CASE to that alternative's
|
||||
* expression. If there are no non-FALSE alternatives,
|
||||
* expression. If there are no non-FALSE alternatives,
|
||||
* we simplify the entire CASE to the default result (ELSE).
|
||||
*
|
||||
* If we have a simple-form CASE with constant test
|
||||
* expression, we substitute the constant value for contained
|
||||
* CaseTestExpr placeholder nodes, so that we have the
|
||||
* opportunity to reduce constant test conditions. For
|
||||
* opportunity to reduce constant test conditions. For
|
||||
* example this allows
|
||||
* CASE 0 WHEN 0 THEN 1 ELSE 1/0 END
|
||||
* to reduce to 1 rather than drawing a divide-by-0 error.
|
||||
@@ -3191,7 +3191,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
{
|
||||
/*
|
||||
* We can optimize field selection from a whole-row Var into a
|
||||
* simple Var. (This case won't be generated directly by the
|
||||
* simple Var. (This case won't be generated directly by the
|
||||
* parser, because ParseComplexProjection short-circuits it.
|
||||
* But it can arise while simplifying functions.) Also, we
|
||||
* can optimize field selection from a RowExpr construct.
|
||||
@@ -3449,7 +3449,7 @@ simplify_or_arguments(List *args,
|
||||
/*
|
||||
* Since the parser considers OR to be a binary operator, long OR lists
|
||||
* become deeply nested expressions. We must flatten these into long
|
||||
* argument lists of a single OR operator. To avoid blowing out the stack
|
||||
* argument lists of a single OR operator. To avoid blowing out the stack
|
||||
* with recursion of eval_const_expressions, we resort to some tenseness
|
||||
* here: we keep a list of not-yet-processed inputs, and handle flattening
|
||||
* of nested ORs by prepending to the to-do list instead of recursing.
|
||||
@@ -3497,7 +3497,7 @@ simplify_or_arguments(List *args,
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, we have a const-simplified non-OR argument. Process it per
|
||||
* OK, we have a const-simplified non-OR argument. Process it per
|
||||
* comments above.
|
||||
*/
|
||||
if (IsA(arg, Const))
|
||||
@@ -3732,7 +3732,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
|
||||
* deliver a constant result, use a transform function to generate a
|
||||
* substitute node tree, or expand in-line the body of the function
|
||||
* definition (which only works for simple SQL-language functions, but
|
||||
* that is a common case). Each case needs access to the function's
|
||||
* that is a common case). Each case needs access to the function's
|
||||
* pg_proc tuple, so fetch it just once.
|
||||
*
|
||||
* Note: the allow_non_const flag suppresses both the second and third
|
||||
@@ -3770,7 +3770,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod,
|
||||
if (!newexpr && allow_non_const && OidIsValid(func_form->protransform))
|
||||
{
|
||||
/*
|
||||
* Build a dummy FuncExpr node containing the simplified arg list. We
|
||||
* Build a dummy FuncExpr node containing the simplified arg list. We
|
||||
* use this approach to present a uniform interface to the transform
|
||||
* function regardless of how the function is actually being invoked.
|
||||
*/
|
||||
@@ -3978,7 +3978,7 @@ fetch_function_defaults(HeapTuple func_tuple)
|
||||
*
|
||||
* It is possible for some of the defaulted arguments to be polymorphic;
|
||||
* therefore we can't assume that the default expressions have the correct
|
||||
* data types already. We have to re-resolve polymorphics and do coercion
|
||||
* data types already. We have to re-resolve polymorphics and do coercion
|
||||
* just like the parser did.
|
||||
*
|
||||
* This should be a no-op if there are no polymorphic arguments,
|
||||
@@ -4141,7 +4141,7 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod,
|
||||
* do not re-expand them. Also, if a parameter is used more than once
|
||||
* in the SQL-function body, we require it not to contain any volatile
|
||||
* functions (volatiles might deliver inconsistent answers) nor to be
|
||||
* unreasonably expensive to evaluate. The expensiveness check not only
|
||||
* unreasonably expensive to evaluate. The expensiveness check not only
|
||||
* prevents us from doing multiple evaluations of an expensive parameter
|
||||
* at runtime, but is a safety value to limit growth of an expression due
|
||||
* to repeated inlining.
|
||||
@@ -4184,7 +4184,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
|
||||
|
||||
/*
|
||||
* Forget it if the function is not SQL-language or has other showstopper
|
||||
* properties. (The nargs check is just paranoia.)
|
||||
* properties. (The nargs check is just paranoia.)
|
||||
*/
|
||||
if (funcform->prolang != SQLlanguageId ||
|
||||
funcform->prosecdef ||
|
||||
@@ -4262,7 +4262,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
|
||||
/*
|
||||
* We just do parsing and parse analysis, not rewriting, because rewriting
|
||||
* will not affect table-free-SELECT-only queries, which is all that we
|
||||
* care about. Also, we can punt as soon as we detect more than one
|
||||
* care about. Also, we can punt as soon as we detect more than one
|
||||
* command in the function body.
|
||||
*/
|
||||
raw_parsetree_list = pg_parse_query(src);
|
||||
@@ -4304,7 +4304,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
|
||||
/*
|
||||
* Make sure the function (still) returns what it's declared to. This
|
||||
* will raise an error if wrong, but that's okay since the function would
|
||||
* fail at runtime anyway. Note that check_sql_fn_retval will also insert
|
||||
* fail at runtime anyway. Note that check_sql_fn_retval will also insert
|
||||
* a RelabelType if needed to make the tlist expression match the declared
|
||||
* type of the function.
|
||||
*
|
||||
@@ -4349,7 +4349,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
|
||||
/*
|
||||
* We may be able to do it; there are still checks on parameter usage to
|
||||
* make, but those are most easily done in combination with the actual
|
||||
* substitution of the inputs. So start building expression with inputs
|
||||
* substitution of the inputs. So start building expression with inputs
|
||||
* substituted.
|
||||
*/
|
||||
usecounts = (int *) palloc0(funcform->pronargs * sizeof(int));
|
||||
@@ -4549,7 +4549,7 @@ evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod,
|
||||
fix_opfuncids((Node *) expr);
|
||||
|
||||
/*
|
||||
* Prepare expr for execution. (Note: we can't use ExecPrepareExpr
|
||||
* Prepare expr for execution. (Note: we can't use ExecPrepareExpr
|
||||
* because it'd result in recursively invoking eval_const_expressions.)
|
||||
*/
|
||||
exprstate = ExecInitExpr(expr, NULL);
|
||||
@@ -4671,7 +4671,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
|
||||
* Refuse to inline if the arguments contain any volatile functions or
|
||||
* sub-selects. Volatile functions are rejected because inlining may
|
||||
* result in the arguments being evaluated multiple times, risking a
|
||||
* change in behavior. Sub-selects are rejected partly for implementation
|
||||
* change in behavior. Sub-selects are rejected partly for implementation
|
||||
* reasons (pushing them down another level might change their behavior)
|
||||
* and partly because they're likely to be expensive and so multiple
|
||||
* evaluation would be bad.
|
||||
@@ -4698,7 +4698,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
|
||||
|
||||
/*
|
||||
* Forget it if the function is not SQL-language or has other showstopper
|
||||
* properties. In particular it mustn't be declared STRICT, since we
|
||||
* properties. In particular it mustn't be declared STRICT, since we
|
||||
* couldn't enforce that. It also mustn't be VOLATILE, because that is
|
||||
* supposed to cause it to be executed with its own snapshot, rather than
|
||||
* sharing the snapshot of the calling query. (Rechecking proretset is
|
||||
@@ -4728,9 +4728,9 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
|
||||
|
||||
/*
|
||||
* When we call eval_const_expressions below, it might try to add items to
|
||||
* root->glob->invalItems. Since it is running in the temp context, those
|
||||
* root->glob->invalItems. Since it is running in the temp context, those
|
||||
* items will be in that context, and will need to be copied out if we're
|
||||
* successful. Temporarily reset the list so that we can keep those items
|
||||
* successful. Temporarily reset the list so that we can keep those items
|
||||
* separate from the pre-existing list contents.
|
||||
*/
|
||||
saveInvalItems = root->glob->invalItems;
|
||||
@@ -4760,7 +4760,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
|
||||
/*
|
||||
* Run eval_const_expressions on the function call. This is necessary to
|
||||
* ensure that named-argument notation is converted to positional notation
|
||||
* and any default arguments are inserted. It's a bit of overkill for the
|
||||
* and any default arguments are inserted. It's a bit of overkill for the
|
||||
* arguments, since they'll get processed again later, but no harm will be
|
||||
* done.
|
||||
*/
|
||||
@@ -4812,7 +4812,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
|
||||
/*
|
||||
* Make sure the function (still) returns what it's declared to. This
|
||||
* will raise an error if wrong, but that's okay since the function would
|
||||
* fail at runtime anyway. Note that check_sql_fn_retval will also insert
|
||||
* fail at runtime anyway. Note that check_sql_fn_retval will also insert
|
||||
* RelabelType(s) and/or NULL columns if needed to make the tlist
|
||||
* expression(s) match the declared type of the function.
|
||||
*
|
||||
|
||||
@@ -83,7 +83,7 @@ have_relevant_joinclause(PlannerInfo *root,
|
||||
* Add 'restrictinfo' to the joininfo list of each relation it requires.
|
||||
*
|
||||
* Note that the same copy of the restrictinfo node is linked to by all the
|
||||
* lists it is in. This allows us to exploit caching of information about
|
||||
* lists it is in. This allows us to exploit caching of information about
|
||||
* the restriction clause (but we must be careful that the information does
|
||||
* not depend on context).
|
||||
*
|
||||
|
||||
@@ -50,7 +50,7 @@ static void consider_new_or_clause(PlannerInfo *root, RelOptInfo *rel,
|
||||
*
|
||||
* The added quals are partially redundant with the original OR, and therefore
|
||||
* would cause the size of the joinrel to be underestimated when it is finally
|
||||
* formed. (This would be true of a full transformation to CNF as well; the
|
||||
* formed. (This would be true of a full transformation to CNF as well; the
|
||||
* fault is not really in the transformation, but in clauselist_selectivity's
|
||||
* inability to recognize redundant conditions.) We can compensate for this
|
||||
* redundancy by changing the cached selectivity of the original OR clause,
|
||||
@@ -60,10 +60,10 @@ static void consider_new_or_clause(PlannerInfo *root, RelOptInfo *rel,
|
||||
* and on the fact that the same RestrictInfo node will appear in every
|
||||
* joininfo list that might be used when the joinrel is formed.
|
||||
* And it doesn't work in cases where the size estimation is nonlinear
|
||||
* (i.e., outer and IN joins). But it beats not doing anything.
|
||||
* (i.e., outer and IN joins). But it beats not doing anything.
|
||||
*
|
||||
* We examine each base relation to see if join clauses associated with it
|
||||
* contain extractable restriction conditions. If so, add those conditions
|
||||
* contain extractable restriction conditions. If so, add those conditions
|
||||
* to the rel's baserestrictinfo and update the cached selectivities of the
|
||||
* join clauses. Note that the same join clause will be examined afresh
|
||||
* from the point of view of each baserel that participates in it, so its
|
||||
@@ -129,7 +129,7 @@ static bool
|
||||
is_safe_restriction_clause_for(RestrictInfo *rinfo, RelOptInfo *rel)
|
||||
{
|
||||
/*
|
||||
* We want clauses that mention the rel, and only the rel. So in
|
||||
* We want clauses that mention the rel, and only the rel. So in
|
||||
* particular pseudoconstant clauses can be rejected quickly. Then check
|
||||
* the clause's Var membership.
|
||||
*/
|
||||
@@ -168,7 +168,7 @@ extract_or_clause(RestrictInfo *or_rinfo, RelOptInfo *rel)
|
||||
* in those nodes to make is_safe_restriction_clause_for()'s checks
|
||||
* cheaper. We'll strip those nodes from the returned tree, though,
|
||||
* meaning that fresh ones will be built if the clause is accepted as a
|
||||
* restriction clause. This might seem wasteful --- couldn't we re-use
|
||||
* restriction clause. This might seem wasteful --- couldn't we re-use
|
||||
* the existing RestrictInfos? But that'd require assuming that
|
||||
* selectivity and other cached data is computed exactly the same way for
|
||||
* a restriction clause as for a join clause, which seems undesirable.
|
||||
@@ -193,7 +193,7 @@ extract_or_clause(RestrictInfo *or_rinfo, RelOptInfo *rel)
|
||||
if (restriction_is_or_clause(rinfo))
|
||||
{
|
||||
/*
|
||||
* Recurse to deal with nested OR. Note we *must* recurse
|
||||
* Recurse to deal with nested OR. Note we *must* recurse
|
||||
* here, this isn't just overly-tense optimization: we
|
||||
* have to descend far enough to find and strip all
|
||||
* RestrictInfos in the expression.
|
||||
@@ -314,7 +314,7 @@ consider_new_or_clause(PlannerInfo *root, RelOptInfo *rel,
|
||||
SpecialJoinInfo sjinfo;
|
||||
|
||||
/*
|
||||
* Make up a SpecialJoinInfo for JOIN_INNER semantics. (Compare
|
||||
* Make up a SpecialJoinInfo for JOIN_INNER semantics. (Compare
|
||||
* approx_tuple_count() in costsize.c.)
|
||||
*/
|
||||
sjinfo.type = T_SpecialJoinInfo;
|
||||
|
||||
@@ -127,11 +127,11 @@ compare_fractional_path_costs(Path *path1, Path *path2,
|
||||
*
|
||||
* The fuzz_factor argument must be 1.0 plus delta, where delta is the
|
||||
* fraction of the smaller cost that is considered to be a significant
|
||||
* difference. For example, fuzz_factor = 1.01 makes the fuzziness limit
|
||||
* difference. For example, fuzz_factor = 1.01 makes the fuzziness limit
|
||||
* be 1% of the smaller cost.
|
||||
*
|
||||
* The two paths are said to have "equal" costs if both startup and total
|
||||
* costs are fuzzily the same. Path1 is said to be better than path2 if
|
||||
* costs are fuzzily the same. Path1 is said to be better than path2 if
|
||||
* it has fuzzily better startup cost and fuzzily no worse total cost,
|
||||
* or if it has fuzzily better total cost and fuzzily no worse startup cost.
|
||||
* Path2 is better than path1 if the reverse holds. Finally, if one path
|
||||
@@ -207,12 +207,12 @@ compare_path_costs_fuzzily(Path *path1, Path *path2, double fuzz_factor,
|
||||
*
|
||||
* cheapest_total_path is normally the cheapest-total-cost unparameterized
|
||||
* path; but if there are no unparameterized paths, we assign it to be the
|
||||
* best (cheapest least-parameterized) parameterized path. However, only
|
||||
* best (cheapest least-parameterized) parameterized path. However, only
|
||||
* unparameterized paths are considered candidates for cheapest_startup_path,
|
||||
* so that will be NULL if there are no unparameterized paths.
|
||||
*
|
||||
* The cheapest_parameterized_paths list collects all parameterized paths
|
||||
* that have survived the add_path() tournament for this relation. (Since
|
||||
* that have survived the add_path() tournament for this relation. (Since
|
||||
* add_path ignores pathkeys and startup cost for a parameterized path,
|
||||
* these will be paths that have best total cost or best row count for their
|
||||
* parameterization.) cheapest_parameterized_paths always includes the
|
||||
@@ -431,7 +431,7 @@ add_path(RelOptInfo *parent_rel, Path *new_path)
|
||||
p1_next = lnext(p1);
|
||||
|
||||
/*
|
||||
* Do a fuzzy cost comparison with 1% fuzziness limit. (XXX does this
|
||||
* Do a fuzzy cost comparison with 1% fuzziness limit. (XXX does this
|
||||
* percentage need to be user-configurable?)
|
||||
*/
|
||||
costcmp = compare_path_costs_fuzzily(new_path, old_path, 1.01,
|
||||
@@ -607,7 +607,7 @@ add_path(RelOptInfo *parent_rel, Path *new_path)
|
||||
* and have lower bounds for its costs.
|
||||
*
|
||||
* Note that we do not know the path's rowcount, since getting an estimate for
|
||||
* that is too expensive to do before prechecking. We assume here that paths
|
||||
* that is too expensive to do before prechecking. We assume here that paths
|
||||
* of a superset parameterization will generate fewer rows; if that holds,
|
||||
* then paths with different parameterizations cannot dominate each other
|
||||
* and so we can simply ignore existing paths of another parameterization.
|
||||
@@ -907,7 +907,7 @@ create_append_path(RelOptInfo *rel, List *subpaths, Relids required_outer)
|
||||
* Compute rows and costs as sums of subplan rows and costs. We charge
|
||||
* nothing extra for the Append itself, which perhaps is too optimistic,
|
||||
* but since it doesn't do any selection or projection, it is a pretty
|
||||
* cheap node. If you change this, see also make_append().
|
||||
* cheap node. If you change this, see also make_append().
|
||||
*/
|
||||
pathnode->path.rows = 0;
|
||||
pathnode->path.startup_cost = 0;
|
||||
@@ -1456,7 +1456,7 @@ translate_sub_tlist(List *tlist, int relid)
|
||||
*
|
||||
* colnos is an integer list of output column numbers (resno's). We are
|
||||
* interested in whether rows consisting of just these columns are certain
|
||||
* to be distinct. "Distinctness" is defined according to whether the
|
||||
* to be distinct. "Distinctness" is defined according to whether the
|
||||
* corresponding upper-level equality operators listed in opids would think
|
||||
* the values are distinct. (Note: the opids entries could be cross-type
|
||||
* operators, and thus not exactly the equality operators that the subquery
|
||||
@@ -1577,7 +1577,7 @@ query_is_distinct_for(Query *query, List *colnos, List *opids)
|
||||
* distinct_col_search - subroutine for query_is_distinct_for
|
||||
*
|
||||
* If colno is in colnos, return the corresponding element of opids,
|
||||
* else return InvalidOid. (We expect colnos does not contain duplicates,
|
||||
* else return InvalidOid. (We expect colnos does not contain duplicates,
|
||||
* so the result is well-defined.)
|
||||
*/
|
||||
static Oid
|
||||
@@ -1977,10 +1977,10 @@ create_hashjoin_path(PlannerInfo *root,
|
||||
|
||||
/*
|
||||
* A hashjoin never has pathkeys, since its output ordering is
|
||||
* unpredictable due to possible batching. XXX If the inner relation is
|
||||
* unpredictable due to possible batching. XXX If the inner relation is
|
||||
* small enough, we could instruct the executor that it must not batch,
|
||||
* and then we could assume that the output inherits the outer relation's
|
||||
* ordering, which might save a sort step. However there is considerable
|
||||
* ordering, which might save a sort step. However there is considerable
|
||||
* downside if our estimate of the inner relation size is badly off. For
|
||||
* the moment we don't risk it. (Note also that if we wanted to take this
|
||||
* seriously, joinpath.c would have to consider many more paths for the
|
||||
@@ -2007,7 +2007,7 @@ create_hashjoin_path(PlannerInfo *root,
|
||||
* same parameterization level, ensuring that they all enforce the same set
|
||||
* of join quals (and thus that that parameterization can be attributed to
|
||||
* an append path built from such paths). Currently, only a few path types
|
||||
* are supported here, though more could be added at need. We return NULL
|
||||
* are supported here, though more could be added at need. We return NULL
|
||||
* if we can't reparameterize the given path.
|
||||
*
|
||||
* Note: we intentionally do not pass created paths to add_path(); it would
|
||||
@@ -2039,7 +2039,7 @@ reparameterize_path(PlannerInfo *root, Path *path,
|
||||
/*
|
||||
* We can't use create_index_path directly, and would not want
|
||||
* to because it would re-compute the indexqual conditions
|
||||
* which is wasted effort. Instead we hack things a bit:
|
||||
* which is wasted effort. Instead we hack things a bit:
|
||||
* flat-copy the path node, revise its param_info, and redo
|
||||
* the cost estimate.
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ make_placeholder_expr(PlannerInfo *root, Expr *expr, Relids phrels)
|
||||
* We build PlaceHolderInfos only for PHVs that are still present in the
|
||||
* simplified query passed to query_planner().
|
||||
*
|
||||
* Note: this should only be called after query_planner() has started. Also,
|
||||
* Note: this should only be called after query_planner() has started. Also,
|
||||
* create_new_ph must not be TRUE after deconstruct_jointree begins, because
|
||||
* make_outerjoininfo assumes that we already know about all placeholders.
|
||||
*/
|
||||
@@ -94,7 +94,7 @@ find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv,
|
||||
/*
|
||||
* Any referenced rels that are outside the PHV's syntactic scope are
|
||||
* LATERAL references, which should be included in ph_lateral but not in
|
||||
* ph_eval_at. If no referenced rels are within the syntactic scope,
|
||||
* ph_eval_at. If no referenced rels are within the syntactic scope,
|
||||
* force evaluation at the syntactic location.
|
||||
*/
|
||||
rels_used = pull_varnos((Node *) phv->phexpr);
|
||||
|
||||
@@ -427,12 +427,12 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
* minimum size estimate of 10 pages. The idea here is to avoid
|
||||
* assuming a newly-created table is really small, even if it
|
||||
* currently is, because that may not be true once some data gets
|
||||
* loaded into it. Once a vacuum or analyze cycle has been done
|
||||
* loaded into it. Once a vacuum or analyze cycle has been done
|
||||
* on it, it's more reasonable to believe the size is somewhat
|
||||
* stable.
|
||||
*
|
||||
* (Note that this is only an issue if the plan gets cached and
|
||||
* used again after the table has been filled. What we're trying
|
||||
* used again after the table has been filled. What we're trying
|
||||
* to avoid is using a nestloop-type plan on a table that has
|
||||
* grown substantially since the plan was made. Normally,
|
||||
* autovacuum/autoanalyze will occur once enough inserts have
|
||||
@@ -441,7 +441,7 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
* such as temporary tables.)
|
||||
*
|
||||
* We approximate "never vacuumed" by "has relpages = 0", which
|
||||
* means this will also fire on genuinely empty relations. Not
|
||||
* means this will also fire on genuinely empty relations. Not
|
||||
* great, but fortunately that's a seldom-seen case in the real
|
||||
* world, and it shouldn't degrade the quality of the plan too
|
||||
* much anyway to err in this direction.
|
||||
@@ -786,7 +786,7 @@ relation_excluded_by_constraints(PlannerInfo *root,
|
||||
return false;
|
||||
|
||||
/*
|
||||
* OK to fetch the constraint expressions. Include "col IS NOT NULL"
|
||||
* OK to fetch the constraint expressions. Include "col IS NOT NULL"
|
||||
* expressions for attnotnull columns, in case we can refute those.
|
||||
*/
|
||||
constraint_pred = get_relation_constraints(root, rte->relid, rel, true);
|
||||
@@ -834,7 +834,7 @@ relation_excluded_by_constraints(PlannerInfo *root,
|
||||
* Exception: if there are any dropped columns, we punt and return NIL.
|
||||
* Ideally we would like to handle the dropped-column case too. However this
|
||||
* creates problems for ExecTypeFromTL, which may be asked to build a tupdesc
|
||||
* for a tlist that includes vars of no-longer-existent types. In theory we
|
||||
* for a tlist that includes vars of no-longer-existent types. In theory we
|
||||
* could dig out the required info from the pg_attribute entries of the
|
||||
* relation, but that data is not readily available to ExecTypeFromTL.
|
||||
* For now, we don't apply the physical-tlist optimization when there are
|
||||
|
||||
@@ -133,7 +133,7 @@ predicate_implied_by(List *predicate_list, List *restrictinfo_list)
|
||||
|
||||
/*
|
||||
* If either input is a single-element list, replace it with its lone
|
||||
* member; this avoids one useless level of AND-recursion. We only need
|
||||
* member; this avoids one useless level of AND-recursion. We only need
|
||||
* to worry about this at top level, since eval_const_expressions should
|
||||
* have gotten rid of any trivial ANDs or ORs below that.
|
||||
*/
|
||||
@@ -191,7 +191,7 @@ predicate_refuted_by(List *predicate_list, List *restrictinfo_list)
|
||||
|
||||
/*
|
||||
* If either input is a single-element list, replace it with its lone
|
||||
* member; this avoids one useless level of AND-recursion. We only need
|
||||
* member; this avoids one useless level of AND-recursion. We only need
|
||||
* to worry about this at top level, since eval_const_expressions should
|
||||
* have gotten rid of any trivial ANDs or ORs below that.
|
||||
*/
|
||||
@@ -225,7 +225,7 @@ predicate_refuted_by(List *predicate_list, List *restrictinfo_list)
|
||||
* OR-expr A => AND-expr B iff: A => each of B's components
|
||||
* OR-expr A => OR-expr B iff: each of A's components => any of B's
|
||||
*
|
||||
* An "atom" is anything other than an AND or OR node. Notice that we don't
|
||||
* An "atom" is anything other than an AND or OR node. Notice that we don't
|
||||
* have any special logic to handle NOT nodes; these should have been pushed
|
||||
* down or eliminated where feasible by prepqual.c.
|
||||
*
|
||||
@@ -658,7 +658,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
|
||||
* We cannot make the stronger conclusion that B is refuted if B
|
||||
* implies A's arg; that would only prove that B is not-TRUE, not
|
||||
* that it's not NULL either. Hence use equal() rather than
|
||||
* predicate_implied_by_recurse(). We could do the latter if we
|
||||
* predicate_implied_by_recurse(). We could do the latter if we
|
||||
* ever had a need for the weak form of refutation.
|
||||
*/
|
||||
not_arg = extract_strong_not_arg(clause);
|
||||
@@ -820,7 +820,7 @@ predicate_classify(Node *clause, PredIterInfo info)
|
||||
}
|
||||
|
||||
/*
|
||||
* PredIterInfo routines for iterating over regular Lists. The iteration
|
||||
* PredIterInfo routines for iterating over regular Lists. The iteration
|
||||
* state variable is the next ListCell to visit.
|
||||
*/
|
||||
static void
|
||||
@@ -1014,13 +1014,13 @@ arrayexpr_cleanup_fn(PredIterInfo info)
|
||||
* implies another:
|
||||
*
|
||||
* A simple and general way is to see if they are equal(); this works for any
|
||||
* kind of expression. (Actually, there is an implied assumption that the
|
||||
* kind of expression. (Actually, there is an implied assumption that the
|
||||
* functions in the expression are immutable, ie dependent only on their input
|
||||
* arguments --- but this was checked for the predicate by the caller.)
|
||||
*
|
||||
* When the predicate is of the form "foo IS NOT NULL", we can conclude that
|
||||
* the predicate is implied if the clause is a strict operator or function
|
||||
* that has "foo" as an input. In this case the clause must yield NULL when
|
||||
* that has "foo" as an input. In this case the clause must yield NULL when
|
||||
* "foo" is NULL, which we can take as equivalent to FALSE because we know
|
||||
* we are within an AND/OR subtree of a WHERE clause. (Again, "foo" is
|
||||
* already known immutable, so the clause will certainly always fail.)
|
||||
@@ -1244,7 +1244,7 @@ list_member_strip(List *list, Expr *datum)
|
||||
*
|
||||
* The strategy numbers defined by btree indexes (see access/skey.h) are:
|
||||
* (1) < (2) <= (3) = (4) >= (5) >
|
||||
* and in addition we use (6) to represent <>. <> is not a btree-indexable
|
||||
* and in addition we use (6) to represent <>. <> is not a btree-indexable
|
||||
* operator, but we assume here that if an equality operator of a btree
|
||||
* opfamily has a negator operator, the negator behaves as <> for the opfamily.
|
||||
* (This convention is also known to get_op_btree_interpretation().)
|
||||
@@ -1328,7 +1328,7 @@ static const StrategyNumber BT_refute_table[6][6] = {
|
||||
* if not able to prove it.
|
||||
*
|
||||
* What we look for here is binary boolean opclauses of the form
|
||||
* "foo op constant", where "foo" is the same in both clauses. The operators
|
||||
* "foo op constant", where "foo" is the same in both clauses. The operators
|
||||
* and constants can be different but the operators must be in the same btree
|
||||
* operator family. We use the above operator implication tables to
|
||||
* derive implications between nonidentical clauses. (Note: "foo" is known
|
||||
@@ -1418,7 +1418,7 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it)
|
||||
/*
|
||||
* Check for matching subexpressions on the non-Const sides. We used to
|
||||
* only allow a simple Var, but it's about as easy to allow any
|
||||
* expression. Remember we already know that the pred expression does not
|
||||
* expression. Remember we already know that the pred expression does not
|
||||
* contain any non-immutable functions, so identical expressions should
|
||||
* yield identical results.
|
||||
*/
|
||||
@@ -1690,7 +1690,7 @@ get_btree_test_op(Oid pred_op, Oid clause_op, bool refute_it)
|
||||
* Last check: test_op must be immutable.
|
||||
*
|
||||
* Note that we require only the test_op to be immutable, not the
|
||||
* original clause_op. (pred_op is assumed to have been checked
|
||||
* original clause_op. (pred_op is assumed to have been checked
|
||||
* immutable by the caller.) Essentially we are assuming that the
|
||||
* opfamily is consistent even if it contains operators that are
|
||||
* merely stable.
|
||||
|
||||
@@ -262,7 +262,7 @@ RelOptInfo *
|
||||
find_join_rel(PlannerInfo *root, Relids relids)
|
||||
{
|
||||
/*
|
||||
* Switch to using hash lookup when list grows "too long". The threshold
|
||||
* Switch to using hash lookup when list grows "too long". The threshold
|
||||
* is arbitrary and is known only here.
|
||||
*/
|
||||
if (!root->join_rel_hash && list_length(root->join_rel_list) > 32)
|
||||
@@ -448,7 +448,7 @@ build_join_rel(PlannerInfo *root,
|
||||
|
||||
/*
|
||||
* Also, if dynamic-programming join search is active, add the new joinrel
|
||||
* to the appropriate sublist. Note: you might think the Assert on number
|
||||
* to the appropriate sublist. Note: you might think the Assert on number
|
||||
* of members should be for equality, but some of the level 1 rels might
|
||||
* have been joinrels already, so we can only assert <=.
|
||||
*/
|
||||
@@ -529,7 +529,7 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
* the join list need only be computed once for any join RelOptInfo.
|
||||
* The join list is fully determined by the set of rels making up the
|
||||
* joinrel, so we should get the same results (up to ordering) from any
|
||||
* candidate pair of sub-relations. But the restriction list is whatever
|
||||
* candidate pair of sub-relations. But the restriction list is whatever
|
||||
* is not handled in the sub-relations, so it depends on which
|
||||
* sub-relations are considered.
|
||||
*
|
||||
@@ -538,7 +538,7 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
* we put it into the joininfo list for the joinrel. Otherwise,
|
||||
* the clause is now a restrict clause for the joined relation, and we
|
||||
* return it to the caller of build_joinrel_restrictlist() to be stored in
|
||||
* join paths made from this pair of sub-relations. (It will not need to
|
||||
* join paths made from this pair of sub-relations. (It will not need to
|
||||
* be considered further up the join tree.)
|
||||
*
|
||||
* In many case we will find the same RestrictInfos in both input
|
||||
@@ -557,7 +557,7 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
*
|
||||
* NB: Formerly, we made deep(!) copies of each input RestrictInfo to pass
|
||||
* up to the join relation. I believe this is no longer necessary, because
|
||||
* RestrictInfo nodes are no longer context-dependent. Instead, just include
|
||||
* RestrictInfo nodes are no longer context-dependent. Instead, just include
|
||||
* the original nodes in the lists made for the join relation.
|
||||
*/
|
||||
static List *
|
||||
@@ -577,7 +577,7 @@ build_joinrel_restrictlist(PlannerInfo *root,
|
||||
result = subbuild_joinrel_restrictlist(joinrel, inner_rel->joininfo, result);
|
||||
|
||||
/*
|
||||
* Add on any clauses derived from EquivalenceClasses. These cannot be
|
||||
* Add on any clauses derived from EquivalenceClasses. These cannot be
|
||||
* redundant with the clauses in the joininfo lists, so don't bother
|
||||
* checking.
|
||||
*/
|
||||
@@ -945,7 +945,7 @@ get_joinrel_parampathinfo(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
*restrict_clauses);
|
||||
|
||||
/*
|
||||
* And now we can build the ParamPathInfo. No point in saving the
|
||||
* And now we can build the ParamPathInfo. No point in saving the
|
||||
* input-pair-dependent clause list, though.
|
||||
*
|
||||
* Note: in GEQO mode, we'll be called in a temporary memory context, but
|
||||
@@ -965,8 +965,8 @@ get_joinrel_parampathinfo(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
* Get the ParamPathInfo for a parameterized path for an append relation.
|
||||
*
|
||||
* For an append relation, the rowcount estimate will just be the sum of
|
||||
* the estimates for its children. However, we still need a ParamPathInfo
|
||||
* to flag the fact that the path requires parameters. So this just creates
|
||||
* the estimates for its children. However, we still need a ParamPathInfo
|
||||
* to flag the fact that the path requires parameters. So this just creates
|
||||
* a suitable struct with zero ppi_rows (and no ppi_clauses either, since
|
||||
* the Append node isn't responsible for checking quals).
|
||||
*/
|
||||
|
||||
@@ -210,7 +210,7 @@ make_restrictinfo_internal(Expr *clause,
|
||||
|
||||
/*
|
||||
* Fill in all the cacheable fields with "not yet set" markers. None of
|
||||
* these will be computed until/unless needed. Note in particular that we
|
||||
* these will be computed until/unless needed. Note in particular that we
|
||||
* don't mark a binary opclause as mergejoinable or hashjoinable here;
|
||||
* that happens only if it appears in the right context (top level of a
|
||||
* joinclause list).
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/*
|
||||
* tlist_member
|
||||
* Finds the (first) member of the given tlist whose expression is
|
||||
* equal() to the given expression. Result is NULL if no such member.
|
||||
* equal() to the given expression. Result is NULL if no such member.
|
||||
*/
|
||||
TargetEntry *
|
||||
tlist_member(Node *node, List *targetlist)
|
||||
|
||||
@@ -165,7 +165,7 @@ pull_varnos_walker(Node *node, pull_varnos_context *context)
|
||||
* lower than that if it references only a subset of the rels in its
|
||||
* syntactic scope. It might also contain lateral references, but we
|
||||
* should ignore such references when computing the set of varnos in
|
||||
* an expression tree. Also, if the PHV contains no variables within
|
||||
* an expression tree. Also, if the PHV contains no variables within
|
||||
* its syntactic scope, it will be forced to be evaluated exactly at
|
||||
* the syntactic scope, so take that as the relid set.
|
||||
*/
|
||||
@@ -364,7 +364,7 @@ contain_var_clause_walker(Node *node, void *context)
|
||||
*
|
||||
* Returns true if any such Var found.
|
||||
*
|
||||
* Will recurse into sublinks. Also, may be invoked directly on a Query.
|
||||
* Will recurse into sublinks. Also, may be invoked directly on a Query.
|
||||
*/
|
||||
bool
|
||||
contain_vars_of_level(Node *node, int levelsup)
|
||||
@@ -424,10 +424,10 @@ contain_vars_of_level_walker(Node *node, int *sublevels_up)
|
||||
* Find the parse location of any Var of the specified query level.
|
||||
*
|
||||
* Returns -1 if no such Var is in the querytree, or if they all have
|
||||
* unknown parse location. (The former case is probably caller error,
|
||||
* unknown parse location. (The former case is probably caller error,
|
||||
* but we don't bother to distinguish it from the latter case.)
|
||||
*
|
||||
* Will recurse into sublinks. Also, may be invoked directly on a Query.
|
||||
* Will recurse into sublinks. Also, may be invoked directly on a Query.
|
||||
*
|
||||
* Note: it might seem appropriate to merge this functionality into
|
||||
* contain_vars_of_level, but that would complicate that function's API.
|
||||
@@ -514,7 +514,7 @@ locate_var_of_level_walker(Node *node,
|
||||
* Upper-level vars (with varlevelsup > 0) should not be seen here,
|
||||
* likewise for upper-level Aggrefs and PlaceHolderVars.
|
||||
*
|
||||
* Returns list of nodes found. Note the nodes themselves are not
|
||||
* Returns list of nodes found. Note the nodes themselves are not
|
||||
* copied, only referenced.
|
||||
*
|
||||
* Does not examine subqueries, therefore must only be used after reduction
|
||||
@@ -591,7 +591,7 @@ pull_var_clause_walker(Node *node, pull_var_clause_context *context)
|
||||
* flatten_join_alias_vars
|
||||
* Replace Vars that reference JOIN outputs with references to the original
|
||||
* relation variables instead. This allows quals involving such vars to be
|
||||
* pushed down. Whole-row Vars that reference JOIN relations are expanded
|
||||
* pushed down. Whole-row Vars that reference JOIN relations are expanded
|
||||
* into RowExpr constructs that name the individual output Vars. This
|
||||
* is necessary since we will not scan the JOIN as a base relation, which
|
||||
* is the only way that the executor can directly handle whole-row Vars.
|
||||
@@ -603,7 +603,7 @@ pull_var_clause_walker(Node *node, pull_var_clause_context *context)
|
||||
* entries might now be arbitrary expressions, not just Vars. This affects
|
||||
* this function in one important way: we might find ourselves inserting
|
||||
* SubLink expressions into subqueries, and we must make sure that their
|
||||
* Query.hasSubLinks fields get set to TRUE if so. If there are any
|
||||
* Query.hasSubLinks fields get set to TRUE if so. If there are any
|
||||
* SubLinks in the join alias lists, the outer Query should already have
|
||||
* hasSubLinks = TRUE, so this is only relevant to un-flattened subqueries.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user