mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-22 22:37:01 +08:00
SQL/JSON: Correctly enforce the default ON EMPTY behavior
Currently, when the ON EMPTY clause is not present, the ON ERROR clause (implicit or explicit) dictates the behavior when jsonpath evaluation in ExecEvalJsonExprPath() results in an empty sequence. That is an oversight in the commit 6185c9737c. This commit fixes things so that a NULL is returned instead in that case which is the default behavior when the ON EMPTY clause is not present. Reported-by: Markus Winand Discussion: https://postgr.es/m/F7DD1442-265C-4220-A603-CB0DEB77E91D%40winand.at
This commit is contained in:
@ -118,19 +118,19 @@ FROM json_table_test vals
|
||||
|
||||
-- Test using casts in DEFAULT .. ON ERROR expression
|
||||
SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$'
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT '"foo1"'::jsonb::text ON ERROR));
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT '"foo1"'::jsonb::text ON EMPTY));
|
||||
|
||||
SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$'
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo'::jsonb_test_domain ON ERROR));
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo'::jsonb_test_domain ON EMPTY));
|
||||
|
||||
SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$'
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo1'::jsonb_test_domain ON ERROR));
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo1'::jsonb_test_domain ON EMPTY));
|
||||
|
||||
SELECT * FROM JSON_TABLE(jsonb '{"d1": "foo"}', '$'
|
||||
COLUMNS (js1 jsonb_test_domain PATH '$.d1' DEFAULT 'foo2'::jsonb_test_domain ON ERROR));
|
||||
|
||||
SELECT * FROM JSON_TABLE(jsonb '{"d1": "foo"}', '$'
|
||||
COLUMNS (js1 oid[] PATH '$.d2' DEFAULT '{1}'::int[]::oid[] ON ERROR));
|
||||
COLUMNS (js1 oid[] PATH '$.d2' DEFAULT '{1}'::int[]::oid[] ON EMPTY));
|
||||
|
||||
-- JSON_TABLE: Test backward parsing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user