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

Commit 4a881f9

Browse files
author
Nikita Glukhov
committed
Use pushSingleScalarJsonbValue() in JsonbValueToJsonb()
1 parent 856dc9a commit 4a881f9

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
@@ -109,6 +109,8 @@ static void uniqueifyJsonbObject(JsonbValue *object, bool unique_keys,
109109
static JsonbValue *pushJsonbValueScalar(JsonbParseState **pstate,
110110
JsonbIteratorToken seq,
111111
JsonbValue *scalarVal);
112+
static JsonbValue *pushSingleScalarJsonbValue(JsonbParseState **pstate,
113+
JsonbValue *jbval);
112114

113115
void
114116
JsonbToJsonbValue(Jsonb *jsonb, JsonbValue *val)
@@ -139,17 +141,7 @@ JsonbValueToJsonb(JsonbValue *val)
139141
{
140142
/* Scalar value */
141143
JsonbParseState *pstate = NULL;
142-
JsonbValue *res;
143-
JsonbValue scalarArray;
144-
145-
scalarArray.type = jbvArray;
146-
scalarArray.val.array.rawScalar = true;
147-
scalarArray.val.array.nElems = 1;
148-
149-
pushJsonbValue(&pstate, WJB_BEGIN_ARRAY, &scalarArray);
150-
pushJsonbValue(&pstate, WJB_ELEM, val);
151-
res = pushJsonbValue(&pstate, WJB_END_ARRAY, NULL);
152-
144+
JsonbValue *res = pushSingleScalarJsonbValue(&pstate, val);
153145
out = convertToJsonb(res);
154146
}
155147
else if (val->type == jbvObject || val->type == jbvArray)

0 commit comments

Comments
 (0)