/ Check-in [a8fd7052]
Login

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

Overview
Comment:Save a few bytes and a few cycles by setting Vdbe.expmask to zero for statements prepared using legacy interface sqlite3_prepare().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a8fd705258643863493476f8b42ee981608a339f
User & Date: dan 2017-02-23 16:30:16
References
2017-03-02
13:13
Make sure the Vdbe.expmask value is set correctly in sqlite3VdbeSwap(). This fixes a problem introduced by [a8fd7052]. check-in: 29f54b89 user: drh tags: trunk
Context
2017-02-25
17:47
Optimize defragmentPage() in the case where the page contains either one or two free-blocks and a small number of fragmented bytes. check-in: 4cd2a967 user: dan tags: trunk
2017-02-24
19:58
Optimize defragmentPage() in the case where the page contains either one or two free-blocks and a small number of fragmented bytes. check-in: 202b1c02 user: dan tags: defragmentpage-opt
2017-02-23
16:30
Save a few bytes and a few cycles by setting Vdbe.expmask to zero for statements prepared using legacy interface sqlite3_prepare(). check-in: a8fd7052 user: dan tags: trunk
2017-02-22
19:41
Move a branch condition in analyze.c inside an #ifdef SQLITE_ENABLE_STAT4 block. check-in: d6afd98d user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

   150    150     sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
   151    151   #endif
   152    152     sqlite3_mutex_enter(mutex);
   153    153     for(i=0; i<p->nVar; i++){
   154    154       sqlite3VdbeMemRelease(&p->aVar[i]);
   155    155       p->aVar[i].flags = MEM_Null;
   156    156     }
   157         -  if( p->isPrepareV2 && p->expmask ){
          157  +  assert( p->isPrepareV2 || p->expmask==0 );
          158  +  if( p->expmask ){
   158    159       p->expired = 1;
   159    160     }
   160    161     sqlite3_mutex_leave(mutex);
   161    162     return rc;
   162    163   }
   163    164   
   164    165   
................................................................................
  1254   1255     **
  1255   1256     ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host
  1256   1257     ** parameter in the WHERE clause might influence the choice of query plan
  1257   1258     ** for a statement, then the statement will be automatically recompiled,
  1258   1259     ** as if there had been a schema change, on the first sqlite3_step() call
  1259   1260     ** following any change to the bindings of that parameter.
  1260   1261     */
  1261         -  if( p->isPrepareV2 &&
  1262         -     ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)
  1263         -  ){
         1262  +  assert( p->isPrepareV2 || p->expmask==0 );
         1263  +  if( p->expmask & ((u32)1 << (i&0x001F)) && (i<32 || p->expmask==0xffffffff) ){
  1264   1264       p->expired = 1;
  1265   1265     }
  1266   1266     return SQLITE_OK;
  1267   1267   }
  1268   1268   
  1269   1269   /*
  1270   1270   ** Bind a text or BLOB value.
................................................................................
  1519   1519   */
  1520   1520   int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
  1521   1521     Vdbe *pFrom = (Vdbe*)pFromStmt;
  1522   1522     Vdbe *pTo = (Vdbe*)pToStmt;
  1523   1523     if( pFrom->nVar!=pTo->nVar ){
  1524   1524       return SQLITE_ERROR;
  1525   1525     }
  1526         -  if( pTo->isPrepareV2 && pTo->expmask ){
         1526  +  assert( pTo->isPrepareV2 || pTo->expmask==0 );
         1527  +  if( pTo->expmask ){
  1527   1528       pTo->expired = 1;
  1528   1529     }
  1529         -  if( pFrom->isPrepareV2 && pFrom->expmask ){
         1530  +  assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
         1531  +  if( pFrom->expmask ){
  1530   1532       pFrom->expired = 1;
  1531   1533     }
  1532   1534     return sqlite3TransferBindings(pFromStmt, pToStmt);
  1533   1535   }
  1534   1536   #endif
  1535   1537   
  1536   1538   /*

Changes to src/vdbeaux.c.

    53     53   
    54     54   /*
    55     55   ** Remember the SQL string for a prepared statement.
    56     56   */
    57     57   void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
    58     58     assert( isPrepareV2==1 || isPrepareV2==0 );
    59     59     if( p==0 ) return;
           60  +  if( !isPrepareV2 ) p->expmask = 0;
    60     61   #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
    61     62     if( !isPrepareV2 ) return;
    62     63   #endif
    63     64     assert( p->zSql==0 );
    64     65     p->zSql = sqlite3DbStrNDup(p->db, z, n);
    65     66     p->isPrepareV2 = (u8)isPrepareV2;
    66     67   }