]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
All tests passing. jsonb-tree
authordrh <>
Mon, 27 Nov 2023 12:30:55 +0000 (12:30 +0000)
committerdrh <>
Mon, 27 Nov 2023 12:30:55 +0000 (12:30 +0000)
FossilOrigin-Name: b5a5660ca22437640c9bf32c44d92c76a7293dafcbaf4fa6a4c171128d64871d

manifest
manifest.uuid
src/json.c
test/json101.test

index 7736b5bcaf9819492e8e6a16ac5387da3a5c26d6..8e410950f689c281d496d37391e9af65a2e13a56 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\scorner-case\serror\sconditions.
-D 2023-11-26T00:56:40.131
+C All\stests\spassing.
+D 2023-11-27T12:30:55.729
 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 59dd8bf951f0c7b2e1004f406f8690d9743146f176d675da06427f99c75c78f7
+F src/json.c efd9ec1cb0f0cbee3e43ebaba69469b3d3f44ee623b53b1ce72361da42e05fbe
 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
 F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
 F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
@@ -1325,7 +1325,7 @@ F test/json/json-generator.tcl dc0dd0f393800c98658fc4c47eaa6af29d4e17527380cd286
 F test/json/json-q1-b.txt 606818a5fba6d9e418c9f4ea7d8418af026775042dad81439b72447a147a462c
 F test/json/json-q1.txt 65f9d1cdcc4cffa9823fb73ed936aae5658700cd001fde448f68bfb91c807307
 F test/json/json-speed-check.sh b060a9a6c696c0a807d8929400fa11bd7113edc58b0d66b9795f424f8d0db326 x
-F test/json101.test 2420fbed1d2dddb9562f8b9d0ac540849b99deba74e869560f94f674ef24171c
+F test/json101.test 19f9abc77c33151bd7fdb7850fb473cb0154f229b863b740590ad9de807a032d
 F test/json102.test 557a46e16df1aa9bdbc4076a71a45814ea0e7503d6621d87d42a8c04cbc2b0ef
 F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe
 F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1
@@ -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 c3da4b079a1a15a4c0b1a6e71f876648b1d9eb32eddc67b9946c2475c7b6d085
-R 6a83cb0634a1b413d8dd9f72a2caf803
+P ec23d34ab75e1d7e9366e59c633e0d30def8759f6d4717583ebeb4c90aeccf0d
+R 6545b38a1b858ef8dae597ee252577f2
 U drh
-Z cf069d3ef952e41c66c8bcc7a7e83b20
+Z b98cdf654b65fc79957da28b6036dc53
 # Remove this line to create a well-formed Fossil manifest.
index 90bef2caadcaaa5b3f52eb521b995a7ea3e6d313..050c01db3cf93c54b12a795e7556777426f6c85b 100644 (file)
@@ -1 +1 @@
-ec23d34ab75e1d7e9366e59c633e0d30def8759f6d4717583ebeb4c90aeccf0d
\ No newline at end of file
+b5a5660ca22437640c9bf32c44d92c76a7293dafcbaf4fa6a4c171128d64871d
\ No newline at end of file
index 93176082672289ba38f0ec6bea2efe413da84b4f..0e3f6fe5755347f9468bbc0b5a66b2b2de844a47 100644 (file)
@@ -5715,6 +5715,7 @@ static void jsonAppendPathName(JsonEachCursor *p){
 /* Advance the cursor to the next element for json_tree() */
 static int jsonEachNext(sqlite3_vtab_cursor *cur){
   JsonEachCursor *p = (JsonEachCursor*)cur;
+  int rc = SQLITE_OK;
   if( p->bRecursive ){
     u8 x;
     u8 levelChange = 0;
@@ -5740,7 +5741,10 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
       pParent->iEnd = i + n + sz;
       pParent->iKey = -1;
       pParent->nPath = (u32)p->path.nUsed;
-      if( p->eType && p->nParent ) jsonAppendPathName(p);
+      if( p->eType && p->nParent ){
+        jsonAppendPathName(p);
+        if( p->path.eErr ) rc = SQLITE_NOMEM;
+      }
       p->nParent++;
       p->i = i + n;
     }else{
@@ -5770,7 +5774,7 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
     p->aParent[p->nParent-1].iKey++;
   }
   p->iRowid++;
-  return SQLITE_OK;
+  return rc;
 }
 
 /* Length of the path for rowid==0 in bRecursive mode.
@@ -5811,7 +5815,9 @@ static int jsonEachColumn(
         if( p->nRoot==1 ) break;
         j = jsonEachPathLength(p);
         n = p->nRoot - j;
-        if( p->path.zBuf[j]=='[' ){
+        if( n==0 ){
+          break;
+        }else if( p->path.zBuf[j]=='[' ){
           i64 x;
           sqlite3Atoi64(&p->path.zBuf[j+1], &x, n-1, SQLITE_UTF8);
           sqlite3_result_int64(ctx, x);
@@ -5992,12 +5998,18 @@ static int jsonEachFilter(
   }else{
     p->sParse.zJson = (char*)sqlite3_value_text(argv[0]);
     p->sParse.nJson = sqlite3_value_bytes(argv[0]);
-    if( p->sParse.zJson==0 || jsonConvertTextToBlob(&p->sParse, 0) ){
+    if( p->sParse.zJson==0 ){
+      p->i = p->iEnd = 0;
+      return SQLITE_OK;
+    }      
+    if( jsonConvertTextToBlob(&p->sParse, 0) ){
       if( p->sParse.oom ){
         return SQLITE_NOMEM;
       }
-      p->i = p->iEnd = 0;
-      return SQLITE_OK;
+      sqlite3_free(cur->pVtab->zErrMsg);
+      cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON");
+      jsonEachCursorReset(p);
+      return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;
     }
   }
   if( idxNum==3 ){
@@ -6016,10 +6028,16 @@ static int jsonEachFilter(
     }else{
       i = jsonLookupBlobStep(&p->sParse, 0, zRoot+1, 0);
       if( JSON_BLOB_ISERROR(i) ){
-        p->i = 0;
-        p->eType = 0;
-        p->iEnd = 0;
-        return SQLITE_OK;
+        if( i==JSON_BLOB_NOTFOUND ){
+          p->i = 0;
+          p->eType = 0;
+          p->iEnd = 0;
+          return SQLITE_OK;
+        }
+        sqlite3_free(cur->pVtab->zErrMsg);
+        cur->pVtab->zErrMsg = jsonPathSyntaxError(zRoot, 0);
+        jsonEachCursorReset(p);
+        return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;
       }
       if( p->sParse.iLabel ){
         p->i = p->sParse.iLabel;
index 426746377c26eb9375963bd59848c9b25324857d..280d4673938747740a3b049c7c7646288152dc04 100644 (file)
@@ -925,16 +925,16 @@ do_execsql_test json101-14.170 {
 #
 do_execsql_test json101-15.100 {
   SELECT * FROM JSON_EACH('{"a":1, "b":2}');
-} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+} {a 1 integer 1 1 {} {$.a} {$} b 2 integer 2 5 {} {$.b} {$}}
 do_execsql_test json101-15.110 {
   SELECT xyz.* FROM JSON_EACH('{"a":1, "b":2}') AS xyz;
-} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+} {a 1 integer 1 1 {} {$.a} {$} b 2 integer 2 5 {} {$.b} {$}}
 do_execsql_test json101-15.120 {
   SELECT * FROM (JSON_EACH('{"a":1, "b":2}'));
-} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+} {a 1 integer 1 1 {} {$.a} {$} b 2 integer 2 5 {} {$.b} {$}}
 do_execsql_test json101-15.130 {
   SELECT xyz.* FROM (JSON_EACH('{"a":1, "b":2}')) AS xyz;
-} {a 1 integer 1 2 {} {$.a} {$} b 2 integer 2 4 {} {$.b} {$}}
+} {a 1 integer 1 1 {} {$.a} {$} b 2 integer 2 5 {} {$.b} {$}}
 
 # 2019-11-10
 # Mailing list bug report on the handling of surrogate pairs