/ Check-in [d23849f6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplification of the VDBE bytecode for incremental blob I/O.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d23849f64a110e336f26282bf2b961a2a2372468
User & Date: drh 2016-01-18 00:46:11
Context
2016-01-18
09:08
Add a debugging function to print human-readable versions of fts5 detail=none leaf pages. check-in: 8358af36 user: dan tags: trunk
00:46
Simplification of the VDBE bytecode for incremental blob I/O. check-in: d23849f6 user: drh tags: trunk
00:20
Fix a problem with SQLITE_TEST_REALLOC_STRESS. check-in: 0aaf3feb user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeblob.c.

245
246
247
248
249
250
251
252
253

254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
      ** uses it to implement the blob_read(), blob_write() and 
      ** blob_bytes() functions.
      **
      ** The sqlite3_blob_close() function finalizes the vdbe program,
      ** which closes the b-tree cursor and (possibly) commits the 
      ** transaction.
      */
      static const int iLn = VDBE_OFFSET_LINENO(3);
      static const VdbeOpList openBlob[] = {

        /* {OP_Transaction, 0, 0, 0},  // inserted separately */
        {OP_TableLock, 0, 0, 0},       /* 0: Acquire a read or write lock */
        {OP_OpenRead, 0, 0, 0},        /* 1: Open cursor 0 for reading */
        {OP_OpenWrite, 0, 0, 0},       /* 2: Open cursor 0 for read/write */
        {OP_Variable, 1, 1, 1},        /* 3: Push the rowid to the stack */
        {OP_NotExists, 0, 10, 1},      /* 4: Seek the cursor */
        {OP_Column, 0, 0, 1},          /* 5  */
        {OP_ResultRow, 1, 0, 0},       /* 6  */
        {OP_Goto, 0, 4, 0},            /* 7  */
        {OP_Close, 0, 0, 0},           /* 8  */
        {OP_Halt, 0, 0, 0},            /* 9 */
      };
      Vdbe *v = (Vdbe *)pBlob->pStmt;
      int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
      VdbeOp *aOp;

      sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags, 
                           pTab->pSchema->schema_cookie,
................................................................................
        sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT);
      }
      if( db->mallocFailed==0 ){
#endif

        /* Remove either the OP_OpenWrite or OpenRead. Set the P2 
        ** parameter of the other to pTab->tnum.  */
        aOp[2-flags].opcode = OP_Noop;
        aOp[1+flags].p2 = pTab->tnum;
        aOp[1+flags].p3 = iDb;   

        /* Configure the number of columns. Configure the cursor to
        ** think that the table has one more column than it really
        ** does. An OP_Column to retrieve this imaginary column will
        ** always return an SQL NULL. This is useful because it means
        ** we can invoke OP_Column to fill in the vdbe cursors type 
        ** and offset cache without causing any IO.
        */
        aOp[1+flags].p4type = P4_INT32;
        aOp[1+flags].p4.i = pTab->nCol+1;
        aOp[5].p2 = pTab->nCol;

        pParse->nVar = 1;
        pParse->nMem = 1;
        pParse->nTab = 1;
        sqlite3VdbeMakeReady(v, pParse);
      }
    }







|

>
|
|
|
<
|
|
|
|
|
|
|







 







|
|
|








|
|
|







245
246
247
248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
      ** uses it to implement the blob_read(), blob_write() and 
      ** blob_bytes() functions.
      **
      ** The sqlite3_blob_close() function finalizes the vdbe program,
      ** which closes the b-tree cursor and (possibly) commits the 
      ** transaction.
      */
      static const int iLn = VDBE_OFFSET_LINENO(4);
      static const VdbeOpList openBlob[] = {
                                    /* addr/ofst */
        /* {OP_Transaction, 0, 0, 0},  // 0/   inserted separately */
        {OP_TableLock, 0, 0, 0},       /* 1/0: Acquire a read or write lock */
        {OP_OpenRead, 0, 0, 0},        /* 2/1: Open a cursor */

        {OP_Variable, 1, 1, 0},        /* 3/2: Move ?1 into reg[1] */
        {OP_NotExists, 0, 8, 1},       /* 4/3: Seek the cursor */
        {OP_Column, 0, 0, 1},          /* 5/4  */
        {OP_ResultRow, 1, 0, 0},       /* 6/5  */
        {OP_Goto, 0, 3, 0},            /* 7/6  */
        {OP_Close, 0, 0, 0},           /* 8/7  */
        {OP_Halt, 0, 0, 0},            /* 9/8  */
      };
      Vdbe *v = (Vdbe *)pBlob->pStmt;
      int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
      VdbeOp *aOp;

      sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags, 
                           pTab->pSchema->schema_cookie,
................................................................................
        sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT);
      }
      if( db->mallocFailed==0 ){
#endif

        /* Remove either the OP_OpenWrite or OpenRead. Set the P2 
        ** parameter of the other to pTab->tnum.  */
        if( flags ) aOp[1].opcode = OP_OpenWrite;
        aOp[1].p2 = pTab->tnum;
        aOp[1].p3 = iDb;   

        /* Configure the number of columns. Configure the cursor to
        ** think that the table has one more column than it really
        ** does. An OP_Column to retrieve this imaginary column will
        ** always return an SQL NULL. This is useful because it means
        ** we can invoke OP_Column to fill in the vdbe cursors type 
        ** and offset cache without causing any IO.
        */
        aOp[1].p4type = P4_INT32;
        aOp[1].p4.i = pTab->nCol+1;
        aOp[4].p2 = pTab->nCol;

        pParse->nVar = 1;
        pParse->nMem = 1;
        pParse->nTab = 1;
        sqlite3VdbeMakeReady(v, pParse);
      }
    }