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

Commit04f576a

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 parent39511da commit04f576a

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
@@ -336,7 +336,7 @@ jsonb_path_match(PG_FUNCTION_ARGS)
336336

337337
if (!silent)
338338
ereport(ERROR,
339-
(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
339+
(errcode(ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED),
340340
errmsg("single boolean result is expected")));
341341

342342
PG_RETURN_NULL();
@@ -601,7 +601,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
601601
returnjperError;
602602

603603
ereport(ERROR,
604-
(errcode(ERRCODE_JSON_MEMBER_NOT_FOUND), \
604+
(errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND), \
605605
errmsg("JSON object does not contain key \"%s\"",
606606
pnstrdup(key.val.string.val,
607607
key.val.string.len))));
@@ -613,7 +613,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
613613
{
614614
Assert(found);
615615
RETURN_ERROR(ereport(ERROR,
616-
(errcode(ERRCODE_JSON_MEMBER_NOT_FOUND),
616+
(errcode(ERRCODE_SQL_JSON_MEMBER_NOT_FOUND),
617617
errmsg("jsonpath member accessor can only be applied to an object"))));
618618
}
619619
break;
@@ -642,7 +642,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
642642
res=executeNextItem(cxt,jsp,NULL,jb,found, true);
643643
elseif (!jspIgnoreStructuralErrors(cxt))
644644
RETURN_ERROR(ereport(ERROR,
645-
(errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
645+
(errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
646646
errmsg("jsonpath wildcard array accessor can only be applied to an array"))));
647647
break;
648648

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

696696
if (index_from<0)
@@ -747,7 +747,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
747747
elseif (!jspIgnoreStructuralErrors(cxt))
748748
{
749749
RETURN_ERROR(ereport(ERROR,
750-
(errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
750+
(errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
751751
errmsg("jsonpath array accessor can only be applied to an array"))));
752752
}
753753
break;
@@ -801,7 +801,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
801801
{
802802
Assert(found);
803803
RETURN_ERROR(ereport(ERROR,
804-
(errcode(ERRCODE_JSON_OBJECT_NOT_FOUND),
804+
(errcode(ERRCODE_SQL_JSON_OBJECT_NOT_FOUND),
805805
errmsg("jsonpath wildcard member accessor can only be applied to an object"))));
806806
}
807807
break;
@@ -931,7 +931,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
931931
{
932932
if (!jspIgnoreStructuralErrors(cxt))
933933
RETURN_ERROR(ereport(ERROR,
934-
(errcode(ERRCODE_JSON_ARRAY_NOT_FOUND),
934+
(errcode(ERRCODE_SQL_JSON_ARRAY_NOT_FOUND),
935935
errmsg("jsonpath item method .%s() can only be applied to an array",
936936
jspOperationName(jsp->type)))));
937937
break;
@@ -985,7 +985,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
985985

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

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

@@ -1019,7 +1019,7 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
10191019

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

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

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

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

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

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

@@ -1759,7 +1759,7 @@ executeKeyValueMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
17591759

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

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

21952195
numeric_index=DirectFunctionCall2(numeric_trunc,
@@ -2201,7 +2201,7 @@ getArrayIndex(JsonPathExecContext *cxt, JsonPathItem *jsp, JsonbValue *jb,
22012201

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

22072207
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