/ Check-in [540a7b28]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:When loading a database schema, do not clear the SQLITE_InternChanges flag. This fixes the problem illustrated by (4211). (CVS 4213)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 540a7b28bc37709056cfdb13286274ec5bdd8423
User & Date: danielk1977 2007-08-13 14:41:19
Context
2007-08-13
14:56
Fix a page leak in btree balance routines that follows a malloc failure. This problem detected by the new soft-heap-limit testing. (CVS 4214) check-in: bad661bb user: drh tags: trunk
14:41
When loading a database schema, do not clear the SQLITE_InternChanges flag. This fixes the problem illustrated by (4211). (CVS 4213) check-in: 540a7b28 user: danielk1977 tags: trunk
12:58
Fix the test labels in mallocC.test. (CVS 4212) check-in: 7d4cdff4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

     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_prepare()
    13     13   ** interface, and routines that contribute to loading the database schema
    14     14   ** from disk.
    15     15   **
    16         -** $Id: prepare.c,v 1.51 2007/06/24 10:14:00 danielk1977 Exp $
           16  +** $Id: prepare.c,v 1.52 2007/08/13 14:41:19 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "os.h"
    20     20   #include <ctype.h>
    21     21   
    22     22   /*
    23     23   ** Fill the InitData structure with an error message that indicates
................................................................................
   333    333   **
   334    334   ** After a database is initialized, the DB_SchemaLoaded bit is set
   335    335   ** bit is set in the flags field of the Db structure. If the database
   336    336   ** file was of zero-length, then the DB_Empty flag is also set.
   337    337   */
   338    338   int sqlite3Init(sqlite3 *db, char **pzErrMsg){
   339    339     int i, rc;
   340         -  int called_initone = 0;
          340  +  int commit_internal = !(db->flags&SQLITE_InternChanges);
   341    341     
   342    342     if( db->init.busy ) return SQLITE_OK;
   343    343     rc = SQLITE_OK;
   344    344     db->init.busy = 1;
   345    345     for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
   346    346       if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue;
   347    347       rc = sqlite3InitOne(db, i, pzErrMsg);
   348    348       if( rc ){
   349    349         sqlite3ResetInternalSchema(db, i);
   350    350       }
   351         -    called_initone = 1;
   352    351     }
   353    352   
   354    353     /* Once all the other databases have been initialised, load the schema
   355    354     ** for the TEMP database. This is loaded last, as the TEMP database
   356    355     ** schema may contain references to objects in other databases.
   357    356     */
   358    357   #ifndef SQLITE_OMIT_TEMPDB
   359    358     if( rc==SQLITE_OK && db->nDb>1 && !DbHasProperty(db, 1, DB_SchemaLoaded) ){
   360    359       rc = sqlite3InitOne(db, 1, pzErrMsg);
   361    360       if( rc ){
   362    361         sqlite3ResetInternalSchema(db, 1);
   363    362       }
   364         -    called_initone = 1;
   365    363     }
   366    364   #endif
   367    365   
   368    366     db->init.busy = 0;
   369         -  if( rc==SQLITE_OK && called_initone ){
          367  +  if( rc==SQLITE_OK && commit_internal ){
   370    368       sqlite3CommitInternalChanges(db);
   371    369     }
   372    370   
   373    371     return rc; 
   374    372   }
   375    373   
   376    374   /*