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

Commit728ec97

Browse files
committed
Correct handling of NULL arguments in json funcs.
Per gripe from Tom Lane.
1 parent410bed2 commit728ec97

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ Datum
12171217
json_populate_record(PG_FUNCTION_ARGS)
12181218
{
12191219
Oidargtype=get_fn_expr_argtype(fcinfo->flinfo,0);
1220-
text*json=PG_GETARG_TEXT_P(1);
1221-
booluse_json_as_text=PG_GETARG_BOOL(2);
1220+
text*json;
1221+
booluse_json_as_text;
12221222
HTAB*json_hash;
12231223
HeapTupleHeaderrec;
12241224
OidtupType;
@@ -1234,6 +1234,7 @@ json_populate_record(PG_FUNCTION_ARGS)
12341234
charfname[NAMEDATALEN];
12351235
JsonHashEntryhashentry;
12361236

1237+
use_json_as_text=PG_ARGISNULL(2) ? false :PG_GETARG_BOOL(2);
12371238

12381239
if (!type_is_rowtype(argtype))
12391240
ereport(ERROR,
@@ -1267,6 +1268,8 @@ json_populate_record(PG_FUNCTION_ARGS)
12671268
tupTypmod=HeapTupleHeaderGetTypMod(rec);
12681269
}
12691270

1271+
json=PG_GETARG_TEXT_P(1);
1272+
12701273
json_hash=get_json_object_as_hash(json,"json_populate_record",use_json_as_text);
12711274

12721275
/*
@@ -1559,8 +1562,8 @@ Datum
15591562
json_populate_recordset(PG_FUNCTION_ARGS)
15601563
{
15611564
Oidargtype=get_fn_expr_argtype(fcinfo->flinfo,0);
1562-
text*json=PG_GETARG_TEXT_P(1);
1563-
booluse_json_as_text=PG_GETARG_BOOL(2);
1565+
text*json;
1566+
booluse_json_as_text;
15641567
ReturnSetInfo*rsi;
15651568
MemoryContextold_cxt;
15661569
OidtupType;
@@ -1573,6 +1576,8 @@ json_populate_recordset(PG_FUNCTION_ARGS)
15731576
JsonSemActionsem;
15741577
PopulateRecordsetStatestate;
15751578

1579+
use_json_as_text=PG_ARGISNULL(2) ? false :PG_GETARG_BOOL(2);
1580+
15761581
if (!type_is_rowtype(argtype))
15771582
ereport(ERROR,
15781583
(errcode(ERRCODE_DATATYPE_MISMATCH),
@@ -1616,6 +1621,8 @@ json_populate_recordset(PG_FUNCTION_ARGS)
16161621
if (PG_ARGISNULL(1))
16171622
PG_RETURN_NULL();
16181623

1624+
json=PG_GETARG_TEXT_P(1);
1625+
16191626
if (PG_ARGISNULL(0))
16201627
rec=NULL;
16211628
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp