diff --git a/manifest b/manifest index dde6f5bb81..f776d6b853 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunused\sSchema.db\svariable. -D 2010-07-23T08:31:36 +C Remove\sthe\sTable.dbMem\svariable,\sas\sit\sis\sno\slonger\sbeing\sused\sfor\sits\soriginal\spurpose. +D 2010-07-23T15:41:47 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -106,8 +106,8 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad -F src/alter.c a9ff6f14b3935502537e90194b66c7bc79bed317 -F src/analyze.c 3457a2af126eb78f20ad239c225a2c8ed61b78b6 +F src/alter.c 8dc27638e7e2553e80b2b621f232be5eb1e85ef3 +F src/analyze.c 4ffed15a35cb669920348365fe71ce4d8800dc28 F src/attach.c 17bec1f18254d9341369f20f90ba24ce35d20d10 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 51d83300fe0baee39405c416ceb19a58ed30a8ed @@ -116,15 +116,15 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 9a214e6141555b183216b73ace058c7a499cdbe2 F src/btree.h dd83041eda10c17daf023257c1fc883b5f71f85a F src/btreeInt.h b0c87f6725b06a0aa194a6d25d54b16ce9d6e291 -F src/build.c 559d38b48f79bc92370c082f4606eefe1e8f94ac -F src/callback.c 01843bdf4b0420fd28046525d150fcd9802931a9 +F src/build.c 8ccdb8ff8e86cbf5b891d4b236e50a91e69732d3 +F src/callback.c 907455fa24d0bf34a5929609d3deceff9f9d9ba0 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 4f3aadad62c6c9f0d4e5a96718516ac4e3c598df F src/date.c 5dd8448a0bfea8d31fb14cff487d0c06ff8c8b20 -F src/delete.c 41cb4f78557810eecc167b7e2317de7e12d20929 +F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd F src/expr.c 7490fc3b16414d1a45d5acadf559317f9244891f F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0 +F src/fkey.c 31b8dc8e73a9d87b4a546f5372146b84f99ef2d4 F src/func.c 0c28599430856631216b6c0131c51c89bf516026 F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af @@ -168,11 +168,11 @@ F src/printf.c 5f5b65a83e63f2096a541a340722a509fa0240a7 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 -F src/select.c 4903ff1bbd08b55cbce00ea43c645530de41b362 +F src/select.c 3437b62b225528eef9cb61858584e86bb74ab35d F src/shell.c fd4ccdb37c3b68de0623eb938a649e0990710714 F src/sqlite.h.in 2585fc82c922f2772e201e60a76d5fd1ca18370e F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 -F src/sqliteInt.h e0d3c223fe5e43693d4b7683b3df6b6e97179ffd +F src/sqliteInt.h 13819304fa198f4a3ff0e6aa8d3a94df662d2829 F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3 F src/status.c e2ad9f18c16209dab501e26020590fcebb2b751b F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -212,7 +212,7 @@ F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 F src/test_vfs.c 7e291f85256516ebde6633bc381ff7eedfa30234 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 -F src/tokenize.c 25ceb0f0a746ea1d0f9553787f3f0a56853cfaeb +F src/tokenize.c eb58d4eabbc9dcc1d1efe7430641a1e651f30607 F src/trigger.c 67e95c76d625b92d43409ace771c8e0d02a09ac2 F src/update.c 19c899c23cd29fd102c9068e0b0ff5b087204beb F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685 @@ -226,7 +226,7 @@ F src/vdbeaux.c 7f99c1f00e4b31e8b28d8a87ecc2322bb46ae99c F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256 F src/vdbemem.c 5e579abf6532001dfbee0e640dc34eae897a9807 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 -F src/vtab.c 477f3dd1ccfabc7a4d930e934cd1b9604259fcfb +F src/vtab.c 4b09cb71090b8a9ce8fdc451816ed2bd62861dcc F src/wal.c 0925601f3299c2941a67c9cfff41ee710f70ca82 F src/wal.h 906c85760598b18584921fe08008435aa4eeeeb2 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -838,7 +838,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f3f9e8e5bb90cc36e0d63a7289a8acf534c5fa2a -R 3b4affe94bacb453466cd5c684e41e75 +P 430be657be68687c998f2f5f8dcd112bf26106be +R b12985159a737efd8ea9a2927ba836e0 U dan -Z 440f3d00aab51cca2a0728ba4051640b +Z 048b116055cce95a3e484c5c3be793ac diff --git a/manifest.uuid b/manifest.uuid index adb3b49209..e2cdd05761 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -430be657be68687c998f2f5f8dcd112bf26106be \ No newline at end of file +6eddc6e601cf8f585c6c2cf79f36fcbfe98a307e \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 359c4e7378..a863c4548b 100644 --- a/src/alter.c +++ b/src/alter.c @@ -769,7 +769,6 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ if( !pNew ) goto exit_begin_add_column; pParse->pNewTable = pNew; pNew->nRef = 1; - pNew->dbMem = pTab->dbMem; pNew->nCol = pTab->nCol; assert( pNew->nCol>0 ); nAlloc = (((pNew->nCol-1)/8)*8)+8; diff --git a/src/analyze.c b/src/analyze.c index 94cf3a39dc..c41fba3437 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -494,14 +494,13 @@ void sqlite3DeleteIndexSamples(Index *pIdx){ #ifdef SQLITE_ENABLE_STAT2 if( pIdx->aSample ){ int j; - sqlite3 *dbMem = pIdx->pTable->dbMem; for(j=0; jaSample[j]; if( p->eType==SQLITE_TEXT || p->eType==SQLITE_BLOB ){ - sqlite3DbFree(pIdx->pTable->dbMem, p->u.z); + sqlite3_free(p->u.z); } } - sqlite3DbFree(dbMem, pIdx->aSample); + sqlite3DbFree(0, pIdx->aSample); pIdx->aSample = 0; } #else @@ -587,18 +586,17 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ Index *pIdx = sqlite3FindIndex(db, zIndex, sInfo.zDatabase); if( pIdx ){ int iSample = sqlite3_column_int(pStmt, 1); - sqlite3 *dbMem = pIdx->pTable->dbMem; - assert( dbMem==db || dbMem==0 ); if( iSample=0 ){ int eType = sqlite3_column_type(pStmt, 2); if( pIdx->aSample==0 ){ static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES; - pIdx->aSample = (IndexSample *)sqlite3DbMallocZero(dbMem, sz); + pIdx->aSample = (IndexSample *)sqlite3Malloc(sz); if( pIdx->aSample==0 ){ db->mallocFailed = 1; break; } + memset(pIdx->aSample, 0, sz); } assert( pIdx->aSample ); @@ -621,7 +619,7 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ if( n < 1){ pSample->u.z = 0; }else{ - pSample->u.z = sqlite3DbMallocRaw(dbMem, n); + pSample->u.z = sqlite3Malloc(n); if( pSample->u.z ){ memcpy(pSample->u.z, z, n); }else{ diff --git a/src/build.c b/src/build.c index d9641774a6..1ca6e24693 100644 --- a/src/build.c +++ b/src/build.c @@ -345,8 +345,7 @@ Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){ /* ** Reclaim the memory used by an index */ -static void freeIndex(Index *p){ - sqlite3 *db = p->pTable->dbMem; +static void freeIndex(sqlite3 *db, Index *p){ #ifndef SQLITE_OMIT_ANALYZE sqlite3DeleteIndexSamples(p); #endif @@ -362,14 +361,14 @@ static void freeIndex(Index *p){ ** it is not unlinked from the Table that it indexes. ** Unlinking from the Table must be done by the calling function. */ -static void sqlite3DeleteIndex(Index *p){ +static void sqlite3DeleteIndex(sqlite3 *db, Index *p){ Index *pOld; const char *zName = p->zName; pOld = sqlite3HashInsert(&p->pSchema->idxHash, zName, sqlite3Strlen30(zName), 0); assert( pOld==0 || pOld==p ); - freeIndex(p); + freeIndex(db, p); } /* @@ -398,7 +397,7 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){ p->pNext = pIndex->pNext; } } - freeIndex(pIndex); + freeIndex(db, pIndex); } db->flags |= SQLITE_InternChanges; } @@ -471,11 +470,9 @@ void sqlite3CommitInternalChanges(sqlite3 *db){ /* ** Clear the column names from a table or view. */ -static void sqliteResetColumnNames(Table *pTable){ +static void sqliteResetColumnNames(sqlite3 *db, Table *pTable){ int i; Column *pCol; - sqlite3 *db = pTable->dbMem; - testcase( db==0 ); assert( pTable!=0 ); if( (pCol = pTable->aCol)!=0 ){ for(i=0; inCol; i++, pCol++){ @@ -500,13 +497,10 @@ static void sqliteResetColumnNames(Table *pTable){ ** memory structures of the indices and foreign keys associated with ** the table. */ -void sqlite3DeleteTable(Table *pTable){ +void sqlite3DeleteTable(sqlite3 *db, Table *pTable){ Index *pIndex, *pNext; - sqlite3 *db; if( pTable==0 ) return; - db = pTable->dbMem; - testcase( db==0 ); /* Do not delete the table until the reference count reaches zero. */ pTable->nRef--; @@ -520,22 +514,22 @@ void sqlite3DeleteTable(Table *pTable){ for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema ); - sqlite3DeleteIndex(pIndex); + sqlite3DeleteIndex(db, pIndex); } /* Delete any foreign keys attached to this table. */ - sqlite3FkDelete(pTable); + sqlite3FkDelete(db, pTable); /* Delete the Table structure itself. */ - sqliteResetColumnNames(pTable); + sqliteResetColumnNames(db, pTable); sqlite3DbFree(db, pTable->zName); sqlite3DbFree(db, pTable->zColAff); sqlite3SelectDelete(db, pTable->pSelect); #ifndef SQLITE_OMIT_CHECK sqlite3ExprDelete(db, pTable->pCheck); #endif - sqlite3VtabClear(pTable); + sqlite3VtabClear(db, pTable); sqlite3DbFree(db, pTable); } @@ -554,7 +548,7 @@ void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){ pDb = &db->aDb[iDb]; p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, sqlite3Strlen30(zTabName),0); - sqlite3DeleteTable(p); + sqlite3DeleteTable(db, p); db->flags |= SQLITE_InternChanges; } @@ -822,7 +816,6 @@ void sqlite3StartTable( pTable->iPKey = -1; pTable->pSchema = db->aDb[iDb].pSchema; pTable->nRef = 1; - pTable->dbMem = 0; assert( pParse->pNewTable==0 ); pParse->pNewTable = pTable; @@ -1555,7 +1548,7 @@ void sqlite3EndTable( p->aCol = pSelTab->aCol; pSelTab->nCol = 0; pSelTab->aCol = 0; - sqlite3DeleteTable(pSelTab); + sqlite3DeleteTable(db, pSelTab); } } @@ -1799,7 +1792,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ pTable->aCol = pSelTab->aCol; pSelTab->nCol = 0; pSelTab->aCol = 0; - sqlite3DeleteTable(pSelTab); + sqlite3DeleteTable(db, pSelTab); pTable->pSchema->flags |= DB_UnresetViews; }else{ pTable->nCol = 0; @@ -1824,7 +1817,7 @@ static void sqliteViewResetAll(sqlite3 *db, int idx){ for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){ Table *pTab = sqliteHashData(i); if( pTab->pSelect ){ - sqliteResetColumnNames(pTab); + sqliteResetColumnNames(db, pTab); } } DbClearProperty(db, idx, DB_UnresetViews); @@ -3200,7 +3193,7 @@ void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ sqlite3DbFree(db, pItem->zName); sqlite3DbFree(db, pItem->zAlias); sqlite3DbFree(db, pItem->zIndex); - sqlite3DeleteTable(pItem->pTab); + sqlite3DeleteTable(db, pItem->pTab); sqlite3SelectDelete(db, pItem->pSelect); sqlite3ExprDelete(db, pItem->pOn); sqlite3IdListDelete(db, pItem->pUsing); diff --git a/src/callback.c b/src/callback.c index c016959fd0..01b292b381 100644 --- a/src/callback.c +++ b/src/callback.c @@ -423,7 +423,7 @@ void sqlite3SchemaFree(void *p){ for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ Table *pTab = sqliteHashData(pElem); assert( pTab->dbMem==0 ); - sqlite3DeleteTable(pTab); + sqlite3DeleteTable(0, pTab); } sqlite3HashClear(&temp1); sqlite3HashClear(&pSchema->fkeyHash); diff --git a/src/delete.c b/src/delete.c index 9608dc2f53..bd7ac3d1f3 100644 --- a/src/delete.c +++ b/src/delete.c @@ -24,7 +24,7 @@ Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ Table *pTab; assert( pItem && pSrc->nSrc==1 ); pTab = sqlite3LocateTable(pParse, 0, pItem->zName, pItem->zDatabase); - sqlite3DeleteTable(pItem->pTab); + sqlite3DeleteTable(pParse->db, pItem->pTab); pItem->pTab = pTab; if( pTab ){ pTab->nRef++; diff --git a/src/fkey.c b/src/fkey.c index e6f4bfc05a..ea71f49aa9 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1155,7 +1155,7 @@ void sqlite3FkActions( ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash ** hash table. */ -void sqlite3FkDelete(Table *pTab){ +void sqlite3FkDelete(sqlite3 *db, Table *pTab){ FKey *pFKey; /* Iterator variable */ FKey *pNext; /* Copy of pFKey->pNextFrom */ @@ -1175,8 +1175,8 @@ void sqlite3FkDelete(Table *pTab){ /* Delete any triggers created to implement actions for this FK. */ #ifndef SQLITE_OMIT_TRIGGER - fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[0]); - fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[1]); + fkTriggerDelete(db, pFKey->apTrigger[0]); + fkTriggerDelete(db, pFKey->apTrigger[1]); #endif /* EV: R-30323-21917 Each foreign key constraint in SQLite is @@ -1185,7 +1185,7 @@ void sqlite3FkDelete(Table *pTab){ assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 ); pNext = pFKey->pNextFrom; - sqlite3DbFree(pTab->dbMem, pFKey); + sqlite3DbFree(db, pFKey); } } #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */ diff --git a/src/select.c b/src/select.c index b03e50638d..3008276a78 100644 --- a/src/select.c +++ b/src/select.c @@ -1300,14 +1300,13 @@ Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){ /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside ** is disabled, so we might as well hard-code pTab->dbMem to NULL. */ assert( db->lookaside.bEnabled==0 ); - pTab->dbMem = 0; pTab->nRef = 1; pTab->zName = 0; selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol); selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSelect); pTab->iPKey = -1; if( db->mallocFailed ){ - sqlite3DeleteTable(pTab); + sqlite3DeleteTable(db, pTab); return 0; } return pTab; @@ -3096,7 +3095,6 @@ static int selectExpander(Walker *pWalker, Select *p){ sqlite3WalkSelect(pWalker, pSel); pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table)); if( pTab==0 ) return WRC_Abort; - pTab->dbMem = db->lookaside.bEnabled ? db : 0; pTab->nRef = 1; pTab->zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", (void*)pTab); while( pSel->pPrior ){ pSel = pSel->pPrior; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3060f07487..a9a0885c18 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1217,7 +1217,6 @@ struct VTable { ** of a SELECT statement. */ struct Table { - sqlite3 *dbMem; /* DB connection used for lookaside allocations. */ char *zName; /* Name of the table or view */ int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ int nCol; /* Number of columns in this table */ @@ -2624,7 +2623,7 @@ void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); #endif void sqlite3DropTable(Parse*, SrcList*, int, int); -void sqlite3DeleteTable(Table*); +void sqlite3DeleteTable(sqlite3*, Table*); #ifndef SQLITE_OMIT_AUTOINCREMENT void sqlite3AutoincrementBegin(Parse *pParse); void sqlite3AutoincrementEnd(Parse *pParse); @@ -2971,7 +2970,7 @@ void sqlite3AutoLoadExtensions(sqlite3*); # define sqlite3VtabUnlock(X) # define sqlite3VtabUnlockList(X) #else - void sqlite3VtabClear(Table*); + void sqlite3VtabClear(sqlite3 *db, Table*); int sqlite3VtabSync(sqlite3 *db, char **); int sqlite3VtabRollback(sqlite3 *db); int sqlite3VtabCommit(sqlite3 *db); @@ -3024,9 +3023,9 @@ int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); #define sqlite3FkRequired(a,b,c,d) 0 #endif #ifndef SQLITE_OMIT_FOREIGN_KEY - void sqlite3FkDelete(Table*); + void sqlite3FkDelete(sqlite3 *, Table*); #else - #define sqlite3FkDelete(a) + #define sqlite3FkDelete(a,b) #endif diff --git a/src/tokenize.c b/src/tokenize.c index 4b40770d53..e8778e69a4 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -504,7 +504,7 @@ abort_parse: ** structure built up in pParse->pNewTable. The calling code (see vtab.c) ** will take responsibility for freeing the Table structure. */ - sqlite3DeleteTable(pParse->pNewTable); + sqlite3DeleteTable(db, pParse->pNewTable); } sqlite3DeleteTrigger(db, pParse->pNewTrigger); @@ -518,7 +518,7 @@ abort_parse: while( pParse->pZombieTab ){ Table *p = pParse->pZombieTab; pParse->pZombieTab = p->pNextZombie; - sqlite3DeleteTable(p); + sqlite3DeleteTable(db, p); } if( nErr>0 && pParse->rc==SQLITE_OK ){ pParse->rc = SQLITE_ERROR; diff --git a/src/vtab.c b/src/vtab.c index d238460241..5bf8676043 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -221,14 +221,14 @@ void sqlite3VtabUnlockList(sqlite3 *db){ ** in the list are moved to the sqlite3.pDisconnect list of the associated ** database connection. */ -void sqlite3VtabClear(Table *p){ +void sqlite3VtabClear(sqlite3 *db, Table *p){ vtabDisconnectAll(0, p); if( p->azModuleArg ){ int i; for(i=0; inModuleArg; i++){ - sqlite3DbFree(p->dbMem, p->azModuleArg[i]); + sqlite3DbFree(db, p->azModuleArg[i]); } - sqlite3DbFree(p->dbMem, p->azModuleArg); + sqlite3DbFree(db, p->azModuleArg); } } @@ -681,7 +681,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ if( pParse->pVdbe ){ sqlite3VdbeFinalize(pParse->pVdbe); } - sqlite3DeleteTable(pParse->pNewTable); + sqlite3DeleteTable(db, pParse->pNewTable); sqlite3StackFree(db, pParse); }