/ 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 Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
....
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858

    /* The cookie mask contains one bit for each database file open.
    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are
    ** set for each database that is used.  Generate code to start a
    ** transaction on each used database and to verify the schema cookie
    ** on each used database.
    */
    if( db->mallocFailed==0 && pParse->cookieMask ){
      yDbMask mask;
      int iDb, i;
      assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );
      sqlite3VdbeJumpHere(v, 0);
      for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){
        if( (mask & pParse->cookieMask)==0 ) continue;
        sqlite3VdbeUsesBtree(v, iDb);
................................................................................
  mask = ((yDbMask)1)<<iDb;
  if( (pToplevel->cookieMask & mask)==0 ){
    pToplevel->cookieMask |= mask;
    pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
    if( !OMIT_TEMPDB && iDb==1 ){
      sqlite3OpenTempDatabase(pToplevel);
    }
    if( pToplevel==pParse && OptimizationEnabled(db,SQLITE_FactorOutConst) ){
      pParse->okConstFactor = 1;
    }
  }
}

/*
** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each 
** attached database. Otherwise, invoke it for the database named zDb only.
*/







|







 







<
<
<







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
....
3842
3843
3844
3845
3846
3847
3848



3849
3850
3851
3852
3853
3854
3855

    /* The cookie mask contains one bit for each database file open.
    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are
    ** set for each database that is used.  Generate code to start a
    ** transaction on each used database and to verify the schema cookie
    ** on each used database.
    */
    if( db->mallocFailed==0 && (pParse->cookieMask || pParse->pConstExpr) ){
      yDbMask mask;
      int iDb, i;
      assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );
      sqlite3VdbeJumpHere(v, 0);
      for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){
        if( (mask & pParse->cookieMask)==0 ) continue;
        sqlite3VdbeUsesBtree(v, iDb);
................................................................................
  mask = ((yDbMask)1)<<iDb;
  if( (pToplevel->cookieMask & mask)==0 ){
    pToplevel->cookieMask |= mask;
    pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
    if( !OMIT_TEMPDB && iDb==1 ){
      sqlite3OpenTempDatabase(pToplevel);
    }



  }
}

/*
** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each 
** attached database. Otherwise, invoke it for the database named zDb only.
*/

Changes to src/select.c.

1612
1613
1614
1615
1616
1617
1618






1619
1620
1621
1622
1623
1624
1625
** If an error occurs, return NULL and leave a message in pParse.
*/
Vdbe *sqlite3GetVdbe(Parse *pParse){
  Vdbe *v = pParse->pVdbe;
  if( v==0 ){
    v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
    if( v ) sqlite3VdbeAddOp0(v, OP_Init);






  }
  return v;
}


/*
** Compute the iLimit and iOffset fields of the SELECT based on the







>
>
>
>
>
>







1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
** If an error occurs, return NULL and leave a message in pParse.
*/
Vdbe *sqlite3GetVdbe(Parse *pParse){
  Vdbe *v = pParse->pVdbe;
  if( v==0 ){
    v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
    if( v ) sqlite3VdbeAddOp0(v, OP_Init);
    if( pParse->pToplevel==0
     && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
    ){
      pParse->okConstFactor = 1;
    }

  }
  return v;
}


/*
** Compute the iLimit and iOffset fields of the SELECT based on the