Pbm with aggregates on empty output

From: Jean-Francois Rabasse <rabasse(at)lra(dot)ens(dot)fr>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Pbm with aggregates on empty output
Date: 2001-03-06 17:08:59
Message-ID: Pine.LNX.4.10.10103061749120.25015-100000@net.lra.ens.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Hello,
I found a problem. I don't know if it's a bug or a misuse from me.

Here is, in a minimal test version
(I use PostgreSQL 6.5.3 on i686-pc-linux-gnu):

1. A table, even very simple
=> create table thetable ( thevalue int4 );

2. I populate the table with several numeric values...
=> insert into thetable values(1);
=> insert into thetable values(2);
=> insert into thetable values(3);
=> insert into thetable values(4);

3. Now, I want to count my records matching a specified clause.
My initial idea was to use an aggregate function such as sum

=> select sum(1) from thetable where thevalue > 1;
sum
---
3
(1 row)

It works fine and I just get what I wanted, the records count.

4. If the clause can't be verified, i.e. would generate no output

=> select * from thetable where thevalue > 10000;
thevalue
--------
(0 rows)

I expected to get a 0 value, for sum().
In fact, the backend hangs.

=> select sum(1) from thetable where thevalue > 10000;
pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated abnormally
before or while processing the request.
We have lost the connection to the backend, so further processing is
impossible. Terminating.

Please, have you an idea of what's wrong with that ?
Is it a problem in the aggregate processing implementation, when the
select output is empty (or null) ?
Is it legal, for me, to do such thing ?

Thanks in advance...

Jean-Francois Rabasse

--
Jean-François Rabasse

Radioastronomie e-mail: jean-francois(dot)rabasse(at)lra(dot)ens(dot)fr
Département de Physique de l'ENS tél: +33 (0)1 44 32 25 15
24, rue Lhomond fax: +33 (0)1 44 32 39 92
F-75231 PARIS Cedex 05 www: http://www.lra.ens.fr/~rabasse/

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-03-06 18:17:03 Mis-firing of rules with a WHERE condition
Previous Message Bruce Momjian 2001-03-06 16:58:29 Re: [BUGS] Irony bug