/ Check-in [47a7dd92]
Login

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

Overview
Comment:Fix a problem with the deferred page allocation on this branch that could occur when the database file is just slightly smaller than the PENDING_BYTE page offset.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256: 47a7dd92355ffd74645cf8da8186d5799c05a95907877a09c28de41135deeede
User & Date: dan 2017-05-25 21:02:00
Wiki:begin-concurrent
Context
2017-05-26
16:15
Fix a problem with deferred page allocation in transactions that revert page allocations by savepoint rollbacks. check-in: a4a3bbe6 user: dan tags: begin-concurrent
2017-05-25
21:02
Fix a problem with the deferred page allocation on this branch that could occur when the database file is just slightly smaller than the PENDING_BYTE page offset. check-in: 47a7dd92 user: dan tags: begin-concurrent
2017-05-23
19:23
Add experimental new API sqlite3_wal_info(). check-in: 5b9d498f user: dan tags: begin-concurrent
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/bitvec.c.

   166    166   ** and that the value for "i" is within range of the Bitvec object.
   167    167   ** Otherwise the behavior is undefined.
   168    168   */
   169    169   int sqlite3BitvecSet(Bitvec *p, u32 i){
   170    170     u32 h;
   171    171     if( p==0 ) return SQLITE_OK;
   172    172     assert( i>0 );
   173         -  /* assert( i<=p->iSize ); */
          173  +  assert( i<=p->iSize );
   174    174     if( i>p->iSize ){
   175    175       sqlite3_log(SQLITE_ERROR, 
   176    176           "Bitvec: setting bit %d of bitvec size %d\n", (int)i, (int)p->iSize
   177    177       );
   178    178     }
   179    179     i--;
   180    180     while((p->iSize > BITVEC_NBIT) && p->iDivisor) {

Changes to src/btree.c.

  4125   4125           ** the transaction out to disk. Before doing so though, attempt to
  4126   4126           ** relocate some of the new pages to free locations within the body
  4127   4127           ** of the database file (i.e. free-list entries). */
  4128   4128           if( rc==SQLITE_OK ){
  4129   4129             assert( nCurrent!=PENDING_BYTE_PAGE(pBt) );
  4130   4130             sqlite3PagerSetDbsize(pBt->pPager, nCurrent);
  4131   4131             nFree = get4byte(&p1[36]);
  4132         -          nFin = MAX(nCurrent-nFree, nHPage);
         4132  +          nFin = nCurrent-nFree;
  4133   4133             if( nCurrent>PENDING_BYTE_PAGE(pBt) && nFin<=PENDING_BYTE_PAGE(pBt) ){
  4134   4134               nFin--;
  4135   4135             }
         4136  +          nFin = MAX(nFin, nHPage);
  4136   4137             rc = btreeRelocateRange(pBt, nFin+1, nCurrent, 0);
  4137   4138           }
  4138   4139   
  4139   4140           put4byte(&p1[28], nFin);
  4140   4141         }
  4141   4142       }
  4142   4143       sqlite3PagerSetDbsize(pPager, nFin);

Changes to test/concurrent2.test.

   572    572   
   573    573     do_test 11.$tn.5 {
   574    574       sql1 { PRAGMA wal_checkpoint }
   575    575       sql2 { INSERT INTO t1 VALUES(3) }
   576    576       code2 { sqlite3_wal_info db2 main }
   577    577     } {0 1}
   578    578   }
          579  +
          580  +reset_db
          581  +do_execsql_test 12.0 {
          582  +  PRAGMA journal_mode = wal;
          583  +  CREATE TABLE tx(a INTEGER PRIMARY KEY, b);
          584  +} {wal}
          585  +do_test 12.1 {
          586  +  for {set i 0} {$i < 50} {incr i} {
          587  +    execsql {
          588  +      BEGIN CONCURRENT;
          589  +      INSERT INTO tx(b) VALUES( randomblob( 1200 ) );
          590  +      COMMIT;
          591  +    }
          592  +  }
          593  +  execsql { PRAGMA page_size }
          594  +} {1024}
          595  +do_execsql_test 12.2 {
          596  +  DELETE FROM tx;
          597  +}
          598  +do_test 12.3 {
          599  +  for {set i 0} {$i < 50} {incr i} {
          600  +    execsql {
          601  +      BEGIN CONCURRENT;
          602  +      INSERT INTO tx(b) VALUES( randomblob( 1200 ) );
          603  +      COMMIT;
          604  +    }
          605  +  }
          606  +  execsql { PRAGMA page_size }
          607  +} {1024}
          608  +do_execsql_test 12.4 {
          609  +  DELETE FROM tx;
          610  +}
          611  +do_test 12.5 {
          612  +  execsql { BEGIN CONCURRENT }
          613  +  for {set i 0} {$i < 5000} {incr i} {
          614  +    execsql {
          615  +      INSERT INTO tx(b) VALUES( randomblob( 1200 ) );
          616  +    }
          617  +  }
          618  +  execsql { COMMIT }
          619  +  execsql { PRAGMA page_size }
          620  +} {1024}
   579    621   
   580    622   
   581    623   finish_test