mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.12 1997/09/07 04:43:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.13 1997/09/08 02:24:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -44,9 +44,9 @@
|
||||
#define TEMP_SORT 1
|
||||
#define TEMP_MATERIAL 2
|
||||
|
||||
static List *switch_outer(List * clauses);
|
||||
static Scan *create_scan_node(Path * best_path, List * tlist);
|
||||
static Join *create_join_node(JoinPath * best_path, List * tlist);
|
||||
static List *switch_outer(List * clauses);
|
||||
static Scan *create_scan_node(Path * best_path, List * tlist);
|
||||
static Join *create_join_node(JoinPath * best_path, List * tlist);
|
||||
static SeqScan *
|
||||
create_seqscan_node(Path * best_path, List * tlist,
|
||||
List * scan_clauses);
|
||||
@@ -65,8 +65,8 @@ static HashJoin *
|
||||
create_hashjoin_node(HashPath * best_path, List * tlist,
|
||||
List * clauses, Plan * outer_node, List * outer_tlist,
|
||||
Plan * inner_node, List * inner_tlist);
|
||||
static Node *fix_indxqual_references(Node * clause, Path * index_path);
|
||||
static Temp *
|
||||
static Node *fix_indxqual_references(Node * clause, Path * index_path);
|
||||
static Temp *
|
||||
make_temp(List * tlist, List * keys, Oid * operators,
|
||||
Plan * plan_node, int temptype);
|
||||
static IndexScan *
|
||||
@@ -78,7 +78,7 @@ make_nestloop(List * qptlist, List * qpqual, Plan * lefttree,
|
||||
static HashJoin *
|
||||
make_hashjoin(List * tlist, List * qpqual,
|
||||
List * hashclauses, Plan * lefttree, Plan * righttree);
|
||||
static Hash *make_hash(List * tlist, Var * hashkey, Plan * lefttree);
|
||||
static Hash *make_hash(List * tlist, Var * hashkey, Plan * lefttree);
|
||||
static MergeJoin *
|
||||
make_mergesort(List * tlist, List * qpqual,
|
||||
List * mergeclauses, Oid opcode, Oid * rightorder,
|
||||
@@ -102,16 +102,16 @@ make_material(List * tlist, Oid tempid, Plan * lefttree,
|
||||
*
|
||||
* Returns the optimal(?) access plan.
|
||||
*/
|
||||
Plan *
|
||||
Plan *
|
||||
create_plan(Path * best_path)
|
||||
{
|
||||
List *tlist;
|
||||
Plan *plan_node = (Plan *) NULL;
|
||||
Rel *parent_rel;
|
||||
int size;
|
||||
int width;
|
||||
int pages;
|
||||
int tuples;
|
||||
List *tlist;
|
||||
Plan *plan_node = (Plan *) NULL;
|
||||
Rel *parent_rel;
|
||||
int size;
|
||||
int width;
|
||||
int pages;
|
||||
int tuples;
|
||||
|
||||
parent_rel = best_path->parent;
|
||||
tlist = get_actual_tlist(parent_rel->targetlist);
|
||||
@@ -122,18 +122,18 @@ create_plan(Path * best_path)
|
||||
|
||||
switch (best_path->pathtype)
|
||||
{
|
||||
case T_IndexScan:
|
||||
case T_SeqScan:
|
||||
plan_node = (Plan *) create_scan_node(best_path, tlist);
|
||||
break;
|
||||
case T_HashJoin:
|
||||
case T_MergeJoin:
|
||||
case T_NestLoop:
|
||||
plan_node = (Plan *) create_join_node((JoinPath *) best_path, tlist);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
case T_IndexScan:
|
||||
case T_SeqScan:
|
||||
plan_node = (Plan *) create_scan_node(best_path, tlist);
|
||||
break;
|
||||
case T_HashJoin:
|
||||
case T_MergeJoin:
|
||||
case T_NestLoop:
|
||||
plan_node = (Plan *) create_join_node((JoinPath *) best_path, tlist);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
plan_node->plan_size = size;
|
||||
@@ -166,12 +166,12 @@ create_plan(Path * best_path)
|
||||
*
|
||||
* Returns the scan node.
|
||||
*/
|
||||
static Scan *
|
||||
static Scan *
|
||||
create_scan_node(Path * best_path, List * tlist)
|
||||
{
|
||||
|
||||
Scan *node = NULL;
|
||||
List *scan_clauses;
|
||||
Scan *node = NULL;
|
||||
List *scan_clauses;
|
||||
|
||||
/*
|
||||
* Extract the relevant clauses from the parent relation and replace
|
||||
@@ -186,20 +186,20 @@ create_scan_node(Path * best_path, List * tlist)
|
||||
|
||||
switch (best_path->pathtype)
|
||||
{
|
||||
case T_SeqScan:
|
||||
node = (Scan *) create_seqscan_node(best_path, tlist, scan_clauses);
|
||||
break;
|
||||
case T_SeqScan:
|
||||
node = (Scan *) create_seqscan_node(best_path, tlist, scan_clauses);
|
||||
break;
|
||||
|
||||
case T_IndexScan:
|
||||
node = (Scan *) create_indexscan_node((IndexPath *) best_path,
|
||||
tlist,
|
||||
scan_clauses);
|
||||
break;
|
||||
case T_IndexScan:
|
||||
node = (Scan *) create_indexscan_node((IndexPath *) best_path,
|
||||
tlist,
|
||||
scan_clauses);
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(WARN, "create_scan_node: unknown node type",
|
||||
best_path->pathtype);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "create_scan_node: unknown node type",
|
||||
best_path->pathtype);
|
||||
break;
|
||||
}
|
||||
|
||||
return node;
|
||||
@@ -215,15 +215,15 @@ create_scan_node(Path * best_path, List * tlist)
|
||||
*
|
||||
* Returns the join node.
|
||||
*/
|
||||
static Join *
|
||||
static Join *
|
||||
create_join_node(JoinPath * best_path, List * tlist)
|
||||
{
|
||||
Plan *outer_node;
|
||||
List *outer_tlist;
|
||||
Plan *inner_node;
|
||||
List *inner_tlist;
|
||||
List *clauses;
|
||||
Join *retval = NULL;
|
||||
Plan *outer_node;
|
||||
List *outer_tlist;
|
||||
Plan *inner_node;
|
||||
List *inner_tlist;
|
||||
List *clauses;
|
||||
Join *retval = NULL;
|
||||
|
||||
outer_node = create_plan((Path *) best_path->outerjoinpath);
|
||||
outer_tlist = outer_node->targetlist;
|
||||
@@ -235,45 +235,45 @@ create_join_node(JoinPath * best_path, List * tlist)
|
||||
|
||||
switch (best_path->path.pathtype)
|
||||
{
|
||||
case T_MergeJoin:
|
||||
retval = (Join *) create_mergejoin_node((MergePath *) best_path,
|
||||
tlist,
|
||||
clauses,
|
||||
outer_node,
|
||||
outer_tlist,
|
||||
inner_node,
|
||||
inner_tlist);
|
||||
break;
|
||||
case T_HashJoin:
|
||||
retval = (Join *) create_hashjoin_node((HashPath *) best_path,
|
||||
tlist,
|
||||
clauses,
|
||||
outer_node,
|
||||
outer_tlist,
|
||||
inner_node,
|
||||
inner_tlist);
|
||||
break;
|
||||
case T_NestLoop:
|
||||
retval = (Join *) create_nestloop_node((JoinPath *) best_path,
|
||||
tlist,
|
||||
clauses,
|
||||
outer_node,
|
||||
outer_tlist,
|
||||
inner_node,
|
||||
inner_tlist);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
elog(WARN, "create_join_node: unknown node type",
|
||||
best_path->path.pathtype);
|
||||
case T_MergeJoin:
|
||||
retval = (Join *) create_mergejoin_node((MergePath *) best_path,
|
||||
tlist,
|
||||
clauses,
|
||||
outer_node,
|
||||
outer_tlist,
|
||||
inner_node,
|
||||
inner_tlist);
|
||||
break;
|
||||
case T_HashJoin:
|
||||
retval = (Join *) create_hashjoin_node((HashPath *) best_path,
|
||||
tlist,
|
||||
clauses,
|
||||
outer_node,
|
||||
outer_tlist,
|
||||
inner_node,
|
||||
inner_tlist);
|
||||
break;
|
||||
case T_NestLoop:
|
||||
retval = (Join *) create_nestloop_node((JoinPath *) best_path,
|
||||
tlist,
|
||||
clauses,
|
||||
outer_node,
|
||||
outer_tlist,
|
||||
inner_node,
|
||||
inner_tlist);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
elog(WARN, "create_join_node: unknown node type",
|
||||
best_path->path.pathtype);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* * Expensive function pullups may have pulled local predicates *
|
||||
* into this path node. Put them in the qpqual of the plan node. *
|
||||
* -- JMH, 6/15/92
|
||||
* into this path node. Put them in the qpqual of the plan node. * --
|
||||
* JMH, 6/15/92
|
||||
*/
|
||||
if (get_locclauseinfo(best_path) != NIL)
|
||||
set_qpqual((Plan) retval,
|
||||
@@ -300,9 +300,9 @@ create_join_node(JoinPath * best_path, List * tlist)
|
||||
static SeqScan *
|
||||
create_seqscan_node(Path * best_path, List * tlist, List * scan_clauses)
|
||||
{
|
||||
SeqScan *scan_node = (SeqScan *) NULL;
|
||||
Index scan_relid = -1;
|
||||
List *temp;
|
||||
SeqScan *scan_node = (SeqScan *) NULL;
|
||||
Index scan_relid = -1;
|
||||
List *temp;
|
||||
|
||||
temp = best_path->parent->relids;
|
||||
if (temp == NULL)
|
||||
@@ -335,15 +335,15 @@ create_indexscan_node(IndexPath * best_path,
|
||||
* Extract the(first if conjunct, only if disjunct) clause from the
|
||||
* clauseinfo list.
|
||||
*/
|
||||
Expr *index_clause = (Expr *) NULL;
|
||||
List *indxqual = NIL;
|
||||
List *qpqual = NIL;
|
||||
List *fixed_indxqual = NIL;
|
||||
List *ixid;
|
||||
IndexScan *scan_node = (IndexScan *) NULL;
|
||||
bool lossy = FALSE;
|
||||
HeapTuple indexTuple;
|
||||
IndexTupleForm index;
|
||||
Expr *index_clause = (Expr *) NULL;
|
||||
List *indxqual = NIL;
|
||||
List *qpqual = NIL;
|
||||
List *fixed_indxqual = NIL;
|
||||
List *ixid;
|
||||
IndexScan *scan_node = (IndexScan *) NULL;
|
||||
bool lossy = FALSE;
|
||||
HeapTuple indexTuple;
|
||||
IndexTupleForm index;
|
||||
|
||||
/*
|
||||
* If an 'or' clause is to be used with this index, the indxqual field
|
||||
@@ -358,7 +358,7 @@ create_indexscan_node(IndexPath * best_path,
|
||||
|
||||
if (or_clause((Node *) index_clause))
|
||||
{
|
||||
List *temp = NIL;
|
||||
List *temp = NIL;
|
||||
|
||||
foreach(temp, index_clause->args)
|
||||
indxqual = lappend(indxqual, lcons(lfirst(temp), NIL));
|
||||
@@ -438,7 +438,7 @@ create_nestloop_node(JoinPath * best_path,
|
||||
Plan * inner_node,
|
||||
List * inner_tlist)
|
||||
{
|
||||
NestLoop *join_node = (NestLoop *) NULL;
|
||||
NestLoop *join_node = (NestLoop *) NULL;
|
||||
|
||||
if (IsA(inner_node, IndexScan))
|
||||
{
|
||||
@@ -453,9 +453,9 @@ create_nestloop_node(JoinPath * best_path,
|
||||
* case of multi-column indices. - vadim 03/18/97
|
||||
*/
|
||||
|
||||
List *inner_indxqual = lfirst(((IndexScan *) inner_node)->indxqual);
|
||||
List *inner_qual;
|
||||
bool found = false;
|
||||
List *inner_indxqual = lfirst(((IndexScan *) inner_node)->indxqual);
|
||||
List *inner_qual;
|
||||
bool found = false;
|
||||
|
||||
foreach(inner_qual, inner_indxqual)
|
||||
{
|
||||
@@ -479,7 +479,7 @@ create_nestloop_node(JoinPath * best_path,
|
||||
*/
|
||||
if (found)
|
||||
{
|
||||
List *new_inner_qual = NIL;
|
||||
List *new_inner_qual = NIL;
|
||||
|
||||
clauses = set_difference(clauses, inner_indxqual); /* XXX */
|
||||
new_inner_qual =
|
||||
@@ -520,12 +520,12 @@ create_mergejoin_node(MergePath * best_path,
|
||||
Plan * inner_node,
|
||||
List * inner_tlist)
|
||||
{
|
||||
List *qpqual,
|
||||
*mergeclauses;
|
||||
RegProcedure opcode;
|
||||
Oid *outer_order,
|
||||
*inner_order;
|
||||
MergeJoin *join_node;
|
||||
List *qpqual,
|
||||
*mergeclauses;
|
||||
RegProcedure opcode;
|
||||
Oid *outer_order,
|
||||
*inner_order;
|
||||
MergeJoin *join_node;
|
||||
|
||||
|
||||
/*
|
||||
@@ -564,11 +564,11 @@ create_mergejoin_node(MergePath * best_path,
|
||||
*/
|
||||
if (best_path->outersortkeys)
|
||||
{
|
||||
Temp *sorted_outer_node = make_temp(outer_tlist,
|
||||
Temp *sorted_outer_node = make_temp(outer_tlist,
|
||||
best_path->outersortkeys,
|
||||
outer_order,
|
||||
outer_node,
|
||||
TEMP_SORT);
|
||||
outer_order,
|
||||
outer_node,
|
||||
TEMP_SORT);
|
||||
|
||||
sorted_outer_node->plan.cost = outer_node->cost;
|
||||
outer_node = (Plan *) sorted_outer_node;
|
||||
@@ -576,11 +576,11 @@ create_mergejoin_node(MergePath * best_path,
|
||||
|
||||
if (best_path->innersortkeys)
|
||||
{
|
||||
Temp *sorted_inner_node = make_temp(inner_tlist,
|
||||
Temp *sorted_inner_node = make_temp(inner_tlist,
|
||||
best_path->innersortkeys,
|
||||
inner_order,
|
||||
inner_node,
|
||||
TEMP_SORT);
|
||||
inner_order,
|
||||
inner_node,
|
||||
TEMP_SORT);
|
||||
|
||||
sorted_inner_node->plan.cost = outer_node->cost;
|
||||
inner_node = (Plan *) sorted_inner_node;
|
||||
@@ -617,11 +617,11 @@ create_hashjoin_node(HashPath * best_path,
|
||||
Plan * inner_node,
|
||||
List * inner_tlist)
|
||||
{
|
||||
List *qpqual;
|
||||
List *hashclauses;
|
||||
HashJoin *join_node;
|
||||
Hash *hash_node;
|
||||
Var *innerhashkey;
|
||||
List *qpqual;
|
||||
List *hashclauses;
|
||||
HashJoin *join_node;
|
||||
Hash *hash_node;
|
||||
Var *innerhashkey;
|
||||
|
||||
/*
|
||||
* Separate the hashclauses from the other join qualification clauses
|
||||
@@ -662,18 +662,18 @@ create_hashjoin_node(HashPath * best_path,
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
static Node *
|
||||
static Node *
|
||||
fix_indxqual_references(Node * clause, Path * index_path)
|
||||
{
|
||||
Node *newclause;
|
||||
Node *newclause;
|
||||
|
||||
if (IsA(clause, Var))
|
||||
{
|
||||
if (lfirsti(index_path->parent->relids) == ((Var *) clause)->varno)
|
||||
{
|
||||
int pos = 0;
|
||||
int varatt = ((Var *) clause)->varattno;
|
||||
int *indexkeys = ((IndexPath *) index_path)->indexkeys;
|
||||
int pos = 0;
|
||||
int varatt = ((Var *) clause)->varattno;
|
||||
int *indexkeys = ((IndexPath *) index_path)->indexkeys;
|
||||
|
||||
if (indexkeys)
|
||||
{
|
||||
@@ -710,7 +710,7 @@ fix_indxqual_references(Node * clause, Path * index_path)
|
||||
is_funcclause((Node *) get_leftop((Expr *) clause)) &&
|
||||
((Func *) ((Expr *) get_leftop((Expr *) clause))->oper)->funcisindex)
|
||||
{
|
||||
Var *newvar =
|
||||
Var *newvar =
|
||||
makeVar((Index) lfirsti(index_path->parent->relids),
|
||||
1, /* func indices have one key */
|
||||
((Func *) ((Expr *) clause)->oper)->functype,
|
||||
@@ -725,10 +725,10 @@ fix_indxqual_references(Node * clause, Path * index_path)
|
||||
}
|
||||
else if (IsA(clause, Expr))
|
||||
{
|
||||
Expr *expr = (Expr *) clause;
|
||||
List *new_subclauses = NIL;
|
||||
Node *subclause = NULL;
|
||||
List *i = NIL;
|
||||
Expr *expr = (Expr *) clause;
|
||||
List *new_subclauses = NIL;
|
||||
Node *subclause = NULL;
|
||||
List *i = NIL;
|
||||
|
||||
foreach(i, expr->args)
|
||||
{
|
||||
@@ -757,10 +757,10 @@ fix_indxqual_references(Node * clause, Path * index_path)
|
||||
}
|
||||
else
|
||||
{
|
||||
List *oldclauses = (List *) clause;
|
||||
List *new_subclauses = NIL;
|
||||
Node *subclause = NULL;
|
||||
List *i = NIL;
|
||||
List *oldclauses = (List *) clause;
|
||||
List *new_subclauses = NIL;
|
||||
Node *subclause = NULL;
|
||||
List *i = NIL;
|
||||
|
||||
foreach(i, oldclauses)
|
||||
{
|
||||
@@ -799,14 +799,14 @@ fix_indxqual_references(Node * clause, Path * index_path)
|
||||
*
|
||||
* XXX Shouldn't the operator be commuted?!
|
||||
*/
|
||||
static List *
|
||||
static List *
|
||||
switch_outer(List * clauses)
|
||||
{
|
||||
List *t_list = NIL;
|
||||
Expr *temp = NULL;
|
||||
List *i = NIL;
|
||||
Expr *clause;
|
||||
Node *op;
|
||||
List *t_list = NIL;
|
||||
Expr *temp = NULL;
|
||||
List *i = NIL;
|
||||
Expr *clause;
|
||||
Node *op;
|
||||
|
||||
foreach(i, clauses)
|
||||
{
|
||||
@@ -843,13 +843,13 @@ switch_outer(List * clauses)
|
||||
*
|
||||
* Returns the modified target list.
|
||||
*/
|
||||
static List *
|
||||
static List *
|
||||
set_temp_tlist_operators(List * tlist, List * pathkeys, Oid * operators)
|
||||
{
|
||||
Node *keys = NULL;
|
||||
int keyno = 1;
|
||||
Resdom *resdom = (Resdom *) NULL;
|
||||
List *i = NIL;
|
||||
Node *keys = NULL;
|
||||
int keyno = 1;
|
||||
Resdom *resdom = (Resdom *) NULL;
|
||||
List *i = NIL;
|
||||
|
||||
foreach(i, pathkeys)
|
||||
{
|
||||
@@ -891,15 +891,15 @@ set_temp_tlist_operators(List * tlist, List * pathkeys, Oid * operators)
|
||||
* 'plan-node' is the node which yields tuples for the sort
|
||||
* 'temptype' indicates which operation(sort or hash) to perform
|
||||
*/
|
||||
static Temp *
|
||||
static Temp *
|
||||
make_temp(List * tlist,
|
||||
List * keys,
|
||||
Oid * operators,
|
||||
Plan * plan_node,
|
||||
int temptype)
|
||||
{
|
||||
List *temp_tlist;
|
||||
Temp *retval = NULL;
|
||||
List *temp_tlist;
|
||||
Temp *retval = NULL;
|
||||
|
||||
/* Create a new target list for the temporary, with keys set. */
|
||||
temp_tlist = set_temp_tlist_operators(new_unsorted_tlist(tlist),
|
||||
@@ -907,42 +907,42 @@ make_temp(List * tlist,
|
||||
operators);
|
||||
switch (temptype)
|
||||
{
|
||||
case TEMP_SORT:
|
||||
retval = (Temp *) make_seqscan(tlist,
|
||||
NIL,
|
||||
_TEMP_RELATION_ID_,
|
||||
(Plan *) make_sort(temp_tlist,
|
||||
case TEMP_SORT:
|
||||
retval = (Temp *) make_seqscan(tlist,
|
||||
NIL,
|
||||
_TEMP_RELATION_ID_,
|
||||
(Plan *) make_sort(temp_tlist,
|
||||
_TEMP_RELATION_ID_,
|
||||
plan_node,
|
||||
plan_node,
|
||||
length(keys)));
|
||||
break;
|
||||
break;
|
||||
|
||||
case TEMP_MATERIAL:
|
||||
retval = (Temp *) make_seqscan(tlist,
|
||||
NIL,
|
||||
_TEMP_RELATION_ID_,
|
||||
case TEMP_MATERIAL:
|
||||
retval = (Temp *) make_seqscan(tlist,
|
||||
NIL,
|
||||
_TEMP_RELATION_ID_,
|
||||
(Plan *) make_material(temp_tlist,
|
||||
_TEMP_RELATION_ID_,
|
||||
plan_node,
|
||||
length(keys)));
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(WARN, "make_temp: unknown temp type %d", temptype);
|
||||
default:
|
||||
elog(WARN, "make_temp: unknown temp type %d", temptype);
|
||||
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
||||
SeqScan *
|
||||
SeqScan *
|
||||
make_seqscan(List * qptlist,
|
||||
List * qpqual,
|
||||
Index scanrelid,
|
||||
Plan * lefttree)
|
||||
{
|
||||
SeqScan *node = makeNode(SeqScan);
|
||||
Plan *plan = &node->plan;
|
||||
SeqScan *node = makeNode(SeqScan);
|
||||
Plan *plan = &node->plan;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -963,8 +963,8 @@ make_indexscan(List * qptlist,
|
||||
List * indxid,
|
||||
List * indxqual)
|
||||
{
|
||||
IndexScan *node = makeNode(IndexScan);
|
||||
Plan *plan = &node->scan.plan;
|
||||
IndexScan *node = makeNode(IndexScan);
|
||||
Plan *plan = &node->scan.plan;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -987,8 +987,8 @@ make_nestloop(List * qptlist,
|
||||
Plan * lefttree,
|
||||
Plan * righttree)
|
||||
{
|
||||
NestLoop *node = makeNode(NestLoop);
|
||||
Plan *plan = &node->join;
|
||||
NestLoop *node = makeNode(NestLoop);
|
||||
Plan *plan = &node->join;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1008,8 +1008,8 @@ make_hashjoin(List * tlist,
|
||||
Plan * lefttree,
|
||||
Plan * righttree)
|
||||
{
|
||||
HashJoin *node = makeNode(HashJoin);
|
||||
Plan *plan = &node->join;
|
||||
HashJoin *node = makeNode(HashJoin);
|
||||
Plan *plan = &node->join;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1026,11 +1026,11 @@ make_hashjoin(List * tlist,
|
||||
return (node);
|
||||
}
|
||||
|
||||
static Hash *
|
||||
static Hash *
|
||||
make_hash(List * tlist, Var * hashkey, Plan * lefttree)
|
||||
{
|
||||
Hash *node = makeNode(Hash);
|
||||
Plan *plan = &node->plan;
|
||||
Hash *node = makeNode(Hash);
|
||||
Plan *plan = &node->plan;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1056,8 +1056,8 @@ make_mergesort(List * tlist,
|
||||
Plan * righttree,
|
||||
Plan * lefttree)
|
||||
{
|
||||
MergeJoin *node = makeNode(MergeJoin);
|
||||
Plan *plan = &node->join;
|
||||
MergeJoin *node = makeNode(MergeJoin);
|
||||
Plan *plan = &node->join;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1073,11 +1073,11 @@ make_mergesort(List * tlist,
|
||||
return (node);
|
||||
}
|
||||
|
||||
Sort *
|
||||
Sort *
|
||||
make_sort(List * tlist, Oid tempid, Plan * lefttree, int keycount)
|
||||
{
|
||||
Sort *node = makeNode(Sort);
|
||||
Plan *plan = &node->plan;
|
||||
Sort *node = makeNode(Sort);
|
||||
Plan *plan = &node->plan;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1097,8 +1097,8 @@ make_material(List * tlist,
|
||||
Plan * lefttree,
|
||||
int keycount)
|
||||
{
|
||||
Material *node = makeNode(Material);
|
||||
Plan *plan = &node->plan;
|
||||
Material *node = makeNode(Material);
|
||||
Plan *plan = &node->plan;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1112,10 +1112,10 @@ make_material(List * tlist,
|
||||
return (node);
|
||||
}
|
||||
|
||||
Agg *
|
||||
Agg *
|
||||
make_agg(List * tlist, int nagg, Aggreg ** aggs)
|
||||
{
|
||||
Agg *node = makeNode(Agg);
|
||||
Agg *node = makeNode(Agg);
|
||||
|
||||
node->plan.cost = 0.0;
|
||||
node->plan.state = (EState *) NULL;
|
||||
@@ -1129,14 +1129,14 @@ make_agg(List * tlist, int nagg, Aggreg ** aggs)
|
||||
return (node);
|
||||
}
|
||||
|
||||
Group *
|
||||
Group *
|
||||
make_group(List * tlist,
|
||||
bool tuplePerGroup,
|
||||
int ngrp,
|
||||
AttrNumber * grpColIdx,
|
||||
Sort * lefttree)
|
||||
{
|
||||
Group *node = makeNode(Group);
|
||||
Group *node = makeNode(Group);
|
||||
|
||||
node->plan.cost = 0.0;
|
||||
node->plan.state = (EState *) NULL;
|
||||
@@ -1159,11 +1159,11 @@ make_group(List * tlist,
|
||||
* or "*"
|
||||
*/
|
||||
|
||||
Unique *
|
||||
Unique *
|
||||
make_unique(List * tlist, Plan * lefttree, char *uniqueAttr)
|
||||
{
|
||||
Unique *node = makeNode(Unique);
|
||||
Plan *plan = &node->plan;
|
||||
Unique *node = makeNode(Unique);
|
||||
Plan *plan = &node->plan;
|
||||
|
||||
plan->cost = 0.0;
|
||||
plan->state = (EState *) NULL;
|
||||
@@ -1182,14 +1182,14 @@ make_unique(List * tlist, Plan * lefttree, char *uniqueAttr)
|
||||
return (node);
|
||||
}
|
||||
|
||||
List *
|
||||
List *
|
||||
generate_fjoin(List * tlist)
|
||||
{
|
||||
#if 0
|
||||
List tlistP;
|
||||
List newTlist = NIL;
|
||||
List fjoinList = NIL;
|
||||
int nIters = 0;
|
||||
List tlistP;
|
||||
List newTlist = NIL;
|
||||
List fjoinList = NIL;
|
||||
int nIters = 0;
|
||||
|
||||
/*
|
||||
* Break the target list into elements with Iter nodes, and those
|
||||
@@ -1197,7 +1197,7 @@ generate_fjoin(List * tlist)
|
||||
*/
|
||||
foreach(tlistP, tlist)
|
||||
{
|
||||
List tlistElem;
|
||||
List tlistElem;
|
||||
|
||||
tlistElem = lfirst(tlistP);
|
||||
if (IsA(lsecond(tlistElem), Iter))
|
||||
@@ -1216,11 +1216,11 @@ generate_fjoin(List * tlist)
|
||||
*/
|
||||
if (nIters > 0)
|
||||
{
|
||||
List *inner;
|
||||
List *tempList;
|
||||
Fjoin *fjoinNode;
|
||||
DatumPtr results = (DatumPtr) palloc(nIters * sizeof(Datum));
|
||||
BoolPtr alwaysDone = (BoolPtr) palloc(nIters * sizeof(bool));
|
||||
List *inner;
|
||||
List *tempList;
|
||||
Fjoin *fjoinNode;
|
||||
DatumPtr results = (DatumPtr) palloc(nIters * sizeof(Datum));
|
||||
BoolPtr alwaysDone = (BoolPtr) palloc(nIters * sizeof(bool));
|
||||
|
||||
inner = lfirst(fjoinList);
|
||||
fjoinList = lnext(fjoinList);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.6 1997/09/07 04:44:00 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.7 1997/09/08 02:24:36 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -33,16 +33,16 @@
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/cost.h"
|
||||
|
||||
extern int Quiet;
|
||||
extern int Quiet;
|
||||
|
||||
static void add_clause_to_rels(Query * root, List * clause);
|
||||
static void add_clause_to_rels(Query * root, List * clause);
|
||||
static void
|
||||
add_join_clause_info_to_rels(Query * root, CInfo * clauseinfo,
|
||||
List * join_relids);
|
||||
static void add_vars_to_rels(Query * root, List * vars, List * join_relids);
|
||||
static void add_vars_to_rels(Query * root, List * vars, List * join_relids);
|
||||
|
||||
static MergeOrder *mergesortop(Expr * clause);
|
||||
static Oid hashjoinop(Expr * clause);
|
||||
static Oid hashjoinop(Expr * clause);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -63,13 +63,13 @@ static Oid hashjoinop(Expr * clause);
|
||||
void
|
||||
initialize_base_rels_list(Query * root, List * tlist)
|
||||
{
|
||||
List *tlist_vars = NIL;
|
||||
List *l = NIL;
|
||||
List *tvar = NIL;
|
||||
List *tlist_vars = NIL;
|
||||
List *l = NIL;
|
||||
List *tvar = NIL;
|
||||
|
||||
foreach(l, tlist)
|
||||
{
|
||||
TargetEntry *entry = (TargetEntry *) lfirst(l);
|
||||
TargetEntry *entry = (TargetEntry *) lfirst(l);
|
||||
|
||||
tlist_vars = append(tlist_vars, pull_var_clause(entry->expr));
|
||||
}
|
||||
@@ -77,9 +77,9 @@ initialize_base_rels_list(Query * root, List * tlist)
|
||||
/* now, the target list only contains Var nodes */
|
||||
foreach(tvar, tlist_vars)
|
||||
{
|
||||
Var *var;
|
||||
Index varno;
|
||||
Rel *result;
|
||||
Var *var;
|
||||
Index varno;
|
||||
Rel *result;
|
||||
|
||||
var = (Var *) lfirst(tvar);
|
||||
varno = var->varno;
|
||||
@@ -100,16 +100,16 @@ initialize_base_rels_list(Query * root, List * tlist)
|
||||
void
|
||||
add_missing_vars_to_base_rels(Query * root, List * tlist)
|
||||
{
|
||||
List *l;
|
||||
int varno;
|
||||
List *l;
|
||||
int varno;
|
||||
|
||||
varno = 1;
|
||||
foreach(l, root->rtable)
|
||||
{
|
||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
|
||||
List *relids;
|
||||
Rel *result;
|
||||
Var *var;
|
||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
|
||||
List *relids;
|
||||
Rel *result;
|
||||
Var *var;
|
||||
|
||||
relids = lconsi(varno, NIL);
|
||||
if (rte->inFromCl &&
|
||||
@@ -147,7 +147,7 @@ add_missing_vars_to_base_rels(Query * root, List * tlist)
|
||||
void
|
||||
initialize_base_rels_jinfo(Query * root, List * clauses)
|
||||
{
|
||||
List *clause;
|
||||
List *clause;
|
||||
|
||||
foreach(clause, clauses)
|
||||
{
|
||||
@@ -168,9 +168,9 @@ initialize_base_rels_jinfo(Query * root, List * clauses)
|
||||
static void
|
||||
add_clause_to_rels(Query * root, List * clause)
|
||||
{
|
||||
List *relids;
|
||||
List *vars;
|
||||
CInfo *clauseinfo = makeNode(CInfo);
|
||||
List *relids;
|
||||
List *vars;
|
||||
CInfo *clauseinfo = makeNode(CInfo);
|
||||
|
||||
/*
|
||||
* Retrieve all relids and vars contained within the clause.
|
||||
@@ -189,7 +189,7 @@ add_clause_to_rels(Query * root, List * clause)
|
||||
|
||||
if (length(relids) == 1)
|
||||
{
|
||||
Rel *rel = get_base_rel(root, lfirsti(relids));
|
||||
Rel *rel = get_base_rel(root, lfirsti(relids));
|
||||
|
||||
/*
|
||||
* There is only one relation participating in 'clause', so
|
||||
@@ -261,13 +261,13 @@ add_clause_to_rels(Query * root, List * clause)
|
||||
static void
|
||||
add_join_clause_info_to_rels(Query * root, CInfo * clauseinfo, List * join_relids)
|
||||
{
|
||||
List *join_relid;
|
||||
List *join_relid;
|
||||
|
||||
foreach(join_relid, join_relids)
|
||||
{
|
||||
JInfo *joininfo;
|
||||
List *other_rels = NIL;
|
||||
List *rel;
|
||||
JInfo *joininfo;
|
||||
List *other_rels = NIL;
|
||||
List *rel;
|
||||
|
||||
foreach(rel, join_relids)
|
||||
{
|
||||
@@ -302,10 +302,10 @@ add_join_clause_info_to_rels(Query * root, CInfo * clauseinfo, List * join_relid
|
||||
static void
|
||||
add_vars_to_rels(Query * root, List * vars, List * join_relids)
|
||||
{
|
||||
Var *var;
|
||||
List *temp = NIL;
|
||||
Rel *rel = (Rel *) NULL;
|
||||
TargetEntry *tlistentry;
|
||||
Var *var;
|
||||
List *temp = NIL;
|
||||
Rel *rel = (Rel *) NULL;
|
||||
TargetEntry *tlistentry;
|
||||
|
||||
foreach(temp, vars)
|
||||
{
|
||||
@@ -336,13 +336,13 @@ add_vars_to_rels(Query * root, List * vars, List * join_relids)
|
||||
void
|
||||
initialize_join_clause_info(List * rel_list)
|
||||
{
|
||||
List *x,
|
||||
*y,
|
||||
*z;
|
||||
Rel *rel;
|
||||
JInfo *joininfo;
|
||||
CInfo *clauseinfo;
|
||||
Expr *clause;
|
||||
List *x,
|
||||
*y,
|
||||
*z;
|
||||
Rel *rel;
|
||||
JInfo *joininfo;
|
||||
CInfo *clauseinfo;
|
||||
Expr *clause;
|
||||
|
||||
foreach(x, rel_list)
|
||||
{
|
||||
@@ -356,8 +356,8 @@ initialize_join_clause_info(List * rel_list)
|
||||
clause = clauseinfo->clause;
|
||||
if (join_clause_p((Node *) clause))
|
||||
{
|
||||
MergeOrder *sortop = (MergeOrder *) NULL;
|
||||
Oid hashop = (Oid) NULL;
|
||||
MergeOrder *sortop = (MergeOrder *) NULL;
|
||||
Oid hashop = (Oid) NULL;
|
||||
|
||||
if (_enable_mergesort_)
|
||||
sortop = mergesortop(clause);
|
||||
@@ -389,9 +389,9 @@ initialize_join_clause_info(List * rel_list)
|
||||
static MergeOrder *
|
||||
mergesortop(Expr * clause)
|
||||
{
|
||||
Oid leftOp,
|
||||
rightOp;
|
||||
bool sortable;
|
||||
Oid leftOp,
|
||||
rightOp;
|
||||
bool sortable;
|
||||
|
||||
sortable = op_mergesortable(((Oper *) clause->oper)->opno,
|
||||
(get_leftop(clause))->vartype,
|
||||
@@ -401,7 +401,7 @@ mergesortop(Expr * clause)
|
||||
|
||||
if (sortable)
|
||||
{
|
||||
MergeOrder *morder = makeNode(MergeOrder);
|
||||
MergeOrder *morder = makeNode(MergeOrder);
|
||||
|
||||
morder->join_operator = ((Oper *) clause->oper)->opno;
|
||||
morder->left_operator = leftOp;
|
||||
@@ -420,7 +420,7 @@ mergesortop(Expr * clause)
|
||||
* hashjoinable, i.e., both operands are single vars and the operator is
|
||||
* a hashjoinable operator.
|
||||
*/
|
||||
static Oid
|
||||
static Oid
|
||||
hashjoinop(Expr * clause)
|
||||
{
|
||||
return (op_hashjoinable(((Oper *) clause->oper)->opno,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.5 1997/09/07 04:44:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.6 1997/09/08 02:24:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,10 +38,10 @@
|
||||
#include "utils/mcxt.h"
|
||||
#include "utils/lsyscache.h"
|
||||
|
||||
static Plan *subplanner(Query * root, List * flat_tlist, List * qual);
|
||||
static Result *make_result(List * tlist, Node * resconstantqual, Plan * subplan);
|
||||
static Plan *subplanner(Query * root, List * flat_tlist, List * qual);
|
||||
static Result *make_result(List * tlist, Node * resconstantqual, Plan * subplan);
|
||||
|
||||
static Plan *
|
||||
static Plan *
|
||||
make_groupPlan(List ** tlist, bool tuplePerGroup,
|
||||
List * groupClause, Plan * subplan);
|
||||
|
||||
@@ -62,17 +62,17 @@ make_groupPlan(List ** tlist, bool tuplePerGroup,
|
||||
*
|
||||
* Returns a query plan.
|
||||
*/
|
||||
Plan *
|
||||
Plan *
|
||||
query_planner(Query * root,
|
||||
int command_type,
|
||||
List * tlist,
|
||||
List * qual)
|
||||
{
|
||||
List *constant_qual = NIL;
|
||||
List *flattened_tlist = NIL;
|
||||
List *level_tlist = NIL;
|
||||
Plan *subplan = (Plan *) NULL;
|
||||
Agg *aggplan = NULL;
|
||||
List *constant_qual = NIL;
|
||||
List *flattened_tlist = NIL;
|
||||
List *level_tlist = NIL;
|
||||
Plan *subplan = (Plan *) NULL;
|
||||
Agg *aggplan = NULL;
|
||||
|
||||
/*
|
||||
* A command without a target list or qualification is an error,
|
||||
@@ -132,36 +132,36 @@ query_planner(Query * root,
|
||||
|
||||
switch (command_type)
|
||||
{
|
||||
case CMD_SELECT:
|
||||
case CMD_INSERT:
|
||||
return ((Plan *) make_result(tlist,
|
||||
(Node *) constant_qual,
|
||||
(Plan *) NULL));
|
||||
break;
|
||||
case CMD_SELECT:
|
||||
case CMD_INSERT:
|
||||
return ((Plan *) make_result(tlist,
|
||||
(Node *) constant_qual,
|
||||
(Plan *) NULL));
|
||||
break;
|
||||
|
||||
case CMD_DELETE:
|
||||
case CMD_UPDATE:
|
||||
{
|
||||
SeqScan *scan = make_seqscan(tlist,
|
||||
case CMD_DELETE:
|
||||
case CMD_UPDATE:
|
||||
{
|
||||
SeqScan *scan = make_seqscan(tlist,
|
||||
(List *) NULL,
|
||||
root->resultRelation,
|
||||
(Plan *) NULL);
|
||||
|
||||
if (constant_qual != NULL)
|
||||
{
|
||||
return ((Plan *) make_result(tlist,
|
||||
(Node *) constant_qual,
|
||||
(Plan *) scan));
|
||||
if (constant_qual != NULL)
|
||||
{
|
||||
return ((Plan *) make_result(tlist,
|
||||
(Node *) constant_qual,
|
||||
(Plan *) scan));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((Plan *) scan);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((Plan *) scan);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
return ((Plan *) NULL);
|
||||
default:
|
||||
return ((Plan *) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ query_planner(Query * root,
|
||||
*/
|
||||
if (root->groupClause != NULL)
|
||||
{
|
||||
bool tuplePerGroup;
|
||||
bool tuplePerGroup;
|
||||
|
||||
/*
|
||||
* decide whether how many tuples per group the Group node needs
|
||||
@@ -223,7 +223,7 @@ query_planner(Query * root,
|
||||
*/
|
||||
if (constant_qual)
|
||||
{
|
||||
Plan *plan;
|
||||
Plan *plan;
|
||||
|
||||
plan = (Plan *) make_result(tlist,
|
||||
(Node *) constant_qual,
|
||||
@@ -277,13 +277,13 @@ query_planner(Query * root,
|
||||
* Returns a subplan.
|
||||
*
|
||||
*/
|
||||
static Plan *
|
||||
static Plan *
|
||||
subplanner(Query * root,
|
||||
List * flat_tlist,
|
||||
List * qual)
|
||||
{
|
||||
Rel *final_relation;
|
||||
List *final_relation_list;
|
||||
Rel *final_relation;
|
||||
List *final_relation_list;
|
||||
|
||||
/*
|
||||
* Initialize the targetlist and qualification, adding entries to
|
||||
@@ -323,7 +323,7 @@ subplanner(Query * root,
|
||||
if (XfuncMode != XFUNC_OFF && XfuncMode != XFUNC_NOPM &&
|
||||
XfuncMode != XFUNC_NOPULL && !final_relation->pruneable)
|
||||
{
|
||||
List *pathnode;
|
||||
List *pathnode;
|
||||
|
||||
foreach(pathnode, final_relation->pathlist)
|
||||
{
|
||||
@@ -353,13 +353,13 @@ subplanner(Query * root,
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
static Result *
|
||||
static Result *
|
||||
make_result(List * tlist,
|
||||
Node * resconstantqual,
|
||||
Plan * subplan)
|
||||
{
|
||||
Result *node = makeNode(Result);
|
||||
Plan *plan = &node->plan;
|
||||
Result *node = makeNode(Result);
|
||||
Plan *plan = &node->plan;
|
||||
|
||||
tlist = generate_fjoin(tlist);
|
||||
plan->cost = 0.0;
|
||||
@@ -377,25 +377,25 @@ make_result(List * tlist,
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
static Plan *
|
||||
static Plan *
|
||||
make_groupPlan(List ** tlist,
|
||||
bool tuplePerGroup,
|
||||
List * groupClause,
|
||||
Plan * subplan)
|
||||
{
|
||||
List *sort_tlist;
|
||||
List *sl,
|
||||
*gl;
|
||||
List *glc = listCopy(groupClause);
|
||||
List *otles = NIL;/* list of removed non-GroupBy entries */
|
||||
List *otlvars = NIL; /* list of var in them */
|
||||
int otlvcnt;
|
||||
Sort *sortplan;
|
||||
Group *grpplan;
|
||||
int numCols;
|
||||
AttrNumber *grpColIdx;
|
||||
int keyno = 1;
|
||||
int last_resno = 1;
|
||||
List *sort_tlist;
|
||||
List *sl,
|
||||
*gl;
|
||||
List *glc = listCopy(groupClause);
|
||||
List *otles = NIL; /* list of removed non-GroupBy entries */
|
||||
List *otlvars = NIL; /* list of var in them */
|
||||
int otlvcnt;
|
||||
Sort *sortplan;
|
||||
Group *grpplan;
|
||||
int numCols;
|
||||
AttrNumber *grpColIdx;
|
||||
int keyno = 1;
|
||||
int last_resno = 1;
|
||||
|
||||
numCols = length(groupClause);
|
||||
grpColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols);
|
||||
@@ -412,12 +412,12 @@ make_groupPlan(List ** tlist,
|
||||
*/
|
||||
foreach(sl, sort_tlist)
|
||||
{
|
||||
Resdom *resdom = NULL;
|
||||
TargetEntry *te = (TargetEntry *) lfirst(sl);
|
||||
Resdom *resdom = NULL;
|
||||
TargetEntry *te = (TargetEntry *) lfirst(sl);
|
||||
|
||||
foreach(gl, glc)
|
||||
{
|
||||
GroupClause *grpcl = (GroupClause *) lfirst(gl);
|
||||
GroupClause *grpcl = (GroupClause *) lfirst(gl);
|
||||
|
||||
if (grpcl->entry->resdom->resno == te->resdom->resno)
|
||||
{
|
||||
@@ -463,7 +463,7 @@ make_groupPlan(List ** tlist,
|
||||
otlvcnt = length(otlvars);
|
||||
foreach(gl, otlvars)
|
||||
{
|
||||
Var *v = (Var *) lfirst(gl);
|
||||
Var *v = (Var *) lfirst(gl);
|
||||
|
||||
if (tlist_member(v, sort_tlist) == NULL)
|
||||
{
|
||||
@@ -490,15 +490,15 @@ make_groupPlan(List ** tlist,
|
||||
*/
|
||||
foreach(sl, sort_tlist)
|
||||
{
|
||||
TargetEntry *te = (TargetEntry *) lfirst(sl);
|
||||
Resdom *resdom = te->resdom;
|
||||
Node *expr = te->expr;
|
||||
TargetEntry *te = (TargetEntry *) lfirst(sl);
|
||||
Resdom *resdom = te->resdom;
|
||||
Node *expr = te->expr;
|
||||
|
||||
if (IsA(expr, Var))
|
||||
{
|
||||
#if 0 /* subplanVar->resdom->resno expected to
|
||||
* be = te->resdom->resno */
|
||||
TargetEntry *subplanVar;
|
||||
TargetEntry *subplanVar;
|
||||
|
||||
subplanVar = match_varid((Var *) expr, subplan->targetlist);
|
||||
((Var *) expr)->varattno = subplanVar->resdom->resno;
|
||||
@@ -533,12 +533,12 @@ make_groupPlan(List ** tlist,
|
||||
sort_tlist = NIL; /* to be new parent TL */
|
||||
foreach(gl, *tlist)
|
||||
{
|
||||
List *temp = NIL;
|
||||
TargetEntry *te = (TargetEntry *) lfirst(gl);
|
||||
List *temp = NIL;
|
||||
TargetEntry *te = (TargetEntry *) lfirst(gl);
|
||||
|
||||
foreach(temp, otles) /* Is it removed non-GroupBy entry ? */
|
||||
{
|
||||
TargetEntry *ote = (TargetEntry *) lfirst(temp);
|
||||
TargetEntry *ote = (TargetEntry *) lfirst(temp);
|
||||
|
||||
if (ote->resdom->resno == te->resdom->resno)
|
||||
{
|
||||
@@ -548,7 +548,7 @@ make_groupPlan(List ** tlist,
|
||||
}
|
||||
if (temp == NIL) /* It's "our" TLE - we're to return */
|
||||
{ /* it from Sort/Group plans */
|
||||
TargetEntry *my = (TargetEntry *) lfirst(sl); /* get it */
|
||||
TargetEntry *my = (TargetEntry *) lfirst(sl); /* get it */
|
||||
|
||||
sl = sl->next; /* prepare for the next "our" */
|
||||
my = copyObject(my);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.7 1997/09/07 04:44:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.8 1997/09/08 02:24:38 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
#include "executor/executor.h"
|
||||
|
||||
static Plan *make_sortplan(List * tlist, List * sortcls, Plan * plannode);
|
||||
static Plan *init_query_planner(Query * parse);
|
||||
static Plan *make_sortplan(List * tlist, List * sortcls, Plan * plannode);
|
||||
static Plan *init_query_planner(Query * parse);
|
||||
static Existential *make_existential(Plan * left, Plan * right);
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -68,18 +68,18 @@ static Existential *make_existential(Plan * left, Plan * right);
|
||||
* Returns a query plan.
|
||||
*
|
||||
*/
|
||||
Plan *
|
||||
Plan *
|
||||
planner(Query * parse)
|
||||
{
|
||||
List *tlist = parse->targetList;
|
||||
List *rangetable = parse->rtable;
|
||||
char *uniqueflag = parse->uniqueFlag;
|
||||
List *sortclause = parse->sortClause;
|
||||
Plan *special_plans = (Plan *) NULL;
|
||||
List *tlist = parse->targetList;
|
||||
List *rangetable = parse->rtable;
|
||||
char *uniqueflag = parse->uniqueFlag;
|
||||
List *sortclause = parse->sortClause;
|
||||
Plan *special_plans = (Plan *) NULL;
|
||||
|
||||
Plan *result_plan = (Plan *) NULL;
|
||||
Plan *result_plan = (Plan *) NULL;
|
||||
|
||||
int rt_index;
|
||||
int rt_index;
|
||||
|
||||
/*
|
||||
* plan inheritance
|
||||
@@ -119,7 +119,7 @@ planner(Query * parse)
|
||||
|
||||
if (uniqueflag)
|
||||
{
|
||||
Plan *sortplan = make_sortplan(tlist, sortclause, result_plan);
|
||||
Plan *sortplan = make_sortplan(tlist, sortclause, result_plan);
|
||||
|
||||
return ((Plan *) make_unique(tlist, sortplan, uniqueflag));
|
||||
}
|
||||
@@ -142,15 +142,15 @@ planner(Query * parse)
|
||||
* sortkeys: ( resdom1 resdom2 resdom3 ...)
|
||||
* sortops: (sortop1 sortop2 sortop3 ...)
|
||||
*/
|
||||
static Plan *
|
||||
static Plan *
|
||||
make_sortplan(List * tlist, List * sortcls, Plan * plannode)
|
||||
{
|
||||
Plan *sortplan = (Plan *) NULL;
|
||||
List *temp_tlist = NIL;
|
||||
List *i = NIL;
|
||||
Resdom *resnode = (Resdom *) NULL;
|
||||
Resdom *resdom = (Resdom *) NULL;
|
||||
int keyno = 1;
|
||||
Plan *sortplan = (Plan *) NULL;
|
||||
List *temp_tlist = NIL;
|
||||
List *i = NIL;
|
||||
Resdom *resnode = (Resdom *) NULL;
|
||||
Resdom *resdom = (Resdom *) NULL;
|
||||
int keyno = 1;
|
||||
|
||||
/*
|
||||
* First make a copy of the tlist so that we don't corrupt the the
|
||||
@@ -161,7 +161,7 @@ make_sortplan(List * tlist, List * sortcls, Plan * plannode)
|
||||
|
||||
foreach(i, sortcls)
|
||||
{
|
||||
SortClause *sortcl = (SortClause *) lfirst(i);
|
||||
SortClause *sortcl = (SortClause *) lfirst(i);
|
||||
|
||||
resnode = sortcl->resdom;
|
||||
resdom = tlist_resdom(temp_tlist, resnode);
|
||||
@@ -203,13 +203,13 @@ make_sortplan(List * tlist, List * sortcls, Plan * plannode)
|
||||
* MODIFIES: tlist,qual
|
||||
*
|
||||
*/
|
||||
static Plan *
|
||||
static Plan *
|
||||
init_query_planner(Query * root)
|
||||
{
|
||||
List *primary_qual;
|
||||
List *existential_qual;
|
||||
Existential *exist_plan;
|
||||
List *tlist = root->targetList;
|
||||
List *primary_qual;
|
||||
List *existential_qual;
|
||||
Existential *exist_plan;
|
||||
List *tlist = root->targetList;
|
||||
|
||||
tlist = preprocess_targetlist(tlist,
|
||||
root->commandType,
|
||||
@@ -230,8 +230,8 @@ init_query_planner(Query * root)
|
||||
}
|
||||
else
|
||||
{
|
||||
int temp = root->commandType;
|
||||
Plan *existential_plan;
|
||||
int temp = root->commandType;
|
||||
Plan *existential_plan;
|
||||
|
||||
root->commandType = CMD_SELECT;
|
||||
existential_plan = query_planner(root,
|
||||
@@ -256,7 +256,7 @@ init_query_planner(Query * root)
|
||||
static Existential *
|
||||
make_existential(Plan * left, Plan * right)
|
||||
{
|
||||
Existential *node = makeNode(Existential);
|
||||
Existential *node = makeNode(Existential);
|
||||
|
||||
node->lefttree = left;
|
||||
node->righttree = left;
|
||||
@@ -275,17 +275,17 @@ make_existential(Plan * left, Plan * right)
|
||||
void
|
||||
pg_checkretval(Oid rettype, QueryTreeList * queryTreeList)
|
||||
{
|
||||
Query *parse;
|
||||
List *tlist;
|
||||
List *rt;
|
||||
int cmd;
|
||||
Type typ;
|
||||
Resdom *resnode;
|
||||
Relation reln;
|
||||
Oid relid;
|
||||
Oid tletype;
|
||||
int relnatts;
|
||||
int i;
|
||||
Query *parse;
|
||||
List *tlist;
|
||||
List *rt;
|
||||
int cmd;
|
||||
Type typ;
|
||||
Resdom *resnode;
|
||||
Relation reln;
|
||||
Oid relid;
|
||||
Oid tletype;
|
||||
int relnatts;
|
||||
int i;
|
||||
|
||||
/* find the final query */
|
||||
parse = queryTreeList->qtrees[queryTreeList->len - 1];
|
||||
@@ -383,8 +383,8 @@ pg_checkretval(Oid rettype, QueryTreeList * queryTreeList)
|
||||
/* expect attributes 1 .. n in order */
|
||||
for (i = 1; i <= relnatts; i++)
|
||||
{
|
||||
TargetEntry *tle = lfirst(tlist);
|
||||
Node *thenode = tle->expr;
|
||||
TargetEntry *tle = lfirst(tlist);
|
||||
Node *thenode = tle->expr;
|
||||
|
||||
tlist = lnext(tlist);
|
||||
tletype = exprType(thenode);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.5 1997/09/07 04:44:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.6 1997/09/08 02:24:39 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -33,20 +33,20 @@
|
||||
#include "optimizer/var.h"
|
||||
#include "optimizer/tlist.h"
|
||||
|
||||
static void set_join_tlist_references(Join * join);
|
||||
static void set_tempscan_tlist_references(SeqScan * tempscan);
|
||||
static void set_temp_tlist_references(Temp * temp);
|
||||
static List *
|
||||
static void set_join_tlist_references(Join * join);
|
||||
static void set_tempscan_tlist_references(SeqScan * tempscan);
|
||||
static void set_temp_tlist_references(Temp * temp);
|
||||
static List *
|
||||
replace_clause_joinvar_refs(Expr * clause,
|
||||
List * outer_tlist, List * inner_tlist);
|
||||
static List *
|
||||
static List *
|
||||
replace_subclause_joinvar_refs(List * clauses,
|
||||
List * outer_tlist, List * inner_tlist);
|
||||
static Var *replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist);
|
||||
static List *tlist_temp_references(Oid tempid, List * tlist);
|
||||
static void replace_result_clause(List * clause, List * subplanTargetList);
|
||||
static bool OperandIsInner(Node * opnd, int inner_relid);
|
||||
static void replace_agg_clause(Node * expr, List * targetlist);
|
||||
static Var *replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist);
|
||||
static List *tlist_temp_references(Oid tempid, List * tlist);
|
||||
static void replace_result_clause(List * clause, List * subplanTargetList);
|
||||
static bool OperandIsInner(Node * opnd, int inner_relid);
|
||||
static void replace_agg_clause(Node * expr, List * targetlist);
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
@@ -94,7 +94,7 @@ set_tlist_references(Plan * plan)
|
||||
}
|
||||
else if (IsA(plan, Choose))
|
||||
{
|
||||
List *x;
|
||||
List *x;
|
||||
|
||||
foreach(x, ((Choose *) plan)->chooseplanlist)
|
||||
{
|
||||
@@ -122,19 +122,19 @@ set_tlist_references(Plan * plan)
|
||||
static void
|
||||
set_join_tlist_references(Join * join)
|
||||
{
|
||||
Plan *outer = ((Plan *) join)->lefttree;
|
||||
Plan *inner = ((Plan *) join)->righttree;
|
||||
List *new_join_targetlist = NIL;
|
||||
TargetEntry *temp = (TargetEntry *) NULL;
|
||||
List *entry = NIL;
|
||||
List *inner_tlist = NULL;
|
||||
List *outer_tlist = NULL;
|
||||
TargetEntry *xtl = (TargetEntry *) NULL;
|
||||
List *qptlist = ((Plan *) join)->targetlist;
|
||||
Plan *outer = ((Plan *) join)->lefttree;
|
||||
Plan *inner = ((Plan *) join)->righttree;
|
||||
List *new_join_targetlist = NIL;
|
||||
TargetEntry *temp = (TargetEntry *) NULL;
|
||||
List *entry = NIL;
|
||||
List *inner_tlist = NULL;
|
||||
List *outer_tlist = NULL;
|
||||
TargetEntry *xtl = (TargetEntry *) NULL;
|
||||
List *qptlist = ((Plan *) join)->targetlist;
|
||||
|
||||
foreach(entry, qptlist)
|
||||
{
|
||||
List *joinvar;
|
||||
List *joinvar;
|
||||
|
||||
xtl = (TargetEntry *) lfirst(entry);
|
||||
inner_tlist = ((inner == NULL) ? NIL : inner->targetlist);
|
||||
@@ -167,7 +167,7 @@ set_join_tlist_references(Join * join)
|
||||
static void
|
||||
set_tempscan_tlist_references(SeqScan * tempscan)
|
||||
{
|
||||
Temp *temp = (Temp *) ((Plan *) tempscan)->lefttree;
|
||||
Temp *temp = (Temp *) ((Plan *) tempscan)->lefttree;
|
||||
|
||||
((Plan *) tempscan)->targetlist =
|
||||
tlist_temp_references(temp->tempid,
|
||||
@@ -189,7 +189,7 @@ set_tempscan_tlist_references(SeqScan * tempscan)
|
||||
static void
|
||||
set_temp_tlist_references(Temp * temp)
|
||||
{
|
||||
Plan *source = ((Plan *) temp)->lefttree;
|
||||
Plan *source = ((Plan *) temp)->lefttree;
|
||||
|
||||
if (source != NULL)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ set_temp_tlist_references(Temp * temp)
|
||||
* Returns the new join clauses.
|
||||
*
|
||||
*/
|
||||
List *
|
||||
List *
|
||||
join_references(List * clauses,
|
||||
List * outer_tlist,
|
||||
List * inner_tlist)
|
||||
@@ -243,15 +243,15 @@ join_references(List * clauses,
|
||||
* Returns the new list of clauses.
|
||||
*
|
||||
*/
|
||||
List *
|
||||
List *
|
||||
index_outerjoin_references(List * inner_indxqual,
|
||||
List * outer_tlist,
|
||||
Index inner_relid)
|
||||
{
|
||||
List *t_list = NIL;
|
||||
Expr *temp = NULL;
|
||||
List *t_clause = NIL;
|
||||
Expr *clause = NULL;
|
||||
List *t_list = NIL;
|
||||
Expr *temp = NULL;
|
||||
List *t_clause = NIL;
|
||||
Expr *clause = NULL;
|
||||
|
||||
foreach(t_clause, inner_indxqual)
|
||||
{
|
||||
@@ -262,7 +262,7 @@ index_outerjoin_references(List * inner_indxqual,
|
||||
*/
|
||||
if (OperandIsInner((Node *) get_rightop(clause), inner_relid))
|
||||
{
|
||||
Var *joinvar = (Var *)
|
||||
Var *joinvar = (Var *)
|
||||
replace_clause_joinvar_refs((Expr *) get_leftop(clause),
|
||||
outer_tlist,
|
||||
NIL);
|
||||
@@ -275,7 +275,7 @@ index_outerjoin_references(List * inner_indxqual,
|
||||
else
|
||||
{
|
||||
/* inner scan on left */
|
||||
Var *joinvar = (Var *)
|
||||
Var *joinvar = (Var *)
|
||||
replace_clause_joinvar_refs((Expr *) get_rightop(clause),
|
||||
outer_tlist,
|
||||
NIL);
|
||||
@@ -306,12 +306,12 @@ index_outerjoin_references(List * inner_indxqual,
|
||||
* Returns the new join clause.
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
static List *
|
||||
replace_clause_joinvar_refs(Expr * clause,
|
||||
List * outer_tlist,
|
||||
List * inner_tlist)
|
||||
{
|
||||
List *temp = NULL;
|
||||
List *temp = NULL;
|
||||
|
||||
if (IsA(clause, Var))
|
||||
{
|
||||
@@ -330,7 +330,7 @@ replace_clause_joinvar_refs(Expr * clause,
|
||||
}
|
||||
else if (or_clause((Node *) clause))
|
||||
{
|
||||
List *orclause =
|
||||
List *orclause =
|
||||
replace_subclause_joinvar_refs(((Expr *) clause)->args,
|
||||
outer_tlist,
|
||||
inner_tlist);
|
||||
@@ -339,7 +339,7 @@ replace_clause_joinvar_refs(Expr * clause,
|
||||
}
|
||||
else if (IsA(clause, ArrayRef))
|
||||
{
|
||||
ArrayRef *aref = (ArrayRef *) clause;
|
||||
ArrayRef *aref = (ArrayRef *) clause;
|
||||
|
||||
temp = replace_subclause_joinvar_refs(aref->refupperindexpr,
|
||||
outer_tlist,
|
||||
@@ -365,7 +365,7 @@ replace_clause_joinvar_refs(Expr * clause,
|
||||
}
|
||||
else if (is_funcclause((Node *) clause))
|
||||
{
|
||||
List *funcclause =
|
||||
List *funcclause =
|
||||
replace_subclause_joinvar_refs(((Expr *) clause)->args,
|
||||
outer_tlist,
|
||||
inner_tlist);
|
||||
@@ -375,7 +375,7 @@ replace_clause_joinvar_refs(Expr * clause,
|
||||
}
|
||||
else if (not_clause((Node *) clause))
|
||||
{
|
||||
List *notclause =
|
||||
List *notclause =
|
||||
replace_clause_joinvar_refs(get_notclausearg(clause),
|
||||
outer_tlist,
|
||||
inner_tlist);
|
||||
@@ -384,11 +384,11 @@ replace_clause_joinvar_refs(Expr * clause,
|
||||
}
|
||||
else if (is_opclause((Node *) clause))
|
||||
{
|
||||
Var *leftvar =
|
||||
Var *leftvar =
|
||||
(Var *) replace_clause_joinvar_refs((Expr *) get_leftop(clause),
|
||||
outer_tlist,
|
||||
inner_tlist);
|
||||
Var *rightvar =
|
||||
Var *rightvar =
|
||||
(Var *) replace_clause_joinvar_refs((Expr *) get_rightop(clause),
|
||||
outer_tlist,
|
||||
inner_tlist);
|
||||
@@ -401,14 +401,14 @@ replace_clause_joinvar_refs(Expr * clause,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static List *
|
||||
static List *
|
||||
replace_subclause_joinvar_refs(List * clauses,
|
||||
List * outer_tlist,
|
||||
List * inner_tlist)
|
||||
{
|
||||
List *t_list = NIL;
|
||||
List *temp = NIL;
|
||||
List *clause = NIL;
|
||||
List *t_list = NIL;
|
||||
List *temp = NIL;
|
||||
List *clause = NIL;
|
||||
|
||||
foreach(clause, clauses)
|
||||
{
|
||||
@@ -420,10 +420,10 @@ replace_subclause_joinvar_refs(List * clauses,
|
||||
return (t_list);
|
||||
}
|
||||
|
||||
static Var *
|
||||
static Var *
|
||||
replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist)
|
||||
{
|
||||
Resdom *outer_resdom = (Resdom *) NULL;
|
||||
Resdom *outer_resdom = (Resdom *) NULL;
|
||||
|
||||
outer_resdom = tlist_member(var, outer_tlist);
|
||||
|
||||
@@ -437,7 +437,7 @@ replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist)
|
||||
}
|
||||
else
|
||||
{
|
||||
Resdom *inner_resdom;
|
||||
Resdom *inner_resdom;
|
||||
|
||||
inner_resdom = tlist_member(var, inner_tlist);
|
||||
if (inner_resdom != NULL && IsA(inner_resdom, Resdom))
|
||||
@@ -466,18 +466,18 @@ replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist)
|
||||
* Returns new target list
|
||||
*
|
||||
*/
|
||||
static List *
|
||||
static List *
|
||||
tlist_temp_references(Oid tempid,
|
||||
List * tlist)
|
||||
{
|
||||
List *t_list = NIL;
|
||||
TargetEntry *temp = (TargetEntry *) NULL;
|
||||
TargetEntry *xtl = NULL;
|
||||
List *entry;
|
||||
List *t_list = NIL;
|
||||
TargetEntry *temp = (TargetEntry *) NULL;
|
||||
TargetEntry *xtl = NULL;
|
||||
List *entry;
|
||||
|
||||
foreach(entry, tlist)
|
||||
{
|
||||
AttrNumber oattno;
|
||||
AttrNumber oattno;
|
||||
|
||||
xtl = lfirst(entry);
|
||||
if (IsA(get_expr(xtl), Var))
|
||||
@@ -513,12 +513,12 @@ tlist_temp_references(Oid tempid,
|
||||
void
|
||||
set_result_tlist_references(Result * resultNode)
|
||||
{
|
||||
Plan *subplan;
|
||||
List *resultTargetList;
|
||||
List *subplanTargetList;
|
||||
List *t;
|
||||
TargetEntry *entry;
|
||||
Expr *expr;
|
||||
Plan *subplan;
|
||||
List *resultTargetList;
|
||||
List *subplanTargetList;
|
||||
List *t;
|
||||
TargetEntry *entry;
|
||||
Expr *expr;
|
||||
|
||||
resultTargetList = ((Plan *) resultNode)->targetlist;
|
||||
|
||||
@@ -564,9 +564,9 @@ replace_result_clause(List * clause,
|
||||
List * subplanTargetList) /* target list of the
|
||||
* subplan */
|
||||
{
|
||||
List *t;
|
||||
List *subClause;
|
||||
TargetEntry *subplanVar;
|
||||
List *t;
|
||||
List *subClause;
|
||||
TargetEntry *subplanVar;
|
||||
|
||||
if (IsA(clause, Var))
|
||||
{
|
||||
@@ -598,7 +598,7 @@ replace_result_clause(List * clause,
|
||||
}
|
||||
else if (IsA(clause, ArrayRef))
|
||||
{
|
||||
ArrayRef *aref = (ArrayRef *) clause;
|
||||
ArrayRef *aref = (ArrayRef *) clause;
|
||||
|
||||
/*
|
||||
* This is an arrayref. Recursively call this routine for its
|
||||
@@ -646,7 +646,7 @@ replace_result_clause(List * clause,
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
bool
|
||||
OperandIsInner(Node * opnd, int inner_relid)
|
||||
{
|
||||
|
||||
@@ -663,7 +663,7 @@ OperandIsInner(Node * opnd, int inner_relid)
|
||||
}
|
||||
if (is_funcclause(opnd))
|
||||
{
|
||||
List *firstArg = lfirst(((Expr *) opnd)->args);
|
||||
List *firstArg = lfirst(((Expr *) opnd)->args);
|
||||
|
||||
if (IsA(firstArg, Var) &&
|
||||
(inner_relid == ((Var *) firstArg)->varno))
|
||||
@@ -688,16 +688,16 @@ OperandIsInner(Node * opnd, int inner_relid)
|
||||
void
|
||||
set_agg_tlist_references(Agg * aggNode)
|
||||
{
|
||||
List *aggTargetList;
|
||||
List *subplanTargetList;
|
||||
List *tl;
|
||||
List *aggTargetList;
|
||||
List *subplanTargetList;
|
||||
List *tl;
|
||||
|
||||
aggTargetList = aggNode->plan.targetlist;
|
||||
subplanTargetList = aggNode->plan.lefttree->targetlist;
|
||||
|
||||
foreach(tl, aggTargetList)
|
||||
{
|
||||
TargetEntry *tle = lfirst(tl);
|
||||
TargetEntry *tle = lfirst(tl);
|
||||
|
||||
replace_agg_clause(tle->expr, subplanTargetList);
|
||||
}
|
||||
@@ -706,9 +706,9 @@ set_agg_tlist_references(Agg * aggNode)
|
||||
void
|
||||
set_agg_agglist_references(Agg * aggNode)
|
||||
{
|
||||
List *subplanTargetList;
|
||||
Aggreg **aggs;
|
||||
int i;
|
||||
List *subplanTargetList;
|
||||
Aggreg **aggs;
|
||||
int i;
|
||||
|
||||
aggs = aggNode->aggs;
|
||||
subplanTargetList = aggNode->plan.lefttree->targetlist;
|
||||
@@ -722,8 +722,8 @@ set_agg_agglist_references(Agg * aggNode)
|
||||
static void
|
||||
replace_agg_clause(Node * clause, List * subplanTargetList)
|
||||
{
|
||||
List *t;
|
||||
TargetEntry *subplanVar;
|
||||
List *t;
|
||||
TargetEntry *subplanVar;
|
||||
|
||||
if (IsA(clause, Var))
|
||||
{
|
||||
@@ -757,7 +757,7 @@ replace_agg_clause(Node * clause, List * subplanTargetList)
|
||||
}
|
||||
else if (IsA(clause, ArrayRef))
|
||||
{
|
||||
ArrayRef *aref = (ArrayRef *) clause;
|
||||
ArrayRef *aref = (ArrayRef *) clause;
|
||||
|
||||
/*
|
||||
* This is an arrayref. Recursively call this routine for its
|
||||
@@ -781,8 +781,8 @@ replace_agg_clause(Node * clause, List * subplanTargetList)
|
||||
* This is an operator. Recursively call this routine for both its
|
||||
* left and right operands
|
||||
*/
|
||||
Node *left = (Node *) get_leftop((Expr *) clause);
|
||||
Node *right = (Node *) get_rightop((Expr *) clause);
|
||||
Node *left = (Node *) get_leftop((Expr *) clause);
|
||||
Node *right = (Node *) get_rightop((Expr *) clause);
|
||||
|
||||
if (left != (Node *) NULL)
|
||||
replace_agg_clause(left, subplanTargetList);
|
||||
|
||||
Reference in New Issue
Block a user