Remove unused elements from the json_tree() cursor.

FossilOrigin-Name: 914a50117d477b2cd30d58388fb8d1b71ff7ff6842ba025f38efc6e9647d06d0
This commit is contained in:
drh 2023-11-25 23:00:50 +00:00
parent 796abda538
commit e09a38c2e8
3 changed files with 11 additions and 17 deletions

View File

@ -1,5 +1,5 @@
C Remove\sthe\svestigal\sJsonNode\slogic\sfrom\sjson_tree()\sand\sjson_each().
D 2023-11-25T20:59:03.008
C Remove\sunused\selements\sfrom\sthe\sjson_tree()\scursor.
D 2023-11-25T23:00:50.622
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 211c4e1b8fd886c97d3224105bfef9d4cc04db2e3f1daca1e95c52343df4e85c
F src/json.c 7bd0d3809b31e32ffa053ba68cf03f67121f6bdd0be7031e8d4c761bef9b6aee
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
@ -2145,8 +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 92258246916a9c0d72785964513113848a850dec78bdade8b3f274e410df4e7e
R 43fba60a847876455ec8abde78205ef3
P 66c2ab9ebbf90477742e6be0d30e061d827c409de038f2a5b73479ed9448c4a6
R 79cb22ebedffb4f5b0a0989ee5c920ed
U drh
Z d0660c039b12ecd1fe4ffd828711a405
Z b95c9f50e6b9041cf41818958255b068
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
66c2ab9ebbf90477742e6be0d30e061d827c409de038f2a5b73479ed9448c4a6
914a50117d477b2cd30d58388fb8d1b71ff7ff6842ba025f38efc6e9647d06d0

View File

@ -5540,16 +5540,14 @@ typedef struct JsonEachCursor JsonEachCursor;
struct JsonEachCursor {
sqlite3_vtab_cursor base; /* Base class - must be first */
u32 iRowid; /* The rowid */
u32 iBegin; /* The first node of the scan */
u32 i; /* Index in sParse.aBlob[] of current row */
u32 iEnd; /* EOF when i equals or exceeds this value */
u32 nRoot; /* Size of the root argument in bytes */
u8 eType; /* Type of the container for element i */
u8 bRecursive; /* True for json_tree(). False for json_each() */
u32 nParent; /* Current nesting depth */
u32 nParentAlloc; /* Space allocated for aParent[] */
JsonParent *aParent; /* Parent elements of i */
char *zJson; /* Input JSON */
char *zRoot; /* Path by which to filter zJson */
sqlite3 *db; /* Database connection */
JsonString path; /* Current path */
JsonParse sParse; /* Parse of the input JSON */
@ -5638,7 +5636,6 @@ static int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
/* Reset a JsonEachCursor back to its original state. Free any memory
** held. */
static void jsonEachCursorReset(JsonEachCursor *p){
sqlite3_free(p->zRoot);
jsonParseReset(&p->sParse);
jsonStringReset(&p->path);
sqlite3DbFree(p->db, p->aParent);
@ -5649,8 +5646,6 @@ static void jsonEachCursorReset(JsonEachCursor *p){
p->nParentAlloc = 0;
p->iEnd = 0;
p->eType = 0;
p->zJson = 0;
p->zRoot = 0;
}
/* Destructor for a jsonEachCursor object */
@ -5839,9 +5834,7 @@ static int jsonEachColumn(
break;
}
default: {
const char *zRoot = p->zRoot;
if( zRoot==0 ) zRoot = "$";
sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);
sqlite3_result_text(ctx, p->path.zBuf, p->nRoot, SQLITE_STATIC);
break;
}
case JEACH_JSON: {
@ -5956,6 +5949,7 @@ static int jsonEachFilter(
if( p->sParse.aBlob==0 ){
return SQLITE_NOMEM;
}
p->sParse.isBinary = 1;
}else{
p->sParse.zJson = (char*)sqlite3_value_text(argv[0]);
p->sParse.nJson = sqlite3_value_bytes(argv[0]);
@ -6001,8 +5995,8 @@ static int jsonEachFilter(
p->eType = 0;
jsonAppendRaw(&p->path, "$", 1);
}
p->nRoot = p->path.nUsed;
p->nParent = 0;
p->sParse.isBinary = 1;
n = jsonbPayloadSize(&p->sParse, i, &sz);
p->iEnd = i+n+sz;
if( (p->sParse.aBlob[i] & 0x0f)>=JSONB_ARRAY && !p->bRecursive ){