mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Only allow returning string types or bytea from json_serialize
These are documented to be the allowed types for the RETURNING clause, but the restriction was not being enforced, which caused a segfault if another type was specified. Add some testing for this. Per report from a.kozhemyakin Backpatch to release 15.
This commit is contained in:
@ -60,8 +60,13 @@ SELECT JSON_SERIALIZE('{ "a" : 1 } ');
|
||||
SELECT JSON_SERIALIZE('1');
|
||||
SELECT JSON_SERIALIZE('1' FORMAT JSON);
|
||||
SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING bytea);
|
||||
SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING varchar);
|
||||
SELECT pg_typeof(JSON_SERIALIZE(NULL));
|
||||
|
||||
-- only string types or bytea allowed
|
||||
SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING jsonb);
|
||||
|
||||
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}');
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}' RETURNING bytea);
|
||||
|
||||
|
Reference in New Issue
Block a user