From 2c72c55dcac876e61a10b672489985f000038eff Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 5 Oct 2024 21:44:21 +0000 Subject: [PATCH 1/5] Back out [2f7eab381e16] because the stderr output on systems without gmake causes grief in the testing tools. FossilOrigin-Name: cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 --- Makefile.in | 2 -- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 91ba94c1aa..6fc821da23 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1663,13 +1663,11 @@ tidy: # clean: tidy rm -rf omittest* testrunner* testdir* - -gmake -C ext/wasm clean # Clean up everything. No exceptions. # distclean: clean rm -f sqlite_cfg.h config.log config.status Makefile $(LIBTOOL) - -gmake -C ext/wasm distclean # # Windows section diff --git a/manifest b/manifest index 3a576a9093..8c049eb6a7 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\sext/wasm\sto\sthe\stop-level\sclean/distclean\srules\sin\ssuch\sa\sway\sthat\sany\serror\sdue\sto\sa\slack\sof\sgmake\sare\signored. -D 2024-10-05T12:02:17.445 +C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools. +D 2024-10-05T21:44:21.913 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 71c69b6eb6d8a5e2d418ab80d16f3621099d58f8afabe4ab0d7240c5ca57494a +F Makefile.in 6a826facc78c3c8ad38bf00ed588f6aa3665ccd7a9749b891d20582fc290c77e F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 9c6d80d9d103fa42e931f4c464884a5e577fae8563acc7589bff4e43fbe8f864 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e -R 749ae8645be170a25b1c641eade23387 +P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f +R 97cc1dd0446101afb82e95a43b8cd5d1 U stephan -Z c3b0bf3081778b6e6721957f472a53c9 +Z 6431efa2a9010e78c1fbe7fa1b33270f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 717f299acd..aec7c8a62f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f +cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 From 74672acd946d12d23f65c3e07f9f88e407784145 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 6 Oct 2024 15:01:31 +0000 Subject: [PATCH 2/5] New SQL function for testing/debugging use only: parseuri(). FossilOrigin-Name: 37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 --- manifest | 17 ++++++----- manifest.uuid | 2 +- src/func.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 95 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8c049eb6a7..39ed9b3502 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools. -D 2024-10-05T21:44:21.913 +C New\sSQL\sfunction\sfor\stesting/debugging\suse\sonly:\sparseuri(). +D 2024-10-06T15:01:31.737 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,7 +722,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f -F src/func.c df400a1d3f4625997d4dd8a81951c303e066277c29b861d37e03cd152d7858dd +F src/func.c ed6baeeb414ef18ce729793587dae8bd30f11e6aacec8675bd33727e0bcb3765 F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2215,8 +2215,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f -R 97cc1dd0446101afb82e95a43b8cd5d1 -U stephan -Z 6431efa2a9010e78c1fbe7fa1b33270f +P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +R 6e07384677af3f3c36d6573a7730f2e0 +T *branch * parseuri +T *sym-parseuri * +T -sym-trunk * +U drh +Z a932a90a1e85d41407c9c1eb7bdee53f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aec7c8a62f..68845d202e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 diff --git a/src/func.c b/src/func.c index a634a7fbea..b17ffa52c4 100644 --- a/src/func.c +++ b/src/func.c @@ -2535,7 +2535,13 @@ static void signFunc( ** Implementation of fpdecode(x,y,z) function. ** ** x is a real number that is to be decoded. y is the precision. -** z is the maximum real precision. +** z is the maximum real precision. Return a string that shows the +** results of the sqlite3FpDecode() function. +** +** Used for testing and debugging only, specifically testing and debugging +** of the sqlite3FpDecode() function. This SQL function does not appear +** in production builds. This function is not an API and is subject to +** modification or removal in future versions of SQLite. */ static void fpdecodeFunc( sqlite3_context *context, @@ -2562,6 +2568,82 @@ static void fpdecodeFunc( } #endif /* SQLITE_DEBUG */ +#ifdef SQLITE_DEBUG +/* +** Implementation of parseuri(uri,flags) function. +** +** Required Arguments: +** "uri" The URI to parse. +** "flags" Bitmask of flags, as if to sqlite3_open_v2(). +** +** Additional arguments beyond the first two make calls to +** sqlite3_uri_key() for integers and sqlite3_uri_parameter for +** anything else. +** +** The result is a string showing the results of calling sqlite3ParseUri(). +** +** Used for testing and debugging only, specifically testing and debugging +** of the sqlite3ParseUri() function. This SQL function does not appear +** in production builds. This function is not an API and is subject to +** modification or removal in future versions of SQLite. +*/ +static void parseuriFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + sqlite3_str *pResult; + const char *zVfs; + const char *zUri; + unsigned int flgs; + int rc; + sqlite3_vfs *pVfs = 0; + char *zFile = 0; + char *zErr = 0; + + if( argc<2 ) return; + pVfs = sqlite3_vfs_find(0); + assert( pVfs ); + zVfs = pVfs->zName; + zUri = (const char*)sqlite3_value_text(argv[0]); + if( zUri==0 ) return; + flgs = (unsigned int)sqlite3_value_int(argv[1]); + rc = sqlite3ParseUri(zVfs, zUri, &flgs, &pVfs, &zFile, &zErr); + pResult = sqlite3_str_new(0); + if( pResult ){ + int i; + sqlite3_str_appendf(pResult, "rc=%d", rc); + sqlite3_str_appendf(pResult, ", flags=0x%x", flgs); + sqlite3_str_appendf(pResult, ", vfs=%Q", pVfs ? pVfs->zName: 0); + sqlite3_str_appendf(pResult, ", err=%Q", zErr); + sqlite3_str_appendf(pResult, ", file=%Q", zFile); + if( zFile ){ + const char *z = zFile; + z += sqlite3Strlen30(z)+1; + while( z[0] ){ + sqlite3_str_appendf(pResult, ", %Q", z); + z += sqlite3Strlen30(z)+1; + } + for(i=2; i Date: Sun, 6 Oct 2024 21:26:56 +0000 Subject: [PATCH 3/5] Origin should not send content for the lock-byte page to the replica, in sqlite3-rsync. [forum:/forumpost/d14b55e5fa19c25f|Forum post d14b55e5fa19c25f]. FossilOrigin-Name: aa9bd711cc1b0136098388976d22adc0a2fc89f50fe2273ed80ee3e4e50c98b6 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- tool/sqlite3-rsync.c | 3 +++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 39ed9b3502..ecfa81388e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\sSQL\sfunction\sfor\stesting/debugging\suse\sonly:\sparseuri(). -D 2024-10-06T15:01:31.737 +C Origin\sshould\snot\ssend\scontent\sfor\sthe\slock-byte\spage\sto\sthe\sreplica,\sin\nsqlite3-rsync.\n[forum:/forumpost/d14b55e5fa19c25f|Forum\spost\sd14b55e5fa19c25f]. +D 2024-10-06T21:26:56.282 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2176,7 +2176,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b -F tool/sqlite3-rsync.c 2f06f02ee3a28f847b3fb8c0f32e3b3296571e0f8027939b95d32df5edfe1dd9 +F tool/sqlite3-rsync.c 7c78ba15afa0b929604adb91c94af8dbdf8cbe87be8a5cba5353af0e320ca65a F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -2215,11 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 -R 6e07384677af3f3c36d6573a7730f2e0 -T *branch * parseuri -T *sym-parseuri * -T -sym-trunk * +P 37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 +R dbb5b993debce35e50244d3495f9b61e U drh -Z a932a90a1e85d41407c9c1eb7bdee53f +Z 45e873ac682d74f4a4a29dbca970bb7d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 68845d202e..c653996c4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 +aa9bd711cc1b0136098388976d22adc0a2fc89f50fe2273ed80ee3e4e50c98b6 diff --git a/tool/sqlite3-rsync.c b/tool/sqlite3-rsync.c index 216390c182..401c4b33ef 100644 --- a/tool/sqlite3-rsync.c +++ b/tool/sqlite3-rsync.c @@ -1197,6 +1197,7 @@ static void originSide(SQLiteRsync *p){ int c = 0; unsigned int nPage = 0; unsigned int iPage = 0; + unsigned int lockBytePage = 0; unsigned int szPg = 0; sqlite3_stmt *pCkHash = 0; char buf[200]; @@ -1235,6 +1236,7 @@ static void originSide(SQLiteRsync *p){ p->nPage = nPage; p->szPage = szPg; p->iProtocol = PROTOCOL_VERSION; + lockBytePage = (1<<30)/szPg + 1; } } @@ -1290,6 +1292,7 @@ static void originSide(SQLiteRsync *p){ " INSERT INTO badHash SELECT n FROM c", iPage+1, p->nPage); } + runSql(p, "DELETE FROM badHash WHERE pgno=%d", lockBytePage); pStmt = prepareStmt(p, "SELECT pgno, data" " FROM badHash JOIN sqlite_dbpage('main') USING(pgno)"); From 29f976432a87793d7b9e29fd4ed0209d634113f7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 7 Oct 2024 11:47:05 +0000 Subject: [PATCH 4/5] Fix an assert() failure in "PRAGMA integrity_check" that could occur when checking a corrupt database. FossilOrigin-Name: d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pragma.c | 1 + test/corruptN.test | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8c049eb6a7..921101d073 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools. -D 2024-10-05T21:44:21.913 +C Fix\san\sassert()\sfailure\sin\s"PRAGMA\sintegrity_check"\sthat\scould\soccur\swhen\schecking\sa\scorrupt\sdatabase. +D 2024-10-07T11:47:05.013 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -762,7 +762,7 @@ F src/parse.y a7a8d42eeff01d267444ddb476029b0b1726fb70ae3d77984140f17ad02e2d61 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 -F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 +F src/pragma.c cd613126f7cdd0c2ded4648c3c7b7b0239e678d7f3489e88c4b6d6858372fd07 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 3ba0ad907b7773ed642f66cea8a2c9c8edc18841aa1050b6218dbb3479e86225 F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 @@ -1042,7 +1042,7 @@ F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4 F test/corruptK.test ac13504593d89d69690d45479547616ed12644d42b5cb7eeb2e759a76fc23dcb F test/corruptL.test 652fc8ac0763a6fd3eb28b951d481924167b2d9936083bcc68253b2274a0c8fe F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067 -F test/corruptN.test 7c099d153a554001b4fb829c799b01f2ea6276cbc32479131e0db0da4efd9cc4 +F test/corruptN.test 40bc47aee4af9aadff902be43f14d69dc17b3731448dad6c7cc722da913f1455 F test/cost.test cc434a026b1e9d0d98137a147e24e5daf1b1ad09e9ff7da63b34c83ddd136d92 F test/count.test cd4bd531066e8d77ef8fe1e3fc8253d042072e117ccab214b290cf83f1602249 F test/countofview.test 4088e461a10ee33e69803c177a69aa1d7bba81a9ffc2df66d76465a22ca7fdfc @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f -R 97cc1dd0446101afb82e95a43b8cd5d1 -U stephan -Z 6431efa2a9010e78c1fbe7fa1b33270f +P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +R 886d14b6c55746d1f77a7d0f4215362a +U dan +Z 224c1064901e8a73a6947d128b8e36d7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aec7c8a62f..aa365f77bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 diff --git a/src/pragma.c b/src/pragma.c index a8045aab1e..07139015f9 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1761,6 +1761,7 @@ void sqlite3Pragma( /* Make sure sufficient number of registers have been allocated */ sqlite3TouchRegister(pParse, 8+cnt); + sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt); sqlite3ClearTempRegCache(pParse); /* Do the b-tree integrity checks */ diff --git a/test/corruptN.test b/test/corruptN.test index 376325f5c5..8108609c09 100644 --- a/test/corruptN.test +++ b/test/corruptN.test @@ -276,4 +276,31 @@ do_catchsql_test 6.3 { UPDATE t1 SET x='hello world' WHERE rowid=1; } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 7.0 { + BEGIN; + CREATE TABLE p1(x PRIMARY KEY); + CREATE TABLE c1(y); + + PRAGMA schema_version = 0; + PRAGMA writable_schema = RESET; + + INSERT INTO c1 VALUES(1000); + ROLLBACK; +} + +do_execsql_test 7.1 { + PRAGMA table_info = p1; +} {0 x {} 0 {} 1} + +do_catchsql_test 7.2 { + SELECT * FROM p1; +} {1 {database disk image is malformed}} + +do_catchsql_test 7.3 { + PRAGMA integrity_check +} {1 {database disk image is malformed}} + + finish_test From ce527f2e971d0c50c779f00fa6a3af61cc94e52e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 7 Oct 2024 12:19:23 +0000 Subject: [PATCH 5/5] Fix handling of U+fffd in the LIKE optimization. dbsqlfuzz eee57fb9eea1dfa5aa40dfa87865cf8c84d12f96. FossilOrigin-Name: bce52ce2a6e7f3d3d1b2807d1ea95243d9b655e557c1bb6f0b8a9a6cefb1aed6 --- manifest | 17 +++++++++-------- manifest.uuid | 2 +- src/whereexpr.c | 25 +++++++++++++++---------- test/like.test | 6 +++--- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 921101d073..7bc5b30095 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sfailure\sin\s"PRAGMA\sintegrity_check"\sthat\scould\soccur\swhen\schecking\sa\scorrupt\sdatabase. -D 2024-10-07T11:47:05.013 +C Fix\shandling\sof\sU+fffd\sin\sthe\sLIKE\soptimization.\ndbsqlfuzz\seee57fb9eea1dfa5aa40dfa87865cf8c84d12f96. +D 2024-10-07T12:19:23.717 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -857,7 +857,7 @@ F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 461d41017d900d4248a268df96d2d30506c4dcc2257f4167c4f46072003ce2cf F src/whereInt.h a5d079c346a658b7a6e9e47bb943d021e02fa1e6aed3b964ca112112a4892192 F src/wherecode.c 5172d647798134e7c92536ddffe7e530c393d79b5dedd648b88faf2646c65baf -F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa +F src/whereexpr.c 562ce89d7f1c24a54c5124576e04928600061c87d83a30e63dcbaadf20eb0653 F src/window.c 499d48f315a09242dc68f2fac635ed27dcf6bbb0d9ab9084857898c64489e975 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -1390,7 +1390,7 @@ F test/kvtest.c 6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/lemon-test01.y 70110eff607ab137ccc851edb2bc7e14a6d4f246b5d2d25f82a60b69d87a9ff2 -F test/like.test 242ee7f5d08a031144c0daf63bbd7e7710c847ccf387a83347e0b61b3aa69526 +F test/like.test b3ea2ba3558199aa8f25a42ddeb54772e234fab50868c9f066047acdbda8fc58 F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3d3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf @@ -2215,8 +2215,9 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 -R 886d14b6c55746d1f77a7d0f4215362a -U dan -Z 224c1064901e8a73a6947d128b8e36d7 +P d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 +Q +13addee687c3fef02c6ef1af9f446822fe0945815648fb2198933c7c644798b2 +R 85a4f3886dc5b88ca917188b27f8b4cb +U drh +Z d22e20bac83a8cacb503bd8770c0d69a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aa365f77bd..31cbb26ab2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 +bce52ce2a6e7f3d3d1b2807d1ea95243d9b655e557c1bb6f0b8a9a6cefb1aed6 diff --git a/src/whereexpr.c b/src/whereexpr.c index 7ea2956a75..24d203046f 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -219,20 +219,25 @@ static int isLikeOrGlob( z = (u8*)pRight->u.zToken; } if( z ){ - - /* Count the number of prefix characters prior to the first wildcard. - ** If the underlying database has a UTF16LE encoding, then only consider - ** ASCII characters. Note that the encoding of z[] is UTF8 - we are - ** dealing with only UTF8 here in this code, but the database engine - ** itself might be processing content using a different encoding. */ + /* Count the number of prefix bytes prior to the first wildcard. + ** or U+fffd character. If the underlying database has a UTF16LE + ** encoding, then only consider ASCII characters. Note that the + ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in + ** this code, but the database engine itself might be processing + ** content using a different encoding. */ cnt = 0; while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; if( c==wc[3] && z[cnt]!=0 ){ cnt++; - }else if( c>=0x80 && ENC(db)==SQLITE_UTF16LE ){ - cnt--; - break; + }else if( c>=0x80 ){ + const u8 *z2 = z+cnt-1; + if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){ + cnt--; + break; + }else{ + cnt = (int)(z2-z); + } } } @@ -244,7 +249,7 @@ static int isLikeOrGlob( ** range search. The third is because the caller assumes that the pattern ** consists of at least one character after all escapes have been ** removed. */ - if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && 255!=(u8)z[cnt-1] ){ + if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && ALWAYS(255!=(u8)z[cnt-1]) ){ Expr *pPrefix; /* A "complete" match if the pattern ends with "*" or "%" */ diff --git a/test/like.test b/test/like.test index d314e96a19..0d732b569c 100644 --- a/test/like.test +++ b/test/like.test @@ -731,16 +731,16 @@ ifcapable like_opt&&!icu { } do_test like-9.5.1 { set res [sqlite3_exec_hex db { - SELECT x FROM t2 WHERE x LIKE '%fe%25' + SELECT 1 FROM t2 WHERE x LIKE '%fe%25' }] - } {0 {}} + } {0 {1 1}} ifcapable explain { do_test like-9.5.2 { set res [sqlite3_exec_hex db { EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25' }] regexp {INDEX i2} $res - } {1} + } {0} } # Do an SQL statement. Append the search count to the end of the result.