From aca0c308013dbf434d54da7e68d20dd45601ac99 Mon Sep 17 00:00:00 2001 From: Amit Langote Date: Wed, 26 Jun 2024 17:46:45 +0900 Subject: [PATCH v1] SQL/JSON: Document behavior when context_item is not jsonb The input document to functions JSON_EXISTS(), JSON_QUERY(), JSON_VALUE(), and JSON_TABLE() can be specified as character or UTF8-encoded bytea strings. These are automatically converted to jsonb with an implicit cast before being passed to the jsonpath machinery. In the current implementation, errors that occur when parsing the specified string into a valid JSON document are thrown unconditionally. This means they are not subject to the explicit or implicit ON ERROR clause of those functions. This behavior is standard-conforming. Reported-by: Markus Winand Discussion: https://postgr.es/m/F7DD1442-265C-4220-A603-CB0DEB77E91D%40winand.at --- doc/src/sgml/func.sgml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 85ebd65892..532c1cc28c 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -18870,6 +18870,16 @@ DETAIL: Missing "]" after array dimensions. + + + The context_item expression is converted to + jsonb by an implicit cast if the expression is not already of + type jsonb. Note, however, that any parsing errors that occur + during that conversion are thrown unconditionally, that is, are not + handled according to the (specified or implicit) ON ERROR + clause. + + -- 2.43.0