pgsql: Fix JSON aggregates to work properly when final function is re-e

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix JSON aggregates to work properly when final function is re-e
Date: 2014-12-02 20:02:55
Message-ID: E1Xvtex-0007DD-TU@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix JSON aggregates to work properly when final function is re-executed.

Davide S. reported that json_agg() sometimes produced multiple trailing
right brackets. This turns out to be because json_agg_finalfn() attaches
the final right bracket, and was doing so by modifying the aggregate state
in-place. That's verboten, though unfortunately it seems there's no way
for nodeAgg.c to check for such mistakes.

Fix that back to 9.3 where the broken code was introduced. In 9.4 and
HEAD, likewise fix json_object_agg(), which had copied the erroneous logic.
Make some cosmetic cleanups as well.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/8571ecb24f57a3aefc412eaf775423f9e456e47f

Modified Files
--------------
src/backend/utils/adt/json.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2014-12-02 20:46:01 Re: pgsql: Move security_label test
Previous Message Tom Lane 2014-12-02 19:08:00 pgsql: Minor cleanup of function declarations for BRIN.