From c579ce0fb03aaf92d184adf369cf13be013adf1b Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 30 Mar 1998 16:36:43 +0000 Subject: I started adding the Having Clause and it works quite fine for sequential scans! (I think it will also work with hash, index, etc but I did not check it out! I made some High level changes which should work for all access methods, but maybe I'm wrong. Please let me know.) Now it is possible to make queries like: select s.sname, max(p.pid), min(p.pid) from part p, supplier s where s.sid=p.sid group by s.sname having max(pid)=6 and min(pid)=1 or avg(pid)=4; Having does not work yet for queries that contain a subselect statement in the Having clause, I'll try to fix this in the next days. If there are some bugs, please let me know, I'll start to read the mailinglists now! Now here is the patch against the original 6.3 version (no snapshot!!): Stefan --- src/backend/executor/nodeAgg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/backend/executor/nodeAgg.c') diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 848bd616bf0..c2b77c6e050 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -29,6 +29,7 @@ #include "storage/bufmgr.h" #include "utils/palloc.h" #include "utils/syscache.h" +#include "optimizer/clauses.h" /* * AggFuncInfo - @@ -109,10 +110,16 @@ ExecAgg(Agg *node) isNull1 = FALSE, isNull2 = FALSE; + + /***S*H***/ + do { + + /* --------------------- * get state info from node * --------------------- */ + aggstate = node->aggstate; if (aggstate->agg_done) return NULL; @@ -229,6 +236,7 @@ ExecAgg(Agg *node) } } } + /* ---------------- * for each tuple from the the outer plan, apply all the aggregates @@ -477,11 +485,19 @@ ExecAgg(Agg *node) * slot and return it. * ---------------- */ + + /***S*H***/ + } + while((ExecQual(fix_opids(node->plan.qual),econtext)!=true) && + (node->plan.qual!=NULL)); + + ExecStoreTuple(oneTuple, aggstate->csstate.css_ScanTupleSlot, InvalidBuffer, false); econtext->ecxt_scantuple = aggstate->csstate.css_ScanTupleSlot; + resultSlot = ExecProject(projInfo, &isDone); if (oneTuple) -- cgit v1.2.3