/ Check-in [192dea97]
Login

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

Overview
Comment:Change the OP_Trace opcode to OP_Init and give it the ability to jump to the initialization code at the bottom of the program, thus avoiding the need for an extra OP_Goto.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:192dea97316144f15f6dd0eabff08a0bf9ef203e
User & Date: drh 2014-02-08 01:40:27
Context
2014-02-08
04:24
Enable constant expression factoring even if no tables are read and no transaction is started. check-in: a45b8771 user: drh tags: trunk
01:40
Change the OP_Trace opcode to OP_Init and give it the ability to jump to the initialization code at the bottom of the program, thus avoiding the need for an extra OP_Goto. check-in: 192dea97 user: drh tags: trunk
2014-02-07
22:21
Add opcodes OP_InitCoroutine and OP_EndCoroutine. Use these to remove the need for separate boolean registers to record when a co-routine has finished. check-in: 5a88b6a7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   145    145   
   146    146       /* The cookie mask contains one bit for each database file open.
   147    147       ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are
   148    148       ** set for each database that is used.  Generate code to start a
   149    149       ** transaction on each used database and to verify the schema cookie
   150    150       ** on each used database.
   151    151       */
   152         -    if( pParse->cookieGoto>0 ){
          152  +    if( db->mallocFailed==0 && pParse->cookieMask ){
   153    153         yDbMask mask;
   154         -      int iDb, i, addr;
   155         -      sqlite3VdbeJumpHere(v, pParse->cookieGoto-1);
          154  +      int iDb, i;
          155  +      assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );
          156  +      sqlite3VdbeJumpHere(v, 0);
   156    157         for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){
   157    158           if( (mask & pParse->cookieMask)==0 ) continue;
   158    159           sqlite3VdbeUsesBtree(v, iDb);
   159    160           sqlite3VdbeAddOp4Int(v,
   160    161             OP_Transaction,                    /* Opcode */
   161    162             iDb,                               /* P1 */
   162    163             (mask & pParse->writeMask)!=0,     /* P2 */
................................................................................
   180    181         codeTableLocks(pParse);
   181    182   
   182    183         /* Initialize any AUTOINCREMENT data structures required.
   183    184         */
   184    185         sqlite3AutoincrementBegin(pParse);
   185    186   
   186    187         /* Code constant expressions that where factored out of inner loops */
   187         -      addr = pParse->cookieGoto;
   188    188         if( pParse->pConstExpr ){
   189    189           ExprList *pEL = pParse->pConstExpr;
   190         -        pParse->cookieGoto = 0;
          190  +        pParse->okConstFactor = 0;
   191    191           for(i=0; i<pEL->nExpr; i++){
   192    192             sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
   193    193           }
   194    194         }
   195    195   
   196    196         /* Finally, jump back to the beginning of the executable code. */
   197         -      sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
          197  +      sqlite3VdbeAddOp2(v, OP_Goto, 0, 1);
   198    198       }
   199    199     }
   200    200   
   201    201   
   202    202     /* Get the VDBE program ready for execution
   203    203     */
   204    204     if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
................................................................................
   213    213       pParse->rc = SQLITE_ERROR;
   214    214     }
   215    215     pParse->nTab = 0;
   216    216     pParse->nMem = 0;
   217    217     pParse->nSet = 0;
   218    218     pParse->nVar = 0;
   219    219     pParse->cookieMask = 0;
   220         -  pParse->cookieGoto = 0;
   221    220   }
   222    221   
   223    222   /*
   224    223   ** Run the parser and code generator recursively in order to generate
   225    224   ** code for the SQL statement given onto the end of the pParse context
   226    225   ** currently under construction.  When the parser is run recursively
   227    226   ** this way, the final OP_Halt is not appended and other initialization
................................................................................
  3822   3821         return 1;
  3823   3822       }
  3824   3823     }
  3825   3824     return 0;
  3826   3825   }
  3827   3826   
  3828   3827   /*
  3829         -** Generate VDBE code that will verify the schema cookie and start
  3830         -** a read-transaction for all named database files.
  3831         -**
  3832         -** It is important that all schema cookies be verified and all
  3833         -** read transactions be started before anything else happens in
  3834         -** the VDBE program.  But this routine can be called after much other
  3835         -** code has been generated.  So here is what we do:
  3836         -**
  3837         -** The first time this routine is called, we code an OP_Goto that
  3838         -** will jump to a subroutine at the end of the program.  Then we
  3839         -** record every database that needs its schema verified in the
  3840         -** pParse->cookieMask field.  Later, after all other code has been
  3841         -** generated, the subroutine that does the cookie verifications and
  3842         -** starts the transactions will be coded and the OP_Goto P2 value
  3843         -** will be made to point to that subroutine.  The generation of the
  3844         -** cookie verification subroutine code happens in sqlite3FinishCoding().
  3845         -**
  3846         -** If iDb<0 then code the OP_Goto only - don't set flag to verify the
  3847         -** schema on any databases.  This can be used to position the OP_Goto
  3848         -** early in the code, before we know if any database tables will be used.
         3828  +** Record the fact that the schema cookie will need to be verified
         3829  +** for database iDb.  The code to actually verify the schema cookie
         3830  +** will occur at the end of the top-level VDBE and will be generated
         3831  +** later, by sqlite3FinishCoding().
  3849   3832   */
  3850   3833   void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  3851   3834     Parse *pToplevel = sqlite3ParseToplevel(pParse);
  3852         -
  3853         -#ifndef SQLITE_OMIT_TRIGGER
  3854         -  if( pToplevel!=pParse ){
  3855         -    /* This branch is taken if a trigger is currently being coded. In this
  3856         -    ** case, set cookieGoto to a non-zero value to show that this function
  3857         -    ** has been called. This is used by the sqlite3ExprCodeConstants()
  3858         -    ** function. */
  3859         -    pParse->cookieGoto = -1;
  3860         -  }
  3861         -#endif
  3862         -  if( pToplevel->cookieGoto==0 ){
  3863         -    Vdbe *v = sqlite3GetVdbe(pToplevel);
  3864         -    if( v==0 ) return;  /* This only happens if there was a prior error */
  3865         -    pToplevel->cookieGoto = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0)+1;
  3866         -  }
  3867         -  if( iDb>=0 ){
  3868         -    sqlite3 *db = pToplevel->db;
  3869         -    yDbMask mask;
  3870         -
  3871         -    assert( iDb<db->nDb );
  3872         -    assert( db->aDb[iDb].pBt!=0 || iDb==1 );
  3873         -    assert( iDb<SQLITE_MAX_ATTACHED+2 );
  3874         -    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
  3875         -    mask = ((yDbMask)1)<<iDb;
  3876         -    if( (pToplevel->cookieMask & mask)==0 ){
  3877         -      pToplevel->cookieMask |= mask;
  3878         -      pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
  3879         -      if( !OMIT_TEMPDB && iDb==1 ){
  3880         -        sqlite3OpenTempDatabase(pToplevel);
  3881         -      }
         3835  +  sqlite3 *db = pToplevel->db;
         3836  +  yDbMask mask;
         3837  +
         3838  +  assert( iDb>=0 && iDb<db->nDb );
         3839  +  assert( db->aDb[iDb].pBt!=0 || iDb==1 );
         3840  +  assert( iDb<SQLITE_MAX_ATTACHED+2 );
         3841  +  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
         3842  +  mask = ((yDbMask)1)<<iDb;
         3843  +  if( (pToplevel->cookieMask & mask)==0 ){
         3844  +    pToplevel->cookieMask |= mask;
         3845  +    pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
         3846  +    if( !OMIT_TEMPDB && iDb==1 ){
         3847  +      sqlite3OpenTempDatabase(pToplevel);
         3848  +    }
         3849  +    if( pToplevel==pParse && OptimizationEnabled(db,SQLITE_FactorOutConst) ){
         3850  +      pParse->okConstFactor = 1;
  3882   3851       }
  3883   3852     }
  3884   3853   }
  3885   3854   
  3886   3855   /*
  3887   3856   ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each 
  3888   3857   ** attached database. Otherwise, invoke it for the database named zDb only.

Changes to src/insert.c.

  2034   2034       sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);
  2035   2035       sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1);
  2036   2036       sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1);
  2037   2037       sqlite3VdbeJumpHere(v, addr1);
  2038   2038       sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);
  2039   2039       sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);
  2040   2040     }
  2041         -  sqlite3VdbeJumpHere(v, emptySrcTest);
         2041  +  if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest);
  2042   2042     sqlite3ReleaseTempReg(pParse, regRowid);
  2043   2043     sqlite3ReleaseTempReg(pParse, regData);
  2044   2044     if( emptyDestTest ){
  2045   2045       sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0);
  2046   2046       sqlite3VdbeJumpHere(v, emptyDestTest);
  2047   2047       sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);
  2048   2048       return 0;
  2049   2049     }else{
  2050   2050       return 1;
  2051   2051     }
  2052   2052   }
  2053   2053   #endif /* SQLITE_OMIT_XFER_OPT */

Changes to src/select.c.

  1611   1611   ** Get a VDBE for the given parser context.  Create a new one if necessary.
  1612   1612   ** If an error occurs, return NULL and leave a message in pParse.
  1613   1613   */
  1614   1614   Vdbe *sqlite3GetVdbe(Parse *pParse){
  1615   1615     Vdbe *v = pParse->pVdbe;
  1616   1616     if( v==0 ){
  1617   1617       v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
  1618         -#ifndef SQLITE_OMIT_TRACE
  1619         -    if( v ){
  1620         -      sqlite3VdbeAddOp0(v, OP_Trace);
  1621         -    }
  1622         -#endif
         1618  +    if( v ) sqlite3VdbeAddOp0(v, OP_Init);
  1623   1619     }
  1624   1620     return v;
  1625   1621   }
  1626   1622   
  1627   1623   
  1628   1624   /*
  1629   1625   ** Compute the iLimit and iOffset fields of the SELECT based on the
................................................................................
  4533   4529              && OptimizationEnabled(db, SQLITE_SubqCoroutine)
  4534   4530       ){
  4535   4531         /* Implement a co-routine that will return a single row of the result
  4536   4532         ** set on each invocation.
  4537   4533         */
  4538   4534         int addrTop;
  4539   4535         pItem->regReturn = ++pParse->nMem;
  4540         -      /* Before coding the OP_Goto to jump to the start of the main routine,
  4541         -      ** ensure that the jump to the verify-schema routine has already
  4542         -      ** been coded. Otherwise, the verify-schema would likely be coded as 
  4543         -      ** part of the co-routine. If the main routine then accessed the 
  4544         -      ** database before invoking the co-routine for the first time (for 
  4545         -      ** example to initialize a LIMIT register from a sub-select), it would 
  4546         -      ** be doing so without having verified the schema version and obtained 
  4547         -      ** the required db locks. See ticket d6b36be38.  */
  4548         -      sqlite3CodeVerifySchema(pParse, -1);
  4549   4536         sqlite3VdbeAddOp0(v, OP_Goto);
  4550   4537         addrTop = sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor);
  4551   4538         sqlite3VdbeChangeP5(v, 1);
  4552   4539         VdbeComment((v, "coroutine %s", pItem->pTab->zName));
  4553   4540         pItem->addrFillSub = addrTop;
  4554   4541         sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
  4555   4542         explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);

Changes to src/sqliteInt.h.

  1084   1084   #define OptimizationEnabled(db, mask)   1
  1085   1085   #endif
  1086   1086   
  1087   1087   /*
  1088   1088   ** Return true if it OK to factor constant expressions into the initialization
  1089   1089   ** code. The argument is a Parse object for the code generator.
  1090   1090   */
  1091         -#define ConstFactorOk(P) \
  1092         -  ((P)->cookieGoto>0 && OptimizationEnabled((P)->db,SQLITE_FactorOutConst))
         1091  +#define ConstFactorOk(P) ((P)->okConstFactor)
  1093   1092   
  1094   1093   /*
  1095   1094   ** Possible values for the sqlite.magic field.
  1096   1095   ** The numbers are obtained at random and have no special meaning, other
  1097   1096   ** than being distinct from one another.
  1098   1097   */
  1099   1098   #define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */
................................................................................
  2350   2349     u8 nTempReg;         /* Number of temporary registers in aTempReg[] */
  2351   2350     u8 nTempInUse;       /* Number of aTempReg[] currently checked out */
  2352   2351     u8 nColCache;        /* Number of entries in aColCache[] */
  2353   2352     u8 iColCache;        /* Next entry in aColCache[] to replace */
  2354   2353     u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */
  2355   2354     u8 mayAbort;         /* True if statement may throw an ABORT exception */
  2356   2355     u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */
         2356  +  u8 okConstFactor;    /* OK to factor out constants */
  2357   2357     int aTempReg[8];     /* Holding area for temporary registers */
  2358   2358     int nRangeReg;       /* Size of the temporary register block */
  2359   2359     int iRangeReg;       /* First register in temporary register block */
  2360   2360     int nErr;            /* Number of errors seen */
  2361   2361     int nTab;            /* Number of previously allocated VDBE cursors */
  2362   2362     int nMem;            /* Number of memory cells used so far */
  2363   2363     int nSet;            /* Number of sets used so far */
................................................................................
  2378   2378       int iReg;             /* Reg with value of this column. 0 means none. */
  2379   2379       int lru;              /* Least recently used entry has the smallest value */
  2380   2380     } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */
  2381   2381     ExprList *pConstExpr;/* Constant expressions */
  2382   2382     Token constraintName;/* Name of the constraint currently being parsed */
  2383   2383     yDbMask writeMask;   /* Start a write transaction on these databases */
  2384   2384     yDbMask cookieMask;  /* Bitmask of schema verified databases */
  2385         -  int cookieGoto;      /* Address of OP_Goto to cookie verifier subroutine */
  2386   2385     int cookieValue[SQLITE_MAX_ATTACHED+2];  /* Values of cookies to verify */
  2387   2386     int regRowid;        /* Register holding rowid of CREATE TABLE entry */
  2388   2387     int regRoot;         /* Register holding root page number for new objects */
  2389   2388     int nMaxArg;         /* Max args passed to user function by sub-program */
  2390   2389   #ifndef SQLITE_OMIT_SHARED_CACHE
  2391   2390     int nTableLock;        /* Number of locks in aTableLock */
  2392   2391     TableLock *aTableLock; /* Required table locks for shared-cache mode */

Changes to src/trigger.c.

   722    722       **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);
   723    723       **   END;
   724    724       **
   725    725       **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy
   726    726       **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy
   727    727       */
   728    728       pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;
   729         -
   730         -    /* Clear the cookieGoto flag. When coding triggers, the cookieGoto 
   731         -    ** variable is used as a flag to indicate to sqlite3ExprCodeConstants()
   732         -    ** that it is not safe to refactor constants (this happens after the
   733         -    ** start of the first loop in the SQL statement is coded - at that 
   734         -    ** point code may be conditionally executed, so it is no longer safe to 
   735         -    ** initialize constant register values).  */
   736         -    assert( pParse->cookieGoto==0 || pParse->cookieGoto==-1 );
   737         -    pParse->cookieGoto = 0;
          729  +    assert( pParse->okConstFactor==0 );
   738    730   
   739    731       switch( pStep->op ){
   740    732         case TK_UPDATE: {
   741    733           sqlite3Update(pParse, 
   742    734             targetSrcList(pParse, pStep),
   743    735             sqlite3ExprListDup(db, pStep->pExprList, 0), 
   744    736             sqlite3ExprDup(db, pStep->pWhere, 0), 

Changes to src/vdbe.c.

  6140   6140     }
  6141   6141     pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
  6142   6142     break;
  6143   6143   }
  6144   6144   #endif
  6145   6145   
  6146   6146   
  6147         -#ifndef SQLITE_OMIT_TRACE
  6148         -/* Opcode: Trace * * * P4 *
         6147  +/* Opcode: Init * P2 * P4 *
         6148  +** Synopsis:  Start at P2
         6149  +**
         6150  +** Programs contain a single instance of this opcode as the very first
         6151  +** opcode.
  6149   6152   **
  6150   6153   ** If tracing is enabled (by the sqlite3_trace()) interface, then
  6151   6154   ** the UTF-8 string contained in P4 is emitted on the trace callback.
         6155  +** Or if P4 is blank, use the string returned by sqlite3_sql().
         6156  +**
         6157  +** If P2 is not zero, jump to instruction P2.
  6152   6158   */
  6153         -case OP_Trace: {
         6159  +case OP_Init: {          /* jump */
  6154   6160     char *zTrace;
  6155   6161     char *z;
  6156   6162   
         6163  +  if( pOp->p2 ){
         6164  +    pc = pOp->p2 - 1;
         6165  +  }
         6166  +#ifndef SQLITE_OMIT_TRACE
  6157   6167     if( db->xTrace
  6158   6168      && !p->doingRerun
  6159   6169      && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
  6160   6170     ){
  6161   6171       z = sqlite3VdbeExpandSql(p, zTrace);
  6162   6172       db->xTrace(db->pTraceArg, z);
  6163   6173       sqlite3DbFree(db, z);
................................................................................
  6175   6185   #ifdef SQLITE_DEBUG
  6176   6186     if( (db->flags & SQLITE_SqlTrace)!=0
  6177   6187      && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
  6178   6188     ){
  6179   6189       sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
  6180   6190     }
  6181   6191   #endif /* SQLITE_DEBUG */
         6192  +#endif /* SQLITE_OMIT_TRACE */
  6182   6193     break;
  6183   6194   }
  6184         -#endif
  6185   6195   
  6186   6196   
  6187   6197   /* Opcode: Noop * * * * *
  6188   6198   **
  6189   6199   ** Do nothing.  This instruction is often useful as a jump
  6190   6200   ** destination.
  6191   6201   */

Changes to src/vdbeaux.c.

   859    859   ** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode
   860    860   ** is readable but not writable, though it is cast to a writable value.
   861    861   ** The return of a dummy opcode allows the call to continue functioning
   862    862   ** after a OOM fault without having to check to see if the return from 
   863    863   ** this routine is a valid pointer.  But because the dummy.opcode is 0,
   864    864   ** dummy will never be written to.  This is verified by code inspection and
   865    865   ** by running with Valgrind.
   866         -**
   867         -** About the #ifdef SQLITE_OMIT_TRACE:  Normally, this routine is never called
   868         -** unless p->nOp>0.  This is because in the absense of SQLITE_OMIT_TRACE,
   869         -** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as
   870         -** a new VDBE is created.  So we are free to set addr to p->nOp-1 without
   871         -** having to double-check to make sure that the result is non-negative. But
   872         -** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to
   873         -** check the value of p->nOp-1 before continuing.
   874    866   */
   875    867   VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
   876    868     /* C89 specifies that the constant "dummy" will be initialized to all
   877    869     ** zeros, which is correct.  MSVC generates a warning, nevertheless. */
   878    870     static VdbeOp dummy;  /* Ignore the MSVC warning about no initializer */
   879    871     assert( p->magic==VDBE_MAGIC_INIT );
   880    872     if( addr<0 ){
   881         -#ifdef SQLITE_OMIT_TRACE
   882         -    if( p->nOp==0 ) return (VdbeOp*)&dummy;
   883         -#endif
   884    873       addr = p->nOp - 1;
   885    874     }
   886    875     assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );
   887    876     if( p->db->mallocFailed ){
   888    877       return (VdbeOp*)&dummy;
   889    878     }else{
   890    879       return &p->aOp[addr];
................................................................................
  1461   1450   */
  1462   1451   void sqlite3VdbePrintSql(Vdbe *p){
  1463   1452     const char *z = 0;
  1464   1453     if( p->zSql ){
  1465   1454       z = p->zSql;
  1466   1455     }else if( p->nOp>=1 ){
  1467   1456       const VdbeOp *pOp = &p->aOp[0];
  1468         -    if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
         1457  +    if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){
  1469   1458         z = pOp->p4.z;
  1470   1459         while( sqlite3Isspace(*z) ) z++;
  1471   1460       }
  1472   1461     }
  1473   1462     if( z ) printf("SQL: [%s]\n", z);
  1474   1463   }
  1475   1464   #endif
................................................................................
  1480   1469   */
  1481   1470   void sqlite3VdbeIOTraceSql(Vdbe *p){
  1482   1471     int nOp = p->nOp;
  1483   1472     VdbeOp *pOp;
  1484   1473     if( sqlite3IoTrace==0 ) return;
  1485   1474     if( nOp<1 ) return;
  1486   1475     pOp = &p->aOp[0];
  1487         -  if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
         1476  +  if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){
  1488   1477       int i, j;
  1489   1478       char z[1000];
  1490   1479       sqlite3_snprintf(sizeof(z), z, "%s", pOp->p4.z);
  1491   1480       for(i=0; sqlite3Isspace(z[i]); i++){}
  1492   1481       for(j=0; z[i]; i++){
  1493   1482         if( sqlite3Isspace(z[i]) ){
  1494   1483           if( z[i-1]!=' ' ){

Changes to src/where.c.

  5432   5432   
  5433   5433     /* Split the WHERE clause into separate subexpressions where each
  5434   5434     ** subexpression is separated by an AND operator.
  5435   5435     */
  5436   5436     initMaskSet(pMaskSet);
  5437   5437     whereClauseInit(&pWInfo->sWC, pWInfo);
  5438   5438     whereSplit(&pWInfo->sWC, pWhere, TK_AND);
  5439         -  sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
  5440   5439       
  5441   5440     /* Special case: a WHERE clause that is constant.  Evaluate the
  5442   5441     ** expression and either jump over all of the code or fall thru.
  5443   5442     */
  5444   5443     for(ii=0; ii<sWLB.pWC->nTerm; ii++){
  5445   5444       if( nTabList==0 || sqlite3ExprIsConstantNotJoin(sWLB.pWC->a[ii].pExpr) ){
  5446   5445         sqlite3ExprIfFalse(pParse, sWLB.pWC->a[ii].pExpr, pWInfo->iBreak,
................................................................................
  5721   5720         pLevel->iIdxCur = iIndexCur;
  5722   5721         assert( pIx->pSchema==pTab->pSchema );
  5723   5722         assert( iIndexCur>=0 );
  5724   5723         sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
  5725   5724         sqlite3VdbeSetP4KeyInfo(pParse, pIx);
  5726   5725         VdbeComment((v, "%s", pIx->zName));
  5727   5726       }
  5728         -    sqlite3CodeVerifySchema(pParse, iDb);
         5727  +    if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);
  5729   5728       notReady &= ~getMask(&pWInfo->sMaskSet, pTabItem->iCursor);
  5730   5729     }
  5731   5730     pWInfo->iTop = sqlite3VdbeCurrentAddr(v);
  5732   5731     if( db->mallocFailed ) goto whereBeginError;
  5733   5732   
  5734   5733     /* Generate the code to do the search.  Each iteration of the for
  5735   5734     ** loop below generates code for a single nested loop of the VM