aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrh <>2025-05-01 16:07:52 +0000
committerdrh <>2025-05-01 16:07:52 +0000
commit391f70c527e3e4ff05ffed90faf5dbeb303dfe46 (patch)
treec37b567470b5b80fd15d9a42cde2a42e1b79e759
parentf23a61258bf9f9e346fe33ad6f740834455ade56 (diff)
downloadsqlite-391f70c527e3e4ff05ffed90faf5dbeb303dfe46.tar.gz
sqlite-391f70c527e3e4ff05ffed90faf5dbeb303dfe46.zip
Allow sqlite3_rsync to work on non-WAL-mode databases, as long as the
--wal-only flag is not used. FossilOrigin-Name: e4126dcd1eba4f040a7c07102d34692287b74b41a3437a3b9d15c4f8c9d4e6fd
-rw-r--r--manifest16
-rw-r--r--manifest.uuid2
-rw-r--r--tool/sqlite3_rsync.c48
3 files changed, 42 insertions, 24 deletions
diff --git a/manifest b/manifest
index d5ac399b0..70e3a50cf 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sharmless\sproblem\sin\sthe\sCLI\sin\swhich\sSQL\serrors\sthat\soccur\sduring\nthe\s".schema"\scommand\sare\sproperly\signored,\syes\sstill\sappear\sin\sthe\s".log"\noutput.\s[forum:/forumpost/42fe6520b803be51|Forum\spost\s42fe6520b8]
-D 2025-04-30T14:37:00.121
+C Allow\ssqlite3_rsync\sto\swork\son\snon-WAL-mode\sdatabases,\sas\slong\sas\sthe\n--wal-only\sflag\sis\snot\sused.
+D 2025-05-01T16:07:52.716
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -2189,7 +2189,7 @@ F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d
F tool/split-sqlite3c.tcl 07e18a1d8cc3f6b3a4a1f3528e63c9b29a5c8a7bca0b8d394b231da464ce1247
F tool/sqldiff.c 134be7866be19f8beb32043d5aea5657f01aaeae2df8d33d758ff722c78666b9
F tool/sqlite3_analyzer.c.in 14f02cb5ec3c264cd6107d1f1dad77092b1cf440fc196c30b69ae87b56a1a43b
-F tool/sqlite3_rsync.c 9a1cca2ab1271c59b37a6493c15dc1bcd0ab9149197a9125926bc08dd26b83fb
+F tool/sqlite3_rsync.c f5e0b13cb159638a8556614dc13c9c3d457df69a7c426b9977fc3fb79130ce2d
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
F tool/src-verify.c d00f93263aa2fa6ba0cba0106d95458e6effb94fdb5fc634f56834f90c05bbb4
@@ -2207,8 +2207,12 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P cdef486e212fe4b26605065d9cff08f608cb80df48ee64e4be63637769bdfacc
-R ff4dbf6198636e450976250aaa2d8234
+P 20abf1ec107f942e4527901685d61283c9c2fe7bcefad63dbf5c6cbf050da849
+Q +9f88f73ce39e761810110dc158ec0e5a84401a80b247a5395a906a6a538d5fec
+R eaf25ba59d2c9244d7aeaa66e676c510
+T *branch * rsync-non-wal-mode
+T *sym-rsync-non-wal-mode *
+T -sym-trunk *
U drh
-Z 88680290faafcb12b4513cbfd1fe3d4f
+Z db3c00b4ead05d580221bc820eec3ab1
# Remove this line to create a well-formed Fossil manifest.
diff --git a/manifest.uuid b/manifest.uuid
index 3d3fb0bd6..c2fd98b0c 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-20abf1ec107f942e4527901685d61283c9c2fe7bcefad63dbf5c6cbf050da849
+e4126dcd1eba4f040a7c07102d34692287b74b41a3437a3b9d15c4f8c9d4e6fd
diff --git a/tool/sqlite3_rsync.c b/tool/sqlite3_rsync.c
index 01dcbed05..bd42a2b8c 100644
--- a/tool/sqlite3_rsync.c
+++ b/tool/sqlite3_rsync.c
@@ -35,6 +35,7 @@ static const char zUsage[] =
" --ssh PATH Name of the SSH program used to reach the remote side\n"
" -v Verbose. Multiple v's for increasing output\n"
" --version Show detailed version information\n"
+ " --wal-only Do not sync unless both databases are in WAL mode\n"
;
typedef unsigned char u8;
@@ -57,6 +58,7 @@ struct SQLiteRsync {
u8 isReplica; /* True if running on the replica side */
u8 iProtocol; /* Protocol version number */
u8 wrongEncoding; /* ATTACH failed due to wrong encoding */
+ u8 bWalOnly; /* Require WAL mode */
sqlite3_uint64 nOut; /* Bytes transmitted */
sqlite3_uint64 nIn; /* Bytes received */
unsigned int nPage; /* Total number of pages in the database */
@@ -1237,9 +1239,11 @@ static void originSide(SQLiteRsync *p){
}
hashRegister(p->db);
runSql(p, "BEGIN");
- runSqlReturnText(p, buf, "PRAGMA journal_mode");
- if( sqlite3_stricmp(buf,"wal")!=0 ){
- reportError(p, "Origin database is not in WAL mode");
+ if( p->bWalOnly ){
+ runSqlReturnText(p, buf, "PRAGMA journal_mode");
+ if( sqlite3_stricmp(buf,"wal")!=0 ){
+ reportError(p, "Origin database is not in WAL mode");
+ }
}
runSqlReturnUInt(p, &nPage, "PRAGMA page_count");
runSqlReturnUInt(p, &szPg, "PRAGMA page_size");
@@ -1463,10 +1467,12 @@ static void replicaSide(SQLiteRsync *p){
runSql(p, "SELECT * FROM replica.sqlite_schema");
}
runSql(p, "BEGIN IMMEDIATE");
- runSqlReturnText(p, buf, "PRAGMA replica.journal_mode");
- if( strcmp(buf, "wal")!=0 ){
- reportError(p, "replica is not in WAL mode");
- break;
+ if( p->bWalOnly ){
+ runSqlReturnText(p, buf, "PRAGMA replica.journal_mode");
+ if( strcmp(buf, "wal")!=0 ){
+ reportError(p, "replica is not in WAL mode");
+ break;
+ }
}
runSqlReturnUInt(p, &nRPage, "PRAGMA replica.page_count");
runSqlReturnUInt(p, &szRPage, "PRAGMA replica.page_size");
@@ -1669,11 +1675,12 @@ int main(int argc, char const * const *argv){
memset(&ctx, 0, sizeof(ctx));
for(i=1; i<argc; i++){
const char *z = argv[i];
- if( strcmp(z,"--origin")==0 ){
+ if( z[0]=='-' && z[1]=='-' && z[2]!=0 ) z++;
+ if( strcmp(z,"-origin")==0 ){
isOrigin = 1;
continue;
}
- if( strcmp(z,"--replica")==0 ){
+ if( strcmp(z,"-replica")==0 ){
isReplica = 1;
continue;
}
@@ -1681,15 +1688,15 @@ int main(int argc, char const * const *argv){
ctx.eVerbose += numVs(z);
continue;
}
- if( strcmp(z, "--ssh")==0 ){
+ if( strcmp(z, "-ssh")==0 ){
zSsh = cli_opt_val;
continue;
}
- if( strcmp(z, "--exe")==0 ){
+ if( strcmp(z, "-exe")==0 ){
zExe = cli_opt_val;
continue;
}
- if( strcmp(z, "--logfile")==0 ){
+ if( strcmp(z, "-logfile")==0 ){
/* DEBUG OPTION: --logfile FILENAME
** Cause all local output traffic to be duplicated in FILENAME */
const char *zLog = cli_opt_val;
@@ -1701,37 +1708,41 @@ int main(int argc, char const * const *argv){
}
continue;
}
- if( strcmp(z, "--errorfile")==0 ){
+ if( strcmp(z, "-errorfile")==0 ){
/* DEBUG OPTION: --errorfile FILENAME
** Error messages on the local side are written into FILENAME */
ctx.zErrFile = cli_opt_val;
continue;
}
- if( strcmp(z, "--remote-errorfile")==0 ){
+ if( strcmp(z, "-remote-errorfile")==0 ){
/* DEBUG OPTION: --remote-errorfile FILENAME
** Error messages on the remote side are written into FILENAME on
** the remote side. */
zRemoteErrFile = cli_opt_val;
continue;
}
+ if( strcmp(z, "-wal-only")==0 ){
+ ctx.bWalOnly = 1;
+ continue;
+ }
if( strcmp(z, "-help")==0 || strcmp(z, "--help")==0
|| strcmp(z, "-?")==0
){
printf("%s", zUsage);
return 0;
}
- if( strcmp(z, "--version")==0 ){
+ if( strcmp(z, "-version")==0 ){
printf("%s\n", sqlite3_sourceid());
return 0;
}
if( z[0]=='-' ){
- if( strcmp(z,"--commcheck")==0 ){ /* DEBUG ONLY */
+ if( strcmp(z,"-commcheck")==0 ){ /* DEBUG ONLY */
/* Run a communication check with the remote side. Do not attempt
** to exchange any database connection */
ctx.bCommCheck = 1;
continue;
}
- if( strcmp(z,"--arg-escape-check")==0 ){ /* DEBUG ONLY */
+ if( strcmp(z,"-arg-escape-check")==0 ){ /* DEBUG ONLY */
/* Test the append_escaped_arg() routine by using it to render a
** copy of the input command-line, assuming all arguments except
** this one are filenames. */
@@ -1819,6 +1830,9 @@ int main(int argc, char const * const *argv){
append_escaped_arg(pStr, "--errorfile", 0);
append_escaped_arg(pStr, zRemoteErrFile, 1);
}
+ if( ctx.bWalOnly ){
+ append_escaped_arg(pStr, "--wal-only", 0);
+ }
append_escaped_arg(pStr, zDiv, 1);
append_escaped_arg(pStr, file_tail(ctx.zReplica), 1);
zCmd = sqlite3_str_finish(pStr);