Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8aaa285

Browse files
author
Nikita Glukhov
committed
Fix NULL path entry case
1 parent ed33e82 commit 8aaa285

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/backend/utils/adt/jsonb_selfuncs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ jsonbStatsVarOpConst(Oid opid, VariableStatData *resdata,
941941
Datum *path;
942942
bool *nulls;
943943
int pathlen;
944-
int i;
944+
bool have_nulls = false;
945945

946946
if (cnst->consttype != TEXTARRAYOID)
947947
{
@@ -952,18 +952,18 @@ jsonbStatsVarOpConst(Oid opid, VariableStatData *resdata,
952952
deconstruct_array(DatumGetArrayTypeP(cnst->constvalue), TEXTOID,
953953
-1, false, 'i', &path, &nulls, &pathlen);
954954

955-
for (i = 0; i < pathlen; i++)
955+
for (int i = 0; i < pathlen; i++)
956956
{
957957
if (nulls[i])
958958
{
959-
pfree(path);
960-
pfree(nulls);
961-
PG_RETURN_VOID();
959+
have_nulls = true;
960+
break;
962961
}
963962
}
964963

965-
resdata->statsTuple =
966-
jsonStatsGetPathStatsTuple(&jsdata, statype, path, pathlen);
964+
if (!have_nulls)
965+
resdata->statsTuple =
966+
jsonStatsGetPathStatsTuple(&jsdata, statype, path, pathlen);
967967

968968
pfree(path);
969969
pfree(nulls);

0 commit comments

Comments
 (0)