Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1S23-00GN7k-1P for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Oct 2024 15:03:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t1S21-0061Sc-8j for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Oct 2024 15:03:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1S21-0061Ru-03 for pgsql-bugs@lists.postgresql.org; Thu, 17 Oct 2024 15:03:17 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1S1y-001YnH-Cc for pgsql-bugs@lists.postgresql.org; Thu, 17 Oct 2024 15:03:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 49HF3Di1657103; Thu, 17 Oct 2024 11:03:13 -0400 From: Tom Lane To: sander.evers@topicus.nl cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18662: ORDER BY after GROUPING SETS does not order correctly for certain WHERE condition In-reply-to: <18662-515b2a51728c237c@postgresql.org> References: <18662-515b2a51728c237c@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 17 Oct 2024 12:56:39 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <657101.1729177393.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Oct 2024 11:03:13 -0400 Message-ID: <657102.1729177393@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > I'm seeing inconsistent results for an ORDER BY in combination with GROU= PING > SETS. Yup. Your example actually works correctly as of HEAD (v18-to-be): regression=3D# select * from (values (1, 1), (1, 2), (2,1), (2,2)) as t (a= ,b) where a=3D1 = group by grouping sets ((b),(a,b)) order by a, b; a | b = ---+--- 1 | 1 1 | 2 | 1 | 2 (4 rows) but I'm afraid there's zero chance of back-patching the fix, as it's far too invasive (and under-tested, for now) for that. > This might be the same bug as > https://www.postgresql.org/message-id/CAL48EtKDHCKnOkLdSgOmgBZBcahU2zpBq= yzeET_ZM74uNZBFHg@mail.gmail.com Indeed. Richard Guo recently completed the fix I alluded to in that thread: https://git.postgresql.org/gitweb/?p=3Dpostgresql.git&a=3Dcommitdiff&h=3D2= 47dea89f https://git.postgresql.org/gitweb/?p=3Dpostgresql.git&a=3Dcommitdiff&h=3Df= 5050f795 regards, tom lane