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 1rL4Xx-005xjR-SH for pgsql-bugs@arkaria.postgresql.org; Wed, 03 Jan 2024 16:56:49 +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 1rL4Xw-006erT-DY for pgsql-bugs@arkaria.postgresql.org; Wed, 03 Jan 2024 16:56:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rL4Xw-006erL-5Z for pgsql-bugs@lists.postgresql.org; Wed, 03 Jan 2024 16:56:48 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rL4Xt-00DZ1j-9f for pgsql-bugs@lists.postgresql.org; Wed, 03 Jan 2024 16:56:46 +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 403GuimU210177; Wed, 3 Jan 2024 11:56:44 -0500 From: Tom Lane To: Oscar van Baten cc: pgsql-bugs@lists.postgresql.org Subject: Re: Bugreport: incorrect result in 16.1 in query with string_agg(distinct+json_build_object In-reply-to: References: Comments: In-reply-to Oscar van Baten message dated "Wed, 03 Jan 2024 17:15:15 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <210175.1704301004.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 03 Jan 2024 11:56:44 -0500 Message-ID: <210176.1704301004@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Oscar van Baten writes: > We've upgraded one of our instances from 14.10 to 16.1 at AWS > All fine, except for a certain output which became different. > At another instance running at 14.7 we are able to reproduce this correc= t > answer. > Removing the `DISTINCT` or replacing `(SELECT a.id)` with `a.id` does so= lve > it. > It looks like a reference issue. > You can reproduce with the query below. Hi, I failed to reproduce this. I get the expected output table_value | string_agg_value | zzz_2 = = -------------+------------------+-----------------------------------------= - val_A | val_B | [{"val_1" : "val_A", "val_2" : "val_A"}] (1 row) both in HEAD and at 16.1 release (3edc6580c). It seems to me that either you have some relevant non-default planner setting, or this is an AWS-specific bug. Could we see the output of EXPLAIN (VERBOSE, SETTINGS) for this query on the troublesome system? We do have an open report of a problem with DISTINCT aggregates, https://www.postgresql.org/message-id/flat/18264-e363593d7e9feb7d%40postgr= esql.org but it's unclear whether this is the same. regards, tom lane