aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/jsonfuncs.c')
-rw-r--r--src/backend/utils/adt/jsonfuncs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 0d3e1121cd0..1d63abc11b9 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -3658,6 +3658,12 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
if (PG_ARGISNULL(json_arg_num))
PG_RETURN_NULL();
+ /*
+ * Forcibly update the cached tupdesc, to ensure we have the right tupdesc
+ * to return even if the JSON contains no rows.
+ */
+ update_cached_tupdesc(&cache->c.io.composite, cache->fn_mcxt);
+
state = palloc0(sizeof(PopulateRecordsetState));
/* make tuplestore in a sufficiently long-lived memory context */