Continuing work on json_tree() against a JSONB.
FossilOrigin-Name: 3df891cb11feee65e239ee2506eda34a9688341f05210d7c2e25a05338cb71ad
This commit is contained in:
parent
abbdbdfc1f
commit
5e6500c81c
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C Incremental\sprogress\stoward\sgetting\sjson_each()\sand\sjson_tree()\sto\swork\ndirectly\soff\sof\sa\sJSONB\sblob.
|
||||
D 2023-11-24T18:44:00.124
|
||||
C Continuing\swork\son\sjson_tree()\sagainst\sa\sJSONB.
|
||||
D 2023-11-24T21:57:38.322
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -688,7 +688,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
||||
F src/json.c 1b9cc57728bc3a420bae5f4ae8233dcd2c3a337f00a2467346f7b788aedf1ba0
|
||||
F src/json.c 699b3fa340c24a10874988b9cbf4a1635b4231569dfaef9e4fd8fb96195406aa
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
|
||||
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
|
||||
@ -2145,11 +2145,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P ab2644aacf4757a51cf62e05cff6711a0a3605d60502a3dd310887df1b993545
|
||||
R b8a3524be145a961ee4bfad02645fa25
|
||||
T *branch * jsonb-tree
|
||||
T *sym-jsonb-tree *
|
||||
T -sym-jsonb *
|
||||
P f8cab41b3bc65af6ff34b481db693d640ea025d09463d50b8e56d855e2abc913
|
||||
R 12dbc87edffde88122e858181ec1f996
|
||||
U drh
|
||||
Z b88ae8be743d3b0432d41e7f9773a471
|
||||
Z f88095c49473dd89bb79ab974b58607c
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
f8cab41b3bc65af6ff34b481db693d640ea025d09463d50b8e56d855e2abc913
|
||||
3df891cb11feee65e239ee2506eda34a9688341f05210d7c2e25a05338cb71ad
|
35
src/json.c
35
src/json.c
@ -5576,6 +5576,7 @@ static void jsonObjectFinal(sqlite3_context *ctx){
|
||||
typedef struct JsonParent JsonParent;
|
||||
struct JsonParent {
|
||||
u32 iHead; /* Start of object or array */
|
||||
u32 iValue; /* Start of the value */
|
||||
u32 iEnd; /* First byte past the end */
|
||||
i64 iKey; /* Key for JSONB_ARRAY */
|
||||
};
|
||||
@ -5773,7 +5774,7 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
|
||||
u32 n, sz = 0;
|
||||
u32 i = jsonSkipLabel(p);
|
||||
x = p->sParse.aBlob[i] & 0x0f;
|
||||
n = jsonbPayloadSize(&p->sParse, p->i, &sz);
|
||||
n = jsonbPayloadSize(&p->sParse, i, &sz);
|
||||
if( x==JSONB_OBJECT || x==JSONB_ARRAY ){
|
||||
JsonParent *pParent;
|
||||
if( p->nParent>=p->nParentAlloc ){
|
||||
@ -5784,32 +5785,41 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
|
||||
if( pNew==0 ) return SQLITE_NOMEM;
|
||||
p->nParentAlloc = (u32)nNew;
|
||||
p->aParent = pNew;
|
||||
levelChange = 1;
|
||||
}
|
||||
levelChange = 1;
|
||||
pParent = &p->aParent[p->nParent++];
|
||||
pParent->iHead = p->i;
|
||||
pParent->iEnd = p->i + n + sz;
|
||||
pParent->iKey = 0;
|
||||
pParent->iValue = i;
|
||||
pParent->iEnd = i + n + sz;
|
||||
pParent->iKey = -1;
|
||||
p->i = i + n;
|
||||
}else{
|
||||
p->i = i + n + sz;
|
||||
}
|
||||
if( p->nParent>0 && p->i >= p->aParent[p->nParent-1].iEnd ){
|
||||
while( p->nParent>0 && p->i >= p->aParent[p->nParent-1].iEnd ){
|
||||
p->nParent--;
|
||||
levelChange = 1;
|
||||
}
|
||||
if( levelChange ){
|
||||
if( p->nParent>0 ){
|
||||
p->eType = p->sParse.aBlob[p->aParent[p->nParent-1].iHead] & 0x0f;
|
||||
JsonParent *pParent = &p->aParent[p->nParent-1];
|
||||
u32 i = pParent->iValue;
|
||||
p->eType = p->sParse.aBlob[i] & 0x0f;
|
||||
}else{
|
||||
p->eType = 0;
|
||||
}
|
||||
}
|
||||
if( p->eType==JSONB_ARRAY ){
|
||||
assert( p->nParent>0 );
|
||||
p->aParent[p->nParent-1].iKey++;
|
||||
}
|
||||
}else{
|
||||
u32 n, sz = 0;
|
||||
u32 i = jsonSkipLabel(p);
|
||||
n = jsonbPayloadSize(&p->sParse, i, &sz);
|
||||
p->i = i + n + sz;
|
||||
}
|
||||
p->iRowid++;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@ -6022,6 +6032,19 @@ static int jsonEachColumn(
|
||||
break;
|
||||
}
|
||||
case JEACH_FULLKEY: {
|
||||
#if 0
|
||||
u32 i;
|
||||
JsonString x;
|
||||
jsonStringInit(&x, ctx);
|
||||
for(i=0; i<p->nParent; i++){
|
||||
jsonPrintf(200,&x,"(%u,%u,%u,%lld)",
|
||||
p->aParent[i].iHead,
|
||||
p->aParent[i].iValue,
|
||||
p->aParent[i].iEnd,
|
||||
p->aParent[i].iKey);
|
||||
}
|
||||
jsonReturnString(&x);
|
||||
#endif
|
||||
#if 0
|
||||
JsonString x;
|
||||
jsonStringInit(&x, ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user