Bug or feature? select, count(*), group by and empty tables

Поиск
Список
Период
Сортировка
От Don Baccus
Тема Bug or feature? select, count(*), group by and empty tables
Дата
Msg-id 3.0.1.32.19991214161139.01074db0@mail.pacifier.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Re: [PATCHES] createdb/dropdb fixes  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] Bug or feature? select, count(*), group by and empty tables  (Don Baccus <dhogaza@pacifier.com>)
Список pgsql-hackers
Here's another anomaly I've run across in porting the Ars Digita
Community System web development toolkit from Oracle to Postgres:

In oracle, if we do:

SQL> create table foo(i integer, j integer);

Table created.

then select like this, we get no rows returned:

SQL> select i, count(*) from foo group by i;

no rows selected

In postgres, the same select on the same empty table yields:

test=> select i, count(*) from foo group by i;
i|count
-+-----|    0
(1 row)

test=> 

Which is correct?  It's the count() causing the row to be output,
apparently PostgreSQL feels obligated to return at least one 
value for the aggragate and since there are no groups has to
invent one.  I assume this is wrong, and that Oracle's right, but
haven't dug through Date's book to verify.



- Don Baccus, Portland OR <dhogaza@pacifier.com> Nature photos, on-line guides, Pacific Northwest Rare Bird Alert
Serviceand other goodies at http://donb.photo.net.
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Re: [PATCHES] createdb/dropdb fixes
Следующее
От: Don Baccus
Дата:
Сообщение: Re: [HACKERS] Bug or feature? select, count(*), group by and empty tables