*** src/backend/optimizer/util/clauses.c.orig	Mon Feb 12 20:26:43 2001
--- src/backend/optimizer/util/clauses.c	Wed Mar  7 20:49:01 2001
***************
*** 540,545 ****
--- 540,553 ----
  										 Query *context)
  {
  	if (node == NULL)
+ 		return false;
+ 
+ 	/*
+ 	 * If we find an aggregate function, do not recurse into its
+ 	 * arguments.  Subplans invoked within aggregate calls are allowed
+ 	 * to receive ungrouped variables.
+ 	 */
+ 	if (IsA(node, Aggref))
  		return false;
  
  	/*
