mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Improvements to error messages returned when the ->> operator fails.
FossilOrigin-Name: 2f3388f14c843f1c02926e8b929365c06c1f1f4ea6fe6316092c3799c14549d3
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Merge\sthe\smemory\sleak\sfix\sfrom\strunk.
|
C Improvements\sto\serror\smessages\sreturned\swhen\sthe\s->>\soperator\sfails.
|
||||||
D 2023-10-07T11:37:00.963
|
D 2023-10-07T17:50:06.014
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -670,7 +670,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
|||||||
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
||||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||||
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
||||||
F src/json.c 969f4897a681aa786f77ed7122db07475cf95f473d3a2de2572ffae600ec0ac1
|
F src/json.c a5d273004e0b0d4b961efe59b403c5b118218b3db2c2d61b4512ea2815ada8b2
|
||||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||||
F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0
|
F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0
|
||||||
F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40
|
F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40
|
||||||
@@ -2124,8 +2124,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 96cfdc31e305406123f6ef1b920423f71902dc4b34381c3efb720274343d37cc f99ff655d09763c4a22d065041644ece793d84c82c644931e89ccf50c4f4564a
|
P 358de1b09f3d5ec0fe459775b0a2a99dfa235817327016b472aaa1ed56d952e6
|
||||||
R 9cb62826bab57bac8933243b48ca592e
|
R 65b1837fdcd2785b2dbe03dd6bcb09bb
|
||||||
U drh
|
U drh
|
||||||
Z cdf0570fe999933e060b2c73f0eb1dc1
|
Z f25f60a6b37a3fc4a80bb7878104ebfa
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
358de1b09f3d5ec0fe459775b0a2a99dfa235817327016b472aaa1ed56d952e6
|
2f3388f14c843f1c02926e8b929365c06c1f1f4ea6fe6316092c3799c14549d3
|
||||||
29
src/json.c
29
src/json.c
@@ -3696,8 +3696,7 @@ static u32 jsonbArrayCount(JsonParse *pParse, u32 iRoot){
|
|||||||
static u32 jsonLookupBlobStep(
|
static u32 jsonLookupBlobStep(
|
||||||
JsonParse *pParse, /* The JSON to search */
|
JsonParse *pParse, /* The JSON to search */
|
||||||
u32 iRoot, /* Begin the search at this element of aBlob[] */
|
u32 iRoot, /* Begin the search at this element of aBlob[] */
|
||||||
const char *zPath, /* The path to search */
|
const char *zPath /* The path to search */
|
||||||
const char **pzErr /* Make *pzErr point to any syntax error in zPath */
|
|
||||||
){
|
){
|
||||||
u32 i, j, k, nKey, sz, n, iEnd;
|
u32 i, j, k, nKey, sz, n, iEnd;
|
||||||
const char *zKey;
|
const char *zKey;
|
||||||
@@ -3707,7 +3706,6 @@ static u32 jsonLookupBlobStep(
|
|||||||
if( zPath[0]==0 ) return iRoot;
|
if( zPath[0]==0 ) return iRoot;
|
||||||
if( zPath[0]=='.' ){
|
if( zPath[0]=='.' ){
|
||||||
x = pParse->aBlob[iRoot];
|
x = pParse->aBlob[iRoot];
|
||||||
if( (x & 0x0f)!=JSONB_OBJECT ) return JSON_BLOB_NOTFOUND;
|
|
||||||
zPath++;
|
zPath++;
|
||||||
if( zPath[0]=='"' ){
|
if( zPath[0]=='"' ){
|
||||||
zKey = zPath + 1;
|
zKey = zPath + 1;
|
||||||
@@ -3716,7 +3714,6 @@ static u32 jsonLookupBlobStep(
|
|||||||
if( zPath[i] ){
|
if( zPath[i] ){
|
||||||
i++;
|
i++;
|
||||||
}else{
|
}else{
|
||||||
*pzErr = "unterminated \"";
|
|
||||||
return JSON_BLOB_PATHERROR;
|
return JSON_BLOB_PATHERROR;
|
||||||
}
|
}
|
||||||
testcase( nKey==0 );
|
testcase( nKey==0 );
|
||||||
@@ -3725,10 +3722,10 @@ static u32 jsonLookupBlobStep(
|
|||||||
for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){}
|
for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){}
|
||||||
nKey = i;
|
nKey = i;
|
||||||
if( nKey==0 ){
|
if( nKey==0 ){
|
||||||
*pzErr = zPath;
|
return JSON_BLOB_PATHERROR;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( (x & 0x0f)!=JSONB_OBJECT ) return JSON_BLOB_NOTFOUND;
|
||||||
n = jsonbPayloadSize(pParse, iRoot, &sz);
|
n = jsonbPayloadSize(pParse, iRoot, &sz);
|
||||||
j = iRoot + n;
|
j = iRoot + n;
|
||||||
iEnd = j+sz;
|
iEnd = j+sz;
|
||||||
@@ -3744,7 +3741,7 @@ static u32 jsonLookupBlobStep(
|
|||||||
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
|
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
|
||||||
n = jsonbPayloadSize(pParse, j, &sz);
|
n = jsonbPayloadSize(pParse, j, &sz);
|
||||||
if( n==0 || j+n+sz>iEnd ) return JSON_BLOB_ERROR;
|
if( n==0 || j+n+sz>iEnd ) return JSON_BLOB_ERROR;
|
||||||
return jsonLookupBlobStep(pParse, j, &zPath[i], pzErr);
|
return jsonLookupBlobStep(pParse, j, &zPath[i]);
|
||||||
}
|
}
|
||||||
j = k+sz;
|
j = k+sz;
|
||||||
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
|
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
|
||||||
@@ -3778,11 +3775,9 @@ static u32 jsonLookupBlobStep(
|
|||||||
k -= nn;
|
k -= nn;
|
||||||
}
|
}
|
||||||
if( zPath[i]!=']' ){
|
if( zPath[i]!=']' ){
|
||||||
*pzErr = "unterminated [";
|
|
||||||
return JSON_BLOB_PATHERROR;
|
return JSON_BLOB_PATHERROR;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
*pzErr = "bad argument to []";
|
|
||||||
return JSON_BLOB_PATHERROR;
|
return JSON_BLOB_PATHERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3790,7 +3785,7 @@ static u32 jsonLookupBlobStep(
|
|||||||
iEnd = j+sz;
|
iEnd = j+sz;
|
||||||
while( j<iEnd ){
|
while( j<iEnd ){
|
||||||
if( k==0 ){
|
if( k==0 ){
|
||||||
return jsonLookupBlobStep(pParse, j, &zPath[i+1], pzErr);
|
return jsonLookupBlobStep(pParse, j, &zPath[i+1]);
|
||||||
}
|
}
|
||||||
k--;
|
k--;
|
||||||
n = jsonbPayloadSize(pParse, j, &sz);
|
n = jsonbPayloadSize(pParse, j, &sz);
|
||||||
@@ -3799,7 +3794,6 @@ static u32 jsonLookupBlobStep(
|
|||||||
}
|
}
|
||||||
if( j>iEnd ) return JSON_BLOB_ERROR;
|
if( j>iEnd ) return JSON_BLOB_ERROR;
|
||||||
}else{
|
}else{
|
||||||
*pzErr = "syntax error";
|
|
||||||
return JSON_BLOB_PATHERROR;
|
return JSON_BLOB_PATHERROR;
|
||||||
}
|
}
|
||||||
return JSON_BLOB_NOTFOUND;
|
return JSON_BLOB_NOTFOUND;
|
||||||
@@ -4011,7 +4005,6 @@ static void jsonExtractFromBlob(
|
|||||||
int flags
|
int flags
|
||||||
){
|
){
|
||||||
const char *zPath = (const char*)sqlite3_value_text(pPath);
|
const char *zPath = (const char*)sqlite3_value_text(pPath);
|
||||||
const char *zErr = 0;
|
|
||||||
u32 i = 0;
|
u32 i = 0;
|
||||||
JsonParse px;
|
JsonParse px;
|
||||||
if( zPath==0 ) return;
|
if( zPath==0 ) return;
|
||||||
@@ -4021,7 +4014,7 @@ static void jsonExtractFromBlob(
|
|||||||
if( px.aBlob==0 ) return;
|
if( px.aBlob==0 ) return;
|
||||||
if( zPath[0]=='$' ){
|
if( zPath[0]=='$' ){
|
||||||
zPath++;
|
zPath++;
|
||||||
i = jsonLookupBlobStep(&px, 0, zPath, &zErr);
|
i = jsonLookupBlobStep(&px, 0, zPath);
|
||||||
}else if( (flags & JSON_ABPATH) ){
|
}else if( (flags & JSON_ABPATH) ){
|
||||||
/* The -> and ->> operators accept abbreviated PATH arguments. This
|
/* The -> and ->> operators accept abbreviated PATH arguments. This
|
||||||
** is mostly for compatibility with PostgreSQL, but also for
|
** is mostly for compatibility with PostgreSQL, but also for
|
||||||
@@ -4044,7 +4037,7 @@ static void jsonExtractFromBlob(
|
|||||||
jsonAppendChar(&jx, 0);
|
jsonAppendChar(&jx, 0);
|
||||||
zPath = jx.zBuf;
|
zPath = jx.zBuf;
|
||||||
}
|
}
|
||||||
i = jsonLookupBlobStep(&px, 0, zPath, &zErr);
|
i = jsonLookupBlobStep(&px, 0, zPath);
|
||||||
jsonStringReset(&jx);
|
jsonStringReset(&jx);
|
||||||
}else{
|
}else{
|
||||||
sqlite3_result_error(ctx, "bad path", -1);
|
sqlite3_result_error(ctx, "bad path", -1);
|
||||||
@@ -4056,13 +4049,11 @@ static void jsonExtractFromBlob(
|
|||||||
return; /* Return NULL if not found */
|
return; /* Return NULL if not found */
|
||||||
}else if( i==JSON_BLOB_ERROR ){
|
}else if( i==JSON_BLOB_ERROR ){
|
||||||
sqlite3_result_error(ctx, "malformed JSON", -1);
|
sqlite3_result_error(ctx, "malformed JSON", -1);
|
||||||
}else if( i==JSON_BLOB_PATHERROR ){
|
}else{
|
||||||
char *zMsg = sqlite3_mprintf("in JSON path '%s': %s",
|
char *zMsg = sqlite3_mprintf("bad path syntax: %s",
|
||||||
sqlite3_value_text(pPath), zErr);
|
sqlite3_value_text(pPath));
|
||||||
sqlite3_result_error(ctx, zMsg, -1);
|
sqlite3_result_error(ctx, zMsg, -1);
|
||||||
sqlite3_free(zMsg);
|
sqlite3_free(zMsg);
|
||||||
}else{
|
|
||||||
sqlite3_result_error(ctx, zErr, -1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user