From: Andrew Dunstan Date: Thu, 25 Sep 2014 12:18:18 +0000 (-0400) Subject: Return NULL from json_object_agg if it gets no rows. X-Git-Tag: REL9_4_BETA3~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bda1d14360404ef58c4647888032158991051b14;p=postgresql Return NULL from json_object_agg if it gets no rows. This makes it consistent with the docs and with all other builtin aggregates apart from count(). --- diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index 494a028526..1820029fe9 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -1973,7 +1973,7 @@ json_object_agg_finalfn(PG_FUNCTION_ARGS) state = PG_ARGISNULL(0) ? NULL : (StringInfo) PG_GETARG_POINTER(0); if (state == NULL) - PG_RETURN_TEXT_P(cstring_to_text("{}")); + PG_RETURN_NULL(); appendStringInfoString(state, " }");