Re: [HACKERS] count(*) of zero rows returns 1

2013-01-21 Thread Marti Raudsepp
On Tue, Jan 15, 2013 at 5:47 AM, Gurjeet Singh singh.gurj...@gmail.com wrote: postgres=# select * from test_0_col_table ; -- (20 rows) Interestingly, PostgreSQL 9.2 has regressed here. Not sure if we care, but worth mentioning: psql (9.2.2) test=# select count(*) from foo1; count

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-21 Thread Tom Lane
Marti Raudsepp ma...@juffo.org writes: Interestingly, PostgreSQL 9.2 has regressed here. Not sure if we care, but worth mentioning: Regressed? The output looks the same to me as it has for some time. test=# select * from foo1; (No rows) Time: 1012.567 ms How did you get that? I don't

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-21 Thread Marti Raudsepp
On Mon, Jan 21, 2013 at 9:33 PM, Tom Lane t...@sss.pgh.pa.us wrote: test=# select * from foo1; (No rows) Time: 1012.567 ms How did you get that? I don't believe it's possible in the default output format. Oh I see, it's because I have \x auto in my .psqlrc. If I set \x auto or \x on then

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-15 Thread Tom Lane
Gurjeet Singh singh.gurj...@gmail.com writes: On Mon, Jan 14, 2013 at 4:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: David Johnston pol...@yahoo.com writes: SELECT *; Results in: SQL Error: ERROR: SELECT * with no tables specified is not valid Interesting to note that SELECT * FROM

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-15 Thread Bruce Momjian
On Mon, Jan 14, 2013 at 10:47:58PM -0500, Gurjeet Singh wrote: Interesting to note that SELECT * FROM table_with_zero_cols does not complain of anything. postgres=# select * from test1; -- (0 rows) This I believe result of the fact that we allow user to drop all columns of a table.

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-15 Thread Bruce Momjian
On Mon, Jan 14, 2013 at 10:25:39PM -0500, Gurjeet Singh wrote: On Mon, Jan 14, 2013 at 3:09 PM, David Johnston pol...@yahoo.com wrote: What does SELECT * FROM dual in Oracle yield? AFAICR, 'dual' table has one column named 'DUMMY' and one row with value, single character X. How

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-15 Thread Shaun Thomas
On 01/15/2013 01:18 PM, Bruce Momjian wrote: AFAICR, 'dual' table has one column named 'DUMMY' and one row with value, single character X. How elegant. :-( Let's see what EnterpriseDB produces: test= select * from dual; dummy --- X (1 row) Yep, elegant gets my vote. ;) But then

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-15 Thread Robert Haas
On Tue, Jan 15, 2013 at 2:26 PM, Shaun Thomas stho...@optionshouse.com wrote: Let's see what EnterpriseDB produces: test= select * from dual; dummy --- X (1 row) Hey, don't blame us. We didn't come up with this bad idea ... just trying to make life easier for those who are used to

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-14 Thread David Johnston
Tom Lane-2 wrote Gurjeet Singh lt; singh.gurjeet@ gt; writes: Can somebody explain why a standalone count(*) returns 1? postgres=# select count(*); count --- 1 (1 row) The Oracle equivalent of that would be SELECT count(*) FROM dual. Does it make more sense to you thought

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-14 Thread Tom Lane
David Johnston pol...@yahoo.com writes: Tom Lane-2 wrote For that to return zero, it would also be necessary for SELECT 2+2 to return zero rows. Which would be consistent with some views of the universe, but not particularly useful. Given that: SELECT *; Results in: SQL Error: ERROR:

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-14 Thread Gurjeet Singh
On Mon, Jan 14, 2013 at 3:09 PM, David Johnston pol...@yahoo.com wrote: What does SELECT * FROM dual in Oracle yield? AFAICR, 'dual' table has one column named 'DUMMY' and one row with value, single character X. -- Gurjeet Singh http://gurjeet.singh.im/

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-14 Thread Gurjeet Singh
On Mon, Jan 14, 2013 at 4:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: David Johnston pol...@yahoo.com writes: Tom Lane-2 wrote For that to return zero, it would also be necessary for SELECT 2+2 to return zero rows. Which would be consistent with some views of the universe, but not

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-14 Thread Alvaro Herrera
Gurjeet Singh escribió: Interesting to note that SELECT * FROM table_with_zero_cols does not complain of anything. postgres=# select * from test1; -- (0 rows) This I believe result of the fact that we allow user to drop all columns of a table. On a side note, Postgres allows me to

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-14 Thread Gurjeet Singh
On Mon, Jan 14, 2013 at 11:03 PM, Alvaro Herrera alvhe...@2ndquadrant.comwrote: Gurjeet Singh escribió: Interesting to note that SELECT * FROM table_with_zero_cols does not complain of anything. postgres=# select * from test1; -- (0 rows) This I believe result of the fact that

[HACKERS] count(*) of zero rows returns 1

2013-01-13 Thread Gurjeet Singh
Can somebody explain why a standalone count(*) returns 1? postgres=# select count(*); count --- 1 (1 row) I agree it's an odd thing for someone to query, but I feel it should return 0, and not 1. -- Gurjeet Singh http://gurjeet.singh.im/

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-13 Thread Tom Lane
Gurjeet Singh singh.gurj...@gmail.com writes: Can somebody explain why a standalone count(*) returns 1? postgres=# select count(*); count --- 1 (1 row) The Oracle equivalent of that would be SELECT count(*) FROM dual. Does it make more sense to you thought of that way? I agree

Re: [HACKERS] count(*) of zero rows returns 1

2013-01-13 Thread Gurjeet Singh
On Sun, Jan 13, 2013 at 4:43 PM, Tom Lane t...@sss.pgh.pa.us wrote: Gurjeet Singh singh.gurj...@gmail.com writes: Can somebody explain why a standalone count(*) returns 1? postgres=# select count(*); count --- 1 (1 row) The Oracle equivalent of that would be SELECT