pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Make SQL/JSON error code names match SQL standard
4+ messages / 3 participants
[nested] [flat]

* Make SQL/JSON error code names match SQL standard
@ 2019-08-20 08:48  Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Peter Eisentraut @ 2019-08-20 08:48 UTC (permalink / raw)
  To: pgsql-hackers

I propose the attached patch to make the new SQL/JSON error code names
match the SQL standard.  The existing minor differences don't seem
necessary.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 026299f325e7d2afbcd6c77b58e2968e88e5f700 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 20 Aug 2019 10:46:32 +0200
Subject: [PATCH] Make SQL/JSON error code names match SQL standard

---
 src/backend/utils/adt/jsonpath_exec.c | 36 +++++++++++++--------------
 src/backend/utils/errcodes.txt        | 22 ++++++++--------
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index 8ab563fded..22ec578d77 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -336,7 +336,7 @@ jsonb_path_match(PG_FUNCTION_ARGS)
 
 	if (!silent)
 		ereport(ERROR,
-				(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
+				(errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
 				 errmsg("single boolean result is expected")));
 
 	PG_RETURN_NULL();
@@ -601,7 +601,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 						return jperError;
 
 					ereport(ERROR,
-							(errcode(ERRCODE_JSON_MEMBER_NOT_FOUND), \
+							(errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND), \
 							 errmsg("JSON object does not contain key \"%s\"",
 									pnstrdup(key.val.string.val,
 											 key.val.string.len))));
@@ -613,7 +613,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 			{
 				Assert(found);
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_MEMBER_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND),
 									  errmsg("jsonpath member accessor can only be applied to an object"))));
 			}
 			break;
@@ -642,7 +642,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 				res = executeNextItem(cxt, jsp, NULL, jb, found, true);
 			else if (!jspIgnoreStructuralErrors(cxt))
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
 									  errmsg("jsonpath wildcard array accessor can only be applied to an array"))));
 			break;
 
@@ -690,7 +690,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 						 index_from > index_to ||
 						 index_to >= size))
 						RETURN_ERROR(ereport(ERROR,
-											 (errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
+											 (errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
 											  errmsg("jsonpath array subscript is out of bounds"))));
 
 					if (index_from < 0)
@@ -747,7 +747,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 			else if (!jspIgnoreStructuralErrors(cxt))
 			{
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
 									  errmsg("jsonpath array accessor can only be applied to an array"))));
 			}
 			break;
@@ -801,7 +801,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 			{
 				Assert(found);
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
 									  errmsg("jsonpath wildcard member accessor can only be applied to an object"))));
 			}
 			break;
@@ -931,7 +931,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 					{
 						if (!jspIgnoreStructuralErrors(cxt))
 							RETURN_ERROR(ereport(ERROR,
-												 (errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
+												 (errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
 												  errmsg("jsonpath item method .%s() can only be applied to an array",
 														 jspOperationName(jsp->type)))));
 						break;
@@ -985,7 +985,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 					if (have_error)
 						RETURN_ERROR(ereport(ERROR,
-											 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+											 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 											  errmsg("jsonpath item method .%s() can only be applied to a numeric value",
 													 jspOperationName(jsp->type)))));
 					res = jperOk;
@@ -1006,7 +1006,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 					if (have_error || isinf(val))
 						RETURN_ERROR(ereport(ERROR,
-											 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+											 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 											  errmsg("jsonpath item method .%s() can only be applied to a numeric value",
 													 jspOperationName(jsp->type)))));
 
@@ -1019,7 +1019,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 				if (res == jperNotFound)
 					RETURN_ERROR(ereport(ERROR,
-										 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+										 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 										  errmsg("jsonpath item method .%s() can only be applied to a string or numeric value",
 												 jspOperationName(jsp->type)))));
 
@@ -1503,14 +1503,14 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
 	if (JsonValueListLength(&lseq) != 1 ||
 		!(lval = getScalar(JsonValueListHead(&lseq), jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
+							 (errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
 							  errmsg("left operand of jsonpath operator %s is not a single numeric value",
 									 jspOperationName(jsp->type)))));
 
 	if (JsonValueListLength(&rseq) != 1 ||
 		!(rval = getScalar(JsonValueListHead(&rseq), jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
+							 (errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
 							  errmsg("right operand of jsonpath operator %s is not a single numeric value",
 									 jspOperationName(jsp->type)))));
 
@@ -1578,7 +1578,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
 				continue;		/* skip non-numerics processing */
 
 			RETURN_ERROR(ereport(ERROR,
-								 (errcode(ERRCODE_JSON_NUMBER_NOT_FOUND),
+								 (errcode(ERRCODE_SQL_JSON_NUMBER_NOT_FOUND),
 								  errmsg("operand of unary jsonpath operator %s is not a numeric value",
 										 jspOperationName(jsp->type)))));
 		}
@@ -1700,7 +1700,7 @@ executeNumericItemMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 	if (!(jb = getScalar(jb, jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+							 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 							  errmsg("jsonpath item method .%s() can only be applied to a numeric value",
 									 jspOperationName(jsp->type)))));
 
@@ -1759,7 +1759,7 @@ executeKeyValueMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 	if (JsonbType(jb) != jbvObject || jb->type != jbvBinary)
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
+							 (errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
 							  errmsg("jsonpath item method .%s() can only be applied to an object",
 									 jspOperationName(jsp->type)))));
 
@@ -2189,7 +2189,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
 	if (JsonValueListLength(&found) != 1 ||
 		!(jbv = getScalar(JsonValueListHead(&found), jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
+							 (errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
 							  errmsg("jsonpath array subscript is not a single numeric value"))));
 
 	numeric_index = DirectFunctionCall2(numeric_trunc,
@@ -2201,7 +2201,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
 
 	if (have_error)
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
+							 (errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
 							  errmsg("jsonpath array subscript is out of integer range"))));
 
 	return jperOk;
diff --git a/src/backend/utils/errcodes.txt b/src/backend/utils/errcodes.txt
index 16f5ca233a..867e98b690 100644
--- a/src/backend/utils/errcodes.txt
+++ b/src/backend/utils/errcodes.txt
@@ -208,19 +208,19 @@ Section: Class 22 - Data Exception
 2200T    E    ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION                     invalid_xml_processing_instruction
 22030    E    ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE                        duplicate_json_object_key_value
 22032    E    ERRCODE_INVALID_JSON_TEXT                                      invalid_json_text
-22033    E    ERRCODE_INVALID_JSON_SUBSCRIPT                                 invalid_json_subscript
-22034    E    ERRCODE_MORE_THAN_ONE_JSON_ITEM                                more_than_one_json_item
-22035    E    ERRCODE_NO_JSON_ITEM                                           no_json_item
-22036    E    ERRCODE_NON_NUMERIC_JSON_ITEM                                  non_numeric_json_item
-22037    E    ERRCODE_NON_UNIQUE_KEYS_IN_JSON_OBJECT                         non_unique_keys_in_json_object
-22038    E    ERRCODE_SINGLETON_JSON_ITEM_REQUIRED                           singleton_json_item_required
-22039    E    ERRCODE_JSON_ARRAY_NOT_FOUND                                   json_array_not_found
-2203A    E    ERRCODE_JSON_MEMBER_NOT_FOUND                                  json_member_not_found
-2203B    E    ERRCODE_JSON_NUMBER_NOT_FOUND                                  json_number_not_found
-2203C    E    ERRCODE_JSON_OBJECT_NOT_FOUND                                  object_not_found
-2203F    E    ERRCODE_JSON_SCALAR_REQUIRED                                   json_scalar_required
+22033    E    ERRCODE_INVALID_SQL_JSON_SUBSCRIPT                             invalid_sql_json_subscript
+22034    E    ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM                            more_than_one_sql_json_item
+22035    E    ERRCODE_NO_SQL_JSON_ITEM                                       no_sql_json_item
+22036    E    ERRCODE_NON_NUMERIC_SQL_JSON_ITEM                              non_numeric_sql_json_item
+22037    E    ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT                       non_unique_keys_in_a_json_object
+22038    E    ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED                       singleton_sql_json_item_required
+22039    E    ERRCODE_SQL_JSON_ARRAY_NOT_FOUND                               sql_json_array_not_found
+2203A    E    ERRCODE_SQL_JSON_MEMBER_NOT_FOUND                              sql_json_member_not_found
+2203B    E    ERRCODE_SQL_JSON_NUMBER_NOT_FOUND                              sql_json_number_not_found
+2203C    E    ERRCODE_SQL_JSON_OBJECT_NOT_FOUND                              sql_json_object_not_found
 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
 
 Section: Class 23 - Integrity Constraint Violation
 
-- 
2.22.0



Attachments:

  [text/plain] 0001-Make-SQL-JSON-error-code-names-match-SQL-standard.patch (10.7K, ../../86b67eef-bb26-c97d-3e35-64f1fbd4f9fe@2ndquadrant.com/2-0001-Make-SQL-JSON-error-code-names-match-SQL-standard.patch)
  download | inline diff:
From 026299f325e7d2afbcd6c77b58e2968e88e5f700 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 20 Aug 2019 10:46:32 +0200
Subject: [PATCH] Make SQL/JSON error code names match SQL standard

---
 src/backend/utils/adt/jsonpath_exec.c | 36 +++++++++++++--------------
 src/backend/utils/errcodes.txt        | 22 ++++++++--------
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index 8ab563fded..22ec578d77 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -336,7 +336,7 @@ jsonb_path_match(PG_FUNCTION_ARGS)
 
 	if (!silent)
 		ereport(ERROR,
-				(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
+				(errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
 				 errmsg("single boolean result is expected")));
 
 	PG_RETURN_NULL();
@@ -601,7 +601,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 						return jperError;
 
 					ereport(ERROR,
-							(errcode(ERRCODE_JSON_MEMBER_NOT_FOUND), \
+							(errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND), \
 							 errmsg("JSON object does not contain key \"%s\"",
 									pnstrdup(key.val.string.val,
 											 key.val.string.len))));
@@ -613,7 +613,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 			{
 				Assert(found);
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_MEMBER_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND),
 									  errmsg("jsonpath member accessor can only be applied to an object"))));
 			}
 			break;
@@ -642,7 +642,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 				res = executeNextItem(cxt, jsp, NULL, jb, found, true);
 			else if (!jspIgnoreStructuralErrors(cxt))
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
 									  errmsg("jsonpath wildcard array accessor can only be applied to an array"))));
 			break;
 
@@ -690,7 +690,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 						 index_from > index_to ||
 						 index_to >= size))
 						RETURN_ERROR(ereport(ERROR,
-											 (errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
+											 (errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
 											  errmsg("jsonpath array subscript is out of bounds"))));
 
 					if (index_from < 0)
@@ -747,7 +747,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 			else if (!jspIgnoreStructuralErrors(cxt))
 			{
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
 									  errmsg("jsonpath array accessor can only be applied to an array"))));
 			}
 			break;
@@ -801,7 +801,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 			{
 				Assert(found);
 				RETURN_ERROR(ereport(ERROR,
-									 (errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
+									 (errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
 									  errmsg("jsonpath wildcard member accessor can only be applied to an object"))));
 			}
 			break;
@@ -931,7 +931,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 					{
 						if (!jspIgnoreStructuralErrors(cxt))
 							RETURN_ERROR(ereport(ERROR,
-												 (errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
+												 (errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
 												  errmsg("jsonpath item method .%s() can only be applied to an array",
 														 jspOperationName(jsp->type)))));
 						break;
@@ -985,7 +985,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 					if (have_error)
 						RETURN_ERROR(ereport(ERROR,
-											 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+											 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 											  errmsg("jsonpath item method .%s() can only be applied to a numeric value",
 													 jspOperationName(jsp->type)))));
 					res = jperOk;
@@ -1006,7 +1006,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 					if (have_error || isinf(val))
 						RETURN_ERROR(ereport(ERROR,
-											 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+											 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 											  errmsg("jsonpath item method .%s() can only be applied to a numeric value",
 													 jspOperationName(jsp->type)))));
 
@@ -1019,7 +1019,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 				if (res == jperNotFound)
 					RETURN_ERROR(ereport(ERROR,
-										 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+										 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 										  errmsg("jsonpath item method .%s() can only be applied to a string or numeric value",
 												 jspOperationName(jsp->type)))));
 
@@ -1503,14 +1503,14 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
 	if (JsonValueListLength(&lseq) != 1 ||
 		!(lval = getScalar(JsonValueListHead(&lseq), jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
+							 (errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
 							  errmsg("left operand of jsonpath operator %s is not a single numeric value",
 									 jspOperationName(jsp->type)))));
 
 	if (JsonValueListLength(&rseq) != 1 ||
 		!(rval = getScalar(JsonValueListHead(&rseq), jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
+							 (errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
 							  errmsg("right operand of jsonpath operator %s is not a single numeric value",
 									 jspOperationName(jsp->type)))));
 
@@ -1578,7 +1578,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
 				continue;		/* skip non-numerics processing */
 
 			RETURN_ERROR(ereport(ERROR,
-								 (errcode(ERRCODE_JSON_NUMBER_NOT_FOUND),
+								 (errcode(ERRCODE_SQL_JSON_NUMBER_NOT_FOUND),
 								  errmsg("operand of unary jsonpath operator %s is not a numeric value",
 										 jspOperationName(jsp->type)))));
 		}
@@ -1700,7 +1700,7 @@ executeNumericItemMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 	if (!(jb = getScalar(jb, jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
+							 (errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
 							  errmsg("jsonpath item method .%s() can only be applied to a numeric value",
 									 jspOperationName(jsp->type)))));
 
@@ -1759,7 +1759,7 @@ executeKeyValueMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
 
 	if (JsonbType(jb) != jbvObject || jb->type != jbvBinary)
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
+							 (errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
 							  errmsg("jsonpath item method .%s() can only be applied to an object",
 									 jspOperationName(jsp->type)))));
 
@@ -2189,7 +2189,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
 	if (JsonValueListLength(&found) != 1 ||
 		!(jbv = getScalar(JsonValueListHead(&found), jbvNumeric)))
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
+							 (errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
 							  errmsg("jsonpath array subscript is not a single numeric value"))));
 
 	numeric_index = DirectFunctionCall2(numeric_trunc,
@@ -2201,7 +2201,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
 
 	if (have_error)
 		RETURN_ERROR(ereport(ERROR,
-							 (errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
+							 (errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
 							  errmsg("jsonpath array subscript is out of integer range"))));
 
 	return jperOk;
diff --git a/src/backend/utils/errcodes.txt b/src/backend/utils/errcodes.txt
index 16f5ca233a..867e98b690 100644
--- a/src/backend/utils/errcodes.txt
+++ b/src/backend/utils/errcodes.txt
@@ -208,19 +208,19 @@ Section: Class 22 - Data Exception
 2200T    E    ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION                     invalid_xml_processing_instruction
 22030    E    ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE                        duplicate_json_object_key_value
 22032    E    ERRCODE_INVALID_JSON_TEXT                                      invalid_json_text
-22033    E    ERRCODE_INVALID_JSON_SUBSCRIPT                                 invalid_json_subscript
-22034    E    ERRCODE_MORE_THAN_ONE_JSON_ITEM                                more_than_one_json_item
-22035    E    ERRCODE_NO_JSON_ITEM                                           no_json_item
-22036    E    ERRCODE_NON_NUMERIC_JSON_ITEM                                  non_numeric_json_item
-22037    E    ERRCODE_NON_UNIQUE_KEYS_IN_JSON_OBJECT                         non_unique_keys_in_json_object
-22038    E    ERRCODE_SINGLETON_JSON_ITEM_REQUIRED                           singleton_json_item_required
-22039    E    ERRCODE_JSON_ARRAY_NOT_FOUND                                   json_array_not_found
-2203A    E    ERRCODE_JSON_MEMBER_NOT_FOUND                                  json_member_not_found
-2203B    E    ERRCODE_JSON_NUMBER_NOT_FOUND                                  json_number_not_found
-2203C    E    ERRCODE_JSON_OBJECT_NOT_FOUND                                  object_not_found
-2203F    E    ERRCODE_JSON_SCALAR_REQUIRED                                   json_scalar_required
+22033    E    ERRCODE_INVALID_SQL_JSON_SUBSCRIPT                             invalid_sql_json_subscript
+22034    E    ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM                            more_than_one_sql_json_item
+22035    E    ERRCODE_NO_SQL_JSON_ITEM                                       no_sql_json_item
+22036    E    ERRCODE_NON_NUMERIC_SQL_JSON_ITEM                              non_numeric_sql_json_item
+22037    E    ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT                       non_unique_keys_in_a_json_object
+22038    E    ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED                       singleton_sql_json_item_required
+22039    E    ERRCODE_SQL_JSON_ARRAY_NOT_FOUND                               sql_json_array_not_found
+2203A    E    ERRCODE_SQL_JSON_MEMBER_NOT_FOUND                              sql_json_member_not_found
+2203B    E    ERRCODE_SQL_JSON_NUMBER_NOT_FOUND                              sql_json_number_not_found
+2203C    E    ERRCODE_SQL_JSON_OBJECT_NOT_FOUND                              sql_json_object_not_found
 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
 
 Section: Class 23 - Integrity Constraint Violation
 
-- 
2.22.0



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Make SQL/JSON error code names match SQL standard
@ 2019-08-20 10:34  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Pavel Stehule @ 2019-08-20 10:34 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: pgsql-hackers

Ășt 20. 8. 2019 v 10:49 odesĂ­latel Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> napsal:

> I propose the attached patch to make the new SQL/JSON error code names
> match the SQL standard.  The existing minor differences don't seem
> necessary.
>

+1

Pavel

>
> --
> Peter Eisentraut              http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Make SQL/JSON error code names match SQL standard
@ 2019-08-20 11:48  Alexander Korotkov <a.korotkov@postgrespro.ru>
  parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Alexander Korotkov @ 2019-08-20 11:48 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: pgsql-hackers

On Tue, Aug 20, 2019 at 11:49 AM Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> I propose the attached patch to make the new SQL/JSON error code names
> match the SQL standard.  The existing minor differences don't seem
> necessary.

Thank you for noticing!
+1 for pushing this

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Make SQL/JSON error code names match SQL standard
@ 2019-08-22 08:56  Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  parent: Alexander Korotkov <a.korotkov@postgrespro.ru>
  0 siblings, 0 replies; 4+ messages in thread

From: Peter Eisentraut @ 2019-08-22 08:56 UTC (permalink / raw)
  To: Alexander Korotkov <a.korotkov@postgrespro.ru>; +Cc: pgsql-hackers

On 2019-08-20 13:48, Alexander Korotkov wrote:
> On Tue, Aug 20, 2019 at 11:49 AM Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
>> I propose the attached patch to make the new SQL/JSON error code names
>> match the SQL standard.  The existing minor differences don't seem
>> necessary.
> 
> Thank you for noticing!
> +1 for pushing this

done

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-08-22 08:56 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 08:48 Make SQL/JSON error code names match SQL standard Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2019-08-20 10:34 ` Pavel Stehule <pavel.stehule@gmail.com>
2019-08-20 11:48 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2019-08-22 08:56   ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox