/ Check-in [471b92f2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the backup logic so that it detects a failure to sqlite3BtreeUpdateMeta() and reports that failure back up to the top level. (CVS 6851)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:471b92f2514aedecb5773825a7ae472190375727
User & Date: drh 2009-07-06 19:03:13
Context
2009-07-06
21:54
Fix the pager so that it remembers the name of the journal for an in-memory database as an empty string. This is important when committing a multi-database transaction that includes one or more attached memory databases. (CVS 6852) check-in: 31a5e819 user: drh tags: trunk
19:03
Fix the backup logic so that it detects a failure to sqlite3BtreeUpdateMeta() and reports that failure back up to the top level. (CVS 6851) check-in: 471b92f2 user: drh tags: trunk
18:56
Make the sqlite3BtreeMoveto function static, since it is only used from within btree.c. Remove unused function lockBtreeWithRetry from btree.c. (CVS 6850) check-in: 30d5ec62 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/backup.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains the implementation of the sqlite3_backup_XXX() 
    13     13   ** API functions and the related features.
    14     14   **
    15         -** $Id: backup.c,v 1.18 2009/07/02 07:47:33 danielk1977 Exp $
           15  +** $Id: backup.c,v 1.19 2009/07/06 19:03:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include "btreeInt.h"
    19     19   
    20     20   /* Macro to find the minimum of two numeric values.
    21     21   */
    22     22   #ifndef MIN
................................................................................
   354    354         if( p->iNext>(Pgno)nSrcPage ){
   355    355           rc = SQLITE_DONE;
   356    356         }else if( !p->isAttached ){
   357    357           attachBackupObject(p);
   358    358         }
   359    359       }
   360    360     
   361         -    if( rc==SQLITE_DONE ){
          361  +    /* Update the schema version field in the destination database. This
          362  +    ** is to make sure that the schema-version really does change in
          363  +    ** the case where the source and destination databases have the
          364  +    ** same schema version.
          365  +    */
          366  +    if( rc==SQLITE_DONE 
          367  +     && (rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1))==SQLITE_OK
          368  +    ){
   362    369         const int nSrcPagesize = sqlite3BtreeGetPageSize(p->pSrc);
   363    370         const int nDestPagesize = sqlite3BtreeGetPageSize(p->pDest);
   364    371         int nDestTruncate;
   365    372     
   366         -      /* Update the schema version field in the destination database. This
   367         -      ** is to make sure that the schema-version really does change in
   368         -      ** the case where the source and destination databases have the
   369         -      ** same schema version.
   370         -      */
   371         -      sqlite3BtreeUpdateMeta(p->pDest, 1, p->iDestSchema+1);
   372    373         if( p->pDestDb ){
   373    374           sqlite3ResetInternalSchema(p->pDestDb, 0);
   374    375         }
   375    376   
   376    377         /* Set nDestTruncate to the final number of pages in the destination
   377    378         ** database. The complication here is that the destination page
   378    379         ** size may be different to the source page size.