mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Ensure that there is always at least one aReadMark slot usable by an unprivileged reader while a checkpoint is running. Also, if one or more transactions are recovered from a log file, initialize one of the aReadMark slots to contain mxFrame as part of the recovery process.
FossilOrigin-Name: e4163596339c2166f9c4356ab824fff8bda8d0b0
This commit is contained in:
22
manifest
22
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Amplification\sof\sa\scomment\sin\swal.c.\s\sChange\sthe\saReadMark[]\sprocessing\sso\nthat\sone\sread\smark\sis\sleft\sat\szero\swhen\sa\sWAL\sresets.
|
C Ensure\sthat\sthere\sis\salways\sat\sleast\sone\saReadMark\sslot\susable\sby\san\sunprivileged\sreader\swhile\sa\scheckpoint\sis\srunning.\sAlso,\sif\sone\sor\smore\stransactions\sare\srecovered\sfrom\sa\slog\sfile,\sinitialize\sone\sof\sthe\saReadMark\sslots\sto\scontain\smxFrame\sas\spart\sof\sthe\srecovery\sprocess.
|
||||||
D 2012-07-17T02:56:05.199
|
D 2012-07-17T14:37:12.494
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4
|
F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -227,7 +227,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
|
|||||||
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
|
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
|
||||||
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
|
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
|
||||||
F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4
|
F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4
|
||||||
F src/test_vfs.c 9d934e111021d56c629efc73a796648c9519ad12
|
F src/test_vfs.c da6d0d982b11756c94c1760196355d33d03ff745
|
||||||
F src/test_vfstrace.c 6b28adb2a0e8ecd0f2e3581482e1f658b11b4067
|
F src/test_vfstrace.c 6b28adb2a0e8ecd0f2e3581482e1f658b11b4067
|
||||||
F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251
|
F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251
|
||||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||||
@@ -247,7 +247,7 @@ F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74
|
|||||||
F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9
|
F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9
|
||||||
F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392
|
F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392
|
||||||
F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998
|
F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998
|
||||||
F src/wal.c 16345cdccc95e13b493854f1253b8395fcd519fa
|
F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b
|
||||||
F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
|
F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
|
||||||
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
|
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
|
||||||
F src/where.c 24c7494d8875ead994b4dfe5461340c27fd424ca
|
F src/where.c 24c7494d8875ead994b4dfe5461340c27fd424ca
|
||||||
@@ -926,8 +926,8 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
|||||||
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
||||||
F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839
|
F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839
|
||||||
F test/wal.test a040047d7f2b9f34bc4d597964e5e7c09609c635
|
F test/wal.test a040047d7f2b9f34bc4d597964e5e7c09609c635
|
||||||
F test/wal2.test d5021064bebfc717fe2bf4db2536ea030b76a773
|
F test/wal2.test 7ca814723c487de87d945cdc85c9a0fa45fa8de8
|
||||||
F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706
|
F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0
|
||||||
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
|
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
|
||||||
F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437
|
F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437
|
||||||
F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
|
F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
|
||||||
@@ -945,7 +945,7 @@ F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483
|
|||||||
F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c
|
F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c
|
||||||
F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
|
F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
|
||||||
F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
|
F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
|
||||||
F test/walro.test e6bb27762c9f22601cbb8bff6e0acfd124e74b63
|
F test/walro.test f183c0003060a64793f9bfafef4c479418ed7fa8
|
||||||
F test/walshared.test 6dda2293880c300baf5d791c307f653094585761
|
F test/walshared.test 6dda2293880c300baf5d791c307f653094585761
|
||||||
F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a
|
F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a
|
||||||
F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a
|
F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a
|
||||||
@@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
|||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
P 6f167adf6050632e8c52f9ac4fb5583bcf27c576
|
P 8c9ee1d78f99394eef73a177141ca9e1c67e4e07
|
||||||
R aff021ec3312340384303b11ff294204
|
R 21a0c6942de3e9593e3e93f462c443c7
|
||||||
U drh
|
U dan
|
||||||
Z 0bb1d32f801f3ecf912dcdccb6dd8135
|
Z a98d8c358c03bd601d60af308961371e
|
||||||
|
@@ -1 +1 @@
|
|||||||
8c9ee1d78f99394eef73a177141ca9e1c67e4e07
|
e4163596339c2166f9c4356ab824fff8bda8d0b0
|
@@ -81,6 +81,7 @@ struct Testvfs {
|
|||||||
Tcl_Obj *pScript; /* Script to execute */
|
Tcl_Obj *pScript; /* Script to execute */
|
||||||
TestvfsBuffer *pBuffer; /* List of shared buffers */
|
TestvfsBuffer *pBuffer; /* List of shared buffers */
|
||||||
int isNoshm;
|
int isNoshm;
|
||||||
|
int isFullshm;
|
||||||
|
|
||||||
int mask; /* Mask controlling [script] and [ioerr] */
|
int mask; /* Mask controlling [script] and [ioerr] */
|
||||||
|
|
||||||
@@ -760,6 +761,7 @@ static int tvfsShmOpen(sqlite3_file *pFile){
|
|||||||
|
|
||||||
pFd = tvfsGetFd(pFile);
|
pFd = tvfsGetFd(pFile);
|
||||||
p = (Testvfs *)pFd->pVfs->pAppData;
|
p = (Testvfs *)pFd->pVfs->pAppData;
|
||||||
|
assert( 0==p->isFullshm );
|
||||||
assert( pFd->pShmId && pFd->pShm==0 && pFd->pNext==0 );
|
assert( pFd->pShmId && pFd->pShm==0 && pFd->pNext==0 );
|
||||||
|
|
||||||
/* Evaluate the Tcl script:
|
/* Evaluate the Tcl script:
|
||||||
@@ -820,6 +822,10 @@ static int tvfsShmMap(
|
|||||||
TestvfsFd *pFd = tvfsGetFd(pFile);
|
TestvfsFd *pFd = tvfsGetFd(pFile);
|
||||||
Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);
|
Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);
|
||||||
|
|
||||||
|
if( p->isFullshm ){
|
||||||
|
return sqlite3OsShmMap(pFd->pReal, iPage, pgsz, isWrite, pp);
|
||||||
|
}
|
||||||
|
|
||||||
if( 0==pFd->pShm ){
|
if( 0==pFd->pShm ){
|
||||||
rc = tvfsShmOpen(pFile);
|
rc = tvfsShmOpen(pFile);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
@@ -864,6 +870,10 @@ static int tvfsShmLock(
|
|||||||
int nLock;
|
int nLock;
|
||||||
char zLock[80];
|
char zLock[80];
|
||||||
|
|
||||||
|
if( p->isFullshm ){
|
||||||
|
return sqlite3OsShmLock(pFd->pReal, ofst, n, flags);
|
||||||
|
}
|
||||||
|
|
||||||
if( p->pScript && p->mask&TESTVFS_SHMLOCK_MASK ){
|
if( p->pScript && p->mask&TESTVFS_SHMLOCK_MASK ){
|
||||||
sqlite3_snprintf(sizeof(zLock), zLock, "%d %d", ofst, n);
|
sqlite3_snprintf(sizeof(zLock), zLock, "%d %d", ofst, n);
|
||||||
nLock = (int)strlen(zLock);
|
nLock = (int)strlen(zLock);
|
||||||
@@ -919,6 +929,11 @@ static void tvfsShmBarrier(sqlite3_file *pFile){
|
|||||||
TestvfsFd *pFd = tvfsGetFd(pFile);
|
TestvfsFd *pFd = tvfsGetFd(pFile);
|
||||||
Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);
|
Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);
|
||||||
|
|
||||||
|
if( p->isFullshm ){
|
||||||
|
sqlite3OsShmBarrier(pFd->pReal);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){
|
if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){
|
||||||
tvfsExecTcl(p, "xShmBarrier",
|
tvfsExecTcl(p, "xShmBarrier",
|
||||||
Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0
|
Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0
|
||||||
@@ -936,6 +951,10 @@ static int tvfsShmUnmap(
|
|||||||
TestvfsBuffer *pBuffer = pFd->pShm;
|
TestvfsBuffer *pBuffer = pFd->pShm;
|
||||||
TestvfsFd **ppFd;
|
TestvfsFd **ppFd;
|
||||||
|
|
||||||
|
if( p->isFullshm ){
|
||||||
|
return sqlite3OsShmUnmap(pFd->pReal, deleteFlag);
|
||||||
|
}
|
||||||
|
|
||||||
if( !pBuffer ) return SQLITE_OK;
|
if( !pBuffer ) return SQLITE_OK;
|
||||||
assert( pFd->pShmId && pFd->pShm );
|
assert( pFd->pShmId && pFd->pShm );
|
||||||
|
|
||||||
@@ -1350,6 +1369,7 @@ static int testvfs_cmd(
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
int isNoshm = 0; /* True if -noshm is passed */
|
int isNoshm = 0; /* True if -noshm is passed */
|
||||||
|
int isFullshm = 0; /* True if -fullshm is passed */
|
||||||
int isDefault = 0; /* True if -default is passed */
|
int isDefault = 0; /* True if -default is passed */
|
||||||
int szOsFile = 0; /* Value passed to -szosfile */
|
int szOsFile = 0; /* Value passed to -szosfile */
|
||||||
int mxPathname = -1; /* Value passed to -mxpathname */
|
int mxPathname = -1; /* Value passed to -mxpathname */
|
||||||
@@ -1365,6 +1385,7 @@ static int testvfs_cmd(
|
|||||||
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isNoshm) ){
|
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isNoshm) ){
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
if( isNoshm ) isFullshm = 0;
|
||||||
}
|
}
|
||||||
else if( nSwitch>2 && 0==strncmp("-default", zSwitch, nSwitch) ){
|
else if( nSwitch>2 && 0==strncmp("-default", zSwitch, nSwitch) ){
|
||||||
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isDefault) ){
|
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isDefault) ){
|
||||||
@@ -1386,6 +1407,12 @@ static int testvfs_cmd(
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( nSwitch>2 && 0==strncmp("-fullshm", zSwitch, nSwitch) ){
|
||||||
|
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isFullshm) ){
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if( isFullshm ) isNoshm = 0;
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
goto bad_args;
|
goto bad_args;
|
||||||
}
|
}
|
||||||
@@ -1427,6 +1454,7 @@ static int testvfs_cmd(
|
|||||||
pVfs->szOsFile = szOsFile;
|
pVfs->szOsFile = szOsFile;
|
||||||
p->pVfs = pVfs;
|
p->pVfs = pVfs;
|
||||||
p->isNoshm = isNoshm;
|
p->isNoshm = isNoshm;
|
||||||
|
p->isFullshm = isFullshm;
|
||||||
p->mask = TESTVFS_ALL_MASK;
|
p->mask = TESTVFS_ALL_MASK;
|
||||||
|
|
||||||
sqlite3_vfs_register(pVfs, isDefault);
|
sqlite3_vfs_register(pVfs, isDefault);
|
||||||
|
@@ -1199,6 +1199,7 @@ finished:
|
|||||||
pInfo->nBackfill = 0;
|
pInfo->nBackfill = 0;
|
||||||
pInfo->aReadMark[0] = 0;
|
pInfo->aReadMark[0] = 0;
|
||||||
for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
|
for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
|
||||||
|
if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame;
|
||||||
|
|
||||||
/* If more than one frame was recovered from the log file, report an
|
/* If more than one frame was recovered from the log file, report an
|
||||||
** event via sqlite3_log(). This is to help with identifying performance
|
** event via sqlite3_log(). This is to help with identifying performance
|
||||||
@@ -1699,7 +1700,7 @@ static int walCheckpoint(
|
|||||||
assert( y<=pWal->hdr.mxFrame );
|
assert( y<=pWal->hdr.mxFrame );
|
||||||
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
|
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
pInfo->aReadMark[i] = READMARK_NOT_USED;
|
pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
|
||||||
walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
|
walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
|
||||||
}else if( rc==SQLITE_BUSY ){
|
}else if( rc==SQLITE_BUSY ){
|
||||||
mxSafeFrame = y;
|
mxSafeFrame = y;
|
||||||
|
@@ -126,9 +126,11 @@ set RECOVER [list \
|
|||||||
{1 7 unlock exclusive} {0 1 unlock exclusive} \
|
{1 7 unlock exclusive} {0 1 unlock exclusive} \
|
||||||
]
|
]
|
||||||
set READ [list \
|
set READ [list \
|
||||||
{4 1 lock exclusive} {4 1 unlock exclusive} \
|
|
||||||
{4 1 lock shared} {4 1 unlock shared} \
|
{4 1 lock shared} {4 1 unlock shared} \
|
||||||
]
|
]
|
||||||
|
set INITSLOT [list \
|
||||||
|
{4 1 lock exclusive} {4 1 unlock exclusive} \
|
||||||
|
]
|
||||||
|
|
||||||
foreach {tn iInsert res wal_index_hdr_mod wal_locks} "
|
foreach {tn iInsert res wal_index_hdr_mod wal_locks} "
|
||||||
2 5 {5 15} 0 {$RECOVER $READ}
|
2 5 {5 15} 0 {$RECOVER $READ}
|
||||||
@@ -141,7 +143,7 @@ foreach {tn iInsert res wal_index_hdr_mod wal_locks} "
|
|||||||
9 12 {12 78} 7 {$RECOVER $READ}
|
9 12 {12 78} 7 {$RECOVER $READ}
|
||||||
10 13 {13 91} 8 {$RECOVER $READ}
|
10 13 {13 91} 8 {$RECOVER $READ}
|
||||||
11 14 {14 105} 9 {$RECOVER $READ}
|
11 14 {14 105} 9 {$RECOVER $READ}
|
||||||
12 15 {15 120} -1 {$READ}
|
12 15 {15 120} -1 {$INITSLOT $READ}
|
||||||
" {
|
" {
|
||||||
|
|
||||||
do_test wal2-1.$tn.1 {
|
do_test wal2-1.$tn.1 {
|
||||||
|
@@ -655,7 +655,7 @@ T filter xShmLock
|
|||||||
T script lock_callback
|
T script lock_callback
|
||||||
|
|
||||||
proc lock_callback {method file handle spec} {
|
proc lock_callback {method file handle spec} {
|
||||||
if {$spec == "4 1 unlock exclusive"} {
|
if {$spec == "1 7 unlock exclusive"} {
|
||||||
T filter {}
|
T filter {}
|
||||||
set ::r [catchsql { SELECT * FROM b } db2]
|
set ::r [catchsql { SELECT * FROM b } db2]
|
||||||
}
|
}
|
||||||
|
125
test/walro.test
125
test/walro.test
@@ -163,6 +163,131 @@ do_multiclient_test tn {
|
|||||||
do_test 1.3.2.4 {
|
do_test 1.3.2.4 {
|
||||||
code1 { sqlite3_extended_errcode db }
|
code1 { sqlite3_extended_errcode db }
|
||||||
} {SQLITE_READONLY_RECOVERY}
|
} {SQLITE_READONLY_RECOVERY}
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Test cases 1.4.* check that checkpoints and log wraps don't prevent
|
||||||
|
# read-only connections from reading the database.
|
||||||
|
do_test 1.4.1 {
|
||||||
|
code1 { db close }
|
||||||
|
forcedelete test.db-shm
|
||||||
|
file exists test.db-shm
|
||||||
|
} {0}
|
||||||
|
|
||||||
|
# Open one read-only and one read-write connection. Write some data
|
||||||
|
# and then run a checkpoint using the read-write connection. Then
|
||||||
|
# check the read-only connection can still read.
|
||||||
|
do_test 1.4.2 {
|
||||||
|
code1 { sqlite3 db file:test.db?readonly_shm=1 }
|
||||||
|
code2 { sqlite3 db2 test.db }
|
||||||
|
csql2 {
|
||||||
|
INSERT INTO t1 VALUES(1, 2);
|
||||||
|
INSERT INTO t1 VALUES(3, 4);
|
||||||
|
INSERT INTO t1 VALUES(5, 6);
|
||||||
|
PRAGMA wal_checkpoint;
|
||||||
|
}
|
||||||
|
} {0 {0 3 3}}
|
||||||
|
do_test 1.4.3 {
|
||||||
|
csql1 { SELECT * FROM t1 }
|
||||||
|
} {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}
|
||||||
|
|
||||||
|
# Using the read-write connection, open a transaction and write lots
|
||||||
|
# of data - causing a cache spill and a log wrap. Then check that the
|
||||||
|
# read-only connection can still read the database.
|
||||||
|
do_test 1.4.4.1 {
|
||||||
|
csql2 {
|
||||||
|
PRAGMA cache_size = 10;
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE t2(x, y);
|
||||||
|
INSERT INTO t2 VALUES('abc', 'xyz');
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
}
|
||||||
|
file size test.db-wal
|
||||||
|
} {147800}
|
||||||
|
do_test 1.4.4.2 {
|
||||||
|
csql1 { SELECT * FROM t1 }
|
||||||
|
} {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}
|
||||||
|
do_test 1.4.4.3 {
|
||||||
|
csql2 COMMIT
|
||||||
|
csql1 { SELECT count(*) FROM t2 }
|
||||||
|
} {0 512}
|
||||||
|
do_test 1.4.5 {
|
||||||
|
code2 { db2 close }
|
||||||
|
code1 { db close }
|
||||||
|
} {}
|
||||||
|
}
|
||||||
|
|
||||||
|
forcedelete test.db
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Test cases 2.* check that a read-only connection may read the
|
||||||
|
# database file while a checkpoint operation is ongoing.
|
||||||
|
#
|
||||||
|
do_multiclient_test tn {
|
||||||
|
# Do not run tests with the connections in the same process.
|
||||||
|
#
|
||||||
|
if {$tn==2} continue
|
||||||
|
|
||||||
|
# Close all connections and delete the database.
|
||||||
|
#
|
||||||
|
code1 { db close }
|
||||||
|
code2 { db2 close }
|
||||||
|
code3 { db3 close }
|
||||||
|
forcedelete test.db
|
||||||
|
forcedelete walro
|
||||||
|
|
||||||
|
foreach c {code1 code2 code3} {
|
||||||
|
$c {
|
||||||
|
sqlite3_shutdown
|
||||||
|
sqlite3_config_uri 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc tv_hook {x file args} {
|
||||||
|
if {[file tail $file]=="test.db-wal"} {
|
||||||
|
do_test 2.1.2 {
|
||||||
|
code2 { sqlite3 db2 file:test.db?readonly_shm=1 }
|
||||||
|
csql2 { SELECT count(*) FROM t2 }
|
||||||
|
} {0 4}
|
||||||
|
do_test 2.1.3 {
|
||||||
|
code2 { db2 close }
|
||||||
|
} {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
do_test 2.1.1 {
|
||||||
|
testvfs tv -default 1 -fullshm 1
|
||||||
|
tv script tv_hook
|
||||||
|
tv filter {}
|
||||||
|
code1 { sqlite3 db test.db }
|
||||||
|
csql1 {
|
||||||
|
PRAGMA journal_mode = WAL;
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE t2(x, y);
|
||||||
|
INSERT INTO t2 VALUES('abc', 'xyz');
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
INSERT INTO t2 SELECT x||y, y||x FROM t2;
|
||||||
|
COMMIT;
|
||||||
|
}
|
||||||
|
} {0 wal}
|
||||||
|
|
||||||
|
tv filter xSync
|
||||||
|
set res [csql1 { PRAGMA wal_checkpoint }]
|
||||||
|
do_test 2.1.4 { set res } {0 {0 2 2}}
|
||||||
|
|
||||||
|
do_test 2.1.5 {
|
||||||
|
code1 { db close }
|
||||||
|
code1 { tv delete }
|
||||||
|
} {}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user