/ Check-in [5dbb255a]
Login

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

Overview
Comment:Simplify the sqlite3VdbeGet() routine. Smaller, faster, and easier to maintain.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5dbb255a9377a6c2619fbac519f18caa4d8cb23257dfba0ffb9e36dd9dc16627
User & Date: drh 2017-09-16 20:58:41
Context
2017-09-17
19:45
Do not make the assumption (as check-in [4da49a95c0f07] incorrectly did) that the ExprList returned by sqlite3ExprListDup() would never be passed into sqlite3ExprListAppend(). Include a new test case that shows this sometimes does happen. check-in: 29227d00 user: drh tags: trunk
2017-09-16
20:58
Simplify the sqlite3VdbeGet() routine. Smaller, faster, and easier to maintain. check-in: 5dbb255a user: drh tags: trunk
2017-09-15
17:40
Remove an unnecessary parameter from selectInnerLoop(). check-in: dd95887f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  1857   1857     return pTab;
  1858   1858   }
  1859   1859   
  1860   1860   /*
  1861   1861   ** Get a VDBE for the given parser context.  Create a new one if necessary.
  1862   1862   ** If an error occurs, return NULL and leave a message in pParse.
  1863   1863   */
  1864         -static SQLITE_NOINLINE Vdbe *allocVdbe(Parse *pParse){
  1865         -  Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
  1866         -  if( v ) sqlite3VdbeAddOp2(v, OP_Init, 0, 1);
         1864  +Vdbe *sqlite3GetVdbe(Parse *pParse){
         1865  +  if( pParse->pVdbe ){
         1866  +    return pParse->pVdbe;
         1867  +  }
  1867   1868     if( pParse->pToplevel==0
  1868   1869      && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
  1869   1870     ){
  1870   1871       pParse->okConstFactor = 1;
  1871   1872     }
  1872         -  return v;
  1873         -}
  1874         -Vdbe *sqlite3GetVdbe(Parse *pParse){
  1875         -  Vdbe *v = pParse->pVdbe;
  1876         -  return v ? v : allocVdbe(pParse);
         1873  +  return sqlite3VdbeCreate(pParse);
  1877   1874   }
  1878   1875   
  1879   1876   
  1880   1877   /*
  1881   1878   ** Compute the iLimit and iOffset fields of the SELECT based on the
  1882   1879   ** pLimit and pOffset expressions.  pLimit and pOffset hold the expressions
  1883   1880   ** that appear in the original SQL statement after the LIMIT and OFFSET

Changes to src/vdbeaux.c.

    29     29       db->pVdbe->pPrev = p;
    30     30     }
    31     31     p->pNext = db->pVdbe;
    32     32     p->pPrev = 0;
    33     33     db->pVdbe = p;
    34     34     p->magic = VDBE_MAGIC_INIT;
    35     35     p->pParse = pParse;
           36  +  pParse->pVdbe = p;
    36     37     assert( pParse->aLabel==0 );
    37     38     assert( pParse->nLabel==0 );
    38     39     assert( pParse->nOpAlloc==0 );
    39     40     assert( pParse->szOpAlloc==0 );
           41  +  sqlite3VdbeAddOp2(p, OP_Init, 0, 1);
    40     42     return p;
    41     43   }
    42     44   
    43     45   /*
    44     46   ** Change the error string stored in Vdbe.zErrMsg
    45     47   */
    46     48   void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){

Changes to src/vdbeblob.c.

   271    271         Vdbe *v = (Vdbe *)pBlob->pStmt;
   272    272         int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   273    273         VdbeOp *aOp;
   274    274   
   275    275         sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag, 
   276    276                              pTab->pSchema->schema_cookie,
   277    277                              pTab->pSchema->iGeneration);
   278         -      sqlite3VdbeChangeP5(v, 1);     
          278  +      sqlite3VdbeChangeP5(v, 1);
          279  +      assert( sqlite3VdbeCurrentAddr(v)==2 || db->mallocFailed );
   279    280         aOp = sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn);
   280    281   
   281    282         /* Make sure a mutex is held on the table to be accessed */
   282    283         sqlite3VdbeUsesBtree(v, iDb); 
   283    284   
   284    285         if( db->mallocFailed==0 ){
   285    286           assert( aOp!=0 );
................................................................................
   286    287           /* Configure the OP_TableLock instruction */
   287    288   #ifdef SQLITE_OMIT_SHARED_CACHE
   288    289           aOp[0].opcode = OP_Noop;
   289    290   #else
   290    291           aOp[0].p1 = iDb;
   291    292           aOp[0].p2 = pTab->tnum;
   292    293           aOp[0].p3 = wrFlag;
   293         -        sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT);
          294  +        sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);
   294    295         }
   295    296         if( db->mallocFailed==0 ){
   296    297   #endif
   297    298   
   298    299           /* Remove either the OP_OpenWrite or OpenRead. Set the P2 
   299    300           ** parameter of the other to pTab->tnum.  */
   300    301           if( wrFlag ) aOp[1].opcode = OP_OpenWrite;