/ Check-in [0ea049f3]
Login

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

Overview
Comment:Fix a failing assert() in sqlite3ResetAllSchemasOfConnection().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0ea049f342d11c676e148239e45d252164081362e921a4beb735d6899eb77344
User & Date: dan 2018-11-27 19:47:55
Context
2018-11-28
01:45
Always enable SQLITE_ENABLE_DESERIALIZE for the MSVC makefile as this is necessary to get releasetest.tcl to work. check-in: d362dedb user: drh tags: trunk
2018-11-27
19:47
Fix a failing assert() in sqlite3ResetAllSchemasOfConnection(). check-in: 0ea049f3 user: dan tags: trunk
17:02
Improvements to two cases in pragma4.test. check-in: 3c893d9b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   540    540   /*
   541    541   ** Erase all schema information from all attached databases (including
   542    542   ** "main" and "temp") for a single database connection.
   543    543   */
   544    544   void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){
   545    545     int i;
   546    546     sqlite3BtreeEnterAll(db);
   547         -  assert( db->nSchemaLock==0 );
   548    547     for(i=0; i<db->nDb; i++){
   549    548       Db *pDb = &db->aDb[i];
   550    549       if( pDb->pSchema ){
   551         -      sqlite3SchemaClear(pDb->pSchema);
          550  +      if( db->nSchemaLock==0 ){
          551  +        sqlite3SchemaClear(pDb->pSchema);
          552  +      }else{
          553  +        DbSetProperty(db, i, DB_ResetWanted);
          554  +      }
   552    555       }
   553    556     }
   554    557     db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);
   555    558     sqlite3VtabUnlockList(db);
   556    559     sqlite3BtreeLeaveAll(db);
   557         -  sqlite3CollapseDatabaseArray(db);
          560  +  if( db->nSchemaLock==0 ){
          561  +    sqlite3CollapseDatabaseArray(db);
          562  +  }
   558    563   }
   559    564   
   560    565   /*
   561    566   ** This routine is called when a commit occurs.
   562    567   */
   563    568   void sqlite3CommitInternalChanges(sqlite3 *db){
   564    569     db->mDbFlags &= ~DBFLAG_SchemaChange;

Changes to test/vtab_err.test.

    16     16   
    17     17   ifcapable !vtab {
    18     18     finish_test
    19     19     return
    20     20   }
    21     21   
    22     22   
    23         -
    24     23   unset -nocomplain echo_module_begin_fail
    25     24   do_ioerr_test vtab_err-1 -tclprep {
    26     25     register_echo_module [sqlite3_connection_pointer db]
    27     26   } -sqlbody {
    28     27     BEGIN;
    29     28     CREATE TABLE r(a PRIMARY KEY, b, c);
    30     29     CREATE VIRTUAL TABLE e USING echo(r);
................................................................................
    58     57       CREATE TABLE r2(a, b, c);
    59     58       INSERT INTO r2 SELECT * FROM e;
    60     59       INSERT INTO e SELECT a||'x', b, c FROM r2;
    61     60     COMMIT;
    62     61   } 
    63     62   
    64     63   sqlite3_memdebug_fail -1
           64  +
           65  +reset_db
           66  +register_echo_module [sqlite3_connection_pointer db]
           67  +do_execsql_test vtab_err-3.0 {
           68  +  CREATE TABLE r(a PRIMARY KEY, b, c);
           69  +  CREATE VIRTUAL TABLE e USING echo(r);
           70  +}
           71  +faultsim_save_and_close
           72  +
           73  +do_faultsim_test vtab_err-3 -faults oom-t* -prep {
           74  +  faultsim_restore_and_reopen
           75  +  register_echo_module [sqlite3_connection_pointer db]
           76  +} -body {
           77  +  execsql {
           78  +    BEGIN;
           79  +      CREATE TABLE xyz(x);
           80  +      SELECT a FROM e;
           81  +    COMMIT;
           82  +  }
           83  +} -test {
           84  +  faultsim_test_result {0 {}}
           85  +}
    65     86   
    66     87   finish_test