/ Check-in [76f23a43]
Login

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

Overview
Comment:A backup must clear the internal schema of the destination database so that the schema will be reloaded for the next sqlite3_prepare() (CVS 6247)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 76f23a4394574e31f237e55c641bc70534f44d97
User & Date: drh 2009-02-03 22:17:42
Context
2009-02-03
22:51
Correction to check-ins (6246) and (6247): The backup object might not hold a valid destination connection pointer. Also, do not reset the page cache when establishing a read-lock while there is a persistent or truncated journal, only if there is a journal that really needs to rollback. Otherwise backups always reset whenever the source database file is read. (CVS 6248) check-in: 7f827ba9 user: drh tags: trunk
22:17
A backup must clear the internal schema of the destination database so that the schema will be reloaded for the next sqlite3_prepare() (CVS 6247) check-in: 76f23a43 user: drh tags: trunk
21:13
Must hold mutex on the destination during backups. Add documentation to warn programmers that attempting to use the destination connection during a backup can lead to deadlock. (CVS 6246) check-in: 5f6c06b9 user: drh 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.2 2009/02/03 21:13:08 drh Exp $
           15  +** $Id: backup.c,v 1.3 2009/02/03 22:17:42 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
................................................................................
   320    320     
   321    321         /* Update the schema version field in the destination database. This
   322    322         ** is to make sure that the schema-version really does change in
   323    323         ** the case where the source and destination databases have the
   324    324         ** same schema version.
   325    325         */
   326    326         sqlite3BtreeUpdateMeta(p->pDest, 1, p->iDestSchema+1);
          327  +      sqlite3ResetInternalSchema(p->pDestDb, 0);
   327    328   
   328    329         /* Set nDestTruncate to the final number of pages in the destination
   329    330         ** database. The complication here is that the destination page
   330    331         ** size may be different to the source page size. 
   331    332         **
   332    333         ** If the source page size is smaller than the destination page size, 
   333    334         ** round up. In this case the call to sqlite3OsTruncate() below will

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.515 2009/02/03 16:51:25 danielk1977 Exp $
           25  +** $Id: build.c,v 1.516 2009/02/03 22:17:42 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   
    29     29   /*
    30     30   ** This routine is called when a new SQL statement is beginning to
    31     31   ** be parsed.  Initialize the pParse structure as needed.
    32     32   */
................................................................................
   406    406   /*
   407    407   ** Erase all schema information from the in-memory hash tables of
   408    408   ** a single database.  This routine is called to reclaim memory
   409    409   ** before the database closes.  It is also called during a rollback
   410    410   ** if there were schema changes during the transaction or if a
   411    411   ** schema-cookie mismatch occurs.
   412    412   **
   413         -** If iDb<=0 then reset the internal schema tables for all database
   414         -** files.  If iDb>=2 then reset the internal schema for only the
          413  +** If iDb==0 then reset the internal schema tables for all database
          414  +** files.  If iDb>=1 then reset the internal schema for only the
   415    415   ** single file indicated.
   416    416   */
   417    417   void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
   418    418     int i, j;
   419    419     assert( iDb>=0 && iDb<db->nDb );
   420    420   
   421    421     if( iDb==0 ){