Re: Bugreport: incorrect result in 16.1 in query with string_agg(distinct+json_build_object

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oscar van Baten <info(at)oxcro(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Re: Bugreport: incorrect result in 16.1 in query with string_agg(distinct+json_build_object
Date: 2024-01-03 18:20:27
Message-ID: 230221.1704306027@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Oscar van Baten <info(at)oxcro(dot)com> writes:
> There you go:

> GroupAggregate (cost=94.38..128.98 rows=200 width=96)
> Output: a.id, string_agg(DISTINCT 'val_B'::text, ', '::text),
> (json_agg(json_build_object('val_1', a.id, 'val_2', (SubPlan 1))))::text|

Ah, that gave me the clue I needed (maybe I should have deduced it
from your Subject, but I plead ENOCAFFEINE). Your query as submitted
doesn't use DISTINCT in the STRING_AGG call, but that's needed to
trigger the bug. And it is indeed the same bug as #18264: it begins
at the same commit, and David's WIP patch fixes it.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-01-03 19:46:43 BUG #18269: RPM key descrepency
Previous Message Oscar van Baten 2024-01-03 18:19:36 Re: Bugreport: incorrect result in 16.1 in query with string_agg(distinct+json_build_object