Add an experimental busy_timeout pragma to facilitate access to the

sqlite3_busy_timeout() interfaces for programmers that are working from
behind a language wrapper that does not expose that interface.

FossilOrigin-Name: 22ebc668516bc3dd5782d6d3d42dc7fd2eed7d79
This commit is contained in:
drh 2012-09-07 16:46:59 +00:00
parent 37f58e9902
commit f360396c47
5 changed files with 52 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Avoid\srepeating\scalls\sto\sthe\ssqlite3_trace()\scallback\swhen\sthe\ssame\sstatement\nis\sevaluted\smultiple\stimes\sby\ssqlite3_step()\sdue\sto\san\sSQLITE_SCHEMA\nreprepare.
D 2012-09-04T21:34:26.807
C Add\san\sexperimental\sbusy_timeout\spragma\sto\sfacilitate\saccess\sto\sthe\nsqlite3_busy_timeout()\sinterfaces\sfor\sprogrammers\sthat\sare\sworking\sfrom\nbehind\sa\slanguage\swrapper\sthat\sdoes\snot\sexpose\sthat\sinterface.
D 2012-09-07T16:46:59.378
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416
F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d
F src/main.c 02255cf1da50956c5427c469abddb15bccc4ba09
F src/main.c 31af732aa4363e85816b09794429c79fe4baa3ac
F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa
@ -170,7 +170,7 @@ F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9
F src/pragma.c 97f9357f0e7e5fb46a2519f14539550aa07db49f
F src/pragma.c e09950b9d0a35c1bf2329038c10f38589e754ae8
F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5
F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@ -571,7 +571,7 @@ F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e
F test/loadext.test 2b5e249c51c986a5aff1f0950cf7ba30976c8f22
F test/loadext2.test 0bcaeb4d81cd5b6e883fdfea3c1bdbe1f173cbca
F test/lock.test db74fdf5a73bad29ab3d862ea78bf1068972cc1d
F test/lock.test 7e9eddd991b3af3a01caec2d9f030e0798deef74
F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff
F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00
F test/lock4.test e175ae13865bc87680607563bafba21f31a26f12
@ -1014,7 +1014,10 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
P c0d89d4a9752922f9e367362366efde4f1b06f2a
R f99616c13334ce584a8b1ebfcd476fa4
P 39f763bfc04174ee0fe2cdf6a92b7c12f726bd1b
R 7a209eaa28bbe6aeaf699b5d2296eb6d
T *branch * busy-timeout-pragma
T *sym-busy-timeout-pragma *
T -sym-trunk *
U drh
Z 2084e672100937502093a8dd98a48d0f
Z 3457f6820fedfafcfc1fb25157630cb3

View File

@ -1 +1 @@
39f763bfc04174ee0fe2cdf6a92b7c12f726bd1b
22ebc668516bc3dd5782d6d3d42dc7fd2eed7d79

View File

@ -1156,6 +1156,7 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){
db->busyTimeout = ms;
sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
}else{
db->busyTimeout = 0;
sqlite3_busy_handler(db, 0, 0);
}
return SQLITE_OK;

View File

@ -1536,6 +1536,22 @@ void sqlite3Pragma(
sqlite3_db_release_memory(db);
}else
/*
** PRAGMA busy_timeout
** PRAGMA busy_timeout = N
**
** Call sqlite3_busy_timeout(db, N). Return the current timeout value
** if one is set. If the busy handler is not set to the default
** busy callback, then the return value is undefined. A value of N
** which is 0 or negative disables the busy handler.
*/
if( sqlite3StrICmp(zLeft, "busy_timeout")==0 ){
if( zRight ){
sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
}
returnSingleInt(pParse, "timeout", db->busyTimeout);
}else
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
/*
** Report the current state of file logs for all databases

View File

@ -247,11 +247,34 @@ do_test lock-2.8 {
execsql {UPDATE t1 SET a = 0 WHERE 0}
catchsql {BEGIN EXCLUSIVE;} db2
} {1 {database is locked}}
do_test lock-2.8b {
db2 eval {PRAGMA busy_timeout}
} {400}
do_test lock-2.9 {
db2 timeout 0
execsql COMMIT
} {}
do_test lock-2.9b {
db2 eval {PRAGMA busy_timeout}
} {0}
integrity_check lock-2.10
do_test lock-2.11 {
db2 eval {PRAGMA busy_timeout(400)}
execsql BEGIN
execsql {UPDATE t1 SET a = 0 WHERE 0}
catchsql {BEGIN EXCLUSIVE;} db2
} {1 {database is locked}}
do_test lock-2.11b {
db2 eval {PRAGMA busy_timeout}
} {400}
do_test lock-2.12 {
db2 eval {PRAGMA busy_timeout(0)}
execsql COMMIT
} {}
do_test lock-2.11b {
db2 eval {PRAGMA busy_timeout}
} {0}
integrity_check lock-2.12
# Try to start two transactions in a row
#