mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Add experimental mode that uses two wal files. Activated using "PRAGMA
journal_mode = wal2". FossilOrigin-Name: e2fc5c814cf6862d536aacb9eca66ecd31ba7e3e3033fa4c5564d533f4a18dfc
This commit is contained in:
41
manifest
41
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Updates\sto\srequirements\smarks.
|
C Add\sexperimental\smode\sthat\suses\stwo\swal\sfiles.\sActivated\susing\s"PRAGMA\njournal_mode\s=\swal2".
|
||||||
D 2017-10-04T18:26:44.610
|
D 2017-10-04T20:57:14.949
|
||||||
F Makefile.in 4bc36d913c2e3e2d326d588d72f618ac9788b2fd4b7efda61102611a6495c3ff
|
F Makefile.in 4bc36d913c2e3e2d326d588d72f618ac9788b2fd4b7efda61102611a6495c3ff
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc 6033b51b6aea702ea059f6ab2d47b1d3cef648695f787247dd4fb395fe60673f
|
F Makefile.msc 6033b51b6aea702ea059f6ab2d47b1d3cef648695f787247dd4fb395fe60673f
|
||||||
@@ -401,7 +401,7 @@ F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73
|
|||||||
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
|
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
|
||||||
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
|
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
|
||||||
F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
|
F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
|
||||||
F src/btree.c cc88a7fca7287dfc004921bb5e2764893dfe4f6dd33be3570126b3fc37932600
|
F src/btree.c c7d94975b015058e6a68278e53d841585552bbc541c1b31b6e024eb9fd888746
|
||||||
F src/btree.h 32ef5d3f25dc70ef1ee9cecf84a023c21378f06a57cd701d2e866e141b150f09
|
F src/btree.h 32ef5d3f25dc70ef1ee9cecf84a023c21378f06a57cd701d2e866e141b150f09
|
||||||
F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc
|
F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc
|
||||||
F src/build.c e71e96a67daf3d1dd23188423e66cd6af38017e2ec73fead5d2b57da2d3c7e16
|
F src/build.c e71e96a67daf3d1dd23188423e66cd6af38017e2ec73fead5d2b57da2d3c7e16
|
||||||
@@ -442,16 +442,16 @@ F src/os.c 93e0979b9b55df29c0c4923f73b48e9d3fe728f01dd8ed4f6a9d2f1d79779bc8
|
|||||||
F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343
|
F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343
|
||||||
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
|
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
|
||||||
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
||||||
F src/os_unix.c 3984fc069df59e26f000e30609611cecdb4e93293e6ee52313a473a7e874af1b
|
F src/os_unix.c 1f9c3e771557edd248e1fcec0818739826b2a3121b609a6e3372b670236d085a
|
||||||
F src/os_win.c 6892c3ff23b7886577e47f13d827ca220c0831bae3ce00eea8c258352692f8c6
|
F src/os_win.c 6892c3ff23b7886577e47f13d827ca220c0831bae3ce00eea8c258352692f8c6
|
||||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||||
F src/pager.c 2aa56a99bb13128d9102e84c7a9f835e546cbb58f0861d481bc3db32973b1628
|
F src/pager.c bc2d2b6784cc2b5103e07aff13b012dab30c7efa0abb9bc2bb949ec45cba4326
|
||||||
F src/pager.h 581698f2177e8bd4008fe4760898ce20b6133d1df22139b9101b5155f900df7a
|
F src/pager.h e11e516208a460bea1b95fe3da697642306e7f350d5f96d2c1d21231ee4d2bf2
|
||||||
F src/parse.y 52ef3cecd0934e9da4a45b585883a03243ad615d338ad94f44501a05891dcdfa
|
F src/parse.y 52ef3cecd0934e9da4a45b585883a03243ad615d338ad94f44501a05891dcdfa
|
||||||
F src/pcache.c 4bada070456980c3c1f16d58ec2e64e389ad77b935e3d77e0c96e7bbd397289c
|
F src/pcache.c 4bada070456980c3c1f16d58ec2e64e389ad77b935e3d77e0c96e7bbd397289c
|
||||||
F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
|
F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
|
||||||
F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
|
F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
|
||||||
F src/pragma.c d04725ac25387d9638919e197fb009f378e13af7bf899516979e54b3164e3602
|
F src/pragma.c 49a04b2ec3199b7967c19b3239182d9c4e860726909ed80b7a3e21fe5bb9e6c4
|
||||||
F src/pragma.h bb83728944b42f6d409c77f5838a8edbdb0fe83046c5496ffc9602b40340a324
|
F src/pragma.h bb83728944b42f6d409c77f5838a8edbdb0fe83046c5496ffc9602b40340a324
|
||||||
F src/prepare.c 9a141a1b02dca53beaa9771699d390aafcac01f5d1f1c0ae6e23ded8dcdb709a
|
F src/prepare.c 9a141a1b02dca53beaa9771699d390aafcac01f5d1f1c0ae6e23ded8dcdb709a
|
||||||
F src/printf.c 40aee47ae9be4bd3dbdc8968bd07fddc027be8edec8daddf24d3391d36698a1c
|
F src/printf.c 40aee47ae9be4bd3dbdc8968bd07fddc027be8edec8daddf24d3391d36698a1c
|
||||||
@@ -526,7 +526,7 @@ F src/update.c 5404be9e840717323a69209190cdbc9d0d34adaedaaf1d1a1069babf2c4171c0
|
|||||||
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
|
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
|
||||||
F src/util.c 5168013cfd937a695d23cce8c67cb07a3dda242d4cb812530ba1148b88e0f159
|
F src/util.c 5168013cfd937a695d23cce8c67cb07a3dda242d4cb812530ba1148b88e0f159
|
||||||
F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739
|
F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739
|
||||||
F src/vdbe.c 176c0897af0aedecd3abc9afaf7fa80eaa7cf5eaf62583de256a9961df474373
|
F src/vdbe.c c3c3fe95d98df8757570fb265236cfdf31536d1025bf37c232237d1e422ae39b
|
||||||
F src/vdbe.h d50cadf12bcf9fb99117ef392ce1ea283aa429270481426b6e8b0280c101fd97
|
F src/vdbe.h d50cadf12bcf9fb99117ef392ce1ea283aa429270481426b6e8b0280c101fd97
|
||||||
F src/vdbeInt.h 1fe00770144c12c4913128f35262d11527ef3284561baaab59b947a41c08d0d9
|
F src/vdbeInt.h 1fe00770144c12c4913128f35262d11527ef3284561baaab59b947a41c08d0d9
|
||||||
F src/vdbeapi.c 9c670ca0dcc1cd86373aa353b747b26fe531ca5cd4331690c611d1f03842e2a1
|
F src/vdbeapi.c 9c670ca0dcc1cd86373aa353b747b26fe531ca5cd4331690c611d1f03842e2a1
|
||||||
@@ -537,8 +537,8 @@ F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2
|
|||||||
F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c
|
F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c
|
||||||
F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a
|
F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a
|
||||||
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||||
F src/wal.c 839db09792fead5052bb35e533fa485e134913d547d05b5f42e537b73e63f07a
|
F src/wal.c 5ca528539a69edd6333dcab1d49e89d4f98efb6a23f0fda85bc52c4ec313db49
|
||||||
F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a
|
F src/wal.h b6063e6be1b03389372f3f32240e99b8ab92c32cdd05aa0e31b30a21e4e41654
|
||||||
F src/walker.c 3ccfa8637f95355bff61144e01a615b8ef26f79c312880848da73f03367da1e6
|
F src/walker.c 3ccfa8637f95355bff61144e01a615b8ef26f79c312880848da73f03367da1e6
|
||||||
F src/where.c 049522adcf5426f1a8c3ed07be15e1ffa3266afd34e8e7bee64b63e2fbfad0b5
|
F src/where.c 049522adcf5426f1a8c3ed07be15e1ffa3266afd34e8e7bee64b63e2fbfad0b5
|
||||||
F src/whereInt.h 82c04c5075308abbac59180c8bad5ecb45b07453981f60a53f3c7dee21e1e971
|
F src/whereInt.h 82c04c5075308abbac59180c8bad5ecb45b07453981f60a53f3c7dee21e1e971
|
||||||
@@ -1097,7 +1097,7 @@ F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854
|
|||||||
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
||||||
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||||
F test/permutations.test d911c9ba49088d22054a05dc73743f677872a92ac89288bcdeafa0ebf3f9c531
|
F test/permutations.test 5fe80f417441ed6a69acd77f5190305dbf255cc2be214f8e36df4715c4f63f08
|
||||||
F test/pragma.test c31b5e98998c160a4c85b1e04f590655c67f2daa7f73854640cd120610e3ac15
|
F test/pragma.test c31b5e98998c160a4c85b1e04f590655c67f2daa7f73854640cd120610e3ac15
|
||||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||||
F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
|
F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
|
||||||
@@ -1142,11 +1142,11 @@ F test/rowvalue9.test d8dd2c6ecac432dadaa79e41dc2434f007be1b6b
|
|||||||
F test/rowvaluefault.test 7cd9ccc6c2fbdd881672984087aad0491bb75504
|
F test/rowvaluefault.test 7cd9ccc6c2fbdd881672984087aad0491bb75504
|
||||||
F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798
|
F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798
|
||||||
F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09
|
F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09
|
||||||
F test/savepoint.test 1f8a6b1aea9a0d05837adc463d4bf47bd9d0f1c842f1c2a9caccd639baf34bf9
|
F test/savepoint.test 69c56b891ce0ff28f1376b5516bf2b6a8b39d0430433216bfc496e72103baaa5
|
||||||
F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
|
F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
|
||||||
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
|
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
|
||||||
F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd
|
F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd
|
||||||
F test/savepoint6.test f41279c5e137139fa5c21485773332c7adb98cd7
|
F test/savepoint6.test 48a645a7bb3a59a6fcf06a7364cfe5b655c336760de39068f7c241b0fc80d963
|
||||||
F test/savepoint7.test cde525ea3075283eb950cdcdefe23ead4f700daa
|
F test/savepoint7.test cde525ea3075283eb950cdcdefe23ead4f700daa
|
||||||
F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2
|
F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2
|
||||||
F test/scanstatus.test 5253c219e331318a437f436268e0e82345700285
|
F test/scanstatus.test 5253c219e331318a437f436268e0e82345700285
|
||||||
@@ -1261,7 +1261,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
|
|||||||
F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e
|
F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e
|
||||||
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
|
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
|
||||||
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
|
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
|
||||||
F test/tester.tcl 9948bd856ce8a1c127f2f7900365387a42a917ce0dc87185bdd128fa5b11aff2
|
F test/tester.tcl 71d30287dd22aae0eb9b07e62574336ae6a57e7a50e5dab320a604cfcca4b173
|
||||||
F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
|
F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
|
||||||
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
|
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
|
||||||
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
||||||
@@ -1520,6 +1520,7 @@ F test/walro.test 4ab7ac01b77c2f894235c699d59e3e3c7f15a160
|
|||||||
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
|
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
|
||||||
F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
|
F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
|
||||||
F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e
|
F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e
|
||||||
|
F test/waltwo2.test 6e4d36500a20ff2d19761cf0e9a5d178e83d1798feda157ebc0681e01a35e56e
|
||||||
F test/where.test f0c325563acde44f2c4ea6ba348e9e29f7121757
|
F test/where.test f0c325563acde44f2c4ea6ba348e9e29f7121757
|
||||||
F test/where2.test 478d2170637b9211f593120648858593bf2445a1
|
F test/where2.test 478d2170637b9211f593120648858593bf2445a1
|
||||||
F test/where3.test 54cdeb02157acc979de41530b804ae7b09552bf1
|
F test/where3.test 54cdeb02157acc979de41530b804ae7b09552bf1
|
||||||
@@ -1655,7 +1656,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 7c69f8f1089c3e3843fbf7ec37a897c849a3df822a4ce3b4fcde586adf991a3f
|
P 40964a4ef7565ea0ddf452f48cb22373d068528e07d40eefc008f2231c969422
|
||||||
R 61b14913c42f4f709d3e3a3845316f97
|
R 07b0a272ae21af8e4cb674b6ac44fa89
|
||||||
U drh
|
T *branch * wal2
|
||||||
Z 37903880ad327c432f24949839963d82
|
T *sym-wal2 *
|
||||||
|
T +closed f04ded1d9b40d54463162264e37e6d92411d09427eea592ef05681035e2f2e64
|
||||||
|
T -sym-trunk *
|
||||||
|
U dan
|
||||||
|
Z 07422baaaff21d5f15df6853d7e92b06
|
||||||
|
@@ -1 +1 @@
|
|||||||
40964a4ef7565ea0ddf452f48cb22373d068528e07d40eefc008f2231c969422
|
e2fc5c814cf6862d536aacb9eca66ecd31ba7e3e3033fa4c5564d533f4a18dfc
|
10
src/btree.c
10
src/btree.c
@@ -2993,10 +2993,10 @@ static int lockBtree(BtShared *pBt){
|
|||||||
goto page1_init_failed;
|
goto page1_init_failed;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if( page1[18]>2 ){
|
if( page1[18]>3 ){
|
||||||
pBt->btsFlags |= BTS_READ_ONLY;
|
pBt->btsFlags |= BTS_READ_ONLY;
|
||||||
}
|
}
|
||||||
if( page1[19]>2 ){
|
if( page1[19]>3 ){
|
||||||
goto page1_init_failed;
|
goto page1_init_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3008,9 +3008,9 @@ static int lockBtree(BtShared *pBt){
|
|||||||
** may not be the latest version - there may be a newer one in the log
|
** may not be the latest version - there may be a newer one in the log
|
||||||
** file.
|
** file.
|
||||||
*/
|
*/
|
||||||
if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){
|
if( page1[19]>=2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){
|
||||||
int isOpen = 0;
|
int isOpen = 0;
|
||||||
rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
|
rc = sqlite3PagerOpenWal(pBt->pPager, (page1[19]==3), &isOpen);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
goto page1_init_failed;
|
goto page1_init_failed;
|
||||||
}else{
|
}else{
|
||||||
@@ -9866,7 +9866,7 @@ int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){
|
|||||||
BtShared *pBt = pBtree->pBt;
|
BtShared *pBt = pBtree->pBt;
|
||||||
int rc; /* Return code */
|
int rc; /* Return code */
|
||||||
|
|
||||||
assert( iVersion==1 || iVersion==2 );
|
assert( iVersion==1 || iVersion==2 || iVersion==3 );
|
||||||
|
|
||||||
/* If setting the version fields to 1, do not automatically open the
|
/* If setting the version fields to 1, do not automatically open the
|
||||||
** WAL connection, even if the version fields are currently set to 2.
|
** WAL connection, even if the version fields are currently set to 2.
|
||||||
|
@@ -4163,7 +4163,7 @@ static int unixShmSystemLock(
|
|||||||
assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
|
assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
|
||||||
|
|
||||||
/* Shared locks never span more than one byte */
|
/* Shared locks never span more than one byte */
|
||||||
assert( n==1 || lockType!=F_RDLCK );
|
/* assert( n==1 || lockType!=F_RDLCK ); */
|
||||||
|
|
||||||
/* Locks are within range */
|
/* Locks are within range */
|
||||||
assert( n>=1 && n<=SQLITE_SHM_NLOCK );
|
assert( n>=1 && n<=SQLITE_SHM_NLOCK );
|
||||||
@@ -4609,7 +4609,7 @@ static int unixShmLock(
|
|||||||
|| flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
|
|| flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
|
||||||
|| flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
|
|| flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
|
||||||
|| flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
|
|| flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
|
||||||
assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );
|
/* assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 ); */
|
||||||
assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );
|
assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );
|
||||||
assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );
|
assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );
|
||||||
|
|
||||||
|
47
src/pager.c
47
src/pager.c
@@ -810,20 +810,6 @@ static const unsigned char aJournalMagic[] = {
|
|||||||
*/
|
*/
|
||||||
#define PAGER_MAX_PGNO 2147483647
|
#define PAGER_MAX_PGNO 2147483647
|
||||||
|
|
||||||
/*
|
|
||||||
** The argument to this macro is a file descriptor (type sqlite3_file*).
|
|
||||||
** Return 0 if it is not open, or non-zero (but not 1) if it is.
|
|
||||||
**
|
|
||||||
** This is so that expressions can be written as:
|
|
||||||
**
|
|
||||||
** if( isOpen(pPager->jfd) ){ ...
|
|
||||||
**
|
|
||||||
** instead of
|
|
||||||
**
|
|
||||||
** if( pPager->jfd->pMethods ){ ...
|
|
||||||
*/
|
|
||||||
#define isOpen(pFd) ((pFd)->pMethods!=0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return true if this pager uses a write-ahead log to read page pgno.
|
** Return true if this pager uses a write-ahead log to read page pgno.
|
||||||
** Return false if the pager reads pgno directly from the database.
|
** Return false if the pager reads pgno directly from the database.
|
||||||
@@ -944,6 +930,7 @@ static int assert_pager_state(Pager *p){
|
|||||||
assert( isOpen(p->jfd)
|
assert( isOpen(p->jfd)
|
||||||
|| p->journalMode==PAGER_JOURNALMODE_OFF
|
|| p->journalMode==PAGER_JOURNALMODE_OFF
|
||||||
|| p->journalMode==PAGER_JOURNALMODE_WAL
|
|| p->journalMode==PAGER_JOURNALMODE_WAL
|
||||||
|
|| p->journalMode==PAGER_JOURNALMODE_WAL2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
assert( pPager->dbOrigSize==pPager->dbFileSize );
|
assert( pPager->dbOrigSize==pPager->dbFileSize );
|
||||||
@@ -958,6 +945,7 @@ static int assert_pager_state(Pager *p){
|
|||||||
assert( isOpen(p->jfd)
|
assert( isOpen(p->jfd)
|
||||||
|| p->journalMode==PAGER_JOURNALMODE_OFF
|
|| p->journalMode==PAGER_JOURNALMODE_OFF
|
||||||
|| p->journalMode==PAGER_JOURNALMODE_WAL
|
|| p->journalMode==PAGER_JOURNALMODE_WAL
|
||||||
|
|| p->journalMode==PAGER_JOURNALMODE_WAL2
|
||||||
|| (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)
|
|| (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)
|
||||||
);
|
);
|
||||||
assert( pPager->dbOrigSize<=pPager->dbHintSize );
|
assert( pPager->dbOrigSize<=pPager->dbHintSize );
|
||||||
@@ -970,6 +958,7 @@ static int assert_pager_state(Pager *p){
|
|||||||
assert( isOpen(p->jfd)
|
assert( isOpen(p->jfd)
|
||||||
|| p->journalMode==PAGER_JOURNALMODE_OFF
|
|| p->journalMode==PAGER_JOURNALMODE_OFF
|
||||||
|| p->journalMode==PAGER_JOURNALMODE_WAL
|
|| p->journalMode==PAGER_JOURNALMODE_WAL
|
||||||
|
|| p->journalMode==PAGER_JOURNALMODE_WAL2
|
||||||
|| (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)
|
|| (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@@ -2063,7 +2052,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){
|
|||||||
}
|
}
|
||||||
pPager->journalOff = 0;
|
pPager->journalOff = 0;
|
||||||
}else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
|
}else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
|
||||||
|| (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)
|
|| (pPager->exclusiveMode && pPager->journalMode<PAGER_JOURNALMODE_WAL)
|
||||||
){
|
){
|
||||||
rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile);
|
rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile);
|
||||||
pPager->journalOff = 0;
|
pPager->journalOff = 0;
|
||||||
@@ -2077,7 +2066,8 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){
|
|||||||
assert( sqlite3JournalIsInMemory(pPager->jfd)==0 );
|
assert( sqlite3JournalIsInMemory(pPager->jfd)==0 );
|
||||||
assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE
|
assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE
|
||||||
|| pPager->journalMode==PAGER_JOURNALMODE_MEMORY
|
|| pPager->journalMode==PAGER_JOURNALMODE_MEMORY
|
||||||
|| pPager->journalMode==PAGER_JOURNALMODE_WAL
|
|| pPager->journalMode==PAGER_JOURNALMODE_WAL
|
||||||
|
|| pPager->journalMode==PAGER_JOURNALMODE_WAL2
|
||||||
);
|
);
|
||||||
sqlite3OsClose(pPager->jfd);
|
sqlite3OsClose(pPager->jfd);
|
||||||
if( bDelete ){
|
if( bDelete ){
|
||||||
@@ -3344,9 +3334,9 @@ static int pagerOpenWalIfPresent(Pager *pPager){
|
|||||||
rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
|
rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
|
||||||
}else{
|
}else{
|
||||||
testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
|
testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
|
||||||
rc = sqlite3PagerOpenWal(pPager, 0);
|
rc = sqlite3PagerOpenWal(pPager, 0, 0);
|
||||||
}
|
}
|
||||||
}else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
|
}else if( pPager->journalMode>=PAGER_JOURNALMODE_WAL ){
|
||||||
pPager->journalMode = PAGER_JOURNALMODE_DELETE;
|
pPager->journalMode = PAGER_JOURNALMODE_DELETE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7245,6 +7235,7 @@ int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
|
|||||||
|| eMode==PAGER_JOURNALMODE_PERSIST
|
|| eMode==PAGER_JOURNALMODE_PERSIST
|
||||||
|| eMode==PAGER_JOURNALMODE_OFF
|
|| eMode==PAGER_JOURNALMODE_OFF
|
||||||
|| eMode==PAGER_JOURNALMODE_WAL
|
|| eMode==PAGER_JOURNALMODE_WAL
|
||||||
|
|| eMode==PAGER_JOURNALMODE_WAL2
|
||||||
|| eMode==PAGER_JOURNALMODE_MEMORY );
|
|| eMode==PAGER_JOURNALMODE_MEMORY );
|
||||||
|
|
||||||
/* This routine is only called from the OP_JournalMode opcode, and
|
/* This routine is only called from the OP_JournalMode opcode, and
|
||||||
@@ -7279,9 +7270,12 @@ int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
|
|||||||
assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );
|
assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );
|
||||||
assert( (PAGER_JOURNALMODE_OFF & 5)==0 );
|
assert( (PAGER_JOURNALMODE_OFF & 5)==0 );
|
||||||
assert( (PAGER_JOURNALMODE_WAL & 5)==5 );
|
assert( (PAGER_JOURNALMODE_WAL & 5)==5 );
|
||||||
|
assert( (PAGER_JOURNALMODE_WAL2 & 5)==4 );
|
||||||
|
|
||||||
assert( isOpen(pPager->fd) || pPager->exclusiveMode );
|
assert( isOpen(pPager->fd) || pPager->exclusiveMode );
|
||||||
if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){
|
if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0
|
||||||
|
&& eMode!=PAGER_JOURNALMODE_WAL2 /* TODO: fix this if possible */
|
||||||
|
){
|
||||||
|
|
||||||
/* In this case we would like to delete the journal file. If it is
|
/* In this case we would like to delete the journal file. If it is
|
||||||
** not possible, then that is not a problem. Deleting the journal file
|
** not possible, then that is not a problem. Deleting the journal file
|
||||||
@@ -7443,7 +7437,7 @@ static int pagerExclusiveLock(Pager *pPager){
|
|||||||
** lock on the database file and use heap-memory to store the wal-index
|
** lock on the database file and use heap-memory to store the wal-index
|
||||||
** in. Otherwise, use the normal shared-memory.
|
** in. Otherwise, use the normal shared-memory.
|
||||||
*/
|
*/
|
||||||
static int pagerOpenWal(Pager *pPager){
|
static int pagerOpenWal(Pager *pPager, int bWal2){
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
|
||||||
assert( pPager->pWal==0 && pPager->tempFile==0 );
|
assert( pPager->pWal==0 && pPager->tempFile==0 );
|
||||||
@@ -7464,7 +7458,7 @@ static int pagerOpenWal(Pager *pPager){
|
|||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
rc = sqlite3WalOpen(pPager->pVfs,
|
rc = sqlite3WalOpen(pPager->pVfs,
|
||||||
pPager->fd, pPager->zWal, pPager->exclusiveMode,
|
pPager->fd, pPager->zWal, pPager->exclusiveMode,
|
||||||
pPager->journalSizeLimit, &pPager->pWal
|
pPager->journalSizeLimit, bWal2, &pPager->pWal
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pagerFixMaplimit(pPager);
|
pagerFixMaplimit(pPager);
|
||||||
@@ -7490,6 +7484,7 @@ static int pagerOpenWal(Pager *pPager){
|
|||||||
*/
|
*/
|
||||||
int sqlite3PagerOpenWal(
|
int sqlite3PagerOpenWal(
|
||||||
Pager *pPager, /* Pager object */
|
Pager *pPager, /* Pager object */
|
||||||
|
int bWal2, /* Open in wal2 mode if not already open */
|
||||||
int *pbOpen /* OUT: Set to true if call is a no-op */
|
int *pbOpen /* OUT: Set to true if call is a no-op */
|
||||||
){
|
){
|
||||||
int rc = SQLITE_OK; /* Return code */
|
int rc = SQLITE_OK; /* Return code */
|
||||||
@@ -7506,9 +7501,9 @@ int sqlite3PagerOpenWal(
|
|||||||
/* Close any rollback journal previously open */
|
/* Close any rollback journal previously open */
|
||||||
sqlite3OsClose(pPager->jfd);
|
sqlite3OsClose(pPager->jfd);
|
||||||
|
|
||||||
rc = pagerOpenWal(pPager);
|
rc = pagerOpenWal(pPager, bWal2);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
pPager->journalMode = PAGER_JOURNALMODE_WAL;
|
pPager->journalMode = bWal2?PAGER_JOURNALMODE_WAL2:PAGER_JOURNALMODE_WAL;
|
||||||
pPager->eState = PAGER_OPEN;
|
pPager->eState = PAGER_OPEN;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -7530,7 +7525,9 @@ int sqlite3PagerOpenWal(
|
|||||||
int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){
|
int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
|
||||||
assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );
|
assert( pPager->journalMode==PAGER_JOURNALMODE_WAL
|
||||||
|
|| pPager->journalMode==PAGER_JOURNALMODE_WAL2
|
||||||
|
);
|
||||||
|
|
||||||
/* If the log file is not already open, but does exist in the file-system,
|
/* If the log file is not already open, but does exist in the file-system,
|
||||||
** it may need to be checkpointed before the connection can switch to
|
** it may need to be checkpointed before the connection can switch to
|
||||||
@@ -7545,7 +7542,7 @@ int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if( rc==SQLITE_OK && logexists ){
|
if( rc==SQLITE_OK && logexists ){
|
||||||
rc = pagerOpenWal(pPager);
|
rc = pagerOpenWal(pPager, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
src/pager.h
19
src/pager.h
@@ -81,6 +81,23 @@ typedef struct PgHdr DbPage;
|
|||||||
#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
|
#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
|
||||||
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
|
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
|
||||||
#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
|
#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
|
||||||
|
#define PAGER_JOURNALMODE_WAL2 6 /* Use write-ahead logging mode 2 */
|
||||||
|
|
||||||
|
#define isWalMode(x) ((x)==PAGER_JOURNALMODE_WAL || (x)==PAGER_JOURNALMODE_WAL2)
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The argument to this macro is a file descriptor (type sqlite3_file*).
|
||||||
|
** Return 0 if it is not open, or non-zero (but not 1) if it is.
|
||||||
|
**
|
||||||
|
** This is so that expressions can be written as:
|
||||||
|
**
|
||||||
|
** if( isOpen(pPager->jfd) ){ ...
|
||||||
|
**
|
||||||
|
** instead of
|
||||||
|
**
|
||||||
|
** if( pPager->jfd->pMethods ){ ...
|
||||||
|
*/
|
||||||
|
#define isOpen(pFd) ((pFd)->pMethods!=0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Flags that make up the mask passed to sqlite3PagerGet().
|
** Flags that make up the mask passed to sqlite3PagerGet().
|
||||||
@@ -177,7 +194,7 @@ int sqlite3PagerSharedLock(Pager *pPager);
|
|||||||
int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);
|
int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);
|
||||||
int sqlite3PagerWalSupported(Pager *pPager);
|
int sqlite3PagerWalSupported(Pager *pPager);
|
||||||
int sqlite3PagerWalCallback(Pager *pPager);
|
int sqlite3PagerWalCallback(Pager *pPager);
|
||||||
int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
|
int sqlite3PagerOpenWal(Pager *pPager, int, int *pisOpen);
|
||||||
int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);
|
int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);
|
||||||
# ifdef SQLITE_DIRECT_OVERFLOW_READ
|
# ifdef SQLITE_DIRECT_OVERFLOW_READ
|
||||||
int sqlite3PagerUseWal(Pager *pPager, Pgno);
|
int sqlite3PagerUseWal(Pager *pPager, Pgno);
|
||||||
|
@@ -260,7 +260,7 @@ const char *sqlite3JournalModename(int eMode){
|
|||||||
static char * const azModeName[] = {
|
static char * const azModeName[] = {
|
||||||
"delete", "persist", "off", "truncate", "memory"
|
"delete", "persist", "off", "truncate", "memory"
|
||||||
#ifndef SQLITE_OMIT_WAL
|
#ifndef SQLITE_OMIT_WAL
|
||||||
, "wal"
|
, "wal", "wal2"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
assert( PAGER_JOURNALMODE_DELETE==0 );
|
assert( PAGER_JOURNALMODE_DELETE==0 );
|
||||||
@@ -269,6 +269,7 @@ const char *sqlite3JournalModename(int eMode){
|
|||||||
assert( PAGER_JOURNALMODE_TRUNCATE==3 );
|
assert( PAGER_JOURNALMODE_TRUNCATE==3 );
|
||||||
assert( PAGER_JOURNALMODE_MEMORY==4 );
|
assert( PAGER_JOURNALMODE_MEMORY==4 );
|
||||||
assert( PAGER_JOURNALMODE_WAL==5 );
|
assert( PAGER_JOURNALMODE_WAL==5 );
|
||||||
|
assert( PAGER_JOURNALMODE_WAL2==6 );
|
||||||
assert( eMode>=0 && eMode<=ArraySize(azModeName) );
|
assert( eMode>=0 && eMode<=ArraySize(azModeName) );
|
||||||
|
|
||||||
if( eMode==ArraySize(azModeName) ) return 0;
|
if( eMode==ArraySize(azModeName) ) return 0;
|
||||||
|
62
src/vdbe.c
62
src/vdbe.c
@@ -6325,6 +6325,7 @@ case OP_JournalMode: { /* out2 */
|
|||||||
|| eNew==PAGER_JOURNALMODE_OFF
|
|| eNew==PAGER_JOURNALMODE_OFF
|
||||||
|| eNew==PAGER_JOURNALMODE_MEMORY
|
|| eNew==PAGER_JOURNALMODE_MEMORY
|
||||||
|| eNew==PAGER_JOURNALMODE_WAL
|
|| eNew==PAGER_JOURNALMODE_WAL
|
||||||
|
|| eNew==PAGER_JOURNALMODE_WAL2
|
||||||
|| eNew==PAGER_JOURNALMODE_QUERY
|
|| eNew==PAGER_JOURNALMODE_QUERY
|
||||||
);
|
);
|
||||||
assert( pOp->p1>=0 && pOp->p1<db->nDb );
|
assert( pOp->p1>=0 && pOp->p1<db->nDb );
|
||||||
@@ -6342,16 +6343,25 @@ case OP_JournalMode: { /* out2 */
|
|||||||
/* Do not allow a transition to journal_mode=WAL for a database
|
/* Do not allow a transition to journal_mode=WAL for a database
|
||||||
** in temporary storage or if the VFS does not support shared memory
|
** in temporary storage or if the VFS does not support shared memory
|
||||||
*/
|
*/
|
||||||
if( eNew==PAGER_JOURNALMODE_WAL
|
if( isWalMode(eNew)
|
||||||
&& (sqlite3Strlen30(zFilename)==0 /* Temp file */
|
&& (sqlite3Strlen30(zFilename)==0 /* Temp file */
|
||||||
|| !sqlite3PagerWalSupported(pPager)) /* No shared-memory support */
|
|| !sqlite3PagerWalSupported(pPager)) /* No shared-memory support */
|
||||||
){
|
){
|
||||||
eNew = eOld;
|
eNew = eOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (eNew!=eOld)
|
if( eNew!=eOld && (isWalMode(eNew) || isWalMode(eOld)) ){
|
||||||
&& (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)
|
|
||||||
){
|
/* Prevent changing directly to wal2 from wal mode. And vice versa. */
|
||||||
|
if( isWalMode(eNew) && isWalMode(eOld) ){
|
||||||
|
rc = SQLITE_ERROR;
|
||||||
|
sqlite3VdbeError(p, "cannot change from %s to %s mode",
|
||||||
|
sqlite3JournalModename(eOld), sqlite3JournalModename(eNew)
|
||||||
|
);
|
||||||
|
goto abort_due_to_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prevent switching into or out of wal/wal2 mode mid-transaction */
|
||||||
if( !db->autoCommit || db->nVdbeRead>1 ){
|
if( !db->autoCommit || db->nVdbeRead>1 ){
|
||||||
rc = SQLITE_ERROR;
|
rc = SQLITE_ERROR;
|
||||||
sqlite3VdbeError(p,
|
sqlite3VdbeError(p,
|
||||||
@@ -6359,31 +6369,33 @@ case OP_JournalMode: { /* out2 */
|
|||||||
(eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
|
(eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
|
||||||
);
|
);
|
||||||
goto abort_due_to_error;
|
goto abort_due_to_error;
|
||||||
}else{
|
}
|
||||||
|
|
||||||
if( eOld==PAGER_JOURNALMODE_WAL ){
|
if( isWalMode(eOld) ){
|
||||||
/* If leaving WAL mode, close the log file. If successful, the call
|
/* If leaving WAL mode, close the log file. If successful, the call
|
||||||
** to PagerCloseWal() checkpoints and deletes the write-ahead-log
|
** to PagerCloseWal() checkpoints and deletes the write-ahead-log
|
||||||
** file. An EXCLUSIVE lock may still be held on the database file
|
** file. An EXCLUSIVE lock may still be held on the database file
|
||||||
** after a successful return.
|
** after a successful return.
|
||||||
*/
|
|
||||||
rc = sqlite3PagerCloseWal(pPager, db);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
sqlite3PagerSetJournalMode(pPager, eNew);
|
|
||||||
}
|
|
||||||
}else if( eOld==PAGER_JOURNALMODE_MEMORY ){
|
|
||||||
/* Cannot transition directly from MEMORY to WAL. Use mode OFF
|
|
||||||
** as an intermediate */
|
|
||||||
sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open a transaction on the database file. Regardless of the journal
|
|
||||||
** mode, this transaction always uses a rollback journal.
|
|
||||||
*/
|
*/
|
||||||
assert( sqlite3BtreeIsInTrans(pBt)==0 );
|
rc = sqlite3PagerCloseWal(pPager, db);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));
|
sqlite3PagerSetJournalMode(pPager, eNew);
|
||||||
}
|
}
|
||||||
|
}else if( eOld==PAGER_JOURNALMODE_MEMORY ){
|
||||||
|
/* Cannot transition directly from MEMORY to WAL. Use mode OFF
|
||||||
|
** as an intermediate */
|
||||||
|
sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open a transaction on the database file. Regardless of the journal
|
||||||
|
** mode, this transaction always uses a rollback journal.
|
||||||
|
*/
|
||||||
|
assert( sqlite3BtreeIsInTrans(pBt)==0 );
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
/* 1==rollback, 2==wal, 3==wal2 */
|
||||||
|
rc = sqlite3BtreeSetVersion(pBt,
|
||||||
|
1 + isWalMode(eNew) + (eNew==PAGER_JOURNALMODE_WAL2)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ifndef SQLITE_OMIT_WAL */
|
#endif /* ifndef SQLITE_OMIT_WAL */
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#define CKPT_SYNC_FLAGS(X) (((X)>>2)&0x03)
|
#define CKPT_SYNC_FLAGS(X) (((X)>>2)&0x03)
|
||||||
|
|
||||||
#ifdef SQLITE_OMIT_WAL
|
#ifdef SQLITE_OMIT_WAL
|
||||||
# define sqlite3WalOpen(x,y,z) 0
|
# define sqlite3WalOpen(w,x,y,z) 0
|
||||||
# define sqlite3WalLimit(x,y)
|
# define sqlite3WalLimit(x,y)
|
||||||
# define sqlite3WalClose(v,w,x,y,z) 0
|
# define sqlite3WalClose(v,w,x,y,z) 0
|
||||||
# define sqlite3WalBeginReadTransaction(y,z) 0
|
# define sqlite3WalBeginReadTransaction(y,z) 0
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
typedef struct Wal Wal;
|
typedef struct Wal Wal;
|
||||||
|
|
||||||
/* Open and close a connection to a write-ahead log. */
|
/* Open and close a connection to a write-ahead log. */
|
||||||
int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);
|
int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *,int,i64,int,Wal**);
|
||||||
int sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);
|
int sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);
|
||||||
|
|
||||||
/* Set the limiting size of a WAL file. */
|
/* Set the limiting size of a WAL file. */
|
||||||
|
@@ -1019,6 +1019,23 @@ test_suite "wal" -description {
|
|||||||
fts3c.test fts3d.test fts3e.test fts3query.test
|
fts3c.test fts3d.test fts3e.test fts3query.test
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_suite "wal2" -description {
|
||||||
|
Run tests with journal_mode=WAL2
|
||||||
|
} -initialize {
|
||||||
|
set ::G(savepoint6_iterations) 100
|
||||||
|
} -shutdown {
|
||||||
|
unset -nocomplain ::G(savepoint6_iterations)
|
||||||
|
} -files {
|
||||||
|
savepoint.test savepoint2.test savepoint6.test
|
||||||
|
trans.test avtrans.test
|
||||||
|
|
||||||
|
fts3aa.test fts3ab.test fts3ac.test fts3ad.test
|
||||||
|
fts3ae.test fts3af.test fts3ag.test fts3ah.test
|
||||||
|
fts3ai.test fts3aj.test fts3ak.test fts3al.test
|
||||||
|
fts3am.test fts3an.test fts3ao.test fts3b.test
|
||||||
|
fts3c.test fts3d.test fts3e.test fts3query.test
|
||||||
|
}
|
||||||
|
|
||||||
test_suite "rtree" -description {
|
test_suite "rtree" -description {
|
||||||
All R-tree related tests. Provides coverage of source file rtree.c.
|
All R-tree related tests. Provides coverage of source file rtree.c.
|
||||||
} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
|
} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
|
||||||
|
@@ -28,6 +28,7 @@ do_test savepoint-1.1 {
|
|||||||
RELEASE sp1;
|
RELEASE sp1;
|
||||||
}
|
}
|
||||||
} {}
|
} {}
|
||||||
|
wal_check_journal_mode savepoint-1.1
|
||||||
do_test savepoint-1.2 {
|
do_test savepoint-1.2 {
|
||||||
execsql {
|
execsql {
|
||||||
SAVEPOINT sp1;
|
SAVEPOINT sp1;
|
||||||
|
@@ -15,6 +15,10 @@ set testdir [file dirname $argv0]
|
|||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
proc sql {zSql} {
|
proc sql {zSql} {
|
||||||
|
if {0 && $::debug_op} {
|
||||||
|
puts stderr "$zSql ;"
|
||||||
|
flush stderr
|
||||||
|
}
|
||||||
uplevel db eval [list $zSql]
|
uplevel db eval [list $zSql]
|
||||||
#puts stderr "$zSql ;"
|
#puts stderr "$zSql ;"
|
||||||
}
|
}
|
||||||
@@ -67,11 +71,13 @@ proc x_to_y {x} {
|
|||||||
# delete_rows XVALUES
|
# delete_rows XVALUES
|
||||||
#
|
#
|
||||||
proc savepoint {zName} {
|
proc savepoint {zName} {
|
||||||
|
if {$::debug_op} { puts stderr "savepoint $zName" ; flush stderr }
|
||||||
catch { sql "SAVEPOINT $zName" }
|
catch { sql "SAVEPOINT $zName" }
|
||||||
lappend ::lSavepoint [list $zName [array get ::aEntry]]
|
lappend ::lSavepoint [list $zName [array get ::aEntry]]
|
||||||
}
|
}
|
||||||
|
|
||||||
proc rollback {zName} {
|
proc rollback {zName} {
|
||||||
|
if {$::debug_op} { puts stderr "rollback $zName" ; flush stderr }
|
||||||
catch { sql "ROLLBACK TO $zName" }
|
catch { sql "ROLLBACK TO $zName" }
|
||||||
for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {
|
for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {
|
||||||
set zSavepoint [lindex $::lSavepoint $i 0]
|
set zSavepoint [lindex $::lSavepoint $i 0]
|
||||||
@@ -89,6 +95,7 @@ proc rollback {zName} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc release {zName} {
|
proc release {zName} {
|
||||||
|
if {$::debug_op} { puts stderr "release $zName" ; flush stderr }
|
||||||
catch { sql "RELEASE $zName" }
|
catch { sql "RELEASE $zName" }
|
||||||
for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {
|
for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {
|
||||||
set zSavepoint [lindex $::lSavepoint $i 0]
|
set zSavepoint [lindex $::lSavepoint $i 0]
|
||||||
@@ -104,6 +111,7 @@ proc release {zName} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc insert_rows {lX} {
|
proc insert_rows {lX} {
|
||||||
|
if {$::debug_op} { puts stderr "insert_rows $lX" ; flush stderr }
|
||||||
foreach x $lX {
|
foreach x $lX {
|
||||||
set y [x_to_y $x]
|
set y [x_to_y $x]
|
||||||
|
|
||||||
@@ -116,6 +124,7 @@ proc insert_rows {lX} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc delete_rows {lX} {
|
proc delete_rows {lX} {
|
||||||
|
if {$::debug_op} { puts stderr "delete_rows $lX" ; flush stderr }
|
||||||
foreach x $lX {
|
foreach x $lX {
|
||||||
# Update database [db]
|
# Update database [db]
|
||||||
sql "DELETE FROM t1 WHERE x = $x"
|
sql "DELETE FROM t1 WHERE x = $x"
|
||||||
@@ -164,6 +173,11 @@ proc random_integers {nRes nRange} {
|
|||||||
}
|
}
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set ::debug_op 0
|
||||||
|
proc debug_ops {} {
|
||||||
|
set ::debug_op 1
|
||||||
|
}
|
||||||
|
|
||||||
proc database_op {} {
|
proc database_op {} {
|
||||||
set i [expr int(rand()*2)]
|
set i [expr int(rand()*2)]
|
||||||
if {$i==0} {
|
if {$i==0} {
|
||||||
@@ -185,9 +199,6 @@ proc savepoint_op {} {
|
|||||||
set C [lindex $cmds [expr int(rand()*6)]]
|
set C [lindex $cmds [expr int(rand()*6)]]
|
||||||
set N [lindex $names [expr int(rand()*5)]]
|
set N [lindex $names [expr int(rand()*5)]]
|
||||||
|
|
||||||
#puts stderr " $C $N ; "
|
|
||||||
#flush stderr
|
|
||||||
|
|
||||||
$C $N
|
$C $N
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
@@ -586,6 +586,7 @@ proc reset_db {} {
|
|||||||
forcedelete test.db
|
forcedelete test.db
|
||||||
forcedelete test.db-journal
|
forcedelete test.db-journal
|
||||||
forcedelete test.db-wal
|
forcedelete test.db-wal
|
||||||
|
forcedelete test.db-wal2
|
||||||
sqlite3 db ./test.db
|
sqlite3 db ./test.db
|
||||||
set ::DB [sqlite3_connection_pointer db]
|
set ::DB [sqlite3_connection_pointer db]
|
||||||
if {[info exists ::SETUP_SQL]} {
|
if {[info exists ::SETUP_SQL]} {
|
||||||
@@ -2053,17 +2054,32 @@ proc drop_all_indexes {{db db}} {
|
|||||||
# Returns true if this test should be run in WAL mode. False otherwise.
|
# Returns true if this test should be run in WAL mode. False otherwise.
|
||||||
#
|
#
|
||||||
proc wal_is_wal_mode {} {
|
proc wal_is_wal_mode {} {
|
||||||
expr {[permutation] eq "wal"}
|
if {[permutation] eq "wal"} { return 1 }
|
||||||
|
if {[permutation] eq "wal2"} { return 2 }
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
proc wal_set_journal_mode {{db db}} {
|
proc wal_set_journal_mode {{db db}} {
|
||||||
if { [wal_is_wal_mode] } {
|
switch -- [wal_is_wal_mode] {
|
||||||
$db eval "PRAGMA journal_mode = WAL"
|
0 {
|
||||||
|
}
|
||||||
|
|
||||||
|
1 {
|
||||||
|
$db eval "PRAGMA journal_mode = WAL"
|
||||||
|
}
|
||||||
|
|
||||||
|
2 {
|
||||||
|
$db eval "PRAGMA journal_mode = WAL2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proc wal_check_journal_mode {testname {db db}} {
|
proc wal_check_journal_mode {testname {db db}} {
|
||||||
if { [wal_is_wal_mode] } {
|
if { [wal_is_wal_mode] } {
|
||||||
$db eval { SELECT * FROM sqlite_master }
|
$db eval { SELECT * FROM sqlite_master }
|
||||||
do_test $testname [list $db eval "PRAGMA main.journal_mode"] {wal}
|
set expected "wal"
|
||||||
|
if {[wal_is_wal_mode]==2} {
|
||||||
|
set expected "wal2"
|
||||||
|
}
|
||||||
|
do_test $testname [list $db eval "PRAGMA main.journal_mode"] $expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
127
test/waltwo2.test
Normal file
127
test/waltwo2.test
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
# 2017 September 19
|
||||||
|
#
|
||||||
|
# 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 implements regression tests for SQLite library. The
|
||||||
|
# focus of this file is testing the operation of the library in
|
||||||
|
# "PRAGMA journal_mode=WAL2" mode.
|
||||||
|
#
|
||||||
|
|
||||||
|
set testdir [file dirname $argv0]
|
||||||
|
source $testdir/tester.tcl
|
||||||
|
source $testdir/lock_common.tcl
|
||||||
|
source $testdir/malloc_common.tcl
|
||||||
|
source $testdir/wal_common.tcl
|
||||||
|
|
||||||
|
set testprefix walsimple
|
||||||
|
ifcapable !wal {finish_test ; return }
|
||||||
|
|
||||||
|
db close
|
||||||
|
foreach f [glob -nocomplain test.db*] { forcedelete $f }
|
||||||
|
sqlite3 db test.db
|
||||||
|
|
||||||
|
do_execsql_test 1.0 {
|
||||||
|
CREATE TABLE t1(x, y);
|
||||||
|
PRAGMA journal_mode = wal2;
|
||||||
|
} {wal2}
|
||||||
|
|
||||||
|
do_execsql_test 1.1 {
|
||||||
|
SELECT * FROM t1;
|
||||||
|
} {}
|
||||||
|
|
||||||
|
do_execsql_test 1.2 {
|
||||||
|
INSERT INTO t1 VALUES(1, 2);
|
||||||
|
} {}
|
||||||
|
|
||||||
|
do_execsql_test 1.3 {
|
||||||
|
SELECT * FROM t1;
|
||||||
|
} {1 2}
|
||||||
|
|
||||||
|
do_test 1.4 {
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
execsql { SELECT * FROM t1 } db2
|
||||||
|
} {1 2}
|
||||||
|
|
||||||
|
do_test 1.5 {
|
||||||
|
lsort [glob test.db*]
|
||||||
|
} {test.db test.db-shm test.db-wal test.db-wal2}
|
||||||
|
|
||||||
|
do_test 1.6 {
|
||||||
|
db close
|
||||||
|
db2 close
|
||||||
|
sqlite3 db test.db
|
||||||
|
execsql { SELECT * FROM t1 }
|
||||||
|
} {1 2}
|
||||||
|
|
||||||
|
do_execsql_test 1.7 {
|
||||||
|
PRAGMA journal_size_limit = 4000;
|
||||||
|
INSERT INTO t1 VALUES(3, 4);
|
||||||
|
INSERT INTO t1 VALUES(5, 6);
|
||||||
|
INSERT INTO t1 VALUES(7, 8);
|
||||||
|
INSERT INTO t1 VALUES(9, 10);
|
||||||
|
INSERT INTO t1 VALUES(11, 12);
|
||||||
|
INSERT INTO t1 VALUES(13, 14);
|
||||||
|
INSERT INTO t1 VALUES(15, 16);
|
||||||
|
INSERT INTO t1 VALUES(17, 18);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
} {4000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18}
|
||||||
|
|
||||||
|
do_test 1.8 {
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
execsql { SELECT * FROM t1 } db2
|
||||||
|
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18}
|
||||||
|
|
||||||
|
do_test 1.9 {
|
||||||
|
db close
|
||||||
|
db2 close
|
||||||
|
lsort [glob test.db*]
|
||||||
|
} {test.db}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
reset_db
|
||||||
|
do_execsql_test 2.0 {
|
||||||
|
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
|
||||||
|
CREATE INDEX i1 ON t1(b, c);
|
||||||
|
PRAGMA journal_mode = wal2;
|
||||||
|
PRAGMA journal_size_limit = 4000;
|
||||||
|
} {wal2 4000}
|
||||||
|
|
||||||
|
proc wal_hook {DB nm nFrame} {
|
||||||
|
$DB eval { PRAGMA wal_checkpoint }
|
||||||
|
}
|
||||||
|
db wal_hook [list wal_hook db]
|
||||||
|
|
||||||
|
|
||||||
|
foreach js {4000 8000 12000} {
|
||||||
|
foreach NROW [list 100 200 300 400 500 600 1000] {
|
||||||
|
do_test 2.$js.$NROW.1 {
|
||||||
|
db eval "DELETE FROM t1"
|
||||||
|
db eval "PRAGMA journal_size_limit = $js"
|
||||||
|
set nTotal 0
|
||||||
|
for {set i 0} {$i < $NROW} {incr i} {
|
||||||
|
db eval { INSERT INTO t1 VALUES($i, $i, randomblob(abs(random()%50))) }
|
||||||
|
incr nTotal $i
|
||||||
|
}
|
||||||
|
set {} {}
|
||||||
|
} {}
|
||||||
|
|
||||||
|
do_test 2.$js.$NROW.2 {
|
||||||
|
sqlite3 db2 test.db
|
||||||
|
db2 eval {
|
||||||
|
PRAGMA integrity_check;
|
||||||
|
SELECT count(*), sum(b) FROM t1;
|
||||||
|
}
|
||||||
|
} [list ok $NROW $nTotal]
|
||||||
|
|
||||||
|
db2 close
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finish_test
|
||||||
|
|
Reference in New Issue
Block a user