From cf72606a7d05c7fc3b51ba596db013d51eb73d4b Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 Nov 2023 22:36:32 +0000 Subject: Inserts invalid JSONB should return "malformed JSON", not a json path error. FossilOrigin-Name: 306ee66fbd0231a9f5b229e5630d5cc66c9cf08b466d2d9204e79e1f44a16374 --- src/json.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/json.c') diff --git a/src/json.c b/src/json.c index 69557aa72..54e221392 100644 --- a/src/json.c +++ b/src/json.c @@ -4427,7 +4427,7 @@ static void jsonInsertIntoBlob( int eEdit /* JEDIT_INS, JEDIT_REPL, or JEDIT_SET */ ){ int i; - u32 rc; + u32 rc = 0; const char *zPath = 0; int flgs; JsonParse px, ax; @@ -4471,7 +4471,11 @@ static void jsonInsertIntoBlob( jsonInsertIntoBlob_patherror: if( px.nBlobAlloc ) sqlite3_free(px.aBlob); - jsonPathSyntaxError(zPath, ctx); + if( rc==JSON_BLOB_ERROR ){ + sqlite3_result_error(ctx, "malformed JSON", -1); + }else{ + jsonPathSyntaxError(zPath, ctx); + } return; } -- cgit v1.2.3