Remove Query->qry_aggs and qry_numaggs and replace with Query->hasAggs.

Pass List* of Aggregs into executor, and create needed array there.
No longer need to double-processs Aggregs with second copy in Query.

Fix crash when doing:

	select sum(x+1) from test where 1 > 0;
This commit is contained in:
Bruce Momjian
1998-01-15 19:00:16 +00:00
parent f22d8e6668
commit 763ff8aef8
20 changed files with 173 additions and 272 deletions

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.43 1998/01/11 03:41:49 momjian Exp $
* $Id: parsenodes.h,v 1.44 1998/01/15 19:00:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -44,6 +44,7 @@ typedef struct Query
bool isPortal; /* is this a retrieve into portal? */
bool isBinary; /* binary portal? */
bool unionall; /* union without unique sort */
bool hasAggs; /* has aggregates in target list */
char *uniqueFlag; /* NULL, '*', or Unique attribute name */
List *sortClause; /* a list of SortClause's */
@ -56,9 +57,6 @@ typedef struct Query
* BY */
Node *havingQual; /* qualification of each group */
int qry_numAgg; /* number of aggregates in the target list */
Aggreg **qry_aggs; /* the aggregates */
List *unionClause; /* unions are linked under the previous query */
/* internal to planner */

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: plannodes.h,v 1.12 1997/12/27 06:41:41 momjian Exp $
* $Id: plannodes.h,v 1.13 1998/01/15 19:00:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -214,8 +214,7 @@ typedef struct HashJoin
typedef struct Agg
{
Plan plan;
int numAgg;
Aggreg **aggs;
List *aggs;
AggState *aggstate;
} Agg;

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: planmain.h,v 1.9 1997/12/20 07:59:43 momjian Exp $
* $Id: planmain.h,v 1.10 1998/01/15 19:00:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -33,7 +33,7 @@ extern SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid,
Plan *lefttree);
extern Sort *make_sort(List *tlist, Oid tempid, Plan *lefttree,
int keycount);
extern Agg *make_agg(List *tlist, int nagg, Aggreg **aggs, Plan *lefttree);
extern Agg *make_agg(List *tlist, Plan *lefttree);
extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
AttrNumber *grpColIdx, Sort *lefttree);
extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr);
@ -55,7 +55,7 @@ extern List *join_references(List *clauses, List *outer_tlist,
extern List *index_outerjoin_references(List *inner_indxqual,
List *outer_tlist, Index inner_relid);
extern void set_result_tlist_references(Result *resultNode);
extern void set_agg_tlist_references(Agg *aggNode);
extern List *set_agg_tlist_references(Agg *aggNode);
extern void set_agg_agglist_references(Agg *aggNode);
extern void del_agg_tlist_references(List *tlist);

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_node.h,v 1.3 1997/11/26 03:43:13 momjian Exp $
* $Id: parse_node.h,v 1.4 1998/01/15 19:00:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -30,10 +30,9 @@ typedef struct ParseState
{
int p_last_resno;
List *p_rtable;
int p_numAgg;
List *p_aggs;
bool p_is_insert;
List *p_insert_columns;
bool p_hasAggs;
bool p_is_insert;
bool p_is_update;
bool p_is_rule;
bool p_in_where_clause;