1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Change the json_valid(X) routine to return true whenever X is a blob that

could plausibly be a valid JSONB.

FossilOrigin-Name: 425f0b85a6f8ad0604c4a5faa18efb90436fedb1fe2612a559147c62cff8b7e7
This commit is contained in:
drh
2023-10-05 18:09:12 +00:00
parent 14fce24a9b
commit 5b6cfb7906
3 changed files with 19 additions and 9 deletions

View File

@@ -4812,8 +4812,14 @@ static void jsonTypeFunc(
/*
** json_valid(JSON)
**
** Return 1 if JSON is a well-formed canonical JSON string according
** to RFC-7159. Return 0 otherwise.
** Return 1 if the argument is one of:
**
** * A well-formed canonical JSON string according to RFC-8259
** (without JSON5 enhancements), or
**
** * A BLOB that plausibly could be a JSONB value.
**
** Return 0 otherwise.
*/
static void jsonValidFunc(
sqlite3_context *ctx,
@@ -4829,6 +4835,10 @@ static void jsonValidFunc(
#endif
return;
}
if( jsonFuncArgMightBeBinary(argv[0]) ){
sqlite3_result_int(ctx, 1);
return;
}
p = jsonParseCached(ctx, argv[0], 0, 0);
if( p==0 || p->oom ){
sqlite3_result_error_nomem(ctx);