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

Commit 8e596d3

Browse files
author
Nikita Glukhov
committed
Add jsonpath JsonbWrapInBinary()
1 parent 46d79d2 commit 8e596d3

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/backend/utils/adt/jsonpath_exec.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ JsonbInitBinary(JsonbValue *jbv, Jsonb *jb)
159159
return jbv;
160160
}
161161

162+
static inline JsonbValue *
163+
JsonbWrapInBinary(JsonbValue *jbv, JsonbValue *out)
164+
{
165+
Jsonb *jb = JsonbValueToJsonb(jbv);
166+
167+
if (!out)
168+
out = palloc(sizeof(*out));
169+
170+
return JsonbInitBinary(out, jb);
171+
}
172+
162173
/********************Execute functions for JsonPath***************************/
163174

164175
/*
@@ -1967,7 +1978,6 @@ static inline JsonbValue *
19671978
wrapItem(JsonbValue *jbv)
19681979
{
19691980
JsonbParseState *ps = NULL;
1970-
Jsonb *jb;
19711981
JsonbValue jbvbuf;
19721982

19731983
switch (JsonbType(jbv))
@@ -1999,14 +2009,7 @@ wrapItem(JsonbValue *jbv)
19992009
pushJsonbValue(&ps, WJB_ELEM, jbv);
20002010
jbv = pushJsonbValue(&ps, WJB_END_ARRAY, NULL);
20012011

2002-
jb = JsonbValueToJsonb(jbv);
2003-
2004-
jbv = palloc(sizeof(*jbv));
2005-
jbv->type = jbvBinary;
2006-
jbv->val.binary.data = &jb->root;
2007-
jbv->val.binary.len = VARSIZE(jb) - VARHDRSZ;
2008-
2009-
return jbv;
2012+
return JsonbWrapInBinary(jbv, NULL);
20102013
}
20112014

20122015
static inline JsonPathExecResult

0 commit comments

Comments
 (0)