/ Check-in [264ace50]
Login

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

Overview
Comment:Changes to build.c to help facilitate full coverage testing. (CVS 6634)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 264ace50bbaec3468de0e42b2b8cebf9ce1d6682
User & Date: drh 2009-05-13 17:21:14
Context
2009-05-13
17:35
Remove incorrect NEVER() macro in the previous check-in (6634). (CVS 6635) check-in: c6849579 user: drh tags: trunk
17:21
Changes to build.c to help facilitate full coverage testing. (CVS 6634) check-in: 264ace50 user: drh tags: trunk
14:46
Do not run async4.test as part of the "journaltest" permutation. It specifically tests that the asynchronous IO backend can be configured to violate the assumptions made by journaltest. (CVS 6633) check-in: b19bf39b user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.541 2009/05/12 18:00:38 drh Exp $
           25  +** $Id: build.c,v 1.542 2009/05/13 17:21:14 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   
    29     29   /*
    30     30   ** This routine is called when a new SQL statement is beginning to
    31     31   ** be parsed.  Initialize the pParse structure as needed.
    32     32   */
................................................................................
    64     64     u8 isWriteLock,    /* True for a write lock */
    65     65     const char *zName  /* Name of the table to be locked */
    66     66   ){
    67     67     int i;
    68     68     int nBytes;
    69     69     TableLock *p;
    70     70   
    71         -  if( iDb<0 ){
    72         -    return;
    73         -  }
    74         -
           71  +  if( NEVER(iDb<0) ) return;
    75     72     for(i=0; i<pParse->nTableLock; i++){
    76     73       p = &pParse->aTableLock[i];
    77     74       if( p->iDb==iDb && p->iTab==iTab ){
    78     75         p->isWriteLock = (p->isWriteLock || isWriteLock);
    79     76         return;
    80     77       }
    81     78     }
................................................................................
    99     96   ** Code an OP_TableLock instruction for each table locked by the
   100     97   ** statement (configured by calls to sqlite3TableLock()).
   101     98   */
   102     99   static void codeTableLocks(Parse *pParse){
   103    100     int i;
   104    101     Vdbe *pVdbe; 
   105    102   
   106         -  if( 0==(pVdbe = sqlite3GetVdbe(pParse)) ){
   107         -    return;
   108         -  }
          103  +  pVdbe = sqlite3GetVdbe(pParse);
          104  +  assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */
   109    105   
   110    106     for(i=0; i<pParse->nTableLock; i++){
   111    107       TableLock *p = &pParse->aTableLock[i];
   112    108       int p1 = p->iDb;
   113    109       sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,
   114    110                         p->zName, P4_STATIC);
   115    111     }
................................................................................
   181    177         sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse->cookieGoto);
   182    178       }
   183    179     }
   184    180   
   185    181   
   186    182     /* Get the VDBE program ready for execution
   187    183     */
   188         -  if( v && pParse->nErr==0 && !db->mallocFailed ){
          184  +  if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
   189    185   #ifdef SQLITE_DEBUG
   190    186       FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
   191    187       sqlite3VdbeTrace(v, trace);
   192    188   #endif
   193    189       assert( pParse->iCacheLevel==0 );  /* Disables and re-enables match */
   194    190       sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem,
   195    191                            pParse->nTab, pParse->explain);
................................................................................
   323    319   Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){
   324    320     Index *p = 0;
   325    321     int i;
   326    322     int nName = sqlite3Strlen30(zName);
   327    323     for(i=OMIT_TEMPDB; i<db->nDb; i++){
   328    324       int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */
   329    325       Schema *pSchema = db->aDb[j].pSchema;
          326  +    assert( pSchema );
   330    327       if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zName) ) continue;
   331         -    assert( pSchema || (j==1 && !db->aDb[1].pBt) );
   332         -    if( pSchema ){
   333         -      p = sqlite3HashFind(&pSchema->idxHash, zName, nName);
   334         -    }
          328  +    p = sqlite3HashFind(&pSchema->idxHash, zName, nName);
   335    329       if( p ) break;
   336    330     }
   337    331     return p;
   338    332   }
   339    333   
   340    334   /*
   341    335   ** Reclaim the memory used by an index
................................................................................
   374    368   void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){
   375    369     Index *pIndex;
   376    370     int len;
   377    371     Hash *pHash = &db->aDb[iDb].pSchema->idxHash;
   378    372   
   379    373     len = sqlite3Strlen30(zIdxName);
   380    374     pIndex = sqlite3HashInsert(pHash, zIdxName, len, 0);
   381         -  if( pIndex ){
          375  +  /* Justification of ALWAYS():  This routine is only called from the
          376  +  ** OP_DropIndex opcode.  And there is no way that opcode will ever run
          377  +  ** unless the corresponding index is in the symbol table. */
          378  +  if( ALWAYS(pIndex) ){
   382    379       if( pIndex->pTable->pIndex==pIndex ){
   383    380         pIndex->pTable->pIndex = pIndex->pNext;
   384    381       }else{
   385    382         Index *p;
   386         -      for(p=pIndex->pTable->pIndex; p && p->pNext!=pIndex; p=p->pNext){}
   387         -      if( p && p->pNext==pIndex ){
          383  +      /* Justification of ALWAYS();  The index must be on the list of
          384  +      ** indices. */
          385  +      p = pIndex->pTable->pIndex;
          386  +      while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }
          387  +      if( ALWAYS(p && p->pNext==pIndex) ){
   388    388           p->pNext = pIndex->pNext;
   389    389         }
   390    390       }
   391    391       freeIndex(pIndex);
   392    392     }
   393    393     db->flags |= SQLITE_InternChanges;
   394    394   }
................................................................................
   425    425   
   426    426     /* If one or more of the auxiliary database files has been closed,
   427    427     ** then remove them from the auxiliary database list.  We take the
   428    428     ** opportunity to do this here since we have just deleted all of the
   429    429     ** schema hash tables and therefore do not have to make any changes
   430    430     ** to any of those tables.
   431    431     */
   432         -  for(i=0; i<db->nDb; i++){
   433         -    struct Db *pDb = &db->aDb[i];
   434         -    if( pDb->pBt==0 ){
   435         -      if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux);
   436         -      pDb->pAux = 0;
   437         -    }
   438         -  }
   439    432     for(i=j=2; i<db->nDb; i++){
   440    433       struct Db *pDb = &db->aDb[i];
   441    434       if( pDb->pBt==0 ){
   442    435         sqlite3DbFree(db, pDb->zName);
   443    436         pDb->zName = 0;
   444    437         continue;
   445    438       }
................................................................................
  1448   1441     Token *pEnd,            /* The final ')' token in the CREATE TABLE */
  1449   1442     Select *pSelect         /* Select from a "CREATE ... AS SELECT" */
  1450   1443   ){
  1451   1444     Table *p;
  1452   1445     sqlite3 *db = pParse->db;
  1453   1446     int iDb;
  1454   1447   
  1455         -  if( (pEnd==0 && pSelect==0) || pParse->nErr || db->mallocFailed ) {
         1448  +  if( (pEnd==0 && pSelect==0) || NEVER(pParse->nErr) || db->mallocFailed ) {
  1456   1449       return;
  1457   1450     }
  1458   1451     p = pParse->pNewTable;
  1459   1452     if( p==0 ) return;
  1460   1453   
  1461   1454     assert( !db->init.busy || !pSelect );
  1462   1455   
................................................................................
  1965   1958   */
  1966   1959   void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){
  1967   1960     Table *pTab;
  1968   1961     Vdbe *v;
  1969   1962     sqlite3 *db = pParse->db;
  1970   1963     int iDb;
  1971   1964   
  1972         -  if( pParse->nErr || db->mallocFailed ){
         1965  +  if( NEVER(pParse->nErr) || db->mallocFailed ){
  1973   1966       goto exit_drop_table;
  1974   1967     }
  1975   1968     assert( pName->nSrc==1 );
  1976   1969     pTab = sqlite3LocateTable(pParse, isView, 
  1977   1970                               pName->a[0].zName, pName->a[0].zDatabase);
  1978   1971   
  1979   1972     if( pTab==0 ){
................................................................................
  2613   2606         nExtra -= nColl;
  2614   2607       }else{
  2615   2608         zColl = pTab->aCol[j].zColl;
  2616   2609         if( !zColl ){
  2617   2610           zColl = db->pDfltColl->zName;
  2618   2611         }
  2619   2612       }
  2620         -    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
         2613  +    if( NEVER(!db->init.busy && !sqlite3LocateCollSeq(pParse, zColl)) ){
  2621   2614         goto exit_create_index;
  2622   2615       }
  2623   2616       pIndex->azColl[i] = zColl;
  2624   2617       requestedSortOrder = pListItem->sortOrder & sortOrderMask;
  2625   2618       pIndex->aSortOrder[i] = (u8)requestedSortOrder;
  2626   2619     }
  2627   2620     sqlite3DefaultRowEst(pIndex);
................................................................................
  3279   3272     sqlite3 *db;
  3280   3273     Vdbe *v;
  3281   3274     int i;
  3282   3275   
  3283   3276     assert( pParse!=0 );
  3284   3277     db = pParse->db;
  3285   3278     assert( db!=0 );
  3286         -  if( db->aDb[0].pBt==0 ) return;
         3279  +/*  if( db->aDb[0].pBt==0 ) return; */
  3287   3280     if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ){
  3288   3281       return;
  3289   3282     }
  3290   3283     v = sqlite3GetVdbe(pParse);
  3291   3284     if( !v ) return;
  3292   3285     if( type!=TK_DEFERRED ){
  3293   3286       for(i=0; i<db->nDb; i++){
................................................................................
  3304   3297   void sqlite3CommitTransaction(Parse *pParse){
  3305   3298     sqlite3 *db;
  3306   3299     Vdbe *v;
  3307   3300   
  3308   3301     assert( pParse!=0 );
  3309   3302     db = pParse->db;
  3310   3303     assert( db!=0 );
  3311         -  if( db->aDb[0].pBt==0 ) return;
         3304  +/*  if( db->aDb[0].pBt==0 ) return; */
  3312   3305     if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ){
  3313   3306       return;
  3314   3307     }
  3315   3308     v = sqlite3GetVdbe(pParse);
  3316   3309     if( v ){
  3317   3310       sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 0);
  3318   3311     }
................................................................................
  3324   3317   void sqlite3RollbackTransaction(Parse *pParse){
  3325   3318     sqlite3 *db;
  3326   3319     Vdbe *v;
  3327   3320   
  3328   3321     assert( pParse!=0 );
  3329   3322     db = pParse->db;
  3330   3323     assert( db!=0 );
  3331         -  if( db->aDb[0].pBt==0 ) return;
         3324  +/*  if( db->aDb[0].pBt==0 ) return; */
  3332   3325     if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ){
  3333   3326       return;
  3334   3327     }
  3335   3328     v = sqlite3GetVdbe(pParse);
  3336   3329     if( v ){
  3337   3330       sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1);
  3338   3331     }
................................................................................
  3463   3456   /*
  3464   3457   ** Check to see if pIndex uses the collating sequence pColl.  Return
  3465   3458   ** true if it does and false if it does not.
  3466   3459   */
  3467   3460   #ifndef SQLITE_OMIT_REINDEX
  3468   3461   static int collationMatch(const char *zColl, Index *pIndex){
  3469   3462     int i;
         3463  +  assert( zColl!=0 );
  3470   3464     for(i=0; i<pIndex->nColumn; i++){
  3471   3465       const char *z = pIndex->azColl[i];
  3472         -    if( z==zColl || (z && zColl && 0==sqlite3StrICmp(z, zColl)) ){
         3466  +    assert( z!=0 );
         3467  +    if( 0==sqlite3StrICmp(z, zColl) ){
  3473   3468         return 1;
  3474   3469       }
  3475   3470     }
  3476   3471     return 0;
  3477   3472   }
  3478   3473   #endif
  3479   3474   

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.870 2009/05/11 20:53:29 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.871 2009/05/13 17:21:14 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Include the configuration header output by 'configure' if we're using the
    21     21   ** autoconf-based build
................................................................................
   614    614   ** databases may be attached.
   615    615   */
   616    616   struct Db {
   617    617     char *zName;         /* Name of this database */
   618    618     Btree *pBt;          /* The B*Tree structure for this database file */
   619    619     u8 inTrans;          /* 0: not writable.  1: Transaction.  2: Checkpoint */
   620    620     u8 safety_level;     /* How aggressive at syncing data to disk */
   621         -  void *pAux;               /* Auxiliary data.  Usually NULL */
   622         -  void (*xFreeAux)(void*);  /* Routine to free pAux */
   623    621     Schema *pSchema;     /* Pointer to database schema (possibly shared) */
   624    622   };
   625    623   
   626    624   /*
   627    625   ** An instance of the following structure stores a database schema.
   628    626   **
   629    627   ** If there are no virtual tables configured in this schema, the