Skip to content

Commit 9f4547d

Browse files
author
Nikita Glukhov
committed
Use pushSingleScalarJsonbValue() in JsonbValueToJsonb()
1 parent 072686d commit 9f4547d

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
/*
110112
* Turn an in-memory JsonbValue into a Jsonb for on-disk storage.
@@ -128,17 +130,7 @@ JsonbValueToJsonb(JsonbValue *val)
128130
{
129131
/* Scalar value */
130132
JsonbParseState *pstate = NULL;
131-
JsonbValue *res;
132-
JsonbValue scalarArray;
133-
134-
scalarArray.type = jbvArray;
135-
scalarArray.val.array.rawScalar = true;
136-
scalarArray.val.array.nElems = 1;
137-
138-
pushJsonbValue(&pstate, WJB_BEGIN_ARRAY, &scalarArray);
139-
pushJsonbValue(&pstate, WJB_ELEM, val);
140-
res = pushJsonbValue(&pstate, WJB_END_ARRAY, NULL);
141-
133+
JsonbValue *res = pushSingleScalarJsonbValue(&pstate, val);
142134
out = convertToJsonb(res);
143135
}
144136
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