Re: Postgres 7.3.5 and count('x') - Mailing list pgsql-hackers

From Edwin S. Ramirez
Subject Re: Postgres 7.3.5 and count('x')
Date
Msg-id 3FD21115.8020703@idconcepts.org
Whole thread Raw
In response to Re: Postgres 7.3.5 and count('x')  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
I tried :<br /> select count('x') from patients;<br /><br /> And I get the same error.  <br /><br /> select
count('x');should return the same as select count(*); which returns 1.<br /><br /> Previous Postgres versions returned
1.<br/><br /> -ESR-<br /><br /> Peter Eisentraut wrote:<br /><blockquote cite="mid200312061746.37190.peter_e@gmx.net"
type="cite"><prewrap="">Tom Lane wrote: </pre><blockquote type="cite"><pre wrap="">Bruce Momjian <a
class="moz-txt-link-rfc2396E"href="mailto:pgman@candle.pha.pa.us"><pgman@candle.pha.pa.us></a> writes:
</pre><blockquotetype="cite"><pre wrap="">What is COUNT('x') supposed to return?  1?  Is that legal SQL?
</pre></blockquote><prewrap="">Why not?   </pre></blockquote><pre wrap="">
 
Because there is nothing to count.

In general,

SELECT count(expr) FROM table1;

counts the number of rows in table1 where expr evaluates to not null.  
If table1 is not specified, that rule no longer holds.  At best you 
could assume that table1 is empty and return 0.  But a result of 1 I 
cannot see justified.
 </pre></blockquote>

pgsql-hackers by date:

Previous
From: NK
Date:
Subject: Help! Parser Stage: Get The Columns Of the Table
Next
From: "Joshua D. Drake"
Date:
Subject: Re: PostgreSQL port to pure Java?