diff options
author | Bruce Momjian <bruce@momjian.us> | 1998-07-19 05:49:26 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1998-07-19 05:49:26 +0000 |
commit | 460b20a43fd2b3062783288868d02f43785251cb (patch) | |
tree | 923faa953f0f04436fa92003ff66cfb55383330a /src/backend/executor | |
parent | 916710fc914b94995438fee36f4480b17ce420ed (diff) | |
download | postgresql-460b20a43fd2b3062783288868d02f43785251cb.tar.gz postgresql-460b20a43fd2b3062783288868d02f43785251cb.zip |
1) Queries using the having clause on base tables should work well
now. Here some tested features, (examples included in the patch):
1.1) Subselects in the having clause 1.2) Double nested subselects
1.3) Subselects used in the where clause and in the having clause
simultaneously 1.4) Union Selects using having 1.5) Indexes
on the base relations are used correctly 1.6) Unallowed Queries
are prevented (e.g. qualifications in the
having clause that belong to the where clause) 1.7) Insert
into as select
2) Queries using the having clause on view relations also work
but there are some restrictions:
2.1) Create View as Select ... Having ...; using base tables in
the select 2.1.1) The Query rewrite system:
2.1.2) Why are only simple queries allowed against a view from 2.1)
? 2.2) Select ... from testview1, testview2, ... having...; 3) Bug
in ExecMergeJoin ??
Regards Stefan
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/nodeAgg.c | 25 | ||||
-rw-r--r-- | src/backend/executor/nodeMergejoin.c | 6 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 58c837e8e9c..28f50bdd4f4 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -109,22 +109,24 @@ ExecAgg(Agg *node) bool isNull = FALSE, isNull1 = FALSE, isNull2 = FALSE; - - - do { - + bool qual_result; + /* --------------------- * get state info from node * --------------------- */ + /* We loop retrieving groups until we find one matching node->plan.qual */ + do { + aggstate = node->aggstate; if (aggstate->agg_done) return NULL; estate = node->plan.state; econtext = aggstate->csstate.cstate.cs_ExprContext; + nagg = length(node->aggs); aggregates = (Aggreg **) palloc(sizeof(Aggreg *) * nagg); @@ -235,8 +237,7 @@ ExecAgg(Agg *node) } } } - - + /* ---------------- * for each tuple from the the outer plan, apply all the aggregates * ---------------- @@ -474,11 +475,6 @@ ExecAgg(Agg *node) * slot and return it. * ---------------- */ - - } - while((ExecQual(fix_opids(node->plan.qual),econtext)!=true) && - (node->plan.qual!=NULL)); - ExecStoreTuple(oneTuple, aggstate->csstate.css_ScanTupleSlot, @@ -488,8 +484,13 @@ ExecAgg(Agg *node) resultSlot = ExecProject(projInfo, &isDone); + /* As long as the retrieved group does not match the qualifications it is ignored and + * the next group is fetched */ + qual_result=ExecQual(fix_opids(node->plan.qual),econtext); if (oneTuple) - pfree(oneTuple); + pfree(oneTuple); + } + while((node->plan.qual!=NULL) && (qual_result!=true)); return resultSlot; } diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index d3a1bdb62ea..5483c864d35 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.16 1998/06/15 19:28:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.17 1998/07/19 05:49:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -365,7 +365,9 @@ CleanUpSort(Plan *plan) { Sort *sort = (Sort *) plan; - psort_end(sort); + /* This may need to be fixed or moved somewhere else, bjm */ + /* psort_end(sort); */ + } } |