]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor simplification to JSON path error reporting.
authordrh <>
Tue, 24 Mar 2026 11:25:44 +0000 (11:25 +0000)
committerdrh <>
Tue, 24 Mar 2026 11:25:44 +0000 (11:25 +0000)
FossilOrigin-Name: 1cd30c4827e382861cf12af48579eedc9685b9612dedb6a2844f20355b910e7e

manifest
manifest.uuid
src/json.c

index 38c95b8042d4d35aeacb505474ad390d9c1cb9c5..ada62db7f16cb2afea629b0e74c1b7e7ea013afb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Recognize\sartifical\sJSONB\sblobs\swith\sdeep\srecursion\sas\sbeing\sill-formed.
-D 2026-03-24T00:31:28.162
+C Minor\ssimplification\sto\sJSON\spath\serror\sreporting.
+D 2026-03-24T11:25:44.474
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -694,7 +694,7 @@ F src/hash.h 46b92795a95bfefb210f52f0c316e9d7cdbcdd7e7fcfb0d8be796d3a5767cddf
 F src/hwtime.h 21c2cf1f736e7b97502c3674d0c386db3f06870d6f10d0cf8174e2a4b8cb726e
 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
 F src/insert.c dfd311b0ac2d4f6359e62013db67799757f4d2cc56cca5c10f4888acfbbfa3fd
-F src/json.c 5768278f0d25c8a29f260efb6cb66ddbdb635de7d3d0f2b6da1d11e9f5989876
+F src/json.c b2e4b71740825ae92170b7abf8b30e42eca64ade30eb34fbdd27d8598b2248ad
 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
 F src/loadext.c 187929338d21f43cbdea359a3c1ec61294f39b7f9032e824c1dbb79f9994c838
 F src/main.c 31a13302193fbd51279c7e69cdfa0320d0de7629f9151e0964c1d320e8bdd7a4
@@ -2195,8 +2195,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 6b3d84d34d1a84eb8ddff08cd85d9dff6e71099e7a4b2c19db8774d942d3a040
-R 5eb812c0a84e63f8ff00aeb0693e545a
+P adac4ed1f13a9a1c4a34c8f59438eac68867981748629ca3957055ad9f940299
+R d7c4a72f588f42f424f9631fb25edda4
 U drh
-Z 1b6a6a92fadad7a1745dc38064bea53f
+Z d6560f44df864865afe983cc9283e3ff
 # Remove this line to create a well-formed Fossil manifest.
index a5c0110a05e080dc68813fa6f646e5cea53ca094..193162e565f9ae571d3a563ba73f7af91bb5cd8d 100644 (file)
@@ -1 +1 @@
-adac4ed1f13a9a1c4a34c8f59438eac68867981748629ca3957055ad9f940299
+1cd30c4827e382861cf12af48579eedc9685b9612dedb6a2844f20355b910e7e
index fef276abd48431e77d26750e676b2fd3a4d4dea4..01aa274a3157491b0302cc772d0a331c2b2be1fa 100644 (file)
@@ -3457,7 +3457,15 @@ static int jsonFunctionArgToBlob(
 }
 
 /*
-** Generate a bad path error.
+** Generate a path error.
+**
+** The specifics of the error are determined by the rc argument.
+**
+**          rc                   error
+**  -----------------       ----------------
+**  JSON_LOOKUP_ARRAY       "not an array"
+**  JSON_LOOKUP_ERROR       "malformed JSON"
+**  otherwise...            "bad JSON path"
 **
 ** If ctx is not NULL then push the error message into ctx and return NULL.
 ** If ctx is NULL, then return the text of the error message.
@@ -3470,6 +3478,8 @@ static char *jsonBadPathError(
   char *zMsg;
   if( rc==(int)JSON_LOOKUP_NOTARRAY ){
     zMsg = sqlite3_mprintf("not an array element: %Q", zPath);
+  }else if( rc==(int)JSON_LOOKUP_ERROR ){
+    zMsg = sqlite3_mprintf("malformed JSON");
   }else{
     zMsg = sqlite3_mprintf("bad JSON path: %Q", zPath);
   }
@@ -3544,11 +3554,7 @@ static void jsonInsertIntoBlob(
 
 jsonInsertIntoBlob_patherror:
   jsonParseFree(p);
-  if( rc==JSON_LOOKUP_ERROR ){
-    sqlite3_result_error(ctx, "malformed JSON", -1);
-  }else{
-    jsonBadPathError(ctx, zPath, rc);
-  }
+  jsonBadPathError(ctx, zPath, rc);
   return;
 }
 
@@ -3988,10 +3994,8 @@ static void jsonArrayLengthFunc(
     if( JSON_LOOKUP_ISERROR(i) ){
       if( i==JSON_LOOKUP_NOTFOUND ){
         /* no-op */
-      }else if( i==JSON_LOOKUP_PATHERROR ){
-        jsonBadPathError(ctx, zPath, 0);
       }else{
-        sqlite3_result_error(ctx, "malformed JSON", -1);
+        jsonBadPathError(ctx, zPath, i);
       }
       eErr = 1;
       i = 0;
@@ -4125,11 +4129,8 @@ static void jsonExtractFunc(
         jsonAppendSeparator(&jx);
         jsonAppendRawNZ(&jx, "null", 4);
       }
-    }else if( j==JSON_LOOKUP_ERROR ){
-      sqlite3_result_error(ctx, "malformed JSON", -1);
-      goto json_extract_error;
     }else{
-      jsonBadPathError(ctx, zPath, 0);
+      jsonBadPathError(ctx, zPath, j);
       goto json_extract_error;
     }
   }
@@ -4457,10 +4458,8 @@ static void jsonRemoveFunc(
     if( JSON_LOOKUP_ISERROR(rc) ){
       if( rc==JSON_LOOKUP_NOTFOUND ){
         continue;  /* No-op */
-      }else if( rc==JSON_LOOKUP_PATHERROR ){
-        jsonBadPathError(ctx, zPath, rc);
       }else{
-        sqlite3_result_error(ctx, "malformed JSON", -1);
+        jsonBadPathError(ctx, zPath, rc);
       }
       goto json_remove_done;
     }
@@ -4557,10 +4556,8 @@ static void jsonTypeFunc(
     if( JSON_LOOKUP_ISERROR(i) ){
       if( i==JSON_LOOKUP_NOTFOUND ){
         /* no-op */
-      }else if( i==JSON_LOOKUP_PATHERROR ){
-        jsonBadPathError(ctx, zPath, 0);
       }else{
-        sqlite3_result_error(ctx, "malformed JSON", -1);
+        jsonBadPathError(ctx, zPath, i);
       }
       goto json_type_done;
     }