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: jit-before-rebase-2017-11-03~6509 X-Git-Url: http://git.postgresql.org/gitweb/static/4.16?a=commitdiff_plain;h=ecacbdbcee67e202cfcaa1180da170b9f13654bb;p=users%2Fandresfreund%2Fpostgres.git 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 19d74014ef..c52f6732b0 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -1948,7 +1948,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, " }");