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

Commit3d83777

Browse files
author
Nikita Glukhov
committed
Fix json_/jsonb_ prefix in error messages
1 parent6c96b51 commit3d83777

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#defineJSON_C
16+
#defineJSONB "json"
1617

1718
#defineJSONXOIDJSONOID
1819

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ jsonb_build_object(PG_FUNCTION_ARGS)
11771177
errmsg("argument list must have even number of elements"),
11781178
/* translator: %s is a SQL function name */
11791179
errhint("The arguments of %s must consist of alternating keys and values.",
1180-
"jsonb_build_object()")));
1180+
JSONB"_build_object()")));
11811181

11821182
memset(&result,0,sizeof(JsonbInState));
11831183

@@ -1189,7 +1189,12 @@ jsonb_build_object(PG_FUNCTION_ARGS)
11891189
if (nulls[i])
11901190
ereport(ERROR,
11911191
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1192+
#ifdefJSON_C
1193+
errmsg("argument %d cannot be null",i+1),
1194+
errhint("Object keys should be text.")));
1195+
#else
11921196
errmsg("argument %d: key must not be null",i+1)));
1197+
#endif
11931198

11941199
add_jsonb(args[i], false,&result,types[i], true);
11951200

@@ -1488,7 +1493,7 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS)
14881493
if (!AggCheckCallContext(fcinfo,&aggcontext))
14891494
{
14901495
/* cannot be called directly because of internal-type argument */
1491-
elog(ERROR,"jsonb_agg_transfn called in non-aggregate context");
1496+
elog(ERROR,JSONB"_agg_transfn called in non-aggregate context");
14921497
}
14931498

14941499
/* set up the accumulator on the first go round */
@@ -1642,7 +1647,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS)
16421647
if (!AggCheckCallContext(fcinfo,&aggcontext))
16431648
{
16441649
/* cannot be called directly because of internal-type argument */
1645-
elog(ERROR,"jsonb_object_agg_transfn called in non-aggregate context");
1650+
elog(ERROR,JSONB"_object_agg_transfn called in non-aggregate context");
16461651
}
16471652

16481653
/* set up the accumulator on the first go round */

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,12 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
594594
ereport(ERROR,
595595
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
596596
errmsg("cannot call %s on a scalar",
597-
"jsonb_object_keys")));
597+
JSONB"_object_keys")));
598598
elseif (JB_ROOT_IS_ARRAY(jb))
599599
ereport(ERROR,
600600
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
601601
errmsg("cannot call %s on an array",
602-
"jsonb_object_keys")));
602+
JSONB"_object_keys")));
603603

604604
funcctx=SRF_FIRSTCALL_INIT();
605605
oldcontext=MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
@@ -1610,7 +1610,7 @@ jsonb_get_element(Jsonb *jb, Datum *path, int npath, bool *isnull, bool as_text)
16101610
/* Container must be array, but make sure */
16111611

16121612
if (!JsonContainerIsArray(container))
1613-
elog(ERROR,"not ajsonb array");
1613+
elog(ERROR,"not a"JSONB" array");
16141614

16151615
nelements=JsonContainerSize(container) >=0 ?
16161616
JsonContainerSize(container) :
@@ -1957,7 +1957,7 @@ json_each(PG_FUNCTION_ARGS)
19571957
Datum
19581958
jsonb_each(PG_FUNCTION_ARGS)
19591959
{
1960-
returneach_worker_jsonb(fcinfo,"jsonb_each", false);
1960+
returneach_worker_jsonb(fcinfo,JSONB"_each", false);
19611961
}
19621962

19631963
#ifndefJSON_GENERIC
@@ -1971,7 +1971,7 @@ json_each_text(PG_FUNCTION_ARGS)
19711971
Datum
19721972
jsonb_each_text(PG_FUNCTION_ARGS)
19731973
{
1974-
returneach_worker_jsonb(fcinfo,"jsonb_each_text", true);
1974+
returneach_worker_jsonb(fcinfo,JSONB"_each_text", true);
19751975
}
19761976

19771977
staticDatum
@@ -2024,7 +2024,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
20242024
MemoryContextSwitchTo(old_cxt);
20252025

20262026
tmp_cxt=AllocSetContextCreate(CurrentMemoryContext,
2027-
"jsonb_each temporary cxt",
2027+
JSONB"_each temporary cxt",
20282028
ALLOCSET_DEFAULT_SIZES);
20292029

20302030
it=JsonbIteratorInit(JsonbRoot(jb));
@@ -2263,13 +2263,13 @@ each_scalar(void *state, char *token, JsonTokenType tokentype)
22632263
Datum
22642264
jsonb_array_elements(PG_FUNCTION_ARGS)
22652265
{
2266-
returnelements_worker_jsonb(fcinfo,"jsonb_array_elements", false);
2266+
returnelements_worker_jsonb(fcinfo,JSONB"_array_elements", false);
22672267
}
22682268

22692269
Datum
22702270
jsonb_array_elements_text(PG_FUNCTION_ARGS)
22712271
{
2272-
returnelements_worker_jsonb(fcinfo,"jsonb_array_elements_text", true);
2272+
returnelements_worker_jsonb(fcinfo,JSONB"_array_elements_text", true);
22732273
}
22742274

22752275
staticDatum
@@ -2323,7 +2323,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
23232323
MemoryContextSwitchTo(old_cxt);
23242324

23252325
tmp_cxt=AllocSetContextCreate(CurrentMemoryContext,
2326-
"jsonb_array_elements temporary cxt",
2326+
JSONB"_array_elements temporary cxt",
23272327
ALLOCSET_DEFAULT_SIZES);
23282328

23292329
it=JsonbIteratorInit(JsonbRoot(jb));
@@ -2567,14 +2567,14 @@ elements_scalar(void *state, char *token, JsonTokenType tokentype)
25672567
Datum
25682568
jsonb_populate_record(PG_FUNCTION_ARGS)
25692569
{
2570-
returnpopulate_record_worker(fcinfo,"jsonb_populate_record",
2570+
returnpopulate_record_worker(fcinfo,JSONB"_populate_record",
25712571
JSONXOID==JSONOID, true);
25722572
}
25732573

25742574
Datum
25752575
jsonb_to_record(PG_FUNCTION_ARGS)
25762576
{
2577-
returnpopulate_record_worker(fcinfo,"jsonb_to_record",
2577+
returnpopulate_record_worker(fcinfo,JSONB"_to_record",
25782578
JSONXOID==JSONOID, false);
25792579
}
25802580

@@ -3814,14 +3814,14 @@ hash_scalar(void *state, char *token, JsonTokenType tokentype)
38143814
Datum
38153815
jsonb_populate_recordset(PG_FUNCTION_ARGS)
38163816
{
3817-
returnpopulate_recordset_worker(fcinfo,"jsonb_populate_recordset",
3817+
returnpopulate_recordset_worker(fcinfo,JSONB"_populate_recordset",
38183818
false, true);
38193819
}
38203820

38213821
Datum
38223822
jsonb_to_recordset(PG_FUNCTION_ARGS)
38233823
{
3824-
returnpopulate_recordset_worker(fcinfo,"jsonb_to_recordset",
3824+
returnpopulate_recordset_worker(fcinfo,JSONB"_to_recordset",
38253825
false, false);
38263826
}
38273827

@@ -5134,7 +5134,7 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
51345134
ereport(ERROR,
51355135
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
51365136
errmsg("cannot replace existing key"),
5137-
errhint("Try using the functionjsonb_set "
5137+
errhint("Try using the function"JSONB"_set "
51385138
"to replace key value.")));
51395139

51405140
r=JsonbIteratorNext(it,&v, true);/* skip value */

‎src/include/utils/jsonb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include"utils/array.h"
1717
#include"utils/numeric.h"
1818

19+
#ifndefJSONB
20+
#defineJSONB "jsonb"
21+
#endif
22+
1923
/* Tokens used when sequentially processing a jsonb value */
2024
typedefenum
2125
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp