mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-07 19:47:50 +08:00
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.
This commit is contained in:
parent
c90b85e4d9
commit
3c000fd9a6
@ -2115,6 +2115,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);
|
||||
}
|
||||
}
|
||||
@ -2123,8 +2124,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;
|
||||
|
Loading…
Reference in New Issue
Block a user