Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -520,10 +520,11 @@ } pMap->aRollback[pMap->nRollback].pgno = pgno; pMap->aRollback[pMap->nRollback].parent = pMap->aPtr[iEntry].parent; pMap->aRollback[pMap->nRollback].eType = pMap->aPtr[iEntry].eType; + pMap->nRollback++; } /* Update the aPtr[] array */ pMap->aPtr[iEntry].parent = parent; pMap->aPtr[iEntry].eType = eType; @@ -536,11 +537,11 @@ ** ** Open savepoint iSavepoint, if it is not already open. */ static int btreePtrmapBegin(BtShared *pBt, int nSvpt){ BtreePtrmap *pMap = pBt->pMap; - if( pMap && nSvptnSvpt ){ + if( pMap && nSvpt>pMap->nSvpt ){ int i; if( nSvpt>=pMap->nSvptAlloc ){ int nNew = pMap->nSvptAlloc ? pMap->nSvptAlloc*2 : 16; int *aNew = sqlite3_realloc(pMap->aSvpt, sizeof(int) * nNew); if( aNew==0 ){ ADDED test/concurrent4.test Index: test/concurrent4.test ================================================================== --- /dev/null +++ test/concurrent4.test @@ -0,0 +1,48 @@ +# 2017 May 26 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Miscellaneous tests for transactions started with BEGIN CONCURRENT. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl +source $testdir/wal_common.tcl +set ::testprefix concurrent4 + +ifcapable !concurrent { + finish_test + return +} + +do_execsql_test 1.0 { + PRAGMA journal_mode = wal; + CREATE TABLE t1(x PRIMARY KEY, y UNIQUE); + WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100) + INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s; + DELETE FROM t1 WHERE rowid<2; +} {wal} + +do_execsql_test 1.1 { + BEGIN CONCURRENT; + INSERT INTO t1(rowid, x, y) VALUES(1000, randomblob(3000), randomblob(3000)); + SAVEPOINT abc; + DELETE FROM t1 WHERE rowid = 1000; +} + +do_execsql_test 1.2 { ROLLBACK TO abc } +do_execsql_test 1.3 { COMMIT } +do_execsql_test 1.4 { PRAGMA integrity_check } {ok} + + + +finish_test +