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

Commitf83c886

Browse files
author
Nikita Glukhov
committed
Fix json_/jsonb_ prefix in error messages
1 parenta6cb870 commitf83c886

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
#definejsonb_in_json_in
1819
#definejsonb_recv_json_recv

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,12 @@ jsonb_build_object(PG_FUNCTION_ARGS)
11721172
if (PG_ARGISNULL(i))
11731173
ereport(ERROR,
11741174
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1175+
#ifdefJSON_C
1176+
errmsg("argument %d cannot be null",i+1),
1177+
errhint("Object keys should be text.")));
1178+
#else
11751179
errmsg("argument %d: key must not be null",i+1)));
1180+
#endif
11761181
val_type=get_fn_expr_argtype(fcinfo->flinfo,i);
11771182

11781183
/*
@@ -1522,7 +1527,7 @@ jsonb_agg_transfn(PG_FUNCTION_ARGS)
15221527
if (!AggCheckCallContext(fcinfo,&aggcontext))
15231528
{
15241529
/* cannot be called directly because of internal-type argument */
1525-
elog(ERROR,"jsonb_agg_transfn called in non-aggregate context");
1530+
elog(ERROR,JSONB"_agg_transfn called in non-aggregate context");
15261531
}
15271532

15281533
/* set up the accumulator on the first go round */
@@ -1676,7 +1681,7 @@ jsonb_object_agg_transfn(PG_FUNCTION_ARGS)
16761681
if (!AggCheckCallContext(fcinfo,&aggcontext))
16771682
{
16781683
/* cannot be called directly because of internal-type argument */
1679-
elog(ERROR,"jsonb_object_agg_transfn called in non-aggregate context");
1684+
elog(ERROR,JSONB"_object_agg_transfn called in non-aggregate context");
16801685
}
16811686

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

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,12 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
537537
ereport(ERROR,
538538
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
539539
errmsg("cannot call %s on a scalar",
540-
"jsonb_object_keys")));
540+
JSONB"_object_keys")));
541541
elseif (JB_ROOT_IS_ARRAY(jb))
542542
ereport(ERROR,
543543
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
544544
errmsg("cannot call %s on an array",
545-
"jsonb_object_keys")));
545+
JSONB"_object_keys")));
546546

547547
funcctx=SRF_FIRSTCALL_INIT();
548548
oldcontext=MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
@@ -1524,7 +1524,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
15241524
/* Container must be array, but make sure */
15251525

15261526
if (!JsonContainerIsArray(container))
1527-
elog(ERROR,"not ajsonb array");
1527+
elog(ERROR,"not a"JSONB" array");
15281528

15291529
nelements=JsonContainerSize(container) >=0 ?
15301530
JsonContainerSize(container) :
@@ -1702,7 +1702,7 @@ json_each(PG_FUNCTION_ARGS)
17021702
Datum
17031703
jsonb_each(PG_FUNCTION_ARGS)
17041704
{
1705-
returneach_worker_jsonb(fcinfo,"jsonb_each", false);
1705+
returneach_worker_jsonb(fcinfo,JSONB"_each", false);
17061706
}
17071707

17081708
#ifndefJSON_GENERIC
@@ -1716,7 +1716,7 @@ json_each_text(PG_FUNCTION_ARGS)
17161716
Datum
17171717
jsonb_each_text(PG_FUNCTION_ARGS)
17181718
{
1719-
returneach_worker_jsonb(fcinfo,"jsonb_each_text", true);
1719+
returneach_worker_jsonb(fcinfo,JSONB"_each_text", true);
17201720
}
17211721

17221722
staticDatum
@@ -1769,7 +1769,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
17691769
MemoryContextSwitchTo(old_cxt);
17701770

17711771
tmp_cxt=AllocSetContextCreate(CurrentMemoryContext,
1772-
"jsonb_each temporary cxt",
1772+
JSONB"_each temporary cxt",
17731773
ALLOCSET_DEFAULT_SIZES);
17741774

17751775
it=JsonbIteratorInit(&jb->root);
@@ -2026,13 +2026,13 @@ each_scalar(void *state, char *token, JsonTokenType tokentype)
20262026
Datum
20272027
jsonb_array_elements(PG_FUNCTION_ARGS)
20282028
{
2029-
returnelements_worker_jsonb(fcinfo,"jsonb_array_elements", false);
2029+
returnelements_worker_jsonb(fcinfo,JSONB"_array_elements", false);
20302030
}
20312031

20322032
Datum
20332033
jsonb_array_elements_text(PG_FUNCTION_ARGS)
20342034
{
2035-
returnelements_worker_jsonb(fcinfo,"jsonb_array_elements_text", true);
2035+
returnelements_worker_jsonb(fcinfo,JSONB"_array_elements_text", true);
20362036
}
20372037

20382038
staticDatum
@@ -2086,7 +2086,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
20862086
MemoryContextSwitchTo(old_cxt);
20872087

20882088
tmp_cxt=AllocSetContextCreate(CurrentMemoryContext,
2089-
"jsonb_array_elements temporary cxt",
2089+
JSONB"_array_elements temporary cxt",
20902090
ALLOCSET_DEFAULT_SIZES);
20912091

20922092
it=JsonbIteratorInit(&jb->root);
@@ -2348,13 +2348,13 @@ elements_scalar(void *state, char *token, JsonTokenType tokentype)
23482348
Datum
23492349
jsonb_populate_record(PG_FUNCTION_ARGS)
23502350
{
2351-
returnpopulate_record_worker(fcinfo,"jsonb_populate_record", true);
2351+
returnpopulate_record_worker(fcinfo,JSONB"_populate_record", true);
23522352
}
23532353

23542354
Datum
23552355
jsonb_to_record(PG_FUNCTION_ARGS)
23562356
{
2357-
returnpopulate_record_worker(fcinfo,"jsonb_to_record", false);
2357+
returnpopulate_record_worker(fcinfo,JSONB"_to_record", false);
23582358
}
23592359

23602360
#ifndefJSON_GENERIC
@@ -3491,13 +3491,13 @@ hash_scalar(void *state, char *token, JsonTokenType tokentype)
34913491
Datum
34923492
jsonb_populate_recordset(PG_FUNCTION_ARGS)
34933493
{
3494-
returnpopulate_recordset_worker(fcinfo,"jsonb_populate_recordset", true);
3494+
returnpopulate_recordset_worker(fcinfo,JSONB"_populate_recordset", true);
34953495
}
34963496

34973497
Datum
34983498
jsonb_to_recordset(PG_FUNCTION_ARGS)
34993499
{
3500-
returnpopulate_recordset_worker(fcinfo,"jsonb_to_recordset", false);
3500+
returnpopulate_recordset_worker(fcinfo,JSONB"_to_recordset", false);
35013501
}
35023502

35033503
#ifndefJSON_GENERIC
@@ -4594,7 +4594,7 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
45944594
*/
45954595
ereport(ERROR,
45964596
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4597-
errmsg("invalid concatenation ofjsonb objects")));
4597+
errmsg("invalid concatenation of"JSONB" objects")));
45984598
}
45994599

46004600
returnres;
@@ -4697,7 +4697,7 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
46974697
ereport(ERROR,
46984698
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
46994699
errmsg("cannot replace existing key"),
4700-
errhint("Try using the functionjsonb_set "
4700+
errhint("Try using the function"JSONB"_set "
47014701
"to replace key value.")));
47024702

47034703
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