Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter
Date
Msg-id 25917.1405520402@sss.pgh.pa.us
Whole thread Raw
In response to BUG #10972: string_agg function incorrectly concatenating varying delimiter  (jeff@goaldriven.com)
Responses Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter  (Jeff Fischer <jeff@goaldriven.com>)
List pgsql-bugs
jeff@goaldriven.com writes:
> Running the query below will show how the delimiter for the current row is
> actually the subsequent rows delimiter.

Hmm, well, the documentation for string_agg doesn't say what happens when
the "delimiter" argument varies across rows; but a quick look at the code
finds that the first-call delimiter isn't actually used at all, and on
subsequent calls the delimiter is appended to the running result before
the associated value is.  Which seems to me to be at least as reasonable,
and certainly a great deal easier to implement, as what you seem to have
in mind.  Can you offer a principled argument why it should be the other
way around?

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Documentation problem: The syntax for "\copy" is just wrong
Next
From: Tom Lane
Date:
Subject: Re: Disable View rule