From 473a352fb393519f22cd4d31839ad3d74b1aeea1 Mon Sep 17 00:00:00 2001 From: Amit Langote Date: Fri, 28 Jun 2024 09:42:13 +0900 Subject: [PATCH] SQL/JSON: Document behavior when input document 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, which is a standard- conforming behavior. Add a note to the documentation to mention that. 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 2609269610b..323098a2377 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -18861,6 +18861,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.47.2