aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonfuncs.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2015-05-04 12:38:58 -0400
committerAndrew Dunstan <andrew@dunslane.net>2015-05-04 12:43:16 -0400
commit997066f4456c0fc582e62a50e296c77360212049 (patch)
tree3fc90199ece7688f38e92008d81a529b4ecbe5f8 /src/backend/utils/adt/jsonfuncs.c
parent79edb298128b00161944b0e2cb6ef2460b717a7a (diff)
downloadpostgresql-997066f4456c0fc582e62a50e296c77360212049.tar.gz
postgresql-997066f4456c0fc582e62a50e296c77360212049.zip
Fix two small bugs in json's populate_record_worker
The first bug is not releasing a tupdesc when doing an early return out of the function. The second bug is a logic error in choosing when to do an early return if given an empty jsonb object. Bug reports from Pavel Stehule and Tom Lane respectively. Backpatch to 9.4 where these were introduced.
Diffstat (limited to 'src/backend/utils/adt/jsonfuncs.c')
-rw-r--r--src/backend/utils/adt/jsonfuncs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 076b00f213c..1a9a060d4eb 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -2099,6 +2099,7 @@ populate_record_worker(FunctionCallInfo fcinfo, const char *funcname,
if (hash_get_num_entries(json_hash) == 0 && rec)
{
hash_destroy(json_hash);
+ ReleaseTupleDesc(tupdesc);
PG_RETURN_POINTER(rec);
}
}
@@ -2107,8 +2108,11 @@ populate_record_worker(FunctionCallInfo fcinfo, const char *funcname,
jb = PG_GETARG_JSONB(json_arg_num);
/* same logic as for json */
- if (!have_record_arg && rec)
+ if (JB_ROOT_COUNT(jb) == 0 && rec)
+ {
+ ReleaseTupleDesc(tupdesc);
PG_RETURN_POINTER(rec);
+ }
}
ncolumns = tupdesc->natts;