aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2023-12-11 20:44:21 +0000
committerdrh <>2023-12-11 20:44:21 +0000
commit5a890b4ed2b0f5732fa370dfbae295aa41748e0b (patch)
treecc79f3b64ceaeb2ed38779659b4c4660ab423c3f /src
parent001caa714fc29ca13aa86605aa2c18a47f875430 (diff)
downloadsqlite-5a890b4ed2b0f5732fa370dfbae295aa41748e0b.tar.gz
sqlite-5a890b4ed2b0f5732fa370dfbae295aa41748e0b.zip
json_error_position() now uses jsonValidityCheck() to find the approximate
position of an error in a JSONB blob. FossilOrigin-Name: c3d60cf7028a333b825d5b89516945a73e0c158ac81d8bcc117d21bfd98602c8
Diffstat (limited to 'src')
-rw-r--r--src/json.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/json.c b/src/json.c
index b73598773..fd741f696 100644
--- a/src/json.c
+++ b/src/json.c
@@ -4170,9 +4170,9 @@ static void jsonValidFunc(
**
** If the argument is NULL, return NULL
**
-** If the argument is BLOB, do a fast validity check and return non-zero
-** if the check fails. The returned value does not indicate where in the
-** BLOB the error occurs.
+** If the argument is BLOB, do a full validity check and return non-zero
+** if the check fails. The return value is the approximate 1-based offset
+** to the byte of the element that contains the first error.
**
** Otherwise interpret the argument is TEXT (even if it is numeric) and
** return the 1-based character position for where the parser first recognized
@@ -4191,15 +4191,9 @@ static void jsonErrorFunc(
UNUSED_PARAMETER(argc);
memset(&s, 0, sizeof(s));
if( jsonFuncArgMightBeBinary(argv[0]) ){
- JsonString out;
- jsonStringInit(&out, 0);
s.aBlob = (u8*)sqlite3_value_blob(argv[0]);
s.nBlob = sqlite3_value_bytes(argv[0]);
- jsonXlateBlobToText(&s, 0, &out);
- if( out.eErr ){
- iErrPos = (out.eErr & JSTRING_MALFORMED)!=0 ? 1 : -1;
- }
- jsonStringReset(&out);
+ iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 0);
}else{
s.zJson = (char*)sqlite3_value_text(argv[0]);
if( s.zJson==0 ) return; /* NULL input or OOM */