Re: Wrong aggregate result when sorting by a NULL value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ondřej Bouda <obouda(at)email(dot)cz>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Wrong aggregate result when sorting by a NULL value
Date: 2018-11-02 15:07:31
Message-ID: 30923.1541171251@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?UTF-8?Q?Ond=c5=99ej_Bouda?= <obouda(at)email(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2018-11-02 15:10:27 Re: BUG #15482: Foreign keys to a partition (NOT A PARTITIONED) break the server
Previous Message Ondřej Bouda 2018-11-02 13:29:53 Wrong aggregate result when sorting by a NULL value