diff options
author | drh <drh@noemail.net> | 2010-05-05 18:46:44 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-05-05 18:46:44 +0000 |
commit | 5c10f77d52b2544b1a0e21de9b130d1a5a46eb7d (patch) | |
tree | 3e68d287e401d99eda61c05d531cd95c75480b2e /src/backup.c | |
parent | 4bc79def36fa01a0b3bd0913a92f34cda317bb94 (diff) | |
download | sqlite-5c10f77d52b2544b1a0e21de9b130d1a5a46eb7d.tar.gz sqlite-5c10f77d52b2544b1a0e21de9b130d1a5a46eb7d.zip |
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
Diffstat (limited to 'src/backup.c')
-rw-r--r-- | src/backup.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backup.c b/src/backup.c index fb23577ed..3e2cba5ff 100644 --- a/src/backup.c +++ b/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. |