Re: We are not following the spec for HAVING without GROUP BY - Mailing list pgsql-hackers

From Greg Stark
Subject Re: We are not following the spec for HAVING without GROUP BY
Date
Msg-id 87acpc5fjh.fsf@stark.xeocode.com
Whole thread Raw
In response to We are not following the spec for HAVING without GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: We are not following the spec for HAVING without GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> In particular this whole business of "moving HAVING into WHERE" is
> wrong and should go away.

It sort of seems like "select aggregate(col) from tab" with no GROUP BY clause
is a bit of a special case. The consistent thing to do would be to return no
records. It's only due to the special case that SQL returns a single record
for this case.

It seems like this special case is the only way to expose this difference
between a WHERE clause and a HAVING clause with an aggregate-free expression.

It seems like all that's needed is a simple flag on the Aggregate node that
says whether to output a single record if there are no input records or to
output no records.

-- 
greg



pgsql-hackers by date:

Previous
From: Kevin Brown
Date:
Subject: Re: We are not following the spec for HAVING without GROUP BY
Next
From: Bruce Momjian
Date:
Subject: Re: [pgsql-hackers-win32] snprintf causes regression tests