Re: json_populate_record issue - TupleDesc reference leak
От | Pavel Stehule |
---|---|
Тема | Re: json_populate_record issue - TupleDesc reference leak |
Дата | |
Msg-id | CAFj8pRBs3kvUbLh4XVF5ZXnLnGZL5yQU5VmWfccqTG=e3zy9LA@mail.gmail.com обсуждение исходный текст |
Ответ на | json_populate_record issue - TupleDesc reference leak (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: json_populate_record issue - TupleDesc reference leak
|
Список | pgsql-hackers |
by the way - this feature is undocumented - I though so only value used as type holder is not used.
Should be documented better, - if I understand - it is base stone for implementation #= hstore operator
some nice example
postgres=# select json_populate_record('(10,20)'::pt, '{"a":30}');
json_populate_record
----------------------
(30,20)
(1 row)
postgres=# select json_populate_record('(10,20)'::pt, '{"a":30}');
json_populate_record
----------------------
(30,20)
(1 row)
a mentioned bug is corner case - bugfix is simple
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
new file mode 100644
index a8cdeaa..6e83f78
*** a/src/backend/utils/adt/jsonfuncs.c
--- b/src/backend/utils/adt/jsonfuncs.c
*************** populate_record_worker(FunctionCallInfo
*** 2114,2119 ****
--- 2114,2122 ----
*/
if (hash_get_num_entries(json_hash) == 0 && rec)
{
+ if (have_record_arg)
+ ReleaseTupleDesc(tupdesc);
+
hash_destroy(json_hash);
PG_RETURN_POINTER(rec);
}
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
new file mode 100644
index a8cdeaa..6e83f78
*** a/src/backend/utils/adt/jsonfuncs.c
--- b/src/backend/utils/adt/jsonfuncs.c
*************** populate_record_worker(FunctionCallInfo
*** 2114,2119 ****
--- 2114,2122 ----
*/
if (hash_get_num_entries(json_hash) == 0 && rec)
{
+ if (have_record_arg)
+ ReleaseTupleDesc(tupdesc);
+
hash_destroy(json_hash);
PG_RETURN_POINTER(rec);
}
2015-02-23 18:27 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
PavelRegardsjsonb is okHiWhen I tested json_populate_function in test http://stackoverflow.com/questions/7711432/how-to-set-value-of-composite-variable-field-using-dynamic-sql/28673097#28673097 I found a small issue
create type pt as (a int, b int);
postgres=# select json_populate_record('(10,20)'::pt, '{}');
WARNING: TupleDesc reference leak: TupleDesc 0x7f10fcf41400 (567018,-1) still referenced
json_populate_record
----------------------
(10,20)
(1 row)
postgres=# select jsonb_populate_record('(10,20)'::pt, '{}');
jsonb_populate_record
-----------------------
(10,20)
(1 row)
В списке pgsql-hackers по дате отправления: