/ Check-in [a45b8771]
Login

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

Overview
Comment:Enable constant expression factoring even if no tables are read and no transaction is started.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a45b87713c0afca2be2ace9500513620a024c0a2
User & Date: drh 2014-02-08 04:24:37
Context
2014-02-10
19:37
Experimental change to os_unix.c to delay creating a database file until it is first written. check-in: 538f7b25 user: dan tags: deferred-open
2014-02-08
13:12
Tweaks to the generated VDBE code to make it a little easier to follow. check-in: 129217ee user: drh tags: trunk
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
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( db->mallocFailed==0 && pParse->cookieMask ){
          152  +    if( db->mallocFailed==0 && (pParse->cookieMask || pParse->pConstExpr) ){
   153    153         yDbMask mask;
   154    154         int iDb, i;
   155    155         assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );
   156    156         sqlite3VdbeJumpHere(v, 0);
   157    157         for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){
   158    158           if( (mask & pParse->cookieMask)==0 ) continue;
   159    159           sqlite3VdbeUsesBtree(v, iDb);
................................................................................
  3842   3842     mask = ((yDbMask)1)<<iDb;
  3843   3843     if( (pToplevel->cookieMask & mask)==0 ){
  3844   3844       pToplevel->cookieMask |= mask;
  3845   3845       pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
  3846   3846       if( !OMIT_TEMPDB && iDb==1 ){
  3847   3847         sqlite3OpenTempDatabase(pToplevel);
  3848   3848       }
  3849         -    if( pToplevel==pParse && OptimizationEnabled(db,SQLITE_FactorOutConst) ){
  3850         -      pParse->okConstFactor = 1;
  3851         -    }
  3852   3849     }
  3853   3850   }
  3854   3851   
  3855   3852   /*
  3856   3853   ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each 
  3857   3854   ** attached database. Otherwise, invoke it for the database named zDb only.
  3858   3855   */

Changes to src/select.c.

  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   1618       if( v ) sqlite3VdbeAddOp0(v, OP_Init);
         1619  +    if( pParse->pToplevel==0
         1620  +     && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
         1621  +    ){
         1622  +      pParse->okConstFactor = 1;
         1623  +    }
         1624  +
  1619   1625     }
  1620   1626     return v;
  1621   1627   }
  1622   1628   
  1623   1629   
  1624   1630   /*
  1625   1631   ** Compute the iLimit and iOffset fields of the SELECT based on the