From 74672acd946d12d23f65c3e07f9f88e407784145 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 6 Oct 2024 15:01:31 +0000 Subject: [PATCH 1/2] 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 2/2] 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)");