]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Pass the names of both the origin and the replica databases to the remote
authordrh <>
Thu, 12 Sep 2024 15:51:56 +0000 (15:51 +0000)
committerdrh <>
Thu, 12 Sep 2024 15:51:56 +0000 (15:51 +0000)
side, so that if the remote is the replica, it will have access to the
origin database name in case the replica name is really a directory.

FossilOrigin-Name: 435c30171d3c6073b7aaf5cc11cc4813f6a2d225ae6dce1b0e478f0cd5a0b532

manifest
manifest.uuid
tool/sqlite3-rsync.c

index aea0407ab4f60bcc5866251a957f5142b44758d8..502f45b59caed30573d64e6378b19efa5d71ae8a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\sprotocol\sversion\snumber\sto\sthe\sfirst\smessage,\sand\sgive\sthe\stwo\ssides\nan\sopportunity\sto\snegotiate\sa\ssuitable\sprotocol\snumber,\sfor\sfuture\ncompatibility.\s\sSend\sthe\spage\ssize\sas\sa\spower-of-two.
-D 2024-09-12T15:36:34.506
+C Pass\sthe\snames\sof\sboth\sthe\sorigin\sand\sthe\sreplica\sdatabases\sto\sthe\sremote\nside,\sso\sthat\sif\sthe\sremote\sis\sthe\sreplica,\sit\swill\shave\saccess\sto\sthe\norigin\sdatabase\sname\sin\scase\sthe\sreplica\sname\sis\sreally\sa\sdirectory.
+D 2024-09-12T15:51:56.339
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -2174,7 +2174,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
 F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x
 F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60
 F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a
-F tool/sqlite3-rsync.c f3283380beddab3cf876be781fbd2d00308249f08d6e4438411e64f27e7b67bd
+F tool/sqlite3-rsync.c 7b7d24177b27f42dfcd7e962be4a526e775b073f2044cd1f7d3414581810baea
 F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f
 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
@@ -2213,8 +2213,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 fe65821a3b912f061026e6fd7174be26897010e6b474e2780350cac60faebaad
-R 70c38e114e917b5cf93c46e6c1a47f24
+P df0623aae1154281157409f62d6d3fb3ce41829281d53bc55868ce44b3d36883
+R 137e53956a972f25c62e4e4b74ab6074
 U drh
-Z 9a7103765746c5b1023f192fb95a127f
+Z 061042360cfb45012e27693425840440
 # Remove this line to create a well-formed Fossil manifest.
index 01d7fcfa05875c40ebeb3a90ff61ecf157b041ca..c4e68cc6074ac4de285520f071340495aedfcb18 100644 (file)
@@ -1 +1 @@
-df0623aae1154281157409f62d6d3fb3ce41829281d53bc55868ce44b3d36883
+435c30171d3c6073b7aaf5cc11cc4813f6a2d225ae6dce1b0e478f0cd5a0b532
index 315c7198a45406ccda1562d8a9c4aa7f97240e6c..60777c40c6cd703a55632d6b71a12ab44ca2cbea 100644 (file)
@@ -516,6 +516,21 @@ static void echoOneLine(SQLiteRsync *p){
   }
 }
 
+/*
+** Return the tail of a file pathname.  The tail is the last component
+** of the path.  For example, the tail of "/a/b/c.d" is "c.d".
+*/
+const char *file_tail(const char *z){
+  const char *zTail = z;
+  if( !zTail ) return 0;
+  while( z[0] ){
+    if( z[0]=='/' ) zTail = &z[1];
+    z++;
+  }
+  return zTail;
+}
+
+
 /* Read a single big-endian 32-bit unsigned integer from the input
 ** stream.  Return 0 on success and 1 if there are any errors.
 */
@@ -1064,7 +1079,6 @@ static void replicaSide(SQLiteRsync *p){
                          "replica is %d bytes", szOPage, szRPage);
           break;
         }
-        
 
         pStmt = prepareStmt(p,
                    "SELECT sha1b(data) FROM sqlite_dbpage"
@@ -1257,12 +1271,12 @@ int main(int argc, char **argv){
     fprintf(stderr, "missing ORIGIN database filename\n");
     return 1;
   }
-  if( isOrigin && isReplica ){
-    fprintf(stderr, "bad option combination\n");
+  if( ctx.zReplica==0 ){
+    fprintf(stderr, "missing REPLICA database filename\n");
     return 1;
   }
-  if( (isOrigin || isReplica) && ctx.zReplica!=0 ){
-    fprintf(stderr, "Unknown argument: \"%s\"\n", ctx.zReplica);
+  if( isOrigin && isReplica ){
+    fprintf(stderr, "bad option combination\n");
     return 1;
   }
   if( isOrigin ){
@@ -1273,8 +1287,6 @@ int main(int argc, char **argv){
     return 0;
   }
   if( isReplica ){
-    ctx.zReplica = ctx.zOrigin;
-    ctx.zOrigin = 0;
     ctx.pIn = stdin;
     ctx.pOut = stdout;
     ctx.isRemote = 1;
@@ -1306,6 +1318,7 @@ int main(int argc, char **argv){
       if( ctx.eVerbose==0 ) ctx.eVerbose = 1;
     }
     append_escaped_arg(pStr, zDiv, 1);
+    append_escaped_arg(pStr, file_tail(ctx.zReplica), 1);
     zCmd = sqlite3_str_finish(pStr);
     if( ctx.eVerbose ) printf("%s\n", zCmd);
     if( popen2(zCmd, &ctx.pIn, &ctx.pOut, &childPid, 0) ){
@@ -1326,6 +1339,7 @@ int main(int argc, char **argv){
       append_escaped_arg(pStr, "--commcheck", 0);
       if( ctx.eVerbose==0 ) ctx.eVerbose = 1;
     }
+    append_escaped_arg(pStr, file_tail(ctx.zOrigin), 1);
     append_escaped_arg(pStr, zDiv, 1);
     zCmd = sqlite3_str_finish(pStr);
     if( ctx.eVerbose ) printf("%s\n", zCmd);
@@ -1342,6 +1356,7 @@ int main(int argc, char **argv){
     if( ctx.bCommCheck ){
       append_escaped_arg(pStr, "--commcheck", 0);
     }
+    append_escaped_arg(pStr, ctx.zOrigin, 1);
     append_escaped_arg(pStr, ctx.zReplica, 1);
     zCmd = sqlite3_str_finish(pStr);
     if( ctx.eVerbose ) printf("%s\n", zCmd);