Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita00c53b

Browse files
committed
Make SQL/JSON error code names match SQL standard
There were some minor differences that didn't seem necessary.Discussion:https://www.postgresql.org/message-id/flat/86b67eef-bb26-c97d-3e35-64f1fbd4f9fe%402ndquadrant.com
1 parent3709376 commita00c53b

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

‎src/backend/utils/adt/jsonpath_exec.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ jsonb_path_match(PG_FUNCTION_ARGS)
337337

338338
if (!silent)
339339
ereport(ERROR,
340-
(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
340+
(errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
341341
errmsg("single boolean result is expected")));
342342

343343
PG_RETURN_NULL();
@@ -602,7 +602,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
602602
returnjperError;
603603

604604
ereport(ERROR,
605-
(errcode(ERRCODE_JSON_MEMBER_NOT_FOUND), \
605+
(errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND), \
606606
errmsg("JSON object does not contain key \"%s\"",
607607
pnstrdup(key.val.string.val,
608608
key.val.string.len))));
@@ -614,7 +614,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
614614
{
615615
Assert(found);
616616
RETURN_ERROR(ereport(ERROR,
617-
(errcode(ERRCODE_JSON_MEMBER_NOT_FOUND),
617+
(errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND),
618618
errmsg("jsonpath member accessor can only be applied to an object"))));
619619
}
620620
break;
@@ -643,7 +643,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
643643
res=executeNextItem(cxt,jsp,NULL,jb,found, true);
644644
elseif (!jspIgnoreStructuralErrors(cxt))
645645
RETURN_ERROR(ereport(ERROR,
646-
(errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
646+
(errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
647647
errmsg("jsonpath wildcard array accessor can only be applied to an array"))));
648648
break;
649649

@@ -691,7 +691,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
691691
index_from>index_to||
692692
index_to >=size))
693693
RETURN_ERROR(ereport(ERROR,
694-
(errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
694+
(errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
695695
errmsg("jsonpath array subscript is out of bounds"))));
696696

697697
if (index_from<0)
@@ -748,7 +748,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
748748
elseif (!jspIgnoreStructuralErrors(cxt))
749749
{
750750
RETURN_ERROR(ereport(ERROR,
751-
(errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
751+
(errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
752752
errmsg("jsonpath array accessor can only be applied to an array"))));
753753
}
754754
break;
@@ -802,7 +802,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
802802
{
803803
Assert(found);
804804
RETURN_ERROR(ereport(ERROR,
805-
(errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
805+
(errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
806806
errmsg("jsonpath wildcard member accessor can only be applied to an object"))));
807807
}
808808
break;
@@ -932,7 +932,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
932932
{
933933
if (!jspIgnoreStructuralErrors(cxt))
934934
RETURN_ERROR(ereport(ERROR,
935-
(errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
935+
(errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
936936
errmsg("jsonpath item method .%s() can only be applied to an array",
937937
jspOperationName(jsp->type)))));
938938
break;
@@ -986,7 +986,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
986986

987987
if (have_error)
988988
RETURN_ERROR(ereport(ERROR,
989-
(errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
989+
(errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
990990
errmsg("jsonpath item method .%s() can only be applied to a numeric value",
991991
jspOperationName(jsp->type)))));
992992
res=jperOk;
@@ -1007,7 +1007,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
10071007

10081008
if (have_error||isinf(val))
10091009
RETURN_ERROR(ereport(ERROR,
1010-
(errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
1010+
(errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
10111011
errmsg("jsonpath item method .%s() can only be applied to a numeric value",
10121012
jspOperationName(jsp->type)))));
10131013

@@ -1020,7 +1020,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
10201020

10211021
if (res==jperNotFound)
10221022
RETURN_ERROR(ereport(ERROR,
1023-
(errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
1023+
(errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
10241024
errmsg("jsonpath item method .%s() can only be applied to a string or numeric value",
10251025
jspOperationName(jsp->type)))));
10261026

@@ -1504,14 +1504,14 @@ executeBinaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
15041504
if (JsonValueListLength(&lseq)!=1||
15051505
!(lval=getScalar(JsonValueListHead(&lseq),jbvNumeric)))
15061506
RETURN_ERROR(ereport(ERROR,
1507-
(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
1507+
(errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
15081508
errmsg("left operand of jsonpath operator %s is not a single numeric value",
15091509
jspOperationName(jsp->type)))));
15101510

15111511
if (JsonValueListLength(&rseq)!=1||
15121512
!(rval=getScalar(JsonValueListHead(&rseq),jbvNumeric)))
15131513
RETURN_ERROR(ereport(ERROR,
1514-
(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
1514+
(errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
15151515
errmsg("right operand of jsonpath operator %s is not a single numeric value",
15161516
jspOperationName(jsp->type)))));
15171517

@@ -1579,7 +1579,7 @@ executeUnaryArithmExpr(JsonPathExecContext *cxt, JsonPathItem *jsp,
15791579
continue;/* skip non-numerics processing */
15801580

15811581
RETURN_ERROR(ereport(ERROR,
1582-
(errcode(ERRCODE_JSON_NUMBER_NOT_FOUND),
1582+
(errcode(ERRCODE_SQL_JSON_NUMBER_NOT_FOUND),
15831583
errmsg("operand of unary jsonpath operator %s is not a numeric value",
15841584
jspOperationName(jsp->type)))));
15851585
}
@@ -1701,7 +1701,7 @@ executeNumericItemMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
17011701

17021702
if (!(jb=getScalar(jb,jbvNumeric)))
17031703
RETURN_ERROR(ereport(ERROR,
1704-
(errcode(ERRCODE_NON_NUMERIC_JSON_ITEM),
1704+
(errcode(ERRCODE_NON_NUMERIC_SQL_JSON_ITEM),
17051705
errmsg("jsonpath item method .%s() can only be applied to a numeric value",
17061706
jspOperationName(jsp->type)))));
17071707

@@ -1760,7 +1760,7 @@ executeKeyValueMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
17601760

17611761
if (JsonbType(jb)!=jbvObject||jb->type!=jbvBinary)
17621762
RETURN_ERROR(ereport(ERROR,
1763-
(errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
1763+
(errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
17641764
errmsg("jsonpath item method .%s() can only be applied to an object",
17651765
jspOperationName(jsp->type)))));
17661766

@@ -2190,7 +2190,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
21902190
if (JsonValueListLength(&found)!=1||
21912191
!(jbv=getScalar(JsonValueListHead(&found),jbvNumeric)))
21922192
RETURN_ERROR(ereport(ERROR,
2193-
(errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
2193+
(errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
21942194
errmsg("jsonpath array subscript is not a single numeric value"))));
21952195

21962196
numeric_index=DirectFunctionCall2(numeric_trunc,
@@ -2202,7 +2202,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
22022202

22032203
if (have_error)
22042204
RETURN_ERROR(ereport(ERROR,
2205-
(errcode(ERRCODE_INVALID_JSON_SUBSCRIPT),
2205+
(errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
22062206
errmsg("jsonpath array subscript is out of integer range"))));
22072207

22082208
returnjperOk;

‎src/backend/utils/errcodes.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,19 @@ Section: Class 22 - Data Exception
208208
2200T E ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION invalid_xml_processing_instruction
209209
22030 E ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE duplicate_json_object_key_value
210210
22032 E ERRCODE_INVALID_JSON_TEXT invalid_json_text
211-
22033 E ERRCODE_INVALID_JSON_SUBSCRIPT invalid_json_subscript
212-
22034 E ERRCODE_MORE_THAN_ONE_JSON_ITEM more_than_one_json_item
213-
22035 E ERRCODE_NO_JSON_ITEM no_json_item
214-
22036 E ERRCODE_NON_NUMERIC_JSON_ITEM non_numeric_json_item
215-
22037 E ERRCODE_NON_UNIQUE_KEYS_IN_JSON_OBJECT non_unique_keys_in_json_object
216-
22038 E ERRCODE_SINGLETON_JSON_ITEM_REQUIRED singleton_json_item_required
217-
22039 E ERRCODE_JSON_ARRAY_NOT_FOUND json_array_not_found
218-
2203A E ERRCODE_JSON_MEMBER_NOT_FOUND json_member_not_found
219-
2203B E ERRCODE_JSON_NUMBER_NOT_FOUND json_number_not_found
220-
2203C E ERRCODE_JSON_OBJECT_NOT_FOUND object_not_found
221-
2203F E ERRCODE_JSON_SCALAR_REQUIRED json_scalar_required
211+
22033 E ERRCODE_INVALID_SQL_JSON_SUBSCRIPT invalid_sql_json_subscript
212+
22034 E ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM more_than_one_sql_json_item
213+
22035 E ERRCODE_NO_SQL_JSON_ITEM no_sql_json_item
214+
22036 E ERRCODE_NON_NUMERIC_SQL_JSON_ITEM non_numeric_sql_json_item
215+
22037 E ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT non_unique_keys_in_a_json_object
216+
22038 E ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED singleton_sql_json_item_required
217+
22039 E ERRCODE_SQL_JSON_ARRAY_NOT_FOUND sql_json_array_not_found
218+
2203A E ERRCODE_SQL_JSON_MEMBER_NOT_FOUND sql_json_member_not_found
219+
2203B E ERRCODE_SQL_JSON_NUMBER_NOT_FOUND sql_json_number_not_found
220+
2203C E ERRCODE_SQL_JSON_OBJECT_NOT_FOUND sql_json_object_not_found
222221
2203D E ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS too_many_json_array_elements
223222
2203E E ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS too_many_json_object_members
223+
2203F E ERRCODE_SQL_JSON_SCALAR_REQUIRED sql_json_scalar_required
224224

225225
Section: Class 23 - Integrity Constraint Violation
226226

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp