Massimo Dal Zotto <dz@cs.unitn.it> writes:
> dz=> select count(1) from my_table;
> pqReadData() -- backend closed the channel unexpectedly.
Further notes --- I find that you can get the same crash with no table
at all, select count(1);
6.4.2 executes both queries --- but curiously enough, it produces "1"
regardless of the size of the table you mention, which is not surprising
when you look at its plan ... it optimizes out the scan of the table
entirely. But if you do select a,count(1) from table group by a;
then you get a count of the number of rows in each group, which is more
or less what I'd expect. This behavior is not consistent with the
ungrouped case.
After a quick gander at the SQL spec, I see no evidence that either of
these queries is allowed by the spec. I'm inclined to think that
"select count(1);" ought to be disallowed and "select count(1) from
my_table;" ought to be treated the same as "select count(*) from
my_table;", like it is in the grouped case. Comments?
regards, tom lane