SQLite

Check-in [5587c73bad]
Login

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

Overview
Comment:Avoid using sqlite3ResetAllSchemasOfConnection() purely for its side-effects.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | shared-schema
Files: files | file ages | folders
SHA1: 5587c73badc07d3e01a7c5c5964e178b5112dd24
User & Date: drh 2012-05-16 01:24:34.201
Context
2012-05-16
14:29
Return SQLITE_MISUSE if an application attempts to register a virtual table module with the same name as an existing module. (check-in: ea2cd55e09 user: dan tags: shared-schema)
01:24
Avoid using sqlite3ResetAllSchemasOfConnection() purely for its side-effects. (check-in: 5587c73bad user: drh tags: shared-schema)
2012-05-15
18:28
The former sqlite3ResetInternalSchema() routine was really two different routines, selected by parameter, each with a confused mission. So split this routine up into three separate smaller routines, calling each separately as needed. Hopefully this will make further refactoring and schema reset collateral damage containment easier. (check-in: aa0c3493d3 user: drh tags: shared-schema)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
789
790
791
792
793
794
795

796
797
798
799
800
801
802
803
804
805



806

807
808
809
810
811
812
813
814
815
816
      return SQLITE_BUSY;
    }
  }

  /* Free any outstanding Savepoint structures. */
  sqlite3CloseSavepoints(db);


  for(j=0; j<db->nDb; j++){
    struct Db *pDb = &db->aDb[j];
    if( pDb->pBt ){
      sqlite3BtreeClose(pDb->pBt);
      pDb->pBt = 0;
      if( j!=1 ){
        pDb->pSchema = 0;
      }
    }
  }





  /* This call frees the schema associated with the temp database only (if
  ** any). It also frees the db->aDb array, if required.  */
  sqlite3ResetAllSchemasOfConnection(db);
  assert( db->nDb<=2 );
  assert( db->aDb==db->aDbStatic );

  /* Tell the code in notify.c that the connection no longer holds any
  ** locks and does not require any further unlock-notify callbacks.
  */
  sqlite3ConnectionClosed(db);







>










>
>
>
|
>
|
|
|







789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
      return SQLITE_BUSY;
    }
  }

  /* Free any outstanding Savepoint structures. */
  sqlite3CloseSavepoints(db);

  /* Close all database connections */
  for(j=0; j<db->nDb; j++){
    struct Db *pDb = &db->aDb[j];
    if( pDb->pBt ){
      sqlite3BtreeClose(pDb->pBt);
      pDb->pBt = 0;
      if( j!=1 ){
        pDb->pSchema = 0;
      }
    }
  }
  /* Clear the TEMP schema separately and last */
  if( db->aDb[1].pSchema ){
    sqlite3SchemaClear(db->aDb[1].pSchema);
  }
  sqlite3VtabUnlockList(db);

  /* Free up the array of auxiliary databases */
  sqlite3CollapseDatabaseArray(db);
  assert( db->nDb<=2 );
  assert( db->aDb==db->aDbStatic );

  /* Tell the code in notify.c that the connection no longer holds any
  ** locks and does not require any further unlock-notify callbacks.
  */
  sqlite3ConnectionClosed(db);