/ Check-in [a4a3bbe6]
Login

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

Overview
Comment:Fix a problem with deferred page allocation in transactions that revert page allocations by savepoint rollbacks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256: a4a3bbe64690856403642352f36e664a5a7fba686463a63446c6ada99df4e89f
User & Date: dan 2017-05-26 16:15:05
Wiki:begin-concurrent
Context
2017-05-26
16:51
Add extra test cases for deferred page allocation. check-in: 9df01957 user: dan tags: begin-concurrent
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
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

   518    518             pMap->nRollbackAlloc = nNew;
   519    519           }
   520    520         }
   521    521   
   522    522         pMap->aRollback[pMap->nRollback].pgno = pgno;
   523    523         pMap->aRollback[pMap->nRollback].parent = pMap->aPtr[iEntry].parent;
   524    524         pMap->aRollback[pMap->nRollback].eType = pMap->aPtr[iEntry].eType;
          525  +      pMap->nRollback++;
   525    526       }
   526    527   
   527    528       /* Update the aPtr[] array */
   528    529       pMap->aPtr[iEntry].parent = parent;
   529    530       pMap->aPtr[iEntry].eType = eType;
   530    531     }
   531    532   
................................................................................
   534    535   
   535    536   /* !defined(SQLITE_OMIT_CONCURRENT)
   536    537   **
   537    538   ** Open savepoint iSavepoint, if it is not already open.
   538    539   */
   539    540   static int btreePtrmapBegin(BtShared *pBt, int nSvpt){
   540    541     BtreePtrmap *pMap = pBt->pMap;
   541         -  if( pMap && nSvpt<pMap->nSvpt ){
          542  +  if( pMap && nSvpt>pMap->nSvpt ){
   542    543       int i;
   543    544       if( nSvpt>=pMap->nSvptAlloc ){
   544    545         int nNew = pMap->nSvptAlloc ? pMap->nSvptAlloc*2 : 16;
   545    546         int *aNew = sqlite3_realloc(pMap->aSvpt, sizeof(int) * nNew);
   546    547         if( aNew==0 ){
   547    548           return SQLITE_NOMEM;
   548    549         }else{

Added test/concurrent4.test.

            1  +# 2017 May 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# Miscellaneous tests for transactions started with BEGIN CONCURRENT. 
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +source $testdir/lock_common.tcl
           18  +source $testdir/wal_common.tcl
           19  +set ::testprefix concurrent4
           20  +
           21  +ifcapable !concurrent {
           22  +  finish_test
           23  +  return
           24  +}
           25  +
           26  +do_execsql_test 1.0 {
           27  +  PRAGMA journal_mode = wal;
           28  +  CREATE TABLE t1(x PRIMARY KEY, y UNIQUE);
           29  +  WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
           30  +  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
           31  +  DELETE FROM t1 WHERE rowid<2;
           32  +} {wal}
           33  +
           34  +do_execsql_test 1.1 {
           35  +  BEGIN CONCURRENT;
           36  +    INSERT INTO t1(rowid, x, y) VALUES(1000, randomblob(3000), randomblob(3000));
           37  +    SAVEPOINT abc;
           38  +    DELETE FROM t1 WHERE rowid = 1000;
           39  +}
           40  +
           41  +do_execsql_test 1.2 { ROLLBACK TO abc }
           42  +do_execsql_test 1.3 { COMMIT }
           43  +do_execsql_test 1.4 { PRAGMA integrity_check } {ok}
           44  +
           45  +
           46  +
           47  +finish_test
           48  +