]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Futher simplifications to json1.c. Also an obscure bug-fix in the initial
authordrh <drh@noemail.net>
Tue, 22 Sep 2015 01:15:49 +0000 (01:15 +0000)
committerdrh <drh@noemail.net>
Tue, 22 Sep 2015 01:15:49 +0000 (01:15 +0000)
output of json_tree() when using a path to an object contained within an array.

FossilOrigin-Name: fcb1e327a64134e5ac539ec3d52733422d3061fd

ext/misc/json1.c
manifest
manifest.uuid

index c3e21dd5086976272b54252250675b35aa822337..db8d09b9bcb74b25736f4fcc00f0f348a9a73bc3 100644 (file)
@@ -156,11 +156,9 @@ static void jsonReset(JsonString *p){
 /* Report an out-of-memory (OOM) condition 
 */
 static void jsonOom(JsonString *p){
-  if( !p->bErr ){
-    p->bErr = 1;
-    sqlite3_result_error_nomem(p->pCtx);
-    jsonReset(p);
-  }
+  p->bErr = 1;
+  sqlite3_result_error_nomem(p->pCtx);
+  jsonReset(p);
 }
 
 /* Enlarge pJson->zBuf so that it can hold at least N more bytes.
@@ -567,10 +565,6 @@ static int jsonParseAddNode(
     JsonNode *pNew;
     if( pParse->oom ) return -1;
     nNew = pParse->nAlloc*2 + 10;
-    if( nNew<=pParse->nNode ){
-      pParse->oom = 1;
-      return -1;
-    }
     pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);
     if( pNew==0 ){
       pParse->oom = 1;
@@ -899,16 +893,16 @@ static JsonNode *jsonLookupStep(
   }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){
     if( pRoot->eType!=JSON_ARRAY ) return 0;
     i = 0;
-    zPath++;
-    while( safe_isdigit(zPath[0]) ){
-      i = i*10 + zPath[0] - '0';
-      zPath++;
+    j = 1;
+    while( safe_isdigit(zPath[j]) ){
+      i = i*10 + zPath[j] - '0';
+      j++;
     }
-    if( zPath[0]!=']' ){
+    if( zPath[j]!=']' ){
       *pzErr = zPath;
       return 0;
     }
-    zPath++;
+    zPath += j + 1;
     j = 1;
     for(;;){
       while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){
@@ -936,7 +930,7 @@ static JsonNode *jsonLookupStep(
       }
       return pNode;
     }
-  }else if( zPath[0]!=0 ){
+  }else{
     *pzErr = zPath;
   }
   return 0;
@@ -1696,7 +1690,7 @@ static int jsonEachColumn(
       sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);
       break;
     }
-    default: {
+    case JEACH_JSON: {
       assert( i==JEACH_JSON );
       sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
       break;
@@ -1820,6 +1814,7 @@ static int jsonEachFilter(
       pNode->u.iKey = 0;
       p->iEnd = p->i + pNode->n + 1;
       if( p->bRecursive ){
+        p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType;
         if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){
           p->i--;
         }
index 808d022b9fc1a95c8cbd236dda26787a52678f15..f12a1c2b120c3895a5ec52602bda69394d62b5ff 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sjson_set()\sso\sthat\sit\scan\soverwrite\sa\svalue\sthat\swas\spreviously\soverwritten\nduring\sthe\ssame\scall.
-D 2015-09-22T00:21:03.350
+C Futher\ssimplifications\sto\sjson1.c.\s\sAlso\san\sobscure\sbug-fix\sin\sthe\sinitial\noutput\sof\sjson_tree()\swhen\susing\sa\spath\sto\san\sobject\scontained\swithin\san\sarray.
+D 2015-09-22T01:15:49.994
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2047811644c5bac91ccdfc2720e49b60965a63a7
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -195,7 +195,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
 F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767
 F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e
-F ext/misc/json1.c c5e7018b8fe23ba778a24d918724b5963ecaa689
+F ext/misc/json1.c 8eefcbdc172e9eff3c613016260c2d82893c12f2
 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc
@@ -1387,7 +1387,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 737ac3faf4e5fcb5855f5f9a1c1ddfc5424e6292
-R 95f992a7687b0db3b0df98a691005bc0
+P 0f16041647993975c316203c7e11f06e27640136
+R 062ca531bf3a825489a40d6145bed1f2
 U drh
-Z 7a61ae480ab77880b942dd9dc8577d84
+Z 6b7ed4fd95fc512864c2dd577eb1b3dd
index 12b88baa1d4914a6d33521703c661cf18d7ba137..26ccba6500980cb637bfefcd6fd4934be120ba17 100644 (file)
@@ -1 +1 @@
-0f16041647993975c316203c7e11f06e27640136
\ No newline at end of file
+fcb1e327a64134e5ac539ec3d52733422d3061fd
\ No newline at end of file