mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
RETURNING clause for JSON() and JSON_SCALAR()
This patch is extracted from a larger patch that allowed setting the default returned value from these functions to json or jsonb. That had problems, but this piece of it is fine. For these functions only json or jsonb can be specified in the RETURNING clause. Extracted from an original patch from Nikita Glukhov Reviewers have included (in no particular order) Andres Freund, Alexander Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers, Zihong Yu, Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby. Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
This commit is contained in:
@ -23,6 +23,14 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON ENCODING UTF8)
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITH UNIQUE KEYS);
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITHOUT UNIQUE KEYS);
|
||||
|
||||
SELECT JSON('123' RETURNING text);
|
||||
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123');
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' RETURNING json);
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' RETURNING jsonb);
|
||||
SELECT pg_typeof(JSON('123'));
|
||||
SELECT pg_typeof(JSON('123' RETURNING json));
|
||||
SELECT pg_typeof(JSON('123' RETURNING jsonb));
|
||||
|
||||
-- JSON_SCALAR()
|
||||
SELECT JSON_SCALAR();
|
||||
@ -41,6 +49,8 @@ SELECT JSON_SCALAR('{}'::jsonb);
|
||||
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR(123);
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR('123');
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR(123 RETURNING json);
|
||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR(123 RETURNING jsonb);
|
||||
|
||||
-- JSON_SERIALIZE()
|
||||
SELECT JSON_SERIALIZE();
|
||||
|
Reference in New Issue
Block a user