mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
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
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
** interface, and routines that contribute to loading the database schema
|
||||
** from disk.
|
||||
**
|
||||
** $Id: prepare.c,v 1.89 2008/07/08 19:34:07 drh Exp $
|
||||
** $Id: prepare.c,v 1.90 2008/07/28 19:34:53 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@@ -32,7 +32,7 @@ static void corruptSchema(
|
||||
sqlite3SetString(pData->pzErrMsg, pData->db,
|
||||
"malformed database schema (%s)", zObj);
|
||||
if( zExtra && zExtra[0] ){
|
||||
*pData->pzErrMsg = sqlite3MPrintf(pData->db, "%z - %s",
|
||||
*pData->pzErrMsg = sqlite3MAppendf(pData->db, *pData->pzErrMsg, "%s - %s",
|
||||
*pData->pzErrMsg, zExtra);
|
||||
}
|
||||
}
|
||||
@@ -79,11 +79,15 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
|
||||
*/
|
||||
char *zErr;
|
||||
int rc;
|
||||
u8 lookasideEnabled;
|
||||
assert( db->init.busy );
|
||||
db->init.iDb = iDb;
|
||||
db->init.newTnum = atoi(argv[1]);
|
||||
lookasideEnabled = db->lookaside.bEnabled;
|
||||
db->lookaside.bEnabled = 0;
|
||||
rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
|
||||
db->init.iDb = 0;
|
||||
db->lookaside.bEnabled = lookasideEnabled;
|
||||
assert( rc!=SQLITE_OK || zErr==0 );
|
||||
if( SQLITE_OK!=rc ){
|
||||
pData->rc = rc;
|
||||
@@ -92,7 +96,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
|
||||
}else if( rc!=SQLITE_INTERRUPT ){
|
||||
corruptSchema(pData, argv[0], zErr);
|
||||
}
|
||||
sqlite3_free(zErr);
|
||||
sqlite3DbFree(db, zErr);
|
||||
return 1;
|
||||
}
|
||||
}else if( argv[0]==0 ){
|
||||
@@ -336,7 +340,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
|
||||
#endif
|
||||
if( rc==SQLITE_ABORT ) rc = initData.rc;
|
||||
(void)sqlite3SafetyOn(db);
|
||||
sqlite3_free(zSql);
|
||||
sqlite3DbFree(db, zSql);
|
||||
#ifndef SQLITE_OMIT_ANALYZE
|
||||
if( rc==SQLITE_OK ){
|
||||
sqlite3AnalysisLoad(db, iDb);
|
||||
@@ -568,7 +572,7 @@ static int sqlite3Prepare(
|
||||
zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);
|
||||
if( zSqlCopy ){
|
||||
sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);
|
||||
sqlite3_free(zSqlCopy);
|
||||
sqlite3DbFree(db, zSqlCopy);
|
||||
sParse.zTail = &zSql[sParse.zTail-zSqlCopy];
|
||||
}else{
|
||||
sParse.zTail = &zSql[nBytes];
|
||||
@@ -632,7 +636,7 @@ static int sqlite3Prepare(
|
||||
|
||||
if( zErrMsg ){
|
||||
sqlite3Error(db, rc, "%s", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
sqlite3DbFree(db, zErrMsg);
|
||||
}else{
|
||||
sqlite3Error(db, rc, 0);
|
||||
}
|
||||
@@ -767,7 +771,7 @@ static int sqlite3Prepare16(
|
||||
int chars_parsed = sqlite3Utf8CharLen(zSql8, zTail8-zSql8);
|
||||
*pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);
|
||||
}
|
||||
sqlite3_free(zSql8);
|
||||
sqlite3DbFree(db, zSql8);
|
||||
rc = sqlite3ApiExit(db, rc);
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user