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

Commit9111d46

Browse files
committed
Remove ill-conceived ban on zero length json object keys.
We removed a similar ban on this in json_object recently, but the ban indatum_to_json was left, which generate4d sprutious errors in othee jsongenerators, notable json_build_object.Along the way, add an assertion that datum_to_json is not passed a nullkey. All current callers comply with this rule, but the assertion willcatch any possible future misbehaviour.
1 parent5d7962c commit9111d46

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,9 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
13421342
boolnumeric_error;
13431343
JsonLexContextdummy_lex;
13441344

1345+
/* callers are expected to ensure that null keys are not passed in */
1346+
Assert( ! (key_scalar&&is_null));
1347+
13451348
if (is_null)
13461349
{
13471350
appendStringInfoString(result,"null");
@@ -1487,10 +1490,6 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
14871490
break;
14881491
default:
14891492
outputstr=OidOutputFunctionCall(outfuncoid,val);
1490-
if (key_scalar&&*outputstr=='\0')
1491-
ereport(ERROR,
1492-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1493-
errmsg("key value must not be empty")));
14941493
escape_json(result,outputstr);
14951494
pfree(outputstr);
14961495
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp