postgres.git / summary / log / commit / refs
commit 976b06c6630cbf09bf933a006b5e662753e7c0be
Author: Peter Eisentraut <peter@eisentraut.org>
Date: Mon Jul 18 12:26:43 2022 +0000
First released in: 16.0, 15.0
Add another SQL/JSON error code
A code comment said that the standard does not define a number for
ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE, but this was
fixed in a later draft version of the standard, so use that number
now.
src/backend/executor/execExprInterp.c | 8 +-------
src/backend/utils/errcodes.txt | 1 +
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 9fcb6be414d..723770fda0e 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -4980,13 +4980,7 @@ ExecEvalJsonExpr(ExprEvalStep *op, ExprContext *econtext,
* type simply does not exist.
*/
ereport(ERROR,
-
- /*
- * XXX Standard says about a separate error code
- * ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE but
- * does not define its number.
- */
- (errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
+ (errcode(ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE),
errmsg("SQL/JSON item cannot be cast to target type")));
}
else if (!jcstate->estate)
diff --git a/src/backend/utils/errcodes.txt b/src/backend/utils/errcodes.txt
index a4e1a466441..62418a051ac 100644
--- a/src/backend/utils/errcodes.txt
+++ b/src/backend/utils/errcodes.txt
@@ -222,6 +222,7 @@ Section: Class 22 - Data Exception
2203D E ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS too_many_json_array_elements
2203E E ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS too_many_json_object_members
2203F E ERRCODE_SQL_JSON_SCALAR_REQUIRED sql_json_scalar_required
+2203G E ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE sql_json_item_cannot_be_cast_to_target_type
Section: Class 23 - Integrity Constraint Violation
[parent: f58d7073b775]