From 55e56c84da99fe7becda2194563f48bb3083c2d1 Mon Sep 17 00:00:00 2001 From: Amit Langote Date: Fri, 28 Jun 2024 13:59:57 +0900 Subject: 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 Reviewed-by: Jian He Discussion: https://postgr.es/m/CACJufxFgWGqpESSYzyJ6tSurr3vFYBSNEmCfkGyB_dMdptFnZQ%40mail.gmail.com --- src/backend/parser/parse_jsontable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/parser/parse_jsontable.c') diff --git a/src/backend/parser/parse_jsontable.c b/src/backend/parser/parse_jsontable.c index b2519c2f329..8a72e498e89 100644 --- a/src/backend/parser/parse_jsontable.c +++ b/src/backend/parser/parse_jsontable.c @@ -92,7 +92,7 @@ transformJsonTable(ParseState *pstate, JsonTable *jt) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid ON ERROR behavior"), - errdetail("Only EMPTY or ERROR is allowed in the top-level ON ERROR clause."), + errdetail("Only EMPTY [ ARRAY ] or ERROR is allowed in the top-level ON ERROR clause."), parser_errposition(pstate, jt->on_error->location)); cxt.pathNameId = 0; -- cgit v1.2.3