Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIb31-00076l-7i for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Nov 2018 15:07:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIb2y-0006HF-Qr for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Nov 2018 15:07:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIb2y-0006Fw-KO for pgsql-bugs@lists.postgresql.org; Fri, 02 Nov 2018 15:07:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIb2w-0002mX-6N for pgsql-bugs@postgresql.org; Fri, 02 Nov 2018 15:07:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wA2F7V4Z030924; Fri, 2 Nov 2018 11:07:31 -0400 From: Tom Lane To: =?UTF-8?Q?Ond=c5=99ej_Bouda?= cc: pgsql-bugs@postgresql.org Subject: Re: Wrong aggregate result when sorting by a NULL value In-reply-to: <2a505161-2727-2473-7c46-591ed108ac52@email.cz> References: <2a505161-2727-2473-7c46-591ed108ac52@email.cz> Comments: In-reply-to =?UTF-8?Q?Ond=c5=99ej_Bouda?= message dated "Fri, 02 Nov 2018 14:29:53 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30922.1541171251.1@sss.pgh.pa.us> Date: Fri, 02 Nov 2018 11:07:31 -0400 Message-ID: <30923.1541171251@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?Ond=c5=99ej_Bouda?= 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