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 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 it says "(N

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

2013-01-21 Thread Tom Lane
Marti Raudsepp 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 believe it's p

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 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 -- 1000 (1 ro

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 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 it. -- Robert

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 ag

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 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 elegant. :-

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 > ta

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

2013-01-15 Thread Tom Lane
Gurjeet Singh writes: > On Mon, Jan 14, 2013 at 4:15 PM, Tom Lane wrote: >> David Johnston writes: >>> SELECT *; >>> Results in: >>> SQL Error: ERROR: SELECT * with no tables specified is not valid > Interesting to note that SELECT * FROM table_with_zero_cols does not > complain of anything.

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 wrote: > 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

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 allo

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 wrote: > David Johnston 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. > > > G

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 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 Tom Lane
David Johnston 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: SELE

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

2013-01-14 Thread David Johnston
Tom Lane-2 wrote > Gurjeet Singh < > singh.gurjeet@ > > 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

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 wrote: > Gurjeet Singh 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 m

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

2013-01-13 Thread Tom Lane
Gurjeet Singh 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 it's an odd thin