Skip to content

Commit 62ae11e

Browse files
author
Nikita Glukhov
committed
Use pushSingleScalarJsonbValue() in JsonbValueToJsonb()
1 parent 846a38a commit 62ae11e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/backend/utils/adt/jsonb_util.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ static void uniqueifyJsonbObject(JsonbValue *object);
9999
static JsonbValue *pushJsonbValueScalar(JsonbParseState **pstate,
100100
JsonbIteratorToken seq,
101101
JsonbValue *scalarVal);
102+
static JsonbValue *pushSingleScalarJsonbValue(JsonbParseState **pstate,
103+
JsonbValue *jbval);
102104

103105
/*
104106
* Turn an in-memory JsonbValue into a Jsonb for on-disk storage.
@@ -122,17 +124,7 @@ JsonbValueToJsonb(JsonbValue *val)
122124
{
123125
/* Scalar value */
124126
JsonbParseState *pstate = NULL;
125-
JsonbValue *res;
126-
JsonbValue scalarArray;
127-
128-
scalarArray.type = jbvArray;
129-
scalarArray.val.array.rawScalar = true;
130-
scalarArray.val.array.nElems = 1;
131-
132-
pushJsonbValue(&pstate, WJB_BEGIN_ARRAY, &scalarArray);
133-
pushJsonbValue(&pstate, WJB_ELEM, val);
134-
res = pushJsonbValue(&pstate, WJB_END_ARRAY, NULL);
135-
127+
JsonbValue *res = pushSingleScalarJsonbValue(&pstate, val);
136128
out = convertToJsonb(res);
137129
}
138130
else if (val->type == jbvObject || val->type == jbvArray)

0 commit comments

Comments
 (0)