/ Check-in [938b91e8]
Login

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

Overview
Comment:Fixes for compiling with SQLITE_OMIT_AUTOVACUUM and/or SQLITE_OMIT_TRIGGER defined.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | omit-fixes
Files: files | file ages | folders
SHA1: 938b91e8552516772060d4e55e2f79cca4c13e27
User & Date: dan 2013-03-11 11:49:03
Context
2013-03-11
11:57
Fixes for compiling with SQLITE_OMIT_AUTOVACUUM and/or SQLITE_OMIT_TRIGGER defined. check-in: 1da15adb user: dan tags: trunk
11:49
Fixes for compiling with SQLITE_OMIT_AUTOVACUUM and/or SQLITE_OMIT_TRIGGER defined. Closed-Leaf check-in: 938b91e8 user: dan tags: omit-fixes
2013-03-09
14:49
Add a test case for the problem fixed by the previous commit. check-in: e899b058 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

    39     39   ** This routine is used to extract the "offset to cell content area" value
    40     40   ** from the header of a btree page.  If the page size is 65536 and the page
    41     41   ** is empty, the offset should be 65536, but the 2-byte value stores zero.
    42     42   ** This routine makes the necessary adjustment to 65536.
    43     43   */
    44     44   #define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)
    45     45   
           46  +/*
           47  +** Values passed as the 5th argument to allocateBtreePage()
           48  +*/
           49  +#define BTALLOC_ANY   0           /* Allocate any page */
           50  +#define BTALLOC_EXACT 1           /* Allocate exact page if possible */
           51  +#define BTALLOC_LE    2           /* Allocate any page <= the parameter */
           52  +
           53  +/*
           54  +** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not 
           55  +** defined, or 0 if it is. For example:
           56  +**
           57  +**   bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum);
           58  +*/
           59  +#ifndef SQLITE_OMIT_AUTOVACUUM
           60  +#define IfNotOmitAV(expr) (expr)
           61  +#else
           62  +#define IfNotOmitAV(expr) 0
           63  +#endif
           64  +
    46     65   #ifndef SQLITE_OMIT_SHARED_CACHE
    47     66   /*
    48     67   ** A list of BtShared objects that are eligible for participation
    49     68   ** in shared cache.  This variable has file scope during normal builds,
    50     69   ** but the test harness needs to access it so we make it global for 
    51     70   ** test builds.
    52     71   **
................................................................................
  2591   2610     /* If the btree is already in a write-transaction, or it
  2592   2611     ** is already in a read-transaction and a read-transaction
  2593   2612     ** is requested, this is a no-op.
  2594   2613     */
  2595   2614     if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
  2596   2615       goto trans_begun;
  2597   2616     }
  2598         -  assert( pBt->bDoTruncate==0 );
         2617  +  assert( IfNotOmitAV(pBt->bDoTruncate)==0 );
  2599   2618   
  2600   2619     /* Write transactions are not possible on a read-only database */
  2601   2620     if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
  2602   2621       rc = SQLITE_READONLY;
  2603   2622       goto trans_begun;
  2604   2623     }
  2605   2624   
................................................................................
  2906   2925       }
  2907   2926     }
  2908   2927     return rc;
  2909   2928   }
  2910   2929   
  2911   2930   /* Forward declaration required by incrVacuumStep(). */
  2912   2931   static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);
  2913         -#define BTALLOC_ANY   0           /* Allocate any page */
  2914         -#define BTALLOC_EXACT 1           /* Allocate exact page if possible */
  2915         -#define BTALLOC_LE    2           /* Allocate any page <= the parameter */
  2916   2932   
  2917   2933   /*
  2918   2934   ** Perform a single step of an incremental-vacuum. If successful, return
  2919   2935   ** SQLITE_OK. If there is no work to do (and therefore no point in 
  2920   2936   ** calling this function again), return SQLITE_DONE. Or, if an error 
  2921   2937   ** occurs, return some other error code.
  2922   2938   **
................................................................................
  4898   4914     u32 n;     /* Number of pages on the freelist */
  4899   4915     u32 k;     /* Number of leaves on the trunk of the freelist */
  4900   4916     MemPage *pTrunk = 0;
  4901   4917     MemPage *pPrevTrunk = 0;
  4902   4918     Pgno mxPage;     /* Total size of the database file */
  4903   4919   
  4904   4920     assert( sqlite3_mutex_held(pBt->mutex) );
  4905         -  assert( eMode==BTALLOC_ANY || (nearby>0 && pBt->autoVacuum) );
         4921  +  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
  4906   4922     pPage1 = pBt->pPage1;
  4907   4923     mxPage = btreePagecount(pBt);
  4908   4924     n = get4byte(&pPage1->aData[36]);
  4909   4925     testcase( n==mxPage-1 );
  4910   4926     if( n>=mxPage ){
  4911   4927       return SQLITE_CORRUPT_BKPT;
  4912   4928     }
................................................................................
  5131   5147       **
  5132   5148       ** Note that the pager will not actually attempt to load or journal 
  5133   5149       ** content for any page that really does lie past the end of the database
  5134   5150       ** file on disk. So the effects of disabling the no-content optimization
  5135   5151       ** here are confined to those pages that lie between the end of the
  5136   5152       ** database image and the end of the database file.
  5137   5153       */
  5138         -    int bNoContent = (0==pBt->bDoTruncate);
         5154  +    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate));
  5139   5155   
  5140   5156       rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
  5141   5157       if( rc ) return rc;
  5142   5158       pBt->nPage++;
  5143   5159       if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;
  5144   5160   
  5145   5161   #ifndef SQLITE_OMIT_AUTOVACUUM

Changes to src/pragma.c.

  1126   1126           }
  1127   1127         }
  1128   1128       }
  1129   1129     }else
  1130   1130   #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
  1131   1131   
  1132   1132   #ifndef SQLITE_OMIT_FOREIGN_KEY
         1133  +#ifndef SQLITE_OMIT_TRIGGER
  1133   1134     if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){
  1134   1135       FKey *pFK;             /* A foreign key constraint */
  1135   1136       Table *pTab;           /* Child table contain "REFERENCES" keyword */
  1136   1137       Table *pParent;        /* Parent table that child points to */
  1137   1138       Index *pIdx;           /* Index in the parent table */
  1138   1139       int i;                 /* Loop counter:  Foreign key number for pTab */
  1139   1140       int j;                 /* Loop counter:  Field of the foreign key */
................................................................................
  1237   1238           sqlite3VdbeResolveLabel(v, addrOk);
  1238   1239           sqlite3DbFree(db, aiCols);
  1239   1240         }
  1240   1241         sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1);
  1241   1242         sqlite3VdbeJumpHere(v, addrTop);
  1242   1243       }
  1243   1244     }else
         1245  +#endif /* !defined(SQLITE_OMIT_TRIGGER) */
  1244   1246   #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
  1245   1247   
  1246   1248   #ifndef NDEBUG
  1247   1249     if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){
  1248   1250       if( zRight ){
  1249   1251         if( sqlite3GetBoolean(zRight, 0) ){
  1250   1252           sqlite3ParserTrace(stderr, "parser: ");