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

From Tom Lane
Subject pgsql: Fix JSON aggregates to work properly when final function is re-e
Date
Msg-id E1Xvtex-0007DA-TJ@gemulon.postgresql.org
Whole thread Raw
List 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
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/75ef435218fe4f6ce29d33e10f6f7a328c93f7e7

Modified Files
--------------
src/backend/utils/adt/json.c |   45 +++++++++++++++++++++++++++++++-----------
1 file changed, 34 insertions(+), 11 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix JSON aggregates to work properly when final function is re-e
Next
From: Alvaro Herrera
Date:
Subject: Re: pgsql: Move security_label test