SQLite4
Check-in [b7f86e5617]
Not logged in

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

Overview
Comment:Fixes so that tcl tests run with bt.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b7f86e5617e8584549e512faef5e562da2b57875
User & Date: dan 2014-02-08 10:51:16
Context
2014-02-14
16:21
Run extra tests with the bt backend. check-in: 1aefe7ef1e user: dan tags: trunk
2014-02-08
10:51
Fixes so that tcl tests run with bt. check-in: b7f86e5617 user: dan tags: trunk
2014-02-05
20:05
Fix a buffer overrun occuring when many overflow pages are recycled by a merge operation. check-in: 28340557fc user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to lsm-test/lsmtest_main.c.

     1      1   
            2  +#include <stdarg.h>
     2      3   #include "lsmtest.h"
     3      4   #include "stdio.h"
     4      5   #include "assert.h"
     5      6   #include "string.h"
     6      7   #include "stdlib.h"
     7      8   
     8      9   #include <sqlite3.h>

Changes to src/btInt.h.

   332    332     /* These are used only by the bt_lock module. */
   333    333     BtShared *pShared;              /* Shared by all handles on this file */
   334    334     BtLock *pNext;                  /* Next connection using pShared */
   335    335     u32 mExclLock;                  /* Mask of exclusive locks held */
   336    336     u32 mSharedLock;                /* Mask of shared locks held */
   337    337     BtFile *pBtFile;                /* Used to defer close if necessary */
   338    338   
   339         -#ifndef NDEBUG
   340    339     u8 *aUsed;
   341         -#endif
   342    340   };
   343    341   
   344    342   struct BtReadSlot {
   345    343     u32 iFirst;
   346    344     u32 iLast;
   347    345   };
   348    346   

Changes to src/bt_main.c.

  1144   1144   ** bNext is true) and Pref() (if bNext is false).
  1145   1145   */
  1146   1146   static int btCsrStep(BtCursor *pCsr, int bNext){
  1147   1147     const int pgsz = sqlite4BtPagerPagesize(pCsr->base.pDb->pPager);
  1148   1148     int rc = SQLITE4_OK;
  1149   1149     int bRequireDescent = 0;
  1150   1150   
  1151         -  pCsr->ovfl.nKey = 0;
  1152   1151     rc = btCsrReseek(pCsr);
  1153   1152     if( rc==SQLITE4_OK && pCsr->nPg==0 ){
  1154   1153       rc = SQLITE4_NOTFOUND;
  1155   1154     }
         1155  +  pCsr->ovfl.nKey = 0;
  1156   1156   
  1157   1157     if( (pCsr->bSkipNext && bNext) || (pCsr->bSkipPrev && bNext==0) ){
  1158   1158       pCsr->bSkipPrev = pCsr->bSkipNext = 0;
  1159   1159       return rc;
  1160   1160     }
  1161   1161     pCsr->bSkipPrev = pCsr->bSkipNext = 0;
  1162   1162   
................................................................................
  4729   4729          && 0==btKeyCompare(pKey, nKey, pSKey, nSKey) 
  4730   4730          && btCsrOverflow(pSub)
  4731   4731         ){
  4732   4732           u32 pgno = sqlite4BtPagePgno(pSub->apPage[pSub->nPg-1]);
  4733   4733           int iCell = pSub->aiCell[pSub->nPg-1];
  4734   4734   
  4735   4735           if( p->aTrunk==0 ){
         4736  +          assert( p->nOvfl==0 );
  4736   4737             rc = btNewBuffer(p->db, &p->aTrunk);
  4737   4738             if( rc==SQLITE4_OK ) memset(p->aTrunk, 0, 8);
  4738         -          assert( p->nOvfl==0 );
  4739   4739           }else if( p->nOvflPerPage==p->nOvfl ){
  4740   4740             rc = fiWriterFlushOvfl(p, 0);
         4741  +          assert( p->nOvfl==0 );
  4741   4742           }
  4742   4743           if( rc==SQLITE4_OK ){
         4744  +          assert( p->nOvfl<p->nOvflPerPage );
  4743   4745             btPutU32(&p->aTrunk[8 + p->nOvfl*8], pgno);
  4744   4746             btPutU32(&p->aTrunk[8 + p->nOvfl*8 + 4], iCell);
  4745   4747             p->nOvfl++;
  4746   4748           }
  4747   4749         }
  4748   4750       }
  4749   4751     }
................................................................................
  4946   4948     }
  4947   4949   
  4948   4950     btCheckPageRefs(db);
  4949   4951     db->bFastInsertOp = 0;
  4950   4952     return rc;
  4951   4953   }
  4952   4954   
         4955  +#ifndef NDEBUG
  4953   4956   void sqlite4BtDebugTree(bt_db *db, int iCall, u32 iRoot){
  4954   4957     BtPage *pPg;
  4955   4958     sqlite4_buffer buf;
  4956   4959     int pgsz;
  4957   4960   
  4958   4961     pgsz = sqlite4BtPagerPagesize(db->pPager);
  4959   4962     sqlite4_buffer_init(&buf, 0);
................................................................................
  4982   4985       if( rc!=SQLITE4_OK ) break;
  4983   4986   
  4984   4987       iSubRoot = btGetU32((const u8*)pK);
  4985   4988       sqlite4BtDebugTree(db, iCall, iSubRoot);
  4986   4989     }
  4987   4990     btCsrReset(&mcsr, 1);
  4988   4991   }
         4992  +#endif   /* ifndef NDEBUG */
  4989   4993   
  4990   4994   
  4991   4995   /*
  4992   4996   ** Delete the entry that the cursor currently points to.
  4993   4997   */
  4994   4998   int sqlite4BtDelete(bt_cursor *pBase){
  4995   4999     bt_db *db = pBase->pDb;
................................................................................
  5212   5216       }
  5213   5217   
  5214   5218     }
  5215   5219   
  5216   5220     return rc;
  5217   5221   }
  5218   5222   
  5219         -#ifndef NDEBUG
  5220         -
  5221   5223   static void markBlockAsUsed(
  5222   5224     bt_db *db,
  5223   5225     u32 iBlk,
  5224   5226     u8 *aUsed
  5225   5227   ){
  5226   5228     if( iBlk ){
  5227   5229       BtDbHdr *pHdr = sqlite4BtPagerDbhdr(db->pPager);
................................................................................
  5409   5411         btControlTransactionDone(db, iCtx);
  5410   5412         pLock->aUsed = 0;
  5411   5413       }
  5412   5414     }
  5413   5415   
  5414   5416     return SQLITE4_OK;
  5415   5417   }
  5416         -#endif
  5417         -
  5418         -
  5419   5418   
  5420   5419   

Changes to src/bt_pager.c.

   375    375     if( nReq<=p->nSavepoint ){
   376    376       int i;
   377    377       for(i=p->nSavepoint-1; i>=nReq; i--){
   378    378         BtSavepoint *pSavepoint = &p->aSavepoint[i];
   379    379         BtSavepage *pSavepg;
   380    380         BtSavepage *pNext;
   381    381   
   382         -      /* Restore the BtDbHdr object to the state it was in at the start of
   383         -      ** this savepoint.  */
   384         -      memcpy(p->pHdr, &pSavepoint->hdr, sizeof(BtDbHdr));
          382  +      /* If this is a rollback operation, restore the BtDbHdr object to the
          383  +      ** state it was in at the start of this savepoint.  */
          384  +      if( bRollback ){
          385  +        memcpy(p->pHdr, &pSavepoint->hdr, sizeof(BtDbHdr));
          386  +      }
   385    387   
   386    388         /* Loop through each of the BtSavepage objects associated with this
   387    389         ** savepoint. Detach them from the BtPage objects and free all
   388    390         ** allocated memory.  */
   389    391         for(pSavepg=pSavepoint->pSavepage; pSavepg; pSavepg=pNext){
   390    392           BtPage *pPg = pSavepg->pPg;
   391    393           pNext = pSavepg->pNext;
................................................................................
   432    434   
   433    435   
   434    436   /*
   435    437   ** Close a pager database handle.
   436    438   */
   437    439   int sqlite4BtPagerClose(BtPager *p){
   438    440     int rc;
          441  +
          442  +  if( p->btl.pFd ){
          443  +    sqlite4BtPagerRollback(p, 0);
          444  +  }
   439    445   
   440    446     rc = sqlite4BtLockDisconnect((BtLock*)p, btCheckpoint, btCleanup);
   441         -
   442    447     p->iTransactionLevel = 0;
   443    448     btCloseSavepoints(p, 0, 0);
   444    449     btPurgeCache(p);
   445    450     sqlite4BtLogClose(p->pLog, 0);
   446    451     sqlite4_free(p->btl.pEnv, p->zFile);
   447    452     sqlite4_free(p->btl.pEnv, p->aSavepoint);
   448    453     sqlite4_free(p->btl.pEnv, p);
................................................................................
   820    825     if( pRet==0 ){
   821    826       rc = btAllocatePage(p, &pRet);
   822    827       if( rc==SQLITE4_OK ){
   823    828         pRet->pgno = pgno;
   824    829         if( pgno<=p->pHdr->nPg ){
   825    830           rc = btLoadPageData(p, pRet);
   826    831         }else{
          832  +        assert( p->iTransactionLevel>=2 );
   827    833           memset(pRet->aData, 0, p->pHdr->pgsz);
   828    834         }
   829    835   
   830    836         if( rc==SQLITE4_OK ){
   831    837           rc = btHashAdd(p, pRet);
   832    838         }
   833    839   

Changes to test/manydb.test.

    14     14   # many different databases at the same time without leaking memory.
    15     15   #
    16     16   # $Id: manydb.test,v 1.4 2008/11/21 00:10:35 aswift Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21         -set N 300
           21  +set N 200
    22     22   set num_fd_per_openwrite_db 4
    23     23   
    24     24   # First test how many file descriptors are available for use. To open a
    25     25   # database for writing SQLite requires 3 file descriptors (the database, the
    26     26   # journal and the directory).
    27     27   set filehandles {}
    28     28   catch {

Changes to test/src4.test.

    11     11   set testdir [file dirname $argv0]
    12     12   source $testdir/permutations.test
    13     13   
    14     14   run_test_suite src4
    15     15   run_test_suite bt
    16     16   
    17     17   finish_test
           18  +