/ Check-in [40ba51fd]
Login

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

Overview
Comment:Get the SQLITE_SECURE_DELETE compile-time option working again. Ticket #3050. (CVS 4999)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 40ba51fd4c621e29e7ff85495b1212c92f06ab31
User & Date: drh 2008-04-14 01:00:58
Context
2008-04-14
13:42
Disable auto_vacuum during the vacuum3 test. (CVS 5000) check-in: e2e1ca81 user: drh tags: trunk
01:00
Get the SQLITE_SECURE_DELETE compile-time option working again. Ticket #3050. (CVS 4999) check-in: 40ba51fd user: drh tags: trunk
2008-04-13
23:13
Fix build errors in test_osinst (CVS 4998) check-in: f0473997 user: mlcreech tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/bitvec.c.

    28     28   ** Clear operations are exceedingly rare.  There are usually between
    29     29   ** 5 and 500 set operations per Bitvec object, though the number of sets can
    30     30   ** sometimes grow into tens of thousands or larger.  The size of the
    31     31   ** Bitvec object is the number of pages in the database file at the
    32     32   ** start of a transaction, and is thus usually less than a few thousand,
    33     33   ** but can be as large as 2 billion for a really big database.
    34     34   **
    35         -** @(#) $Id: bitvec.c,v 1.3 2008/03/21 16:45:47 drh Exp $
           35  +** @(#) $Id: bitvec.c,v 1.4 2008/04/14 01:00:58 drh Exp $
    36     36   */
    37     37   #include "sqliteInt.h"
    38     38   
    39     39   #define BITVEC_SZ        512
    40     40   /* Round the union size down to the nearest pointer boundary, since that's how 
    41     41   ** it will be aligned within the Bitvec struct. */
    42     42   #define BITVEC_USIZE     (((BITVEC_SZ-12)/sizeof(Bitvec*))*sizeof(Bitvec*))
................................................................................
   126    126   ** Set the i-th bit.  Return 0 on success and an error code if
   127    127   ** anything goes wrong.
   128    128   */
   129    129   int sqlite3BitvecSet(Bitvec *p, u32 i){
   130    130     u32 h;
   131    131     assert( p!=0 );
   132    132     assert( i>0 );
          133  +  assert( i<=p->iSize );
   133    134     if( p->iSize<=BITVEC_NBIT ){
   134    135       i--;
   135    136       p->u.aBitmap[i/8] |= 1 << (i&7);
   136    137       return SQLITE_OK;
   137    138     }
   138    139     if( p->iDivisor ){
   139    140       u32 bin = (i-1)/p->iDivisor;

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.423 2008/04/03 10:13:01 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.424 2008/04/14 01:00:58 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include <assert.h>
    26     26   #include <string.h>
    27     27   
    28     28   /*
................................................................................
  4430   4430   ** means that the pager does not have to record the given page in the
  4431   4431   ** rollback journal.
  4432   4432   **
  4433   4433   ** If we have not yet actually read the content of this page (if
  4434   4434   ** the PgHdr.needRead flag is set) then this routine acts as a promise
  4435   4435   ** that we will never need to read the page content in the future.
  4436   4436   ** so the needRead flag can be cleared at this point.
  4437         -**
  4438         -** This routine is only called from a single place in the sqlite btree
  4439         -** code (when a leaf is removed from the free-list). This allows the
  4440         -** following assumptions to be made about pPg:
  4441         -**
  4442         -**   1. PagerDontWrite() has been called on the page, OR 
  4443         -**      PagerWrite() has not yet been called on the page.
  4444         -**
  4445         -**   2. The page existed when the transaction was started.
  4446         -**
  4447         -** Details: DontRollback() (this routine) is only called when a leaf is
  4448         -** removed from the free list. DontWrite() is called whenever a page 
  4449         -** becomes a free-list leaf.
  4450   4437   */
  4451   4438   void sqlite3PagerDontRollback(DbPage *pPg){
  4452   4439     Pager *pPager = pPg->pPager;
  4453   4440   
  4454   4441     pagerEnter(pPager);
  4455   4442     assert( pPager->state>=PAGER_RESERVED );
  4456   4443   
................................................................................
  4460   4447     */
  4461   4448     if( pPager->journalOpen==0 || pPg->alwaysRollback || pPager->alwaysRollback ){
  4462   4449       pagerLeave(pPager);
  4463   4450       return;
  4464   4451     }
  4465   4452     assert( !MEMDB );    /* For a memdb, pPager->journalOpen is always 0 */
  4466   4453   
  4467         -  /* Check that PagerWrite() has not yet been called on this page, and
  4468         -  ** that the page existed when the transaction started.
         4454  +#ifdef SQLITE_SECURE_DELETE
         4455  +  if( pPg->inJournal || (int)pPg->pgno > pPager->origDbSize ){
         4456  +    return;
         4457  +  }
         4458  +#endif
         4459  +
         4460  +  /* If SECURE_DELETE is disabled, then there is no way that this
         4461  +  ** routine can be called on a page for which sqlite3PagerDontWrite()
         4462  +  ** has not been previously called during the same transaction.
         4463  +  ** And if DontWrite() has previously been called, the following
         4464  +  ** conditions must be met.
  4469   4465     */
  4470   4466     assert( !pPg->inJournal && (int)pPg->pgno <= pPager->origDbSize );
  4471   4467   
  4472   4468     assert( pPager->pInJournal!=0 );
  4473   4469     sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);
  4474   4470     pPg->inJournal = 1;
  4475   4471     pPg->needRead = 0;
  4476   4472     if( pPager->stmtInUse ){
  4477         -    assert( pPager->stmtSize <= pPager->origDbSize );
         4473  +    assert( pPager->stmtSize >= pPager->origDbSize );
  4478   4474       sqlite3BitvecSet(pPager->pInStmt, pPg->pgno);
  4479   4475     }
  4480   4476     PAGERTRACE3("DONT_ROLLBACK page %d of %d\n", pPg->pgno, PAGERID(pPager));
  4481   4477     IOTRACE(("GARBAGE %p %d\n", pPager, pPg->pgno))
  4482   4478     pagerLeave(pPager);
  4483   4479   }
  4484   4480   

Changes to src/test_config.c.

    12     12   ** 
    13     13   ** This file contains code used for testing the SQLite system.
    14     14   ** None of the code in this file goes into a deliverable build.
    15     15   ** 
    16     16   ** The focus of this file is providing the TCL testing layer
    17     17   ** access to compile-time constants.
    18     18   **
    19         -** $Id: test_config.c,v 1.24 2008/03/22 01:07:18 drh Exp $
           19  +** $Id: test_config.c,v 1.25 2008/04/14 01:00:58 drh Exp $
    20     20   */
    21     21   
    22     22   #include "sqliteLimit.h"
    23     23   
    24     24   #include "sqliteInt.h"
    25     25   #include "tcl.h"
    26     26   #include <stdlib.h>
................................................................................
   414    414   #endif
   415    415   
   416    416   #ifdef SQLITE_OMIT_VIRTUALTABLE
   417    417     Tcl_SetVar2(interp, "sqlite_options", "vtab", "0", TCL_GLOBAL_ONLY);
   418    418   #else
   419    419     Tcl_SetVar2(interp, "sqlite_options", "vtab", "1", TCL_GLOBAL_ONLY);
   420    420   #endif
          421  +
          422  +#ifdef SQLITE_SECURE_DELETE
          423  +  Tcl_SetVar2(interp, "sqlite_options", "secure_delete", "1", TCL_GLOBAL_ONLY);
          424  +#else
          425  +  Tcl_SetVar2(interp, "sqlite_options", "secure_delete", "0", TCL_GLOBAL_ONLY);
          426  +#endif
   421    427   
   422    428   #define LINKVAR(x) { \
   423    429       static const int cv_ ## x = SQLITE_ ## x; \
   424    430       Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(cv_ ## x), \
   425    431                   TCL_LINK_INT | TCL_LINK_READ_ONLY); }
   426    432   
   427    433     LINKVAR( MAX_LENGTH );

Changes to test/pageropt.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   # The focus of the tests in this file are to verify that the
    13     13   # pager optimizations implemented in version 3.3.14 work.
    14     14   #
    15         -# $Id: pageropt.test,v 1.3 2007/08/12 20:07:59 drh Exp $
           15  +# $Id: pageropt.test,v 1.4 2008/04/14 01:00:58 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20         -ifcapable {!pager_pragmas} {
           20  +ifcapable {!pager_pragmas||secure_delete} {
    21     21     finish_test
    22     22     return
    23     23   }
    24     24   
    25     25   # Run the SQL statement supplied by the argument and return
    26     26   # the results.  Prepend four integers to the beginning of the
    27     27   # result which are
................................................................................
   184    184   
   185    185   # Now we delete that big entries starting from a cold cache and an
   186    186   # empty freelist.  The first 10 of the 11 pages overflow chain have
   187    187   # to be read, together with page1 and the root of the t1 table.  12
   188    188   # reads total.  But only page1, the t1 root, and the trunk of the
   189    189   # freelist need to be journalled and written back.
   190    190   #
   191         -do_test pageroot-4.2 {
          191  +do_test pageropt-4.2 {
   192    192     db close
   193    193     sqlite3 db test.db
   194    194     pagercount_sql {
   195    195       DELETE FROM t1
   196    196     }
   197    197   } {12 3 3 0}
   198    198   
   199    199   sqlite3_soft_heap_limit $soft_limit
   200    200   catch {db2 close}
   201    201   finish_test