mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-24 22:22:08 +03:00
Enhance sqlite3_rsync so that, by default, it will sync non-WAL-mode
database files. Add a new command-line option --wal-only that restricts the sync to WAL-mode databases only (the former default). Improve command-line option parsing so that only a single "-" is required before each option. FossilOrigin-Name: 4b53603fe468c0c28b818762917e41bdd870de6d4cc143688f1cdea3136c81a4
This commit is contained in:
13
manifest
13
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 Enhance\ssqlite3_rsync\sso\sthat,\sby\sdefault,\sit\swill\ssync\snon-WAL-mode\ndatabase\sfiles.\s\sAdd\sa\snew\scommand-line\soption\s--wal-only\sthat\srestricts\nthe\ssync\sto\sWAL-mode\sdatabases\sonly\s(the\sformer\sdefault).\s\sImprove\ncommand-line\soption\sparsing\sso\sthat\sonly\sa\ssingle\s"-"\sis\srequired\sbefore\neach\soption.
|
||||
D 2025-05-01T18:07:27.165
|
||||
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,9 @@ 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 e4126dcd1eba4f040a7c07102d34692287b74b41a3437a3b9d15c4f8c9d4e6fd
|
||||
R eaf25ba59d2c9244d7aeaa66e676c510
|
||||
T +closed e4126dcd1eba4f040a7c07102d34692287b74b41a3437a3b9d15c4f8c9d4e6fd
|
||||
U drh
|
||||
Z 88680290faafcb12b4513cbfd1fe3d4f
|
||||
Z 308dcdc3a40ce25db24c1b710b31692f
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
20abf1ec107f942e4527901685d61283c9c2fe7bcefad63dbf5c6cbf050da849
|
||||
4b53603fe468c0c28b818762917e41bdd870de6d4cc143688f1cdea3136c81a4
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user