aboutsummaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rewriteHandler.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-10-02 04:42:04 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-10-02 04:42:04 +0000
commit54204e6c78f3a227ee1769908524d15d8fe2d0b8 (patch)
treea0719fb7b5be477db2e32d01fa390aa803ed94fb /src/backend/rewrite/rewriteHandler.c
parentfc43696d1a28ccc5f58b2b0abce8e86f0920433d (diff)
downloadpostgresql-54204e6c78f3a227ee1769908524d15d8fe2d0b8.tar.gz
postgresql-54204e6c78f3a227ee1769908524d15d8fe2d0b8.zip
Stick finger into a couple more holes in the leaky dike of
modifyAggrefQual. This routine really, really needs to be retired, but until we have subselects in FROM there's no chance of doing the job right. In the meantime try to respond to unhandlable cases with elog rather than coredump.
Diffstat (limited to 'src/backend/rewrite/rewriteHandler.c')
-rw-r--r--src/backend/rewrite/rewriteHandler.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 42e87244e18..4ad87f16ba4 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.58 1999/10/01 04:08:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.59 1999/10/02 04:42:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -530,6 +530,13 @@ modifyAggrefMakeSublink(Expr *origexp, Query *parsetree)
subquery->targetList = lcons(tle, NIL);
subquery->qual = modifyAggrefDropQual((Node *) parsetree->qual,
(Node *) origexp);
+ /*
+ * If there are still aggs in the subselect's qual, give up.
+ * Recursing would be a bad idea --- we'd likely produce an
+ * infinite recursion. This whole technique is a crock, really...
+ */
+ if (checkQueryHasAggs(subquery->qual))
+ elog(ERROR, "Cannot handle aggregate function inserted at this place in WHERE clause");
subquery->groupClause = NIL;
subquery->havingQual = NULL;
subquery->hasAggs = TRUE;
@@ -576,10 +583,18 @@ modifyAggrefQual(Node *node, Query *parsetree)
SubLink *sub = modifyAggrefMakeSublink(expr,
parsetree);
parsetree->hasSubLinks = true;
+ /* check for aggs in resulting lefthand... */
+ sub->lefthand = (List *) modifyAggrefQual((Node *) sub->lefthand,
+ parsetree);
return (Node *) sub;
}
/* otherwise, fall through and copy the expr normally */
}
+ if (IsA(node, Aggref))
+ {
+ /* Oops, found one that's not inside an Expr we can rearrange... */
+ elog(ERROR, "Cannot handle aggregate function inserted at this place in WHERE clause");
+ }
/* We do NOT recurse into subselects in this routine. It's sufficient
* to get rid of aggregates that are in the qual expression proper.
*/