mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Do not allow sqlite3_rsync to convert the replica from WAL-mode into
DELETE-mode, as that can disrupt existing clients on the replica side. DELETE-mode to WAL-mode conversions are allowed, however. See [forum:/forumpost/6b575b66156673ee|forum thread 6b575b66156]. FossilOrigin-Name: 660a035b6ce6684d429b882133e032181cc1664f4efadf1bc0e4ae27d45071c4
This commit is contained in:
@ -1393,6 +1393,7 @@ static void replicaSide(SQLiteRsync *p){
|
||||
int c;
|
||||
sqlite3_stmt *pIns = 0;
|
||||
unsigned int szOPage = 0;
|
||||
char eJMode = 0; /* Journal mode prior to sync */
|
||||
char buf[65536];
|
||||
|
||||
p->isReplica = 1;
|
||||
@ -1463,16 +1464,18 @@ static void replicaSide(SQLiteRsync *p){
|
||||
}
|
||||
if( nRPage==0 ){
|
||||
runSql(p, "PRAGMA replica.page_size=%u", szOPage);
|
||||
runSql(p, "PRAGMA replica.journal_mode=WAL");
|
||||
runSql(p, "SELECT * FROM replica.sqlite_schema");
|
||||
}
|
||||
runSql(p, "BEGIN IMMEDIATE");
|
||||
if( p->bWalOnly ){
|
||||
runSqlReturnText(p, buf, "PRAGMA replica.journal_mode");
|
||||
if( strcmp(buf, "wal")!=0 ){
|
||||
runSqlReturnText(p, buf, "PRAGMA replica.journal_mode");
|
||||
if( strcmp(buf, "wal")!=0 ){
|
||||
if( p->bWalOnly && nRPage>0 ){
|
||||
reportError(p, "replica is not in WAL mode");
|
||||
break;
|
||||
}
|
||||
eJMode = 1; /* Non-WAL mode prior to sync */
|
||||
}else{
|
||||
eJMode = 2; /* WAL-mode prior to sync */
|
||||
}
|
||||
runSqlReturnUInt(p, &nRPage, "PRAGMA replica.page_count");
|
||||
runSqlReturnUInt(p, &szRPage, "PRAGMA replica.page_size");
|
||||
@ -1537,6 +1540,11 @@ static void replicaSide(SQLiteRsync *p){
|
||||
}
|
||||
readBytes(p, szOPage, buf);
|
||||
if( p->nErr ) break;
|
||||
if( pgno==1 && eJMode==2 && buf[18]==1 ){
|
||||
/* Do not switch the replica out of WAL mode if it started in
|
||||
** WAL mode */
|
||||
buf[18] = buf[19] = 2;
|
||||
}
|
||||
p->nPageSent++;
|
||||
sqlite3_bind_int64(pIns, 1, pgno);
|
||||
sqlite3_bind_blob(pIns, 2, buf, szOPage, SQLITE_STATIC);
|
||||
|
Reference in New Issue
Block a user