]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Allow sqlite3_rsync to work on non-WAL-mode databases, as long as the rsync-delete-mode
authordrh <>
Thu, 1 May 2025 16:02:02 +0000 (16:02 +0000)
committerdrh <>
Thu, 1 May 2025 16:02:02 +0000 (16:02 +0000)
--wal-only flag is not used.

FossilOrigin-Name: 9f88f73ce39e761810110dc158ec0e5a84401a80b247a5395a906a6a538d5fec

manifest
manifest.uuid
tool/sqlite3_rsync.c

index b7b274ec830914136991cce28e7949f2b0328434..0728458dd5fa41576aeae03d67d2a7157ad773b1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s3.49.1
-D 2025-02-18T13:38:58.435
+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:02:02.037
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@@ -2190,7 +2190,7 @@ F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d
 F tool/split-sqlite3c.tcl 07e18a1d8cc3f6b3a4a1f3528e63c9b29a5c8a7bca0b8d394b231da464ce1247
 F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b
 F tool/sqlite3_analyzer.c.in fc7735c499d226a49d843d8209b2543e4e5229eeb71a674c331323a2217b65b4
-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
@@ -2209,10 +2209,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 57eceb361f0290b1326acf791565eb33267a10a5201aee34bdd2d1c93d647ff8
-R 75ce877abe8a04df5ba4cb86e46a277d
-T +sym-release *
-T +sym-version-3.49.1 *
+P 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70
+R 92095fa11b8ae347e8faff30eac0dc4a
+T *branch * rsync-delete-mode
+T *sym-rsync-delete-mode *
+T -sym-branch-3.49 *
 U drh
-Z ca30243dceef882d9114cf681397efb8
+Z ea6b3d3575592e4e0539f9a05fdc7c9c
 # Remove this line to create a well-formed Fossil manifest.
index f6dad3ea69f2cb542023c4cee3f60ef8ba55a760..f226e0279b58ce7b55fdc0534b1285aef1b2f328 100644 (file)
@@ -1 +1 @@
-873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70
+9f88f73ce39e761810110dc158ec0e5a84401a80b247a5395a906a6a538d5fec
index 01dcbed0500095aae3aa45617cc4a9c577146d7f..bd42a2b8c2eba0591e4547fd84bfabfed31fb6d6 100644 (file)
@@ -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);