@@ -41,7 +41,7 @@ static inline JsonPathExecResult recursiveExecute(JsonPathExecContext *cxt,
41
41
JsonPathItem * jsp , JsonbValue * jb ,
42
42
JsonValueList * found );
43
43
44
- static JsonPathExecResult recursiveExecuteUnwrap (JsonPathExecContext * cxt ,
44
+ static inline JsonPathExecResult recursiveExecuteUnwrap (JsonPathExecContext * cxt ,
45
45
JsonPathItem * jsp , JsonbValue * jb , JsonValueList * found );
46
46
47
47
static inline JsonbValue * wrapItemsInArray (const JsonValueList * items );
@@ -1814,51 +1814,56 @@ recursiveExecuteNoUnwrap(JsonPathExecContext *cxt, JsonPathItem *jsp,
1814
1814
}
1815
1815
1816
1816
static JsonPathExecResult
1817
- recursiveExecuteUnwrap (JsonPathExecContext * cxt , JsonPathItem * jsp ,
1818
- JsonbValue * jb , JsonValueList * found )
1817
+ recursiveExecuteUnwrapArray (JsonPathExecContext * cxt , JsonPathItem * jsp ,
1818
+ JsonbValue * jb , JsonValueList * found )
1819
1819
{
1820
- if (cxt -> lax && JsonbType (jb ) == jbvArray )
1820
+ JsonPathExecResult res = jperNotFound ;
1821
+
1822
+ if (jb -> type == jbvArray )
1821
1823
{
1822
- JsonPathExecResult res = jperNotFound ;
1824
+ JsonbValue * elem = jb -> val .array .elems ;
1825
+ JsonbValue * last = elem + jb -> val .array .nElems ;
1823
1826
1824
- if ( jb -> type == jbvArray )
1827
+ for (; elem < last ; elem ++ )
1825
1828
{
1826
- JsonbValue * elem = jb -> val .array .elems ;
1827
- JsonbValue * last = elem + jb -> val .array .nElems ;
1829
+ res = recursiveExecuteNoUnwrap (cxt , jsp , elem , found );
1828
1830
1829
- for (; elem < last ; elem ++ )
1830
- {
1831
- res = recursiveExecuteNoUnwrap (cxt , jsp , elem , found );
1831
+ if (jperIsError (res ))
1832
+ break ;
1833
+ if (res == jperOk && !found )
1834
+ break ;
1835
+ }
1836
+ }
1837
+ else
1838
+ {
1839
+ JsonbValue v ;
1840
+ JsonbIterator * it ;
1841
+ JsonbIteratorToken tok ;
1842
+
1843
+ it = JsonbIteratorInit (jb -> val .binary .data );
1832
1844
1845
+ while ((tok = JsonbIteratorNext (& it , & v , true)) != WJB_DONE )
1846
+ {
1847
+ if (tok == WJB_ELEM )
1848
+ {
1849
+ res = recursiveExecuteNoUnwrap (cxt , jsp , & v , found );
1833
1850
if (jperIsError (res ))
1834
1851
break ;
1835
1852
if (res == jperOk && !found )
1836
1853
break ;
1837
1854
}
1838
1855
}
1839
- else
1840
- {
1841
- JsonbValue v ;
1842
- JsonbIterator * it ;
1843
- JsonbIteratorToken tok ;
1844
-
1845
- it = JsonbIteratorInit (jb -> val .binary .data );
1856
+ }
1846
1857
1847
- while ((tok = JsonbIteratorNext (& it , & v , true)) != WJB_DONE )
1848
- {
1849
- if (tok == WJB_ELEM )
1850
- {
1851
- res = recursiveExecuteNoUnwrap (cxt , jsp , & v , found );
1852
- if (jperIsError (res ))
1853
- break ;
1854
- if (res == jperOk && !found )
1855
- break ;
1856
- }
1857
- }
1858
- }
1858
+ return res ;
1859
+ }
1859
1860
1860
- return res ;
1861
- }
1861
+ static inline JsonPathExecResult
1862
+ recursiveExecuteUnwrap (JsonPathExecContext * cxt , JsonPathItem * jsp ,
1863
+ JsonbValue * jb , JsonValueList * found )
1864
+ {
1865
+ if (cxt -> lax && JsonbType (jb ) == jbvArray )
1866
+ return recursiveExecuteUnwrapArray (cxt , jsp , jb , found );
1862
1867
1863
1868
return recursiveExecuteNoUnwrap (cxt , jsp , jb , found );
1864
1869
}
0 commit comments