aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analyze.c10
-rw-r--r--src/build.c11
-rw-r--r--src/delete.c5
-rw-r--r--src/expr.c7
-rw-r--r--src/insert.c46
-rw-r--r--src/select.c5
-rw-r--r--src/update.c5
-rw-r--r--src/vdbe.c28
-rw-r--r--src/vdbe.h3
-rw-r--r--src/vdbeaux.c11
-rw-r--r--src/vdbeblob.c33
-rw-r--r--src/where.c7
12 files changed, 78 insertions, 93 deletions
diff --git a/src/analyze.c b/src/analyze.c
index 0c70db5b1..ffcc6d6cf 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code associated with the ANALYZE command.
**
-** @(#) $Id: analyze.c,v 1.27 2008/01/03 00:01:24 drh Exp $
+** @(#) $Id: analyze.c,v 1.28 2008/01/03 07:54:24 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_ANALYZE
#include "sqliteInt.h"
@@ -72,8 +72,7 @@ static void openStatTable(
if( iRootPage>0 ){
sqlite3TableLock(pParse, iDb, iRootPage, 1, "sqlite_stat1");
}
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
- sqlite3VdbeAddOp2(v, OP_OpenWrite, iStatCur, iRootPage);
+ sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur, iRootPage, iDb);
sqlite3VdbeAddOp2(v, OP_SetNumColumns, iStatCur, 3);
}
@@ -122,10 +121,9 @@ static void analyzeOneTable(
/* Open a cursor to the index to be analyzed
*/
assert( iDb==sqlite3SchemaToIndex(pParse->db, pIdx->pSchema) );
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
- VdbeComment((v, "%s", pIdx->zName));
- sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb,
(char *)pKey, P4_KEYINFO_HANDOFF);
+ VdbeComment((v, "%s", pIdx->zName));
nCol = pIdx->nColumn;
if( iMem+nCol*2>=pParse->nMem ){
pParse->nMem = iMem+nCol*2+1;
diff --git a/src/build.c b/src/build.c
index 620663d75..48ed5bd41 100644
--- a/src/build.c
+++ b/src/build.c
@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
-** $Id: build.c,v 1.453 2008/01/03 00:01:24 drh Exp $
+** $Id: build.c,v 1.454 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -600,8 +600,7 @@ char *sqlite3NameFromToken(sqlite3 *db, Token *pName){
void sqlite3OpenMasterTable(Parse *p, int iDb){
Vdbe *v = sqlite3GetVdbe(p);
sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb));
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
- sqlite3VdbeAddOp2(v, OP_OpenWrite, 0, MASTER_ROOT);
+ sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb);
sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, 5); /* sqlite_master has 5 columns */
}
@@ -1495,8 +1494,7 @@ void sqlite3EndTable(
SelectDest dest = {SRT_Table, 1, 0};
Table *pSelTab;
sqlite3VdbeAddOp1(v, OP_Dup, 0);
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
- sqlite3VdbeAddOp2(v, OP_OpenWrite, 1, 0);
+ sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, 0, iDb);
pParse->nTab = 2;
sqlite3Select(pParse, pSelect, &dest, 0, 0, 0, 0);
sqlite3VdbeAddOp1(v, OP_Close, 1);
@@ -2243,9 +2241,8 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
tnum = pIndex->tnum;
sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
}
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
pKey = sqlite3IndexKeyinfo(pParse, pIndex);
- sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb,
(char *)pKey, P4_KEYINFO_HANDOFF);
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
diff --git a/src/delete.c b/src/delete.c
index 5f8269d9f..6214249b4 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements.
**
-** $Id: delete.c,v 1.140 2008/01/03 00:01:24 drh Exp $
+** $Id: delete.c,v 1.141 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -75,9 +75,8 @@ void sqlite3OpenTable(
v = sqlite3GetVdbe(p);
assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite), pTab->zName);
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
+ sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);
VdbeComment((v, "%s", pTab->zName));
- sqlite3VdbeAddOp2(v, opcode, iCur, pTab->tnum);
sqlite3VdbeAddOp2(v, OP_SetNumColumns, iCur, pTab->nCol);
}
diff --git a/src/expr.c b/src/expr.c
index 910966dff..776119730 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.325 2008/01/03 00:01:24 drh Exp $
+** $Id: expr.c,v 1.326 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1647,10 +1647,9 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int mustBeUnique){
iAddr = sqlite3VdbeAddOp2(v, OP_If, 0, iMem);
sqlite3VdbeAddOp2(v, OP_MemInt, 1, iMem);
- sqlite3VdbeAddOp1(v, OP_Integer, iDb);
- VdbeComment((v, "%s", pIdx->zName));
- sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb,
pKey,P4_KEYINFO_HANDOFF);
+ VdbeComment((v, "%s", pIdx->zName));
eType = IN_INDEX_INDEX;
sqlite3VdbeAddOp2(v, OP_SetNumColumns, iTab, pIdx->nColumn);
diff --git a/src/insert.c b/src/insert.c
index 58a4151a1..e8e0a0f4a 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.202 2008/01/03 00:01:24 drh Exp $
+** $Id: insert.c,v 1.203 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -111,21 +111,16 @@ static int readsTable(Vdbe *v, int iStartAddr, int iDb, Table *pTab){
for(i=iStartAddr; i<iEnd; i++){
VdbeOp *pOp = sqlite3VdbeGetOp(v, i);
assert( pOp!=0 );
- if( pOp->opcode==OP_OpenRead ){
- VdbeOp *pPrior = &pOp[-1];
+ if( pOp->opcode==OP_OpenRead && pOp->p3==iDb ){
+ Index *pIndex;
int tnum = pOp->p2;
- assert( i>iStartAddr );
- assert( pPrior->opcode==OP_Integer );
- if( pPrior->p1==iDb ){
- Index *pIndex;
- if( tnum==pTab->tnum ){
+ if( tnum==pTab->tnum ){
+ return 1;
+ }
+ for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
+ if( tnum==pIndex->tnum ){
return 1;
}
- for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
- if( tnum==pIndex->tnum ){
- return 1;
- }
- }
}
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -171,16 +166,16 @@ static int autoIncBegin(
memId = pParse->nMem+1;
pParse->nMem += 2;
sqlite3OpenTable(pParse, iCur, iDb, pDb->pSchema->pSeqTab, OP_OpenRead);
- sqlite3VdbeAddOp2(v, OP_Rewind, iCur, addr+13);
+ sqlite3VdbeAddOp2(v, OP_Rewind, iCur, addr+12);
sqlite3VdbeAddOp2(v, OP_Column, iCur, 0);
sqlite3VdbeAddOp4(v, OP_String8, 0, 0, 0, pTab->zName, 0);
- sqlite3VdbeAddOp2(v, OP_Ne, 0x100, addr+12);
+ sqlite3VdbeAddOp2(v, OP_Ne, 0x100, addr+11);
sqlite3VdbeAddOp2(v, OP_Rowid, iCur, 0);
sqlite3VdbeAddOp2(v, OP_MemStore, memId-1, 1);
sqlite3VdbeAddOp2(v, OP_Column, iCur, 1);
sqlite3VdbeAddOp2(v, OP_MemStore, memId, 1);
- sqlite3VdbeAddOp2(v, OP_Goto, 0, addr+13);
- sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+4);
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addr+12);
+ sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+3);
sqlite3VdbeAddOp2(v, OP_Close, iCur, 0);
}
return memId;
@@ -220,7 +215,7 @@ static void autoIncEnd(
addr = sqlite3VdbeCurrentAddr(v);
sqlite3OpenTable(pParse, iCur, iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);
sqlite3VdbeAddOp2(v, OP_MemLoad, memId-1, 0);
- sqlite3VdbeAddOp2(v, OP_NotNull, -1, addr+7);
+ sqlite3VdbeAddOp2(v, OP_NotNull, -1, addr+6);
sqlite3VdbeAddOp2(v, OP_Pop, 1, 0);
sqlite3VdbeAddOp2(v, OP_NewRowid, iCur, 0);
sqlite3VdbeAddOp4(v, OP_String8, 0, 0, 0, pTab->zName, 0);
@@ -1282,10 +1277,9 @@ void sqlite3OpenTableAndIndices(
for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);
assert( pIdx->pSchema==pTab->pSchema );
- sqlite3VdbeAddOp2(v, OP_Integer, iDb, 0);
- VdbeComment((v, "%s", pIdx->zName));
- sqlite3VdbeAddOp4(v, op, i+base, pIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, op, i+base, pIdx->tnum, iDb,
(char*)pKey, P4_KEYINFO_HANDOFF);
+ VdbeComment((v, "%s", pIdx->zName));
}
if( pParse->nTab<=base+i ){
pParse->nTab = base+i;
@@ -1581,16 +1575,14 @@ static int xferOptimization(
assert( pSrcIdx );
sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);
sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);
- sqlite3VdbeAddOp2(v, OP_Integer, iDbSrc, 0);
pKey = sqlite3IndexKeyinfo(pParse, pSrcIdx);
- VdbeComment((v, "%s", pSrcIdx->zName));
- sqlite3VdbeAddOp4(v, OP_OpenRead, iSrc, pSrcIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc,
(char*)pKey, P4_KEYINFO_HANDOFF);
- sqlite3VdbeAddOp2(v, OP_Integer, iDbDest, 0);
+ VdbeComment((v, "%s", pSrcIdx->zName));
pKey = sqlite3IndexKeyinfo(pParse, pDestIdx);
- VdbeComment((v, "%s", pDestIdx->zName));
- sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest,
(char*)pKey, P4_KEYINFO_HANDOFF);
+ VdbeComment((v, "%s", pDestIdx->zName));
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0);
sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, 0);
sqlite3VdbeAddOp2(v, OP_IdxInsert, iDest, 1);
diff --git a/src/select.c b/src/select.c
index f6c39bf42..38569fac7 100644
--- a/src/select.c
+++ b/src/select.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.378 2008/01/03 00:01:25 drh Exp $
+** $Id: select.c,v 1.379 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -2749,8 +2749,7 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, SelectDest *pDest){
KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);
iIdx = pParse->nTab++;
assert( pIdx->pSchema==pTab->pSchema );
- sqlite3VdbeAddOp2(v, OP_Integer, iDb, 0);
- sqlite3VdbeAddOp4(v, OP_OpenRead, iIdx, pIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenRead, iIdx, pIdx->tnum, iDb,
(char*)pKey, P4_KEYINFO_HANDOFF);
if( seekOp==OP_Rewind ){
sqlite3VdbeAddOp2(v, OP_Null, 0, 0);
diff --git a/src/update.c b/src/update.c
index 9d64b7d12..5791e52ad 100644
--- a/src/update.c
+++ b/src/update.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
-** $Id: update.c,v 1.149 2008/01/03 00:01:25 drh Exp $
+** $Id: update.c,v 1.150 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -380,8 +380,7 @@ void sqlite3Update(
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
if( openAll || aIdxUsed[i] ){
KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);
- sqlite3VdbeAddOp2(v, OP_Integer, iDb, 0);
- sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur+i+1, pIdx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur+i+1, pIdx->tnum, iDb,
(char*)pKey, P4_KEYINFO_HANDOFF);
assert( pParse->nTab>iCur+i+1 );
}
diff --git a/src/vdbe.c b/src/vdbe.c
index f7b149a65..c94bf4ab1 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.665 2008/01/03 07:09:48 danielk1977 Exp $
+** $Id: vdbe.c,v 1.666 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -2796,17 +2796,16 @@ case OP_VerifyCookie: { /* no-push */
break;
}
-/* Opcode: OpenRead P1 P2 P4
+/* Opcode: OpenRead P1 P2 P3 P4 *
**
** Open a read-only cursor for the database table whose root page is
-** P2 in a database file. The database file is determined by an
-** integer from the top of the stack. 0 means the main database and
-** 1 means the database used for temporary tables. Give the new
-** cursor an identifier of P1. The P1 values need not be contiguous
-** but all P1 values should be small integers. It is an error for
-** P1 to be negative.
+** P2 in a database file. The database file is determined by P3.
+** 0 means the main database and 1 means the database used for
+** temporary tables. Give the new cursor an identifier of P1. The P1
+** values need not be contiguous but all P1 values should be small integers.
+** It is an error for P1 to be negative.
**
-** If P2==0 then take the root page number from the next of the stack.
+** If P2==0 then take the root page number from the top of the stack.
**
** There will be a read lock on the database whenever there is an
** open cursor. If the database was unlocked prior to this instruction
@@ -2823,7 +2822,7 @@ case OP_VerifyCookie: { /* no-push */
**
** See also OpenWrite.
*/
-/* Opcode: OpenWrite P1 P2 P4
+/* Opcode: OpenWrite P1 P2 P3 P4 *
**
** Open a read/write cursor named P1 on the table or index whose root
** page is P2. If P2==0 then take the root page number from the stack.
@@ -2842,17 +2841,12 @@ case OP_OpenRead: /* no-push */
case OP_OpenWrite: { /* no-push */
int i = pOp->p1;
int p2 = pOp->p2;
+ int iDb = pOp->p3;
int wrFlag;
Btree *pX;
- int iDb;
Cursor *pCur;
Db *pDb;
- assert( pTos>=p->aStack );
- sqlite3VdbeMemIntegerify(pTos);
- iDb = pTos->u.i;
- assert( (pTos->flags & MEM_Dyn)==0 );
- pTos--;
assert( iDb>=0 && iDb<db->nDb );
assert( (p->btreeMask & (1<<iDb))!=0 );
pDb = &db->aDb[iDb];
@@ -2896,7 +2890,7 @@ case OP_OpenWrite: { /* no-push */
case SQLITE_BUSY: {
p->pc = pc;
p->rc = rc = SQLITE_BUSY;
- p->pTos = &pTos[1 + (pOp->p2<=0)]; /* Operands must remain on stack */
+ p->pTos = &pTos[(pOp->p2<=0)]; /* Operands must remain on stack */
goto vdbe_return;
}
case SQLITE_OK: {
diff --git a/src/vdbe.h b/src/vdbe.h
index 6b1462ffa..30538add2 100644
--- a/src/vdbe.h
+++ b/src/vdbe.h
@@ -15,7 +15,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database.
**
-** $Id: vdbe.h,v 1.119 2008/01/03 01:28:59 drh Exp $
+** $Id: vdbe.h,v 1.120 2008/01/03 07:54:24 danielk1977 Exp $
*/
#ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_
@@ -133,6 +133,7 @@ int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
+void sqlite3VdbeChangeP3(Vdbe*, int addr, int P2);
void sqlite3VdbeJumpHere(Vdbe*, int addr);
void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N);
void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index dd631571f..e0f7d824e 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -438,6 +438,17 @@ void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){
}
/*
+** Change the value of the P2 operand for a specific instruction.
+** This routine is useful for setting a jump destination.
+*/
+void sqlite3VdbeChangeP3(Vdbe *p, int addr, int val){
+ assert( p==0 || p->magic==VDBE_MAGIC_INIT );
+ if( p && addr>=0 && p->nOp>addr && p->aOp ){
+ p->aOp[addr].p3 = val;
+ }
+}
+
+/*
** Change the P2 operand of instruction addr so that it points to
** the address of the next instruction to be coded.
*/
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index d56fbd127..864aadd9b 100644
--- a/src/vdbeblob.c
+++ b/src/vdbeblob.c
@@ -12,7 +12,7 @@
**
** This file contains code used to implement incremental BLOB I/O.
**
-** $Id: vdbeblob.c,v 1.16 2007/08/30 01:19:59 drh Exp $
+** $Id: vdbeblob.c,v 1.17 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -66,21 +66,20 @@ int sqlite3_blob_open(
static const VdbeOpList openBlob[] = {
{OP_Transaction, 0, 0, 0}, /* 0: Start a transaction */
{OP_VerifyCookie, 0, 0, 0}, /* 1: Check the schema cookie */
- {OP_Integer, 0, 0, 0}, /* 2: Database number */
/* One of the following two instructions is replaced by an
** OP_Noop before exection.
*/
- {OP_OpenRead, 0, 0, 0}, /* 3: Open cursor 0 for reading */
- {OP_OpenWrite, 0, 0, 0}, /* 4: Open cursor 0 for read/write */
- {OP_SetNumColumns, 0, 0, 0}, /* 5: Num cols for cursor */
-
- {OP_Variable, 1, 0, 0}, /* 6: Push the rowid to the stack */
- {OP_NotExists, 0, 10, 0}, /* 7: Seek the cursor */
- {OP_Column, 0, 0, 0}, /* 8 */
- {OP_Callback, 0, 0, 0}, /* 9 */
- {OP_Close, 0, 0, 0}, /* 10 */
- {OP_Halt, 0, 0, 0}, /* 11 */
+ {OP_OpenRead, 0, 0, 0}, /* 2: Open cursor 0 for reading */
+ {OP_OpenWrite, 0, 0, 0}, /* 3: Open cursor 0 for read/write */
+ {OP_SetNumColumns, 0, 0, 0}, /* 4: Num cols for cursor */
+
+ {OP_Variable, 1, 0, 0}, /* 5: Push the rowid to the stack */
+ {OP_NotExists, 0, 10, 0}, /* 6: Seek the cursor */
+ {OP_Column, 0, 0, 0}, /* 7 */
+ {OP_Callback, 0, 0, 0}, /* 8 */
+ {OP_Close, 0, 0, 0}, /* 9 */
+ {OP_Halt, 0, 0, 0}, /* 10 */
};
Vdbe *v = 0;
@@ -166,14 +165,12 @@ int sqlite3_blob_open(
/* Make sure a mutex is held on the table to be accessed */
sqlite3VdbeUsesBtree(v, iDb);
- /* Configure the db number pushed onto the stack */
- sqlite3VdbeChangeP1(v, 2, iDb);
-
/* Remove either the OP_OpenWrite or OpenRead. Set the P2
** parameter of the other to pTab->tnum.
*/
- sqlite3VdbeChangeToNoop(v, (flags ? 3 : 4), 1);
- sqlite3VdbeChangeP2(v, (flags ? 4 : 3), pTab->tnum);
+ sqlite3VdbeChangeToNoop(v, (flags ? 2 : 3), 1);
+ sqlite3VdbeChangeP2(v, (flags ? 3 : 2), pTab->tnum);
+ sqlite3VdbeChangeP3(v, (flags ? 3 : 2), iDb);
/* Configure the OP_SetNumColumns. Configure the cursor to
** think that the table has one more column than it really
@@ -182,7 +179,7 @@ int sqlite3_blob_open(
** we can invoke OP_Column to fill in the vdbe cursors type
** and offset cache without causing any IO.
*/
- sqlite3VdbeChangeP2(v, 5, pTab->nCol+1);
+ sqlite3VdbeChangeP2(v, 4, pTab->nCol+1);
if( !db->mallocFailed ){
sqlite3VdbeMakeReady(v, 1, 0, 1, 0);
}
diff --git a/src/where.c b/src/where.c
index 38083e89a..f2a86658b 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.268 2008/01/03 00:01:26 drh Exp $
+** $Id: where.c,v 1.269 2008/01/03 07:54:24 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -2212,10 +2212,9 @@ WhereInfo *sqlite3WhereBegin(
if( (pIx = pLevel->pIdx)!=0 ){
KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIx);
assert( pIx->pSchema==pTab->pSchema );
- sqlite3VdbeAddOp2(v, OP_Integer, iDb, 0);
- VdbeComment((v, "%s", pIx->zName));
- sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx->tnum, 0,
+ sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx->tnum, iDb,
(char*)pKey, P4_KEYINFO_HANDOFF);
+ VdbeComment((v, "%s", pIx->zName));
sqlite3VdbeAddOp2(v, OP_SetNumColumns, iIdxCur, pIx->nColumn+1);
}
sqlite3CodeVerifySchema(pParse, iDb);