mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-20 13:27:00 +08:00
SQL/JSON: Validate values in ON ERROR/EMPTY clauses
Currently, the grammar allows any supported values in the ON ERROR and ON EMPTY clauses for SQL/JSON functions, regardless of whether the values are appropriate for the function. This commit ensures that during parse analysis, the provided value is checked for validity for the given function and throws a syntax error if it is not. While at it, this fixes some omissions in the documentation of the ON ERROR/EMPTY clauses for JSON_TABLE(). Reported-by: Jian He <jian.universality@gmail.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/CACJufxFgWGqpESSYzyJ6tSurr3vFYBSNEmCfkGyB_dMdptFnZQ%40mail.gmail.com
This commit is contained in:
@ -521,3 +521,10 @@ DROP TABLE s;
|
||||
|
||||
-- Prevent ON EMPTY specification on EXISTS columns
|
||||
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty));
|
||||
|
||||
-- Test ON ERROR / EMPTY value validity for the function and column types;
|
||||
-- all fail
|
||||
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int) NULL ON ERROR);
|
||||
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int true on empty));
|
||||
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int omit quotes true on error));
|
||||
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on error));
|
||||
|
||||
Reference in New Issue
Block a user