From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | andrew(dot)wheelwright(at)familysearch(dot)org |
Subject: | BUG #16107: string_agg looses first item |
Date: | 2019-11-11 22:34:28 |
Message-ID: | 16107-f46d9b66440d7f45@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 16107
Logged by: Andrew Wheelwright
Email address: andrew(dot)wheelwright(at)familysearch(dot)org
PostgreSQL version: 11.5
Operating system: Linux
Description:
I ran into a scenario where I found results getting dropped from string
aggregation. Here's a basic example which reproduces the problem on three
different servers running PostgreSQL 9.6.6, 10.6, and 11.5, respectively. I
don't have an instance running version 12.
with dataset as (
select 'One' "Label", 1 "ID"
union
select 'Two' "Label", 2 "ID"
union
select 'Three' "Label", 3 "ID"
)
select
string_agg(', ', "Label" order by "ID") "String Aggregated Labels",
array_agg("Label" order by "ID") "Array Aggregated Labels"
from
dataset
;
Which renders the following result:
String Aggregated Labels: `, Two, Three, `
Array Aggregated Labels: `{One,Two,Three}`
The value "One" is missing from the string aggregate result and there is a
dangling separator on both ends of the string.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-11-11 22:47:39 | Re: BUG #16107: string_agg looses first item |
Previous Message | Thomas Munro | 2019-11-11 21:46:43 | Re: BUG #16104: Invalid DSA Memory Alloc Request in Parallel Hash |