From: jeff@goaldriven.com
To: pgsql-bugs@postgresql.org
Subject: BUG #10972: string_agg function incorrectly concatenating varying delimiter
Date: Wed, 16 Jul 2014 00:16:32 +0000
Message-ID: <20140716001632.2502.98836@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 10972
Logged by: Jeff Fischer
Email address: jeff@goaldriven.com
PostgreSQL version: 9.3.1
Operating system: CentOS
Description:
Running the query below will show how the delimiter for the current row is
actually the subsequent rows delimiter. The sequence goes like this:
TestBlah 1
ITTest 2
testfail 3
Yet, the concatened output is this:
"testblah 2 ITtest 3 testfail"
You can see that the delimiter for the current row is actually getting the
subsequent rows delimiter. It's as though the string concat moves to the
next row prior to concatenting the delimiter, which is likely the cause of
this bug.
SELECT
string_agg(
Field1,
' ' || RowIndex::text || ' '
ORDER BY RowIndex) as VeryLongConcatenatedResultsFieldName
FROM (
SELECT
'testblah' as Field1,
1 as RowIndex
UNION
SELECT
'ITtest' as Field1,
2 as RowIndex
UNION
SELECT
'testfail' as Field1,
3 as RowIndex
) t;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: jeff@goaldriven.com
Subject: Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter
In-Reply-To: <20140716001632.2502.98836@wrigleys.postgresql.org>
References: <20140716001632.2502.98836@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox