mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
pgindent run.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: geqo_misc.c,v 1.33 2002/07/20 04:59:10 momjian Exp $
|
||||
* $Id: geqo_misc.c,v 1.34 2002/09/04 20:31:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -250,4 +250,4 @@ geqo_print_rel(Query *root, RelOptInfo *rel)
|
||||
geqo_print_path(root, rel->cheapest_total_path, 1);
|
||||
}
|
||||
|
||||
#endif /* GEQO_DEBUG */
|
||||
#endif /* GEQO_DEBUG */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.87 2002/08/29 16:03:48 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.88 2002/09/04 20:31:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -43,14 +43,14 @@ static void set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
|
||||
static void set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
Index rti, RangeTblEntry *rte);
|
||||
static void set_function_pathlist(Query *root, RelOptInfo *rel,
|
||||
RangeTblEntry *rte);
|
||||
RangeTblEntry *rte);
|
||||
static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed,
|
||||
List *initial_rels);
|
||||
static bool subquery_is_pushdown_safe(Query *subquery, Query *topquery);
|
||||
static bool recurse_pushdown_safe(Node *setOp, Query *topquery);
|
||||
static void subquery_push_qual(Query *subquery, Index rti, Node *qual);
|
||||
static void recurse_push_qual(Node *setOp, Query *topquery,
|
||||
Index rti, Node *qual);
|
||||
Index rti, Node *qual);
|
||||
|
||||
|
||||
/*
|
||||
@@ -304,9 +304,10 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
*
|
||||
* There are several cases where we cannot push down clauses.
|
||||
* Restrictions involving the subquery are checked by
|
||||
* subquery_is_pushdown_safe(). Also, we do not push down clauses that
|
||||
* contain subselects, mainly because I'm not sure it will work correctly
|
||||
* (the subplan hasn't yet transformed sublinks to subselects).
|
||||
* subquery_is_pushdown_safe(). Also, we do not push down clauses
|
||||
* that contain subselects, mainly because I'm not sure it will work
|
||||
* correctly (the subplan hasn't yet transformed sublinks to
|
||||
* subselects).
|
||||
*
|
||||
* Non-pushed-down clauses will get evaluated as qpquals of the
|
||||
* SubqueryScan node.
|
||||
@@ -542,7 +543,7 @@ make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels)
|
||||
* quals into it, because that would change the results. For subqueries
|
||||
* using UNION/UNION ALL/INTERSECT/INTERSECT ALL, we can push the quals
|
||||
* into each component query, so long as all the component queries share
|
||||
* identical output types. (That restriction could probably be relaxed,
|
||||
* identical output types. (That restriction could probably be relaxed,
|
||||
* but it would take much more code to include type coercion code into
|
||||
* the quals, and I'm also concerned about possible semantic gotchas.)
|
||||
*/
|
||||
@@ -633,14 +634,14 @@ subquery_push_qual(Query *subquery, Index rti, Node *qual)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We need to replace Vars in the qual (which must refer
|
||||
* to outputs of the subquery) with copies of the
|
||||
* subquery's targetlist expressions. Note that at this
|
||||
* point, any uplevel Vars in the qual should have been
|
||||
* replaced with Params, so they need no work.
|
||||
* We need to replace Vars in the qual (which must refer to
|
||||
* outputs of the subquery) with copies of the subquery's
|
||||
* targetlist expressions. Note that at this point, any uplevel
|
||||
* Vars in the qual should have been replaced with Params, so they
|
||||
* need no work.
|
||||
*
|
||||
* This step also ensures that when we are pushing into a setop
|
||||
* tree, each component query gets its own copy of the qual.
|
||||
* This step also ensures that when we are pushing into a setop tree,
|
||||
* each component query gets its own copy of the qual.
|
||||
*/
|
||||
qual = ResolveNew(qual, rti, 0,
|
||||
subquery->targetList,
|
||||
@@ -649,10 +650,9 @@ subquery_push_qual(Query *subquery, Index rti, Node *qual)
|
||||
qual);
|
||||
|
||||
/*
|
||||
* We need not change the subquery's hasAggs or
|
||||
* hasSublinks flags, since we can't be pushing down any
|
||||
* aggregates that weren't there before, and we don't push
|
||||
* down subselects at all.
|
||||
* We need not change the subquery's hasAggs or hasSublinks flags,
|
||||
* since we can't be pushing down any aggregates that weren't
|
||||
* there before, and we don't push down subselects at all.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.89 2002/07/04 15:23:56 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.90 2002/09/04 20:31:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -408,8 +408,8 @@ cost_functionscan(Path *path, Query *root, RelOptInfo *baserel)
|
||||
|
||||
/*
|
||||
* For now, estimate function's cost at one operator eval per function
|
||||
* call. Someday we should revive the function cost estimate columns in
|
||||
* pg_proc...
|
||||
* call. Someday we should revive the function cost estimate columns
|
||||
* in pg_proc...
|
||||
*/
|
||||
cpu_per_tuple = cpu_operator_cost;
|
||||
|
||||
@@ -607,7 +607,7 @@ cost_mergejoin(Path *path, Query *root,
|
||||
double outer_rows,
|
||||
inner_rows;
|
||||
double ntuples;
|
||||
Selectivity outerscansel,
|
||||
Selectivity outerscansel,
|
||||
innerscansel;
|
||||
Path sort_path; /* dummy for result of cost_sort */
|
||||
|
||||
@@ -617,15 +617,15 @@ cost_mergejoin(Path *path, Query *root,
|
||||
/*
|
||||
* A merge join will stop as soon as it exhausts either input stream.
|
||||
* Estimate fraction of the left and right inputs that will actually
|
||||
* need to be scanned. We use only the first (most significant)
|
||||
* merge clause for this purpose.
|
||||
* need to be scanned. We use only the first (most significant) merge
|
||||
* clause for this purpose.
|
||||
*
|
||||
* Since this calculation is somewhat expensive, and will be the same
|
||||
* for all mergejoin paths associated with the merge clause, we cache
|
||||
* the results in the RestrictInfo node.
|
||||
* Since this calculation is somewhat expensive, and will be the same for
|
||||
* all mergejoin paths associated with the merge clause, we cache the
|
||||
* results in the RestrictInfo node.
|
||||
*/
|
||||
firstclause = (RestrictInfo *) lfirst(mergeclauses);
|
||||
if (firstclause->left_mergescansel < 0) /* not computed yet? */
|
||||
if (firstclause->left_mergescansel < 0) /* not computed yet? */
|
||||
mergejoinscansel(root, (Node *) firstclause->clause,
|
||||
&firstclause->left_mergescansel,
|
||||
&firstclause->right_mergescansel);
|
||||
@@ -697,10 +697,10 @@ cost_mergejoin(Path *path, Query *root,
|
||||
/*
|
||||
* The number of tuple comparisons needed depends drastically on the
|
||||
* number of equal keys in the two source relations, which we have no
|
||||
* good way of estimating. (XXX could the MCV statistics help?)
|
||||
* Somewhat arbitrarily, we charge one tuple
|
||||
* comparison (one cpu_operator_cost) for each tuple in the two source
|
||||
* relations. This is probably a lower bound.
|
||||
* good way of estimating. (XXX could the MCV statistics help?)
|
||||
* Somewhat arbitrarily, we charge one tuple comparison (one
|
||||
* cpu_operator_cost) for each tuple in the two source relations.
|
||||
* This is probably a lower bound.
|
||||
*/
|
||||
run_cost += cpu_operator_cost * (outer_rows + inner_rows);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.121 2002/09/02 06:22:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.122 2002/09/04 20:31:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1332,7 +1332,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
|
||||
test_oper = makeOper(test_op, /* opno */
|
||||
InvalidOid, /* opid */
|
||||
BOOLOID, /* opresulttype */
|
||||
false); /* opretset */
|
||||
false); /* opretset */
|
||||
replace_opid(test_oper);
|
||||
test_expr = make_opclause(test_oper,
|
||||
(Var *) clause_const,
|
||||
@@ -1712,7 +1712,7 @@ match_special_index_operator(Expr *clause, Oid opclass,
|
||||
|
||||
case OID_BYTEA_LIKE_OP:
|
||||
isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like,
|
||||
&prefix, &rest) != Pattern_Prefix_None;
|
||||
&prefix, &rest) != Pattern_Prefix_None;
|
||||
break;
|
||||
|
||||
case OID_TEXT_ICLIKE_OP:
|
||||
@@ -1922,7 +1922,7 @@ expand_indexqual_conditions(List *indexquals)
|
||||
case OID_CIDR_SUBEQ_OP:
|
||||
resultquals = nconc(resultquals,
|
||||
network_prefix_quals(leftop, expr_op,
|
||||
patt->constvalue));
|
||||
patt->constvalue));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.70 2002/09/02 02:47:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.71 2002/09/04 20:31:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -171,7 +171,7 @@ sort_inner_and_outer(Query *root,
|
||||
default:
|
||||
elog(ERROR, "sort_inner_and_outer: unexpected join type %d",
|
||||
(int) jointype);
|
||||
useallclauses = false; /* keep compiler quiet */
|
||||
useallclauses = false; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.39 2002/06/20 20:29:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.40 2002/09/04 20:31:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -519,7 +519,7 @@ build_index_pathkeys(Query *root,
|
||||
|
||||
funcnode->funcid = index->indproc;
|
||||
funcnode->funcresulttype = get_func_rettype(index->indproc);
|
||||
funcnode->funcretset = false; /* can never be a set */
|
||||
funcnode->funcretset = false; /* can never be a set */
|
||||
funcnode->func_fcache = NULL;
|
||||
|
||||
while (*indexkeys != 0)
|
||||
@@ -769,22 +769,22 @@ find_mergeclauses_for_pathkeys(Query *root,
|
||||
|
||||
/*
|
||||
* We can match a pathkey against either left or right side of any
|
||||
* mergejoin clause. (We examine both sides since we aren't told if
|
||||
* the given pathkeys are for inner or outer input path; no confusion
|
||||
* is possible.) Furthermore, if there are multiple matching
|
||||
* clauses, take them all. In plain inner-join scenarios we expect
|
||||
* only one match, because redundant-mergeclause elimination will
|
||||
* have removed any redundant mergeclauses from the input list.
|
||||
* However, in outer-join scenarios there might be multiple matches.
|
||||
* An example is
|
||||
* mergejoin clause. (We examine both sides since we aren't told
|
||||
* if the given pathkeys are for inner or outer input path; no
|
||||
* confusion is possible.) Furthermore, if there are multiple
|
||||
* matching clauses, take them all. In plain inner-join scenarios
|
||||
* we expect only one match, because redundant-mergeclause
|
||||
* elimination will have removed any redundant mergeclauses from
|
||||
* the input list. However, in outer-join scenarios there might be
|
||||
* multiple matches. An example is
|
||||
*
|
||||
* select * from a full join b on
|
||||
* a.v1 = b.v1 and a.v2 = b.v2 and a.v1 = b.v2;
|
||||
* select * from a full join b on a.v1 = b.v1 and a.v2 = b.v2 and
|
||||
* a.v1 = b.v2;
|
||||
*
|
||||
* Given the pathkeys ((a.v1), (a.v2)) it is okay to return all
|
||||
* three clauses (in the order a.v1=b.v1, a.v1=b.v2, a.v2=b.v2)
|
||||
* and indeed we *must* do so or we will be unable to form a
|
||||
* valid plan.
|
||||
* Given the pathkeys ((a.v1), (a.v2)) it is okay to return all three
|
||||
* clauses (in the order a.v1=b.v1, a.v1=b.v2, a.v2=b.v2) and
|
||||
* indeed we *must* do so or we will be unable to form a valid
|
||||
* plan.
|
||||
*/
|
||||
foreach(j, restrictinfos)
|
||||
{
|
||||
@@ -812,8 +812,8 @@ find_mergeclauses_for_pathkeys(Query *root,
|
||||
break;
|
||||
|
||||
/*
|
||||
* If we did find usable mergeclause(s) for this sort-key position,
|
||||
* add them to result list.
|
||||
* If we did find usable mergeclause(s) for this sort-key
|
||||
* position, add them to result list.
|
||||
*/
|
||||
mergeclauses = nconc(mergeclauses, matched_restrictinfos);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.117 2002/09/02 02:47:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.118 2002/09/04 20:31:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
|
||||
static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid,
|
||||
List *tideval);
|
||||
static FunctionScan *make_functionscan(List *qptlist, List *qpqual,
|
||||
Index scanrelid);
|
||||
Index scanrelid);
|
||||
static NestLoop *make_nestloop(List *tlist,
|
||||
List *joinclauses, List *otherclauses,
|
||||
Plan *lefttree, Plan *righttree,
|
||||
@@ -206,8 +206,8 @@ create_scan_plan(Query *root, Path *best_path)
|
||||
|
||||
case T_FunctionScan:
|
||||
plan = (Scan *) create_functionscan_plan(best_path,
|
||||
tlist,
|
||||
scan_clauses);
|
||||
tlist,
|
||||
scan_clauses);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1346,8 +1346,8 @@ make_functionscan(List *qptlist,
|
||||
List *qpqual,
|
||||
Index scanrelid)
|
||||
{
|
||||
FunctionScan *node = makeNode(FunctionScan);
|
||||
Plan *plan = &node->scan.plan;
|
||||
FunctionScan *node = makeNode(FunctionScan);
|
||||
Plan *plan = &node->scan.plan;
|
||||
|
||||
/* cost should be inserted by caller */
|
||||
plan->state = (EState *) NULL;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.74 2002/09/02 02:47:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.75 2002/09/04 20:31:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -108,12 +108,15 @@ add_base_rels_to_query(Query *root, Node *jtnode)
|
||||
add_base_rels_to_query(root, j->rarg));
|
||||
/* the join's own rtindex is NOT added to result */
|
||||
jrel = build_other_rel(root, j->rtindex);
|
||||
|
||||
/*
|
||||
* Mark the join's otherrel with outerjoinset = list of baserel ids
|
||||
* included in the join. Note we must copy here because result list
|
||||
* is destructively modified by nconcs at higher levels.
|
||||
* Mark the join's otherrel with outerjoinset = list of baserel
|
||||
* ids included in the join. Note we must copy here because
|
||||
* result list is destructively modified by nconcs at higher
|
||||
* levels.
|
||||
*/
|
||||
jrel->outerjoinset = listCopy(result);
|
||||
|
||||
/*
|
||||
* Safety check: join RTEs should not be SELECT FOR UPDATE targets
|
||||
*/
|
||||
@@ -172,8 +175,8 @@ add_vars_to_targetlist(Query *root, List *vars)
|
||||
if (rel->reloptkind == RELOPT_OTHER_JOIN_REL)
|
||||
{
|
||||
/* Var is an alias */
|
||||
Node *expansion;
|
||||
List *varsused;
|
||||
Node *expansion;
|
||||
List *varsused;
|
||||
|
||||
expansion = flatten_join_alias_vars((Node *) var,
|
||||
root->rtable, true);
|
||||
@@ -196,7 +199,7 @@ add_vars_to_targetlist(Query *root, List *vars)
|
||||
* distribute_quals_to_rels
|
||||
* Recursively scan the query's join tree for WHERE and JOIN/ON qual
|
||||
* clauses, and add these to the appropriate RestrictInfo and JoinInfo
|
||||
* lists belonging to base RelOptInfos. Also, base RelOptInfos are marked
|
||||
* lists belonging to base RelOptInfos. Also, base RelOptInfos are marked
|
||||
* with outerjoinset information, to aid in proper positioning of qual
|
||||
* clauses that appear above outer joins.
|
||||
*
|
||||
@@ -400,7 +403,8 @@ distribute_qual_to_rels(Query *root, Node *clause,
|
||||
restrictinfo->right_sortop = InvalidOid;
|
||||
restrictinfo->left_pathkey = NIL; /* not computable yet */
|
||||
restrictinfo->right_pathkey = NIL;
|
||||
restrictinfo->left_mergescansel = -1; /* not computed until needed */
|
||||
restrictinfo->left_mergescansel = -1; /* not computed until
|
||||
* needed */
|
||||
restrictinfo->right_mergescansel = -1;
|
||||
restrictinfo->hashjoinoperator = InvalidOid;
|
||||
restrictinfo->left_bucketsize = -1; /* not computed until needed */
|
||||
@@ -419,7 +423,7 @@ distribute_qual_to_rels(Query *root, Node *clause,
|
||||
* earlier by add_base_rels_to_query.
|
||||
*
|
||||
* We can combine this step with a cross-check that the clause contains
|
||||
* no relids not within its scope. If the first crosscheck succeeds,
|
||||
* no relids not within its scope. If the first crosscheck succeeds,
|
||||
* the clause contains no aliases and we needn't look more closely.
|
||||
*/
|
||||
if (!is_subseti(relids, qualscope))
|
||||
@@ -763,10 +767,10 @@ process_implied_equality(Query *root, Node *item1, Node *item2,
|
||||
clause = makeNode(Expr);
|
||||
clause->typeOid = BOOLOID;
|
||||
clause->opType = OP_EXPR;
|
||||
clause->oper = (Node *) makeOper(oprid(eq_operator),/* opno */
|
||||
clause->oper = (Node *) makeOper(oprid(eq_operator), /* opno */
|
||||
InvalidOid, /* opid */
|
||||
BOOLOID, /* opresulttype */
|
||||
false); /* opretset */
|
||||
BOOLOID, /* opresulttype */
|
||||
false); /* opretset */
|
||||
clause->args = makeList2(item1, item2);
|
||||
|
||||
ReleaseSysCache(eq_operator);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.123 2002/08/28 20:46:23 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.124 2002/09/04 20:31:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
|
||||
static Node *pull_up_subqueries(Query *parse, Node *jtnode,
|
||||
bool below_outer_join);
|
||||
bool below_outer_join);
|
||||
static bool is_simple_subquery(Query *subquery);
|
||||
static bool has_nullable_targetlist(Query *subquery);
|
||||
static void resolvenew_in_jointree(Node *jtnode, int varno, List *subtlist);
|
||||
@@ -301,16 +301,16 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
|
||||
*
|
||||
* If we are inside an outer join, only pull up subqueries whose
|
||||
* targetlists are nullable --- otherwise substituting their tlist
|
||||
* entries for upper Var references would do the wrong thing
|
||||
* (the results wouldn't become NULL when they're supposed to).
|
||||
* XXX This could be improved by generating pseudo-variables for
|
||||
* such expressions; we'd have to figure out how to get the pseudo-
|
||||
* variables evaluated at the right place in the modified plan tree.
|
||||
* Fix it someday.
|
||||
* entries for upper Var references would do the wrong thing (the
|
||||
* results wouldn't become NULL when they're supposed to). XXX
|
||||
* This could be improved by generating pseudo-variables for such
|
||||
* expressions; we'd have to figure out how to get the pseudo-
|
||||
* variables evaluated at the right place in the modified plan
|
||||
* tree. Fix it someday.
|
||||
*
|
||||
* Note: even if the subquery itself is simple enough, we can't pull
|
||||
* it up if there is a reference to its whole tuple result. Perhaps
|
||||
* a pseudo-variable is the answer here too.
|
||||
* it up if there is a reference to its whole tuple result.
|
||||
* Perhaps a pseudo-variable is the answer here too.
|
||||
*/
|
||||
if (rte->rtekind == RTE_SUBQUERY && is_simple_subquery(subquery) &&
|
||||
(!below_outer_join || has_nullable_targetlist(subquery)) &&
|
||||
@@ -336,8 +336,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
|
||||
below_outer_join);
|
||||
|
||||
/*
|
||||
* Now make a modifiable copy of the subquery that we can
|
||||
* run OffsetVarNodes on.
|
||||
* Now make a modifiable copy of the subquery that we can run
|
||||
* OffsetVarNodes on.
|
||||
*/
|
||||
subquery = copyObject(subquery);
|
||||
|
||||
@@ -352,7 +352,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
|
||||
* Replace all of the top query's references to the subquery's
|
||||
* outputs with copies of the adjusted subtlist items, being
|
||||
* careful not to replace any of the jointree structure.
|
||||
* (This'd be a lot cleaner if we could use query_tree_mutator.)
|
||||
* (This'd be a lot cleaner if we could use
|
||||
* query_tree_mutator.)
|
||||
*/
|
||||
subtlist = subquery->targetList;
|
||||
parse->targetList = (List *)
|
||||
@@ -375,15 +376,16 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
|
||||
}
|
||||
|
||||
/*
|
||||
* Now append the adjusted rtable entries to upper query.
|
||||
* (We hold off until after fixing the upper rtable entries;
|
||||
* no point in running that code on the subquery ones too.)
|
||||
* Now append the adjusted rtable entries to upper query. (We
|
||||
* hold off until after fixing the upper rtable entries; no
|
||||
* point in running that code on the subquery ones too.)
|
||||
*/
|
||||
parse->rtable = nconc(parse->rtable, subquery->rtable);
|
||||
|
||||
/*
|
||||
* Pull up any FOR UPDATE markers, too. (OffsetVarNodes
|
||||
* already adjusted the marker values, so just nconc the list.)
|
||||
* already adjusted the marker values, so just nconc the
|
||||
* list.)
|
||||
*/
|
||||
parse->rowMarks = nconc(parse->rowMarks, subquery->rowMarks);
|
||||
|
||||
@@ -500,9 +502,9 @@ is_simple_subquery(Query *subquery)
|
||||
|
||||
/*
|
||||
* Don't pull up a subquery that has any set-returning functions in
|
||||
* its targetlist. Otherwise we might well wind up inserting
|
||||
* set-returning functions into places where they mustn't go,
|
||||
* such as quals of higher queries.
|
||||
* its targetlist. Otherwise we might well wind up inserting
|
||||
* set-returning functions into places where they mustn't go, such as
|
||||
* quals of higher queries.
|
||||
*/
|
||||
if (expression_returns_set((Node *) subquery->targetList))
|
||||
return false;
|
||||
@@ -724,8 +726,8 @@ preprocess_expression(Query *parse, Node *expr, int kind)
|
||||
|
||||
/*
|
||||
* If the query has any join RTEs, try to replace join alias variables
|
||||
* with base-relation variables, to allow quals to be pushed down.
|
||||
* We must do this after sublink processing, since it does not recurse
|
||||
* with base-relation variables, to allow quals to be pushed down. We
|
||||
* must do this after sublink processing, since it does not recurse
|
||||
* into sublinks.
|
||||
*
|
||||
* The flattening pass is expensive enough that it seems worthwhile to
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.80 2002/09/02 02:47:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.81 2002/09/04 20:31:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -423,7 +423,7 @@ join_references_mutator(Node *node,
|
||||
resdom = tlist_member((Node *) var, context->outer_tlist);
|
||||
if (resdom)
|
||||
{
|
||||
Var *newvar = (Var *) copyObject(var);
|
||||
Var *newvar = (Var *) copyObject(var);
|
||||
|
||||
newvar->varno = OUTER;
|
||||
newvar->varattno = resdom->resno;
|
||||
@@ -432,7 +432,7 @@ join_references_mutator(Node *node,
|
||||
resdom = tlist_member((Node *) var, context->inner_tlist);
|
||||
if (resdom)
|
||||
{
|
||||
Var *newvar = (Var *) copyObject(var);
|
||||
Var *newvar = (Var *) copyObject(var);
|
||||
|
||||
newvar->varno = INNER;
|
||||
newvar->varattno = resdom->resno;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.54 2002/06/20 20:29:31 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.55 2002/09/04 20:31:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -369,7 +369,7 @@ make_subplan(SubLink *slink)
|
||||
}
|
||||
if (use_material)
|
||||
{
|
||||
Plan *matplan;
|
||||
Plan *matplan;
|
||||
|
||||
matplan = (Plan *) make_material(plan->targetlist, plan);
|
||||
/* kluge --- see comments above */
|
||||
@@ -663,8 +663,8 @@ SS_finalize_plan(Plan *plan, List *rtable)
|
||||
case T_Append:
|
||||
foreach(lst, ((Append *) plan)->appendplans)
|
||||
results.paramids = set_unioni(results.paramids,
|
||||
SS_finalize_plan((Plan *) lfirst(lst),
|
||||
rtable));
|
||||
SS_finalize_plan((Plan *) lfirst(lst),
|
||||
rtable));
|
||||
break;
|
||||
|
||||
case T_NestLoop:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.55 2002/08/31 22:10:43 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.56 2002/09/04 20:31:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -128,7 +128,8 @@ expand_targetlist(List *tlist, int command_type,
|
||||
|
||||
/*
|
||||
* The rewriter should have already ensured that the TLEs are in
|
||||
* correct order; but we have to insert TLEs for any missing attributes.
|
||||
* correct order; but we have to insert TLEs for any missing
|
||||
* attributes.
|
||||
*
|
||||
* Scan the tuple description in the relation's relcache entry to make
|
||||
* sure we have all the user attributes in the right order.
|
||||
@@ -161,14 +162,14 @@ expand_targetlist(List *tlist, int command_type,
|
||||
/*
|
||||
* Didn't find a matching tlist entry, so make one.
|
||||
*
|
||||
* For INSERT, generate a NULL constant. (We assume the
|
||||
* rewriter would have inserted any available default value.)
|
||||
* Also, if the column isn't dropped, apply any domain constraints
|
||||
* that might exist --- this is to catch domain NOT NULL.
|
||||
* For INSERT, generate a NULL constant. (We assume the rewriter
|
||||
* would have inserted any available default value.) Also, if
|
||||
* the column isn't dropped, apply any domain constraints that
|
||||
* might exist --- this is to catch domain NOT NULL.
|
||||
*
|
||||
* For UPDATE, generate a Var reference to the existing value of
|
||||
* the attribute, so that it gets copied to the new tuple.
|
||||
* But generate a NULL for dropped columns (we want to drop any
|
||||
* the attribute, so that it gets copied to the new tuple. But
|
||||
* generate a NULL for dropped columns (we want to drop any
|
||||
* old values).
|
||||
*/
|
||||
Oid atttype = att_tup->atttypid;
|
||||
@@ -181,13 +182,13 @@ expand_targetlist(List *tlist, int command_type,
|
||||
new_expr = (Node *) makeConst(atttype,
|
||||
att_tup->attlen,
|
||||
(Datum) 0,
|
||||
true, /* isnull */
|
||||
true, /* isnull */
|
||||
att_tup->attbyval,
|
||||
false, /* not a set */
|
||||
false, /* not a set */
|
||||
false);
|
||||
if (!att_tup->attisdropped)
|
||||
new_expr = coerce_type_constraints(NULL, new_expr,
|
||||
atttype, false);
|
||||
atttype, false);
|
||||
break;
|
||||
case CMD_UPDATE:
|
||||
/* Insert NULLs for dropped columns */
|
||||
@@ -215,7 +216,7 @@ expand_targetlist(List *tlist, int command_type,
|
||||
new_tle = makeTargetEntry(makeResdom(attrno,
|
||||
atttype,
|
||||
atttypmod,
|
||||
pstrdup(NameStr(att_tup->attname)),
|
||||
pstrdup(NameStr(att_tup->attname)),
|
||||
false),
|
||||
new_expr);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.77 2002/09/02 02:47:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.78 2002/09/04 20:31:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -63,8 +63,8 @@ static List *generate_setop_tlist(List *colTypes, int flag,
|
||||
List *input_tlist,
|
||||
List *refnames_tlist);
|
||||
static List *generate_append_tlist(List *colTypes, bool flag,
|
||||
List *input_plans,
|
||||
List *refnames_tlist);
|
||||
List *input_plans,
|
||||
List *refnames_tlist);
|
||||
static Node *adjust_inherited_attrs_mutator(Node *node,
|
||||
adjust_inherited_attrs_context *context);
|
||||
|
||||
@@ -172,8 +172,9 @@ recurse_set_operations(Node *setOp, Query *parse,
|
||||
* This would fail if the Vars generated by generate_setop_tlist()
|
||||
* were not exactly equal() to the corresponding tlist entries of
|
||||
* the subplan. However, since the subplan was generated by
|
||||
* generate_union_plan() or generate_nonunion_plan(), and hence its
|
||||
* tlist was generated by generate_append_tlist(), this will work.
|
||||
* generate_union_plan() or generate_nonunion_plan(), and hence
|
||||
* its tlist was generated by generate_append_tlist(), this will
|
||||
* work.
|
||||
*/
|
||||
if (flag >= 0 ||
|
||||
!tlist_same_datatypes(plan->targetlist, colTypes, junkOK))
|
||||
@@ -485,15 +486,15 @@ generate_append_tlist(List *colTypes, bool flag,
|
||||
/*
|
||||
* First extract typmods to use.
|
||||
*
|
||||
* If the inputs all agree on type and typmod of a particular column,
|
||||
* use that typmod; else use -1.
|
||||
* If the inputs all agree on type and typmod of a particular column, use
|
||||
* that typmod; else use -1.
|
||||
*/
|
||||
colTypmods = (int32 *) palloc(length(colTypes) * sizeof(int32));
|
||||
|
||||
foreach(planl, input_plans)
|
||||
{
|
||||
Plan *subplan = (Plan *) lfirst(planl);
|
||||
List *subtlist;
|
||||
Plan *subplan = (Plan *) lfirst(planl);
|
||||
List *subtlist;
|
||||
|
||||
curColType = colTypes;
|
||||
colindex = 0;
|
||||
@@ -796,8 +797,8 @@ adjust_inherited_attrs_mutator(Node *node,
|
||||
var->varno = context->new_rt_index;
|
||||
if (var->varattno > 0)
|
||||
{
|
||||
char *attname = get_attname(context->old_relid,
|
||||
var->varattno);
|
||||
char *attname = get_attname(context->old_relid,
|
||||
var->varattno);
|
||||
|
||||
var->varattno = get_attnum(context->new_relid, attname);
|
||||
if (var->varattno == InvalidAttrNumber)
|
||||
@@ -819,10 +820,10 @@ adjust_inherited_attrs_mutator(Node *node,
|
||||
if (IsA(node, JoinExpr))
|
||||
{
|
||||
/* Copy the JoinExpr node with correct mutation of subnodes */
|
||||
JoinExpr *j;
|
||||
JoinExpr *j;
|
||||
|
||||
j = (JoinExpr *) expression_tree_mutator(node,
|
||||
adjust_inherited_attrs_mutator,
|
||||
adjust_inherited_attrs_mutator,
|
||||
(void *) context);
|
||||
/* now fix JoinExpr's rtindex */
|
||||
if (j->rtindex == context->old_rt_index)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.107 2002/08/31 22:10:43 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.108 2002/09/04 20:31:22 momjian Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -43,7 +43,7 @@ typedef struct
|
||||
{
|
||||
Query *query;
|
||||
List *groupClauses;
|
||||
} check_subplans_for_ungrouped_vars_context;
|
||||
} check_subplans_for_ungrouped_vars_context;
|
||||
|
||||
static bool contain_agg_clause_walker(Node *node, void *context);
|
||||
static bool pull_agg_clause_walker(Node *node, List **listptr);
|
||||
@@ -51,7 +51,7 @@ static bool expression_returns_set_walker(Node *node, void *context);
|
||||
static bool contain_subplans_walker(Node *node, void *context);
|
||||
static bool pull_subplans_walker(Node *node, List **listptr);
|
||||
static bool check_subplans_for_ungrouped_vars_walker(Node *node,
|
||||
check_subplans_for_ungrouped_vars_context * context);
|
||||
check_subplans_for_ungrouped_vars_context *context);
|
||||
static bool contain_mutable_functions_walker(Node *node, void *context);
|
||||
static bool contain_volatile_functions_walker(Node *node, void *context);
|
||||
static Node *eval_const_expressions_mutator(Node *node, void *context);
|
||||
@@ -479,7 +479,7 @@ expression_returns_set_walker(Node *node, void *context)
|
||||
return false;
|
||||
if (IsA(node, Expr))
|
||||
{
|
||||
Expr *expr = (Expr *) node;
|
||||
Expr *expr = (Expr *) node;
|
||||
|
||||
switch (expr->opType)
|
||||
{
|
||||
@@ -633,7 +633,7 @@ check_subplans_for_ungrouped_vars(Query *query)
|
||||
|
||||
static bool
|
||||
check_subplans_for_ungrouped_vars_walker(Node *node,
|
||||
check_subplans_for_ungrouped_vars_context * context)
|
||||
check_subplans_for_ungrouped_vars_context *context)
|
||||
{
|
||||
List *gl;
|
||||
|
||||
@@ -786,11 +786,11 @@ contain_mutable_functions_walker(Node *node, void *context)
|
||||
* Recursively search for volatile functions within a clause.
|
||||
*
|
||||
* Returns true if any volatile function (or operator implemented by a
|
||||
* volatile function) is found. This test prevents invalid conversions
|
||||
* volatile function) is found. This test prevents invalid conversions
|
||||
* of volatile expressions into indexscan quals.
|
||||
*
|
||||
* XXX we do not examine sublinks/subplans to see if they contain uses of
|
||||
* volatile functions. It's not real clear if that is correct or not...
|
||||
* volatile functions. It's not real clear if that is correct or not...
|
||||
*/
|
||||
bool
|
||||
contain_volatile_functions(Node *clause)
|
||||
@@ -837,7 +837,7 @@ contain_volatile_functions_walker(Node *node, void *context)
|
||||
* of the current query level and no uses of volatile functions.
|
||||
* Such a clause 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 clause's value
|
||||
* may vary from one statement to the next. However, the clause's value
|
||||
* will be constant over any one scan of the current query, so it can be
|
||||
* used as an indexscan key or (if a top-level qual) can be pushed up to
|
||||
* become a gating qual.
|
||||
@@ -1143,7 +1143,7 @@ eval_const_expressions_mutator(Node *node, void *context)
|
||||
* expression_tree_mutator directly rather than recursing to self.
|
||||
*/
|
||||
args = (List *) expression_tree_mutator((Node *) expr->args,
|
||||
eval_const_expressions_mutator,
|
||||
eval_const_expressions_mutator,
|
||||
(void *) context);
|
||||
|
||||
switch (expr->opType)
|
||||
@@ -1166,13 +1166,14 @@ eval_const_expressions_mutator(Node *node, void *context)
|
||||
break;
|
||||
case DISTINCT_EXPR:
|
||||
{
|
||||
List *arg;
|
||||
bool has_null_input = false;
|
||||
bool all_null_input = true;
|
||||
bool has_nonconst_input = false;
|
||||
List *arg;
|
||||
bool has_null_input = false;
|
||||
bool all_null_input = true;
|
||||
bool has_nonconst_input = false;
|
||||
|
||||
/*
|
||||
* Check for constant inputs and especially constant-NULL inputs.
|
||||
* Check for constant inputs and especially
|
||||
* constant-NULL inputs.
|
||||
*/
|
||||
Assert(length(args) == 2);
|
||||
foreach(arg, args)
|
||||
@@ -1183,9 +1184,7 @@ eval_const_expressions_mutator(Node *node, void *context)
|
||||
all_null_input &= ((Const *) lfirst(arg))->constisnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
has_nonconst_input = true;
|
||||
}
|
||||
}
|
||||
/* all nulls? then not distinct */
|
||||
if (all_null_input)
|
||||
@@ -1206,18 +1205,23 @@ eval_const_expressions_mutator(Node *node, void *context)
|
||||
bool const_is_null;
|
||||
|
||||
Oper *oper = (Oper *) expr->oper;
|
||||
replace_opid(oper); /* OK to scribble on input to this extent */
|
||||
|
||||
replace_opid(oper); /* OK to scribble on input
|
||||
* to this extent */
|
||||
result_typeid = oper->opresulttype;
|
||||
|
||||
/*
|
||||
* OK, looks like we can simplify this operator/function.
|
||||
* OK, looks like we can simplify this
|
||||
* operator/function.
|
||||
*
|
||||
* We use the executor's routine ExecEvalExpr() to avoid duplication of
|
||||
* code and ensure we get the same result as the executor would get.
|
||||
* We use the executor's routine ExecEvalExpr() to
|
||||
* avoid duplication of code and ensure we get the
|
||||
* same result as the executor would get.
|
||||
*
|
||||
* Build a new Expr node containing the already-simplified arguments. The
|
||||
* only other setup needed here is the replace_opid() that we already
|
||||
* did for the OP_EXPR case.
|
||||
* Build a new Expr node containing the
|
||||
* already-simplified arguments. The only other
|
||||
* setup needed here is the replace_opid() that we
|
||||
* already did for the OP_EXPR case.
|
||||
*/
|
||||
newexpr = makeNode(Expr);
|
||||
newexpr->typeOid = expr->typeOid;
|
||||
@@ -1229,17 +1233,22 @@ eval_const_expressions_mutator(Node *node, void *context)
|
||||
get_typlenbyval(result_typeid, &resultTypLen, &resultTypByVal);
|
||||
|
||||
/*
|
||||
* It is OK to pass a dummy econtext because none of the
|
||||
* ExecEvalExpr() code used in this situation will use econtext. That
|
||||
* might seem fortuitous, but it's not so unreasonable --- a constant
|
||||
* expression does not depend on context, by definition, n'est ce pas?
|
||||
* It is OK to pass a dummy econtext because none
|
||||
* of the ExecEvalExpr() code used in this
|
||||
* situation will use econtext. That might seem
|
||||
* fortuitous, but it's not so unreasonable --- a
|
||||
* constant expression does not depend on context,
|
||||
* by definition, n'est ce pas?
|
||||
*/
|
||||
econtext = MakeExprContext(NULL, CurrentMemoryContext);
|
||||
|
||||
const_val = ExecEvalExprSwitchContext((Node *) newexpr, econtext,
|
||||
&const_is_null, NULL);
|
||||
&const_is_null, NULL);
|
||||
|
||||
/* Must copy result out of sub-context used by expression eval */
|
||||
/*
|
||||
* Must copy result out of sub-context used by
|
||||
* expression eval
|
||||
*/
|
||||
if (!const_is_null)
|
||||
const_val = datumCopy(const_val, resultTypByVal, resultTypLen);
|
||||
|
||||
@@ -1250,8 +1259,8 @@ eval_const_expressions_mutator(Node *node, void *context)
|
||||
* Make the constant result node.
|
||||
*/
|
||||
return (Node *) makeConst(result_typeid, resultTypLen,
|
||||
const_val, const_is_null,
|
||||
resultTypByVal, false, false);
|
||||
const_val, const_is_null,
|
||||
resultTypByVal, false, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1952,6 +1961,7 @@ expression_tree_walker(Node *node,
|
||||
return true;
|
||||
if (walker(join->quals, context))
|
||||
return true;
|
||||
|
||||
/*
|
||||
* alias clause, using list are deemed uninteresting.
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.73 2002/06/20 20:29:31 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.74 2002/09/04 20:31:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -163,7 +163,7 @@ find_secondary_indexes(Oid relationObjectId)
|
||||
MemSet(info->ordering, 0, sizeof(Oid) * (INDEX_MAX_KEYS + 1));
|
||||
if (amorderstrategy != 0)
|
||||
{
|
||||
int oprindex = amorderstrategy - 1;
|
||||
int oprindex = amorderstrategy - 1;
|
||||
|
||||
for (i = 0; i < info->ncolumns; i++)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.38 2002/06/20 20:29:31 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.39 2002/09/04 20:31:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -157,16 +157,16 @@ make_base_rel(Query *root, int relid)
|
||||
switch (rte->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
{
|
||||
/* Table --- retrieve statistics from the system catalogs */
|
||||
bool indexed;
|
||||
{
|
||||
/* Table --- retrieve statistics from the system catalogs */
|
||||
bool indexed;
|
||||
|
||||
get_relation_info(rte->relid,
|
||||
&indexed, &rel->pages, &rel->tuples);
|
||||
if (indexed)
|
||||
rel->indexlist = find_secondary_indexes(rte->relid);
|
||||
break;
|
||||
}
|
||||
get_relation_info(rte->relid,
|
||||
&indexed, &rel->pages, &rel->tuples);
|
||||
if (indexed)
|
||||
rel->indexlist = find_secondary_indexes(rte->relid);
|
||||
break;
|
||||
}
|
||||
case RTE_SUBQUERY:
|
||||
case RTE_FUNCTION:
|
||||
/* Subquery or function --- nothing to do here */
|
||||
@@ -379,11 +379,11 @@ build_join_rel(Query *root,
|
||||
* of the outer and inner join relations and then merging the results
|
||||
* together.
|
||||
*
|
||||
* XXX right now we don't remove any irrelevant elements, we just
|
||||
* append the two tlists together. Someday consider pruning vars from the
|
||||
* XXX right now we don't remove any irrelevant elements, we just append
|
||||
* the two tlists together. Someday consider pruning vars from the
|
||||
* join's targetlist if they are needed only to evaluate restriction
|
||||
* clauses of this join, and will never be accessed at higher levels of
|
||||
* the plantree.
|
||||
* clauses of this join, and will never be accessed at higher levels
|
||||
* of the plantree.
|
||||
*
|
||||
* NOTE: the tlist order for a join rel will depend on which pair of
|
||||
* outer and inner rels we first try to build it from. But the
|
||||
@@ -396,12 +396,12 @@ build_join_rel(Query *root,
|
||||
|
||||
/*
|
||||
* If there are any alias variables attached to the matching join RTE,
|
||||
* attach them to the tlist too, so that they will be evaluated for use
|
||||
* at higher plan levels.
|
||||
* attach them to the tlist too, so that they will be evaluated for
|
||||
* use at higher plan levels.
|
||||
*/
|
||||
if (joinrterel)
|
||||
{
|
||||
List *jrtetl;
|
||||
List *jrtetl;
|
||||
|
||||
foreach(jrtetl, joinrterel->targetlist)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.38 2002/06/20 20:29:31 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.39 2002/09/04 20:31:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ static bool contain_var_clause_walker(Node *node, void *context);
|
||||
static bool pull_var_clause_walker(Node *node,
|
||||
pull_var_clause_context *context);
|
||||
static Node *flatten_join_alias_vars_mutator(Node *node,
|
||||
flatten_join_alias_vars_context *context);
|
||||
flatten_join_alias_vars_context *context);
|
||||
|
||||
|
||||
/*
|
||||
@@ -317,7 +317,7 @@ pull_var_clause_walker(Node *node, pull_var_clause_context *context)
|
||||
* If force is TRUE then we will reduce all JOIN alias Vars to non-alias Vars
|
||||
* or expressions thereof (there may be COALESCE and/or type conversions
|
||||
* involved). If force is FALSE we will not expand a Var to a non-Var
|
||||
* expression. This is a hack to avoid confusing mergejoin planning, which
|
||||
* expression. This is a hack to avoid confusing mergejoin planning, which
|
||||
* currently cannot cope with non-Var join items --- we leave the join vars
|
||||
* as Vars till after planning is done, then expand them during setrefs.c.
|
||||
*
|
||||
@@ -346,9 +346,9 @@ flatten_join_alias_vars_mutator(Node *node,
|
||||
return NULL;
|
||||
if (IsA(node, Var))
|
||||
{
|
||||
Var *var = (Var *) node;
|
||||
Var *var = (Var *) node;
|
||||
RangeTblEntry *rte;
|
||||
Node *newvar;
|
||||
Node *newvar;
|
||||
|
||||
if (var->varlevelsup != 0)
|
||||
return node; /* no need to copy, really */
|
||||
@@ -357,7 +357,7 @@ flatten_join_alias_vars_mutator(Node *node,
|
||||
return node;
|
||||
Assert(var->varattno > 0);
|
||||
newvar = (Node *) nth(var->varattno - 1, rte->joinaliasvars);
|
||||
if (IsA(newvar, Var) || context->force)
|
||||
if (IsA(newvar, Var) ||context->force)
|
||||
{
|
||||
/* expand it; recurse in case join input is itself a join */
|
||||
return flatten_join_alias_vars_mutator(newvar, context);
|
||||
|
||||
Reference in New Issue
Block a user