|
6 | 6 | * |
7 | 7 | * |
8 | 8 | * IDENTIFICATION |
9 | | - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.58 1999/10/01 04:08:24 tgl Exp $ |
| 9 | + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.59 1999/10/02 04:42:04 tgl Exp $ |
10 | 10 | * |
11 | 11 | *------------------------------------------------------------------------- |
12 | 12 | */ |
@@ -530,6 +530,13 @@ modifyAggrefMakeSublink(Expr *origexp, Query *parsetree) |
530 | 530 | subquery->targetList=lcons(tle,NIL); |
531 | 531 | subquery->qual=modifyAggrefDropQual((Node*)parsetree->qual, |
532 | 532 | (Node*)origexp); |
| 533 | +/* |
| 534 | + * If there are still aggs in the subselect's qual, give up. |
| 535 | + * Recursing would be a bad idea --- we'd likely produce an |
| 536 | + * infinite recursion. This whole technique is a crock, really... |
| 537 | + */ |
| 538 | +if (checkQueryHasAggs(subquery->qual)) |
| 539 | +elog(ERROR,"Cannot handle aggregate function inserted at this place in WHERE clause"); |
533 | 540 | subquery->groupClause=NIL; |
534 | 541 | subquery->havingQual=NULL; |
535 | 542 | subquery->hasAggs= TRUE; |
@@ -576,10 +583,18 @@ modifyAggrefQual(Node *node, Query *parsetree) |
576 | 583 | SubLink*sub=modifyAggrefMakeSublink(expr, |
577 | 584 | parsetree); |
578 | 585 | parsetree->hasSubLinks= true; |
| 586 | +/* check for aggs in resulting lefthand... */ |
| 587 | +sub->lefthand= (List*)modifyAggrefQual((Node*)sub->lefthand, |
| 588 | +parsetree); |
579 | 589 | return (Node*)sub; |
580 | 590 | } |
581 | 591 | /* otherwise, fall through and copy the expr normally */ |
582 | 592 | } |
| 593 | +if (IsA(node,Aggref)) |
| 594 | +{ |
| 595 | +/* Oops, found one that's not inside an Expr we can rearrange... */ |
| 596 | +elog(ERROR,"Cannot handle aggregate function inserted at this place in WHERE clause"); |
| 597 | +} |
583 | 598 | /* We do NOT recurse into subselects in this routine. It's sufficient |
584 | 599 | * to get rid of aggregates that are in the qual expression proper. |
585 | 600 | */ |
|