Skip to content

Commit c85806e

Browse files
author
Nikita Glukhov
committed
Use pushSingleScalarJsonbValue() in JsonbValueToJsonb()
1 parent 21a4163 commit c85806e

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
@@ -105,6 +105,8 @@ static void uniqueifyJsonbObject(JsonbValue *object);
105105
static JsonbValue *pushJsonbValueScalar(JsonbParseState **pstate,
106106
JsonbIteratorToken seq,
107107
JsonbValue *scalarVal);
108+
static JsonbValue *pushSingleScalarJsonbValue(JsonbParseState **pstate,
109+
JsonbValue *jbval);
108110

109111
void
110112
JsonbToJsonbValue(Jsonb *jsonb, JsonbValue *val)
@@ -135,17 +137,7 @@ JsonbValueToJsonb(JsonbValue *val)
135137
{
136138
/* Scalar value */
137139
JsonbParseState *pstate = NULL;
138-
JsonbValue *res;
139-
JsonbValue scalarArray;
140-
141-
scalarArray.type = jbvArray;
142-
scalarArray.val.array.rawScalar = true;
143-
scalarArray.val.array.nElems = 1;
144-
145-
pushJsonbValue(&pstate, WJB_BEGIN_ARRAY, &scalarArray);
146-
pushJsonbValue(&pstate, WJB_ELEM, val);
147-
res = pushJsonbValue(&pstate, WJB_END_ARRAY, NULL);
148-
140+
JsonbValue *res = pushSingleScalarJsonbValue(&pstate, val);
149141
out = convertToJsonb(res);
150142
}
151143
else if (val->type == jbvObject || val->type == jbvArray)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy