Do not set the J subtype when the output is JSONB.

FossilOrigin-Name: 4f106b64fe8988435872806bd0a6c223b61f53af0dd1c47c847bb4eec4e03e27
This commit is contained in:
drh 2023-11-28 23:18:04 +00:00
parent 1ef232c0e1
commit 1f8c7c7053
3 changed files with 14 additions and 72 deletions

View File

@ -1,5 +1,5 @@
C Preserve\sflexibility\sin\sthe\sformat\sof\sthe\sRHS\sof\s->\sand\s->>\soperators\sfound\nin\slegacy.
D 2023-11-28T20:33:20.843
C Do\snot\sset\sthe\sJ\ssubtype\swhen\sthe\soutput\sis\sJSONB.
D 2023-11-28T23:18:04.442
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -688,7 +688,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
F src/json.c 4dfa914bc57559ba1ee7e67211b7146d6ea522630fa2b51ddbc9244097d50b2b
F src/json.c dd5c3f52877448cc9644887e83a2ff33ab0be87e158de7d5a86db12f90b28045
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
@ -2145,8 +2145,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8c324af1eca27e86adc45622af4f3b06a67a3f968596ac58aa7434b1f6f05f3c
R 8969d2e433c13563f53a82b455df93bc
P 6231ec43adb7436195eb1497de39a6c13c6b4f1c5032e6ea52515d214e61fdbc
R e440543ab70160e0cdb3ca23863ac507
U drh
Z 4af78bee74fbed5f3138fbbbd5c5ff0e
Z d79a3adcec115b27b232bb847ce59659
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
6231ec43adb7436195eb1497de39a6c13c6b4f1c5032e6ea52515d214e61fdbc
4f106b64fe8988435872806bd0a6c223b61f53af0dd1c47c847bb4eec4e03e27

View File

@ -4043,69 +4043,6 @@ static void jsonReturnFromBlob(
}
}
#if 0
/* Do a JSON_EXTRACT(JSON, PATH) on a when JSON is a BLOB.
*/
static void jsonExtractFromBlob(
sqlite3_context *ctx,
sqlite3_value *pJson,
sqlite3_value *pPath,
int flags
){
const char *zPath = (const char*)sqlite3_value_text(pPath);
u32 i = 0;
JsonParse px;
if( zPath==0 ) return;
memset(&px, 0, sizeof(px));
px.nBlob = sqlite3_value_bytes(pJson);
px.aBlob = (u8*)sqlite3_value_blob(pJson);
if( px.aBlob==0 ) return;
if( zPath[0]=='$' ){
zPath++;
i = jsonLookupBlobStep(&px, 0, zPath, 0);
}else if( (flags & JSON_ABPATH) ){
/* The -> and ->> operators accept abbreviated PATH arguments. This
** is mostly for compatibility with PostgreSQL, but also for
** convenience.
**
** NUMBER ==> $[NUMBER] // PG compatible
** LABEL ==> $.LABEL // PG compatible
** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
*/
JsonString jx;
jsonStringInit(&jx, ctx);
if( sqlite3Isdigit(zPath[0]) ){
jsonAppendRawNZ(&jx, "[", 1);
jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
jsonAppendRawNZ(&jx, "]", 2);
zPath = jx.zBuf;
}else if( zPath[0]!='[' ){
jsonAppendRawNZ(&jx, ".", 1);
jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
jsonAppendChar(&jx, 0);
zPath = jx.zBuf;
}
i = jsonLookupBlobStep(&px, 0, zPath, 0);
jsonStringReset(&jx);
}else{
sqlite3_result_error(ctx, "bad path", -1);
return;
}
if( i<px.nBlob ){
jsonReturnFromBlob(&px, i, ctx, 0);
}else if( i==JSON_BLOB_NOTFOUND ){
return; /* Return NULL if not found */
}else if( i==JSON_BLOB_ERROR ){
sqlite3_result_error(ctx, "malformed JSON", -1);
}else{
char *zMsg = sqlite3_mprintf("bad path syntax: %s",
sqlite3_value_text(pPath));
sqlite3_result_error(ctx, zMsg, -1);
sqlite3_free(zMsg);
}
}
#endif
/*
** pArg is a function argument that might be an SQL value or a JSON
** value. Figure out what it is and encode it as a JSONB blob.
@ -4741,10 +4678,13 @@ static void jsonExtractFunc(
jsonXlateBlobToText(p, j, &jx);
jsonReturnString(&jx);
jsonStringReset(&jx);
assert( (flags & JSON_BLOB)==0 );
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
}else{
jsonReturnFromBlob(p, j, ctx, 0);
if( (flags & JSON_SQL)==0 && (p->aBlob[j]&0x0f)>=JSONB_ARRAY ){
if( (flags & (JSON_SQL|JSON_BLOB))==0
&& (p->aBlob[j]&0x0f)>=JSONB_ARRAY
){
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
}
}
@ -4770,7 +4710,9 @@ static void jsonExtractFunc(
if( argc>2 ){
jsonAppendChar(&jx, ']');
jsonReturnString(&jx);
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
if( (flags & JSON_BLOB)==0 ){
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
}
}
json_extract_error:
jsonStringReset(&jx);