Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jeff(at)goaldriven(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter
Date: 2014-07-16 14:20:02
Message-ID: 25917.1405520402@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

jeff(at)goaldriven(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-07-16 14:25:59 Re: Disable View rule
Previous Message Tom Lane 2014-07-16 14:07:54 Re: Documentation problem: The syntax for "\copy" is just wrong