diff options
author | drh <drh@noemail.net> | 2008-07-28 19:34:53 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-07-28 19:34:53 +0000 |
commit | 633e6d57d92e943fbd3a52ea6627e1a1d0c338b7 (patch) | |
tree | 2a7a73f29836bc687d239754a4ff914cd4d46d27 /src/vtab.c | |
parent | 78bd9ca86f2d3537c2384896efe9882944222656 (diff) | |
download | sqlite-633e6d57d92e943fbd3a52ea6627e1a1d0c338b7.tar.gz sqlite-633e6d57d92e943fbd3a52ea6627e1a1d0c338b7.zip |
Implement the "lookaside" memory allocation cache. Use of this cache makes
the speed1.test script run about 15% faster. Added new interfaces to
control the cache. (CVS 5488)
FossilOrigin-Name: e48f9697e9fea339e150ddc32940760027dd07d9
Diffstat (limited to 'src/vtab.c')
-rw-r--r-- | src/vtab.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/vtab.c b/src/vtab.c index 2c71215de..c9ff4e0bd 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.71 2008/07/23 18:17:32 drh Exp $ +** $Id: vtab.c,v 1.72 2008/07/28 19:34:54 drh Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" @@ -41,7 +41,7 @@ static int createModule( if( pDel && pDel->xDestroy ){ pDel->xDestroy(pDel->pAux); } - sqlite3_free(pDel); + sqlite3DbFree(db, pDel); if( pDel==pMod ){ db->mallocFailed = 1; } @@ -116,17 +116,18 @@ void sqlite3VtabUnlock(sqlite3 *db, sqlite3_vtab *pVtab){ */ void sqlite3VtabClear(Table *p){ sqlite3_vtab *pVtab = p->pVtab; + sqlite3 *db = p->db; if( pVtab ){ assert( p->pMod && p->pMod->pModule ); - sqlite3VtabUnlock(p->pSchema->db, pVtab); + sqlite3VtabUnlock(db, pVtab); p->pVtab = 0; } if( p->azModuleArg ){ int i; for(i=0; i<p->nModuleArg; i++){ - sqlite3_free(p->azModuleArg[i]); + sqlite3DbFree(db, p->azModuleArg[i]); } - sqlite3_free(p->azModuleArg); + sqlite3DbFree(db, p->azModuleArg); } } @@ -144,10 +145,10 @@ static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){ if( azModuleArg==0 ){ int j; for(j=0; j<i; j++){ - sqlite3_free(pTable->azModuleArg[j]); + sqlite3DbFree(db, pTable->azModuleArg[j]); } - sqlite3_free(zArg); - sqlite3_free(pTable->azModuleArg); + sqlite3DbFree(db, zArg); + sqlite3DbFree(db, pTable->azModuleArg); pTable->nModuleArg = 0; }else{ azModuleArg[i] = zArg; @@ -278,7 +279,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ zStmt, pParse->regRowid ); - sqlite3_free(zStmt); + sqlite3DbFree(db, zStmt); v = sqlite3GetVdbe(pParse); sqlite3ChangeCookie(pParse, iDb); @@ -377,7 +378,7 @@ static int vtabCallConstructor( *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName); }else { *pzErr = sqlite3MPrintf(db, "%s", zErr); - sqlite3_free(zErr); + sqlite3DbFree(db, zErr); } }else if( db->pVTab ){ const char *zFormat = "vtable constructor did not declare schema: %s"; @@ -388,7 +389,7 @@ static int vtabCallConstructor( rc = rc2; } db->pVTab = 0; - sqlite3_free(zModuleName); + sqlite3DbFree(db, zModuleName); /* If everything went according to plan, loop through the columns ** of the table to see if any of them contain the token "hidden". @@ -457,7 +458,7 @@ int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){ if( rc!=SQLITE_OK ){ sqlite3ErrorMsg(pParse, "%s", zErr); } - sqlite3_free(zErr); + sqlite3DbFree(db, zErr); } return rc; @@ -493,7 +494,7 @@ static int addToVTrans(sqlite3 *db, sqlite3_vtab *pVtab){ ** ** If an error occurs, *pzErr is set to point an an English language ** description of the error and an SQLITE_XXX error code is returned. -** In this case the caller must call sqlite3_free() on *pzErr. +** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. */ int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){ int rc = SQLITE_OK; @@ -562,7 +563,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ db->pVTab = 0; } else { sqlite3Error(db, SQLITE_ERROR, zErr); - sqlite3_free(zErr); + sqlite3DbFree(db, zErr); rc = SQLITE_ERROR; } sParse.declareVtab = 0; @@ -632,7 +633,7 @@ static void callFinaliser(sqlite3 *db, int offset){ if( x ) x(pVtab); sqlite3VtabUnlock(db, pVtab); } - sqlite3_free(db->aVTrans); + sqlite3DbFree(db, db->aVTrans); db->nVTrans = 0; db->aVTrans = 0; } @@ -787,7 +788,7 @@ FuncDef *sqlite3VtabOverloadFunction( *z = sqlite3UpperToLower[*z]; } rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg); - sqlite3_free(zLowerName); + sqlite3DbFree(db, zLowerName); sqlite3VtabTransferError(db, rc, pVtab); } if( rc==0 ){ @@ -835,7 +836,7 @@ void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){ void sqlite3VtabTransferError(sqlite3 *db, int rc, sqlite3_vtab *pVtab){ if( pVtab->zErrMsg ){ sqlite3Error(db, rc, "%s", pVtab->zErrMsg); - sqlite3_free(pVtab->zErrMsg); + sqlite3DbFree(db, pVtab->zErrMsg); pVtab->zErrMsg = 0; } } |