mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Fix the PG-compatible -> and ->> path parsing.
FossilOrigin-Name: 22d5138315fb77eeea1c7e66ccc4190bcae18d058a99aa37ddd119e54b52f723
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\stypo\sin\sthe\sjson-enhancements.md\sdocument.
|
C Fix\sthe\sPG-compatible\s->\sand\s->>\spath\sparsing.
|
||||||
D 2022-01-10T17:43:54.652
|
D 2022-01-11T18:01:17.466
|
||||||
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
|
||||||
@@ -512,7 +512,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
|||||||
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
|
||||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||||
F src/insert.c e528416ff5d86fc5d656ea6a26f03fde39836b6175f93048c32a03cb2ee16743
|
F src/insert.c e528416ff5d86fc5d656ea6a26f03fde39836b6175f93048c32a03cb2ee16743
|
||||||
F src/json.c d3134d392d88cb21ab352dd877b901ee5d46e6404fc1321f77cf67bb4d4dc9d3
|
F src/json.c 5dee750a85262600817f20e3ced050f9c2a47d8c3db77f31f4ee379c0f843a8a
|
||||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||||
F src/loadext.c 95db1fe62c5973f1c5d9c53f6083e21a73ece14cdd47eeca0639691332e85c4d
|
F src/loadext.c 95db1fe62c5973f1c5d9c53f6083e21a73ece14cdd47eeca0639691332e85c4d
|
||||||
F src/main.c 2b6b0dbfeb14d4bb57e368604b0736b2aa42b51b00339d399b01d6b1fc9b4960
|
F src/main.c 2b6b0dbfeb14d4bb57e368604b0736b2aa42b51b00339d399b01d6b1fc9b4960
|
||||||
@@ -1938,8 +1938,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 39eff3b9bf1f318d3606d8e5361a2adb2ba8bc1ca2a436ce4f9a204aa4cf20dd
|
P feba24ef774d80ebbaf87a93fc106cb7e482edcc3f237edd4c9d4e918ffb3131
|
||||||
R 8ac564d1981cf04622f1f15a60ba0e5b
|
R 0007d377d0ed1c0dc1f81b209b625ab0
|
||||||
U drh
|
U drh
|
||||||
Z c237913f633491314765f45ba87ab8df
|
Z e45b9675c3fefc0ecfe81398e8f3bbb1
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
feba24ef774d80ebbaf87a93fc106cb7e482edcc3f237edd4c9d4e918ffb3131
|
22d5138315fb77eeea1c7e66ccc4190bcae18d058a99aa37ddd119e54b52f723
|
||||||
47
src/json.c
47
src/json.c
@@ -1549,36 +1549,39 @@ static void jsonExtractFunc(
|
|||||||
/* With a single PATH argument */
|
/* With a single PATH argument */
|
||||||
zPath = (const char*)sqlite3_value_text(argv[1]);
|
zPath = (const char*)sqlite3_value_text(argv[1]);
|
||||||
if( zPath==0 ) return;
|
if( zPath==0 ) return;
|
||||||
if( zPath[0]!='$' && (flags & JSON_ABPATH)!=0 ){
|
if( flags & JSON_ABPATH ){
|
||||||
/* The -> and ->> operators accept abbreviated PATH arguments. This
|
if( zPath[0]!='$' ){
|
||||||
** is mostly for compatibility with PostgreSQL, but also for convenience.
|
/* The -> and ->> operators accept abbreviated PATH arguments. This
|
||||||
**
|
** is mostly for compatibility with PostgreSQL, but also for
|
||||||
** NUMBER ==> $[NUMBER] // PG compatible
|
** convenience.
|
||||||
** LABEL ==> $.LABEL // PG compatible
|
**
|
||||||
** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
|
** NUMBER ==> $[NUMBER] // PG compatible
|
||||||
*/
|
** LABEL ==> $.LABEL // PG compatible
|
||||||
jsonInit(&jx, ctx);
|
** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
|
||||||
if( sqlite3Isdigit(zPath[0]) ){
|
*/
|
||||||
jsonAppendRaw(&jx, "$[", 2);
|
jsonInit(&jx, ctx);
|
||||||
jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
|
if( sqlite3Isdigit(zPath[0]) ){
|
||||||
jsonAppendRaw(&jx, "]", 2);
|
jsonAppendRaw(&jx, "$[", 2);
|
||||||
|
jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
|
||||||
|
jsonAppendRaw(&jx, "]", 2);
|
||||||
|
}else{
|
||||||
|
jsonAppendRaw(&jx, "$.", 1 + (zPath[0]!='['));
|
||||||
|
jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
|
||||||
|
jsonAppendChar(&jx, 0);
|
||||||
|
}
|
||||||
|
pNode = jx.bErr ? 0 : jsonLookup(p, jx.zBuf, 0, ctx);
|
||||||
|
jsonReset(&jx);
|
||||||
}else{
|
}else{
|
||||||
jsonAppendRaw(&jx, "$.", 1 + (zPath[0]!='['));
|
pNode = jsonLookup(p, zPath, 0, ctx);
|
||||||
jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
|
|
||||||
jsonAppendChar(&jx, 0);
|
|
||||||
}
|
}
|
||||||
if( jx.bErr==0 ){
|
if( pNode ){
|
||||||
pNode = jsonLookup(p, jx.zBuf, 0, ctx);
|
if( flags & JSON_JSON ){
|
||||||
if( pNode==0 ){
|
|
||||||
/* No-op. jsonLookup will have left an error for us */
|
|
||||||
}else if( flags & JSON_JSON ){
|
|
||||||
jsonReturnJson(pNode, ctx, 0);
|
jsonReturnJson(pNode, ctx, 0);
|
||||||
}else{
|
}else{
|
||||||
jsonReturn(pNode, ctx, 0);
|
jsonReturn(pNode, ctx, 0);
|
||||||
sqlite3_result_subtype(ctx, 0);
|
sqlite3_result_subtype(ctx, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonReset(&jx);
|
|
||||||
}else{
|
}else{
|
||||||
pNode = jsonLookup(p, zPath, 0, ctx);
|
pNode = jsonLookup(p, zPath, 0, ctx);
|
||||||
if( p->nErr==0 && pNode ) jsonReturn(pNode, ctx, 0);
|
if( p->nErr==0 && pNode ) jsonReturn(pNode, ctx, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user