>> Here's a query that doesn't work on 7.1. Is this a bug or am I doing
>> something wrong?
> Hmm, I think you have found some subtle bugs in aggregate processing;
> offhand it seems like both these queries should be legal. I'll see what
> I can do about it.
Not so subtle after all :-(. Curious that no one noticed this before.
Here's the patch if you need it right away...
regards, tom lane
*** 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; /*