mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Slightly smaller and faster by allocating Parser objects on the stack.
FossilOrigin-Name: 436a89b91901851ce21bf0cb997291b48888c52788b904822083d8dfac32b84b
This commit is contained in:
@@ -129,8 +129,8 @@ int sqlite3_blob_open(
|
||||
int rc = SQLITE_OK;
|
||||
char *zErr = 0;
|
||||
Table *pTab;
|
||||
Parse *pParse = 0;
|
||||
Incrblob *pBlob = 0;
|
||||
Parse sParse;
|
||||
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( ppBlob==0 ){
|
||||
@@ -148,37 +148,34 @@ int sqlite3_blob_open(
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
|
||||
pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));
|
||||
if( !pBlob ) goto blob_open_out;
|
||||
pParse = sqlite3StackAllocRaw(db, sizeof(*pParse));
|
||||
if( !pParse ) goto blob_open_out;
|
||||
|
||||
do {
|
||||
memset(pParse, 0, sizeof(Parse));
|
||||
pParse->db = db;
|
||||
memset(&sParse, 0, sizeof(Parse));
|
||||
if( !pBlob ) goto blob_open_out;
|
||||
sParse.db = db;
|
||||
sqlite3DbFree(db, zErr);
|
||||
zErr = 0;
|
||||
|
||||
sqlite3BtreeEnterAll(db);
|
||||
pTab = sqlite3LocateTable(pParse, 0, zTable, zDb);
|
||||
pTab = sqlite3LocateTable(&sParse, 0, zTable, zDb);
|
||||
if( pTab && IsVirtual(pTab) ){
|
||||
pTab = 0;
|
||||
sqlite3ErrorMsg(pParse, "cannot open virtual table: %s", zTable);
|
||||
sqlite3ErrorMsg(&sParse, "cannot open virtual table: %s", zTable);
|
||||
}
|
||||
if( pTab && !HasRowid(pTab) ){
|
||||
pTab = 0;
|
||||
sqlite3ErrorMsg(pParse, "cannot open table without rowid: %s", zTable);
|
||||
sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIEW
|
||||
if( pTab && pTab->pSelect ){
|
||||
pTab = 0;
|
||||
sqlite3ErrorMsg(pParse, "cannot open view: %s", zTable);
|
||||
sqlite3ErrorMsg(&sParse, "cannot open view: %s", zTable);
|
||||
}
|
||||
#endif
|
||||
if( !pTab ){
|
||||
if( pParse->zErrMsg ){
|
||||
if( sParse.zErrMsg ){
|
||||
sqlite3DbFree(db, zErr);
|
||||
zErr = pParse->zErrMsg;
|
||||
pParse->zErrMsg = 0;
|
||||
zErr = sParse.zErrMsg;
|
||||
sParse.zErrMsg = 0;
|
||||
}
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
@@ -242,7 +239,7 @@ int sqlite3_blob_open(
|
||||
}
|
||||
}
|
||||
|
||||
pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(pParse);
|
||||
pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(&sParse);
|
||||
assert( pBlob->pStmt || db->mallocFailed );
|
||||
if( pBlob->pStmt ){
|
||||
|
||||
@@ -315,10 +312,10 @@ int sqlite3_blob_open(
|
||||
aOp[1].p4.i = pTab->nCol+1;
|
||||
aOp[3].p2 = pTab->nCol;
|
||||
|
||||
pParse->nVar = 0;
|
||||
pParse->nMem = 1;
|
||||
pParse->nTab = 1;
|
||||
sqlite3VdbeMakeReady(v, pParse);
|
||||
sParse.nVar = 0;
|
||||
sParse.nMem = 1;
|
||||
sParse.nTab = 1;
|
||||
sqlite3VdbeMakeReady(v, &sParse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,8 +337,7 @@ blob_open_out:
|
||||
}
|
||||
sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
|
||||
sqlite3DbFree(db, zErr);
|
||||
sqlite3ParserReset(pParse);
|
||||
sqlite3StackFree(db, pParse);
|
||||
sqlite3ParserReset(&sParse);
|
||||
rc = sqlite3ApiExit(db, rc);
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user