/ Check-in [736d6ea6]
Login

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

Overview
Comment:Add assert()s to verify that Table objects in the schema never use lookaside memory.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 736d6ea677f58e4aa2914fa79a3156b775c5a3f5
User & Date: drh 2012-05-15 12:49:32
Context
2012-05-20
20:23
Fix a test case so that it works even with very long pathnames. check-in: ecd4a063 user: drh tags: trunk
20:14
Check-in included unrelated debugging code by mistake. Was: Fix a test case in the shell1.test script so that it works even for very long pathnames. Closed-Leaf check-in: 0c0a0398 user: drh tags: mistake
2012-05-17
21:04
Merge updates from trunk. check-in: 224c65e4 user: mistachkin tags: winrt
2012-05-15
17:15
When a connection disconnects from a shared-cache database, only delete the in-memory schema if there are no other connections. check-in: 46f4eb54 user: dan tags: shared-schema
12:49
Add assert()s to verify that Table objects in the schema never use lookaside memory. check-in: 736d6ea6 user: drh tags: trunk
2012-05-14
12:20
Add an assert() that verifies that the statement pointer from the sqlite3_prepare() family of functions is always NULL if the routines return other than SQLITE_OK. check-in: 0bb1cfc6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   498    498   ** Remove the memory data structures associated with the given
   499    499   ** Table.  No changes are made to disk by this routine.
   500    500   **
   501    501   ** This routine just deletes the data structure.  It does not unlink
   502    502   ** the table data structure from the hash table.  But it does destroy
   503    503   ** memory structures of the indices and foreign keys associated with 
   504    504   ** the table.
          505  +**
          506  +** The db parameter is optional.  It is needed if the Table object 
          507  +** contains lookaside memory.  (Table objects in the schema do not use
          508  +** lookaside memory, but some ephemeral Table objects do.)  Or the
          509  +** db parameter can be used with db->pnBytesFreed to measure the memory
          510  +** used by the Table object.
   505    511   */
   506    512   void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
   507    513     Index *pIndex, *pNext;
          514  +  TESTONLY( int nLookaside; ) /* Used to verify lookaside not used for schema */
   508    515   
   509    516     assert( !pTable || pTable->nRef>0 );
   510    517   
   511    518     /* Do not delete the table until the reference count reaches zero. */
   512    519     if( !pTable ) return;
   513    520     if( ((!db || db->pnBytesFreed==0) && (--pTable->nRef)>0) ) return;
          521  +
          522  +  /* Record the number of outstanding lookaside allocations in schema Tables
          523  +  ** prior to doing any free() operations.  Since schema Tables do not use
          524  +  ** lookaside, this number should not change. */
          525  +  TESTONLY( nLookaside = (db && (pTable->tabFlags & TF_Ephemeral)==0) ?
          526  +                         db->lookaside.nOut : 0 );
   514    527   
   515    528     /* Delete all indices associated with this table. */
   516    529     for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
   517    530       pNext = pIndex->pNext;
   518    531       assert( pIndex->pSchema==pTable->pSchema );
   519    532       if( !db || db->pnBytesFreed==0 ){
   520    533         char *zName = pIndex->zName; 
................................................................................
   539    552   #ifndef SQLITE_OMIT_CHECK
   540    553     sqlite3ExprListDelete(db, pTable->pCheck);
   541    554   #endif
   542    555   #ifndef SQLITE_OMIT_VIRTUALTABLE
   543    556     sqlite3VtabClear(db, pTable);
   544    557   #endif
   545    558     sqlite3DbFree(db, pTable);
          559  +
          560  +  /* Verify that no lookaside memory was used by schema tables */
          561  +  assert( nLookaside==0 || nLookaside==db->lookaside.nOut );
   546    562   }
   547    563   
   548    564   /*
   549    565   ** Unlink the given table from the hash tables and the delete the
   550    566   ** table structure with all its indices and foreign keys.
   551    567   */
   552    568   void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){