SQL/JSON: Validate values in ON ERROR/EMPTY clauses
authorAmit Langote <[email protected]>
Fri, 28 Jun 2024 04:59:57 +0000 (13:59 +0900)
committerAmit Langote <[email protected]>
Fri, 28 Jun 2024 05:01:43 +0000 (14:01 +0900)
commit55e56c84da99fe7becda2194563f48bb3083c2d1
tree6084cedc60bb73dcbb8e3fedbb9bb0cc81e84eab
parente3c1393efc31ac70de7b68e9a283ec3f2d7f9bd2
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 <[email protected]>
Reviewed-by: Jian He <[email protected]>
Discussion: https://postgr.es/m/CACJufxFgWGqpESSYzyJ6tSurr3vFYBSNEmCfkGyB_dMdptFnZQ%40mail.gmail.com
doc/src/sgml/func.sgml
src/backend/parser/parse_expr.c
src/backend/parser/parse_jsontable.c
src/test/regress/expected/sqljson_jsontable.out
src/test/regress/expected/sqljson_queryfuncs.out
src/test/regress/sql/sqljson_jsontable.sql
src/test/regress/sql/sqljson_queryfuncs.sql