Commits

Andrew Dunstan committed d308c18

Fix json_agg for no rows case.

  • Participants
  • Parent commits c981732
  • Branches jsonng

Comments (0)

Files changed (1)

src/backend/utils/adt/json.c

 {
     StringInfo  state;
 
-    Assert( ! PG_ARGISNULL(0));
-
     /* cannot be called directly because of internal-type argument */
     Assert(AggCheckCallContext(fcinfo, NULL));
 
-    state = (StringInfo) PG_GETARG_POINTER(0);
+    state = PG_ARGISNULL(0) ? NULL : (StringInfo) PG_GETARG_POINTER(0);
+
+	if (state == NULL)
+		PG_RETURN_NULL();
 
 	appendStringInfoChar(state,']');