From bda1d14360404ef58c4647888032158991051b14 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 25 Sep 2014 08:18:18 -0400 Subject: [PATCH] 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(). --- src/backend/utils/adt/json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, " }"); -- 2.40.0