void **ppChangeset /* OUT: Buffer containing changeset */
);
++/*
++** CAPI3REF: Generate A Full Changeset From A Session Object
++**
++** This function is similar to sqlite3session_changeset(), except that for
++** each row affected by an UPDATE statement, all old.* values are recorded
++** as part of the changeset, not just those modified.
++*/
++int sqlite3session_fullchangeset(
++ sqlite3_session *pSession, /* Session object */
++ int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
++ void **ppChangeset /* OUT: Buffer containing changeset */
++);
++
/*
** CAPI3REF: Load The Difference Between Tables Into A Session
** METHOD: sqlite3_session
- C Increase\scoverage\sprovided\sby\spermutation\s"coverage-wal"\son\sthis\sbranch.
- D 2018-12-29T16:34:22.239
-C Fix\sa\sproblem\scausing\sa\scorrupt\spager-cache\sif\san\sOOM\sor\sIO\serror\swas\nencountered\swhile\scommitting\sa\sconcurrent\stransacation.
-D 2018-12-29T20:42:12.966
++C Merge\slatest\sbegin-concurrent\schanges\swith\sthis\sbranch.
++D 2018-12-29T20:47:45.530
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6
F ext/session/sqlite3changebatch.c d5553b79e012ee2cb06c0a96bdf9dfe19e66354390ea0036cc46c4953142d517
F ext/session/sqlite3changebatch.h e72016998c9a22d439ddfd547b69e1ebac810c24
F ext/session/sqlite3session.c 994b1b691f3e1ab72a9d3949c2ca7dca4db3d9dd5ece5e34f74953411b8d36f9
- F ext/session/sqlite3session.h fd5d353901575b587c877b957918ff9f2d8e0ff40a96b210cf79459c0e17d3b7
-F ext/session/sqlite3session.h 2a449bb4ba954dd374bd8524af6187454f98fa1d61d16a9f6709ce0a191cf4f1
++F ext/session/sqlite3session.h ef72e7738edcaf8d1a29e74480cac3b3171781870d248160b2d9147b8dac0d6b
F ext/session/test_session.c 60e15d5db8ae7a0f521e70a7504ba1f74fc50548a25a5397808f487bc6a92b5d
F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
-F src/os_unix.c 86eca42c3d955bebea0082450f978e5633448235f03f86b27a02538bb26e7fff
+F src/os_unix.c 1aa113b261a0ad44fd410a001f6e39bfc1ebd4279b2fb8c2d636a7620d76a45a
F src/os_win.c 85d9e532d0444ab6c16d7431490c2e279e282aa0917b0e988996b1ae0de5c5a0
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
- F src/pager.c bd11bf6971789994b4c1972019f16caf6e5ed5a59165d65f0147535aab191703
-F src/pager.c 94e8c52c0f91fbf7059ffbbd3be7939ee5122221e0e63855df7ba83100733580
-F src/pager.h 389ba8f526d13026aa7081dc581aa742eb7207e3277e7106c522c5b65ad92590
++F src/pager.c 24dbb25d447629bc8167dcf16dcb449a6eb2067393935d97ff42377798e44979
+F src/pager.h d8cf37b3415c742d1f267ae2e0e6495826a72d403cbdbefdab2e2f5ff2a1dde7
F src/parse.y 8206217fe7fa96652aa1b8a797246e23b30a9d4c1a5175d9c12b13750f51dc2f
F src/pcache.c 696a01f1a6370c1b50a09c15972bc3bee3333f8fcd1f2da8e9a76b1b062c59ee
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
F src/vdbetrace.c 79d6dbbc479267b255a7de8080eee6e729928a0ef93ed9b0bfa5618875b48392
F src/vtab.c 70188a745dc4e57d26e942681ff4b2912b7c8249ad5de3f60f0677b4337bcfaa
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
- F src/wal.c 598891224a5b45d984b8cf24517aa907c47b03d46578bed58f74b7e28b8d3250
- F src/wal.h c398e0269e8f37495cedb63b5e288c2aac6f6d103d05fb55f4affec21311615d
-F src/wal.c 2d5771a64354e7a7ef926a38fec8c06193a50fda40cee027c5385c3330abb791
-F src/wal.h ac2100eeda406a4492b8c183154507532d23ab9d5a8e32e208adfe4f9ea554f9
++F src/wal.c d1908ffa514275dc6f27c4b27abc6d5a2ce18c89e98dce10925972266b960f37
++F src/wal.h 86a71244ad934135743cb50dd00cd380763ec5dca5b68012ea394731a369b741
F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
F src/where.c 3818e8a736a05d2cb194e64399af707e367fbcc5c251d785804d02eaf121288e
F src/whereInt.h f125f29fca80890768e0b2caa14f95db74b2dacd3a122a168f97aa7b64d6968f
F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151ecac0b95
F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1
F test/colname.test fb28b3687e03625425bc216edf8b186ce974aa71008e2aa1f426a7dcb75a601d
-F test/concfault.test e5370cd686f601a01909377cac3bbf13dac56d39dd4ad6b04ccbec9eeeaccb18
+F test/concfault.test 500f17c3fcfe7705114422bcc6ddd3c740001a43
- F test/concfault2.test 0c4094db632e585244ca3b1cbfb74b794dd93629bf699bd1a2b511055c52c0bc
++F test/concfault2.test 34b3fd258836aa305475d00e804c7450ade92f0de0bf9fa620e701446669bb12
F test/concurrent.test 86661967a680670127a62a819e60dc93c2d3d49043ac95b26dfa70d3e60dbde5
-F test/concurrent2.test 9dfbeb0a323733fe1d13443371734bb94a674dbf777f464365475903873111f8
+F test/concurrent2.test f447dfae67e4d80a2b61e2796c2c081564a8126cf96c39a14780e89c8c53eff5
F test/concurrent3.test 530671ac706f6a1d0f4992dbdd33a86408330d03cd90fb9e82ecb1b27f5fd081
F test/concurrent4.test e0b12cd467137e50259df3b4f837507e82aaa07c35941c88664dc8ed1d089c44
F test/concurrent5.test 0c16cbf7446af162a14e6def30445e94016064eb994e5aa4ebb2bebc59554176
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
- P ea96001e801fbf228d1fb63b9d3c73fd9da54994d3cfe383ea76edfa6da83b8d
- R 42c4829d3c89025ea70567a057d519f0
-P 123cbb3312917ad5b3c32556547c5b7e8ba4e2d2def8651ff80f9fc1bdc1875c
-R 512dc15e0eb54608feb82659e89c990b
++P f664f940a7eb6938b1ee171143a691e2f497aec921f979be63ef844d38053f56 48ca30f9d7817d87a5e9a069fdc51b1a34e00585f8a35771895dd743c7bfe07c
++R 96b75411a5a80fefb4035842cde30725
U dan
- Z 4b3d49cde64b9c3f6154999717a75fb6
-Z 01d5996e76265f2df93e10aa0e859282
++Z c4caebd173a274144c3a15ad58f87055
- f664f940a7eb6938b1ee171143a691e2f497aec921f979be63ef844d38053f56
-48ca30f9d7817d87a5e9a069fdc51b1a34e00585f8a35771895dd743c7bfe07c
++1625887c0240eb1cb37e41d79e789c4ff311352c5708e6a2d3ed1b223ff382e3
** Otherwise, if the callback function does not return an error, this
** function returns SQLITE_OK.
*/
- int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
+ int sqlite3WalUndo(
+ Wal *pWal,
+ int (*xUndo)(void *, Pgno),
+ void *pUndoCtx,
+ int bConcurrent /* True if this is a CONCURRENT transaction */
+ ){
int rc = SQLITE_OK;
if( pWal->writeLock ){
- Pgno iMax = pWal->hdr.mxFrame;
+ int iWal = walidxGetFile(&pWal->hdr);
+ Pgno iMax = walidxGetMxFrame(&pWal->hdr, iWal);
+ Pgno iNew;
Pgno iFrame;
-
+
+ assert( isWalMode2(pWal) || iWal==0 );
+
/* Restore the clients cache of the wal-index header to the state it
** was in before the client began writing to the database.
*/
memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));
+ iNew = walidxGetMxFrame(&pWal->hdr, walidxGetFile(&pWal->hdr));
+
+ /* BEGIN CONCURRENT transactions are different, as the header just
+ ** memcpy()d into pWal->hdr may not be the same as the current header
+ ** when the transaction was started. Instead, pWal->hdr now contains
+ ** the header written by the most recent successful COMMIT. Because
+ ** Wal.writeLock is set, if this is a BEGIN CONCURRENT transaction,
+ ** the rollback must be taking place because an error occurred during
+ ** a COMMIT.
+ **
+ ** The code below is still valid. All frames between (iNew+1) and iMax
+ ** must have been written by this transaction before the error occurred.
+ ** The exception is in wal2 mode - if the current wal file at the time
+ ** of the last COMMIT is not wal file iWal, then the error must have
+ ** occurred in WalLockForCommit(), before any pages were written
+ ** to the database file. In this case return early. */
#ifndef SQLITE_OMIT_CONCURRENT
-#else
- UNUSED_PARAMETER(bConcurrent);
+ if( bConcurrent ){
+ pWal->hdr.aCksum[0]++;
+ }
- assert( isWalMode2(pWal) );
+ if( walidxGetFile(&pWal->hdr)!=iWal ){
++ assert( bConcurrent && isWalMode2(pWal) );
+ return SQLITE_OK;
+ }
#endif
+ assert( walidxGetFile(&pWal->hdr)==iWal );
- for(iFrame=pWal->hdr.mxFrame+1;
- ALWAYS(rc==SQLITE_OK) && iFrame<=iMax;
- iFrame++
- ){
+ for(iFrame=iNew+1; ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; iFrame++){
/* This call cannot fail. Unless the page for which the page number
** is passed as the second argument is (a) in the cache and
** (b) has an outstanding reference, then xUndo is either a no-op
--- /dev/null
+# 2018 Dec 28
+#
+# 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.
+#
+#***********************************************************************
+#
+# This file contains fault injection tests designed to test the concurrent
+# transactions feature.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix concfault2
+
+ifcapable !concurrent {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA journal_mode = wal2;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ CREATE TABLE t2(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
+ DELETE FROM t1 WHERE rowid%2;
+} {wal2}
+
+do_test 1.1 {
+ list [expr [file size test.db-wal]>75000] [file size test.db-shm]
+} {1 32768}
+
+faultsim_save_and_close
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+ execsql {
++ SELECT * FROM t1;
+ BEGIN CONCURRENT;
+ INSERT INTO t2 VALUES(1, 2);
+ }
+ sqlite3 db2 test.db
+ execsql {
+ PRAGMA journal_size_limit = 10000;
+ INSERT INTO t1 VALUES(randomblob(1000), randomblob(1000));
+ } db2
+ db2 close
+} -body {
+ execsql { COMMIT }
+} -test {
+ faultsim_test_result {0 {}}
+ catchsql { ROLLBACK }
++ set res [catchsql { SELECT count(*) FROM t1 }]
++ if {$res!="0 9"} { error "expected {0 9} got {$res}" }
+ faultsim_integrity_check
+}
++
+finish_test
+