mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Minor performance optimizations to sqlite3_blob_open() and
sqlite3_blob_reopen(). FossilOrigin-Name: 52a61967d920047ea0b4409b79793e05c0128964
This commit is contained in:
@@ -57,12 +57,17 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
|
||||
char *zErr = 0; /* Error message */
|
||||
Vdbe *v = (Vdbe *)p->pStmt;
|
||||
|
||||
/* Set the value of the SQL statements only variable to integer iRow.
|
||||
** This is done directly instead of using sqlite3_bind_int64() to avoid
|
||||
** triggering asserts related to mutexes.
|
||||
/* Set the value of register r[1] in the SQL statement to integer iRow.
|
||||
** This is done directly as a performance optimization
|
||||
*/
|
||||
assert( v->aVar[0].flags&MEM_Int );
|
||||
v->aVar[0].u.i = iRow;
|
||||
v->aMem[1].flags = MEM_Int;
|
||||
v->aMem[1].u.i = iRow;
|
||||
|
||||
/* If the statement has been run before (and is paused at the OP_ResultRow)
|
||||
** then back it up to the point where it does the OP_SeekRowid. This could
|
||||
** have been down with an extra OP_Goto, but simply setting the program
|
||||
** counter is faster. */
|
||||
if( v->pc>3 ) v->pc = 3;
|
||||
|
||||
rc = sqlite3_step(p->pStmt);
|
||||
if( rc==SQLITE_ROW ){
|
||||
@@ -257,12 +262,11 @@ int sqlite3_blob_open(
|
||||
static const VdbeOpList openBlob[] = {
|
||||
{OP_TableLock, 0, 0, 0}, /* 0: Acquire a read or write lock */
|
||||
{OP_OpenRead, 0, 0, 0}, /* 1: Open a cursor */
|
||||
{OP_Variable, 1, 1, 0}, /* 2: Move ?1 into reg[1] */
|
||||
{OP_NotExists, 0, 7, 1}, /* 3: Seek the cursor */
|
||||
{OP_Column, 0, 0, 1}, /* 4 */
|
||||
{OP_ResultRow, 1, 0, 0}, /* 5 */
|
||||
{OP_Goto, 0, 2, 0}, /* 6 */
|
||||
{OP_Halt, 0, 0, 0}, /* 7 */
|
||||
/* blobSeekToRow() will initialize r[1] to the desired rowid */
|
||||
{OP_NotExists, 0, 5, 1}, /* 2: Seek the cursor to rowid=r[1] */
|
||||
{OP_Column, 0, 0, 1}, /* 3 */
|
||||
{OP_ResultRow, 1, 0, 0}, /* 4 */
|
||||
{OP_Halt, 0, 0, 0}, /* 5 */
|
||||
};
|
||||
Vdbe *v = (Vdbe *)pBlob->pStmt;
|
||||
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
@@ -306,9 +310,9 @@ int sqlite3_blob_open(
|
||||
*/
|
||||
aOp[1].p4type = P4_INT32;
|
||||
aOp[1].p4.i = pTab->nCol+1;
|
||||
aOp[4].p2 = pTab->nCol;
|
||||
aOp[3].p2 = pTab->nCol;
|
||||
|
||||
pParse->nVar = 1;
|
||||
pParse->nVar = 0;
|
||||
pParse->nMem = 1;
|
||||
pParse->nTab = 1;
|
||||
sqlite3VdbeMakeReady(v, pParse);
|
||||
|
||||
Reference in New Issue
Block a user