mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Do not compare page sizes on source and destination of backup until
transactions are started and the page sizes are locked. This is a fix to check-in [7bd44794c4]. FossilOrigin-Name: ec7157788b16936b4b6e4642107b3c86aa44df24
This commit is contained in:
26
src/backup.c
26
src/backup.c
@@ -288,8 +288,8 @@ static void attachBackupObject(sqlite3_backup *p){
|
||||
int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
||||
int rc;
|
||||
int destMode; /* Destination journal mode */
|
||||
int pgszSrc; /* Source page size */
|
||||
int pgszDest; /* Destination page size */
|
||||
int pgszSrc = 0; /* Source page size */
|
||||
int pgszDest = 0; /* Destination page size */
|
||||
|
||||
sqlite3_mutex_enter(p->pSrcDb->mutex);
|
||||
sqlite3BtreeEnter(p->pSrc);
|
||||
@@ -297,17 +297,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
||||
sqlite3_mutex_enter(p->pDestDb->mutex);
|
||||
}
|
||||
|
||||
/* Do not allow backup if the destination database is in WAL mode */
|
||||
destMode = sqlite3PagerJournalMode(sqlite3BtreePager(p->pDest),
|
||||
PAGER_JOURNALMODE_QUERY);
|
||||
pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
|
||||
pgszDest = sqlite3BtreeGetPageSize(p->pDest);
|
||||
if( destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){
|
||||
rc = SQLITE_READONLY;
|
||||
}else{
|
||||
rc = p->rc;
|
||||
}
|
||||
|
||||
rc = p->rc;
|
||||
if( !isFatalError(rc) ){
|
||||
Pager * const pSrcPager = sqlite3BtreePager(p->pSrc); /* Source pager */
|
||||
Pager * const pDestPager = sqlite3BtreePager(p->pDest); /* Dest pager */
|
||||
@@ -340,6 +330,16 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
||||
rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
|
||||
bCloseTrans = 1;
|
||||
}
|
||||
|
||||
/* Do not allow backup if the destination database is in WAL mode
|
||||
** and the page sizes are different between source and destination */
|
||||
pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
|
||||
pgszDest = sqlite3BtreeGetPageSize(p->pDest);
|
||||
destMode = sqlite3PagerJournalMode(sqlite3BtreePager(p->pDest),
|
||||
PAGER_JOURNALMODE_QUERY);
|
||||
if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){
|
||||
rc = SQLITE_READONLY;
|
||||
}
|
||||
|
||||
/* Now that there is a read-lock on the source database, query the
|
||||
** source pager for the number of pages in the database.
|
||||
|
Reference in New Issue
Block a user