Change OP_OpenRead and OP_OpenWrite so that the database number is read from the P3 operand, not the stack. (CVS 4663)

FossilOrigin-Name: 35da261daf602b1e938f05bbad1ff99213d9f4b9
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index d56fbd1..864aadd 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 @@
   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_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},        /* 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_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 @@
       /* 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 @@
       ** 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);
       }