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

Commitd99d0e6

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 parent2024ead commitd99d0e6

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
@@ -1341,6 +1341,9 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
13411341
boolnumeric_error;
13421342
JsonLexContextdummy_lex;
13431343

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp