Re: Wrong aggregate result when sorting by a NULL value - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Wrong aggregate result when sorting by a NULL value
Date
Msg-id 30923.1541171251@sss.pgh.pa.us
Whole thread Raw
In response to Wrong aggregate result when sorting by a NULL value  (Ondřej Bouda <obouda@email.cz>)
Responses Re: Wrong aggregate result when sorting by a NULL value  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
=?UTF-8?Q?Ond=c5=99ej_Bouda?= <obouda@email.cz> writes:
> the following seems as a bug to me on Postgres 11.0:

Yeah, somebody broke this between 10.x and 11.0.  You don't need the
custom aggregate, even plain min() fails:

regression=# SELECT min(x ORDER BY z) FROM t;
 min 
-----
 
(1 row)

while 10.5 delivers the expected result:

regression=# SELECT min(x ORDER BY z) FROM t;
 min 
-----
 val
(1 row)

I've not looked at the code yet, but it's acting like somebody changed the
STRICT logic from "are any of the aggregate's arguments null" to "is any
part of the whole row (including ordering values) null".  Wrong ...

            regards, tom lane


pgsql-bugs by date:

Previous
From: Ondřej Bouda
Date:
Subject: Wrong aggregate result when sorting by a NULL value
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #15482: Foreign keys to a partition (NOT A PARTITIONED)break the server