Re: [HACKERS] Re: [GENERAL] Re: [PHP3] Re: PostgreSQL vs Mysql comparison
| От | Tom Lane |
|---|---|
| Тема | Re: [HACKERS] Re: [GENERAL] Re: [PHP3] Re: PostgreSQL vs Mysql comparison |
| Дата | |
| Msg-id | 10982.939134791@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: [GENERAL] Re: [PHP3] Re: PostgreSQL vs Mysql comparison (The Hermit Hacker <scrappy@hub.org>) |
| Ответы |
Re: [HACKERS] Re: [GENERAL] Re: [PHP3] Re: PostgreSQL vs Mysql comparison
Re: [HACKERS] Re: [GENERAL] Re: [PHP3] Re: PostgreSQL vs Mysql comparison Re: [HACKERS] Re: [GENERAL] Re: [PHP3] Re: PostgreSQL vs Mysql comparison |
| Список | pgsql-hackers |
The Hermit Hacker <scrappy@hub.org> writes:
> Anyone want to comment on this one? Just tested with v6.5.0 and it still
> exists there...
> vhosts=> create table test ( a int, b char );
> CREATE
> vhosts=> insert into test values ( 1, 'a' );
> INSERT 149258 1
> vhosts=> select a from test group by a having a > 0;
> ERROR: SELECT/HAVING requires aggregates to be valid
That's not a bug, it means what it says: HAVING clauses should contain
aggregate functions. Otherwise they might as well be WHERE clauses.
(In this example, flushing rows with negative a before the group step,
rather than after, is obviously a win, not least because it would
allow the use of an index on a.)
However, I can't see anything in the SQL92 spec that requires you to
use HAVING intelligently, so maybe this error should be downgraded to
a notice? "HAVING with no aggregates would be faster as a WHERE"
(but we'll do it anyway to satisfy pedants...)
regards, tom lane
В списке pgsql-hackers по дате отправления: