mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-24 22:22:08 +03:00
Have sqlite3_wal_checkpoint() populate the database handle error message and error code (as returned by sqlite3_errmsg() and sqlite3_errcode()).
FossilOrigin-Name: ff234cf574c7ae384ab1ebc79b2171ef0541bc91
This commit is contained in:
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\s"PRAGMA\swal_autocheckpoint"\scommand.\sRename\s"PRAGMA\scheckpoint"\sto\s"PRAGMA\swal_checkpoint".
|
||||
D 2010-05-03T11:05:09
|
||||
C Have\ssqlite3_wal_checkpoint()\spopulate\sthe\sdatabase\shandle\serror\smessage\sand\serror\scode\s(as\sreturned\sby\ssqlite3_errmsg()\sand\ssqlite3_errcode()).
|
||||
D 2010-05-03T12:14:16
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -131,7 +131,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c
|
||||
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
|
||||
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
|
||||
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
|
||||
F src/main.c d08f2f34e92e5ad7b5ab605a2d22d24e12567efa
|
||||
F src/main.c 1cc6f391018f2b868d812bf2b1be7c20a5269805
|
||||
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
|
||||
@ -173,7 +173,7 @@ F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3
|
||||
F src/status.c 4df6fe7dce2d256130b905847c6c60055882bdbe
|
||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||
F src/tclsqlite.c 4de81521174fedacd8393ea7b70b730ce17f8eae
|
||||
F src/test1.c 8b4c246c41e75c3ff033edb2e8c2cf15820861ae
|
||||
F src/test1.c ff95ca772d1df51618f9f1ef7ea432cdf851f97b
|
||||
F src/test2.c b6b43413d495addd039a88b87d65c839f86b18cb
|
||||
F src/test3.c 4c21700c73a890a47fc685c1097bfb661346ac94
|
||||
F src/test4.c ad03bb987ddedce928f4258c1e7fa4109a73497d
|
||||
@ -758,7 +758,7 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61
|
||||
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
||||
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
||||
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
|
||||
F test/wal.test 9f142c65c436b209ffdce0eba37b1b90d2998c1a
|
||||
F test/wal.test 0c7c059c194871dd42811c31599cf74f1e1123e4
|
||||
F test/walbak.test a0e45187c7d8928df035dfea29b99b016b21ca3c
|
||||
F test/walcrash.test 63edc6a9e05f645b54d649186a5818fc82953e2e
|
||||
F test/walhook.test 5f18e0fc8787f1f8889d7a9971af18f334f83786
|
||||
@ -808,7 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 23c0e6c3f333e878fe5a2ae5d61df0d765f437b4
|
||||
R f8f9e7aa1d48de791ac4d31549cb2c66
|
||||
P 714e5947264571386f966aa8fcdd5607b5832238
|
||||
R 10b5fe590305e038296dabbf1b136051
|
||||
U dan
|
||||
Z 864d996940b21341339cd035e1e7f0cc
|
||||
Z 5bc5dc751e1eadc239ebcfefeac3d5fa
|
||||
|
@ -1 +1 @@
|
||||
714e5947264571386f966aa8fcdd5607b5832238
|
||||
ff234cf574c7ae384ab1ebc79b2171ef0541bc91
|
@ -1254,12 +1254,14 @@ int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
|
||||
}
|
||||
if( iDb<0 ){
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3Error(db, SQLITE_ERROR, "unknown database: %s", zDb);
|
||||
}else{
|
||||
rc = sqlite3Checkpoint(db, iDb);
|
||||
sqlite3Error(db, rc, 0);
|
||||
}
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
|
||||
return rc;
|
||||
return sqlite3ApiExit(db, rc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
30
src/test1.c
30
src/test1.c
@ -4868,6 +4868,35 @@ static int test_unlock_notify(
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** tclcmd: sqlite3_wal_checkpoint db ?NAME?
|
||||
*/
|
||||
static int test_wal_checkpoint(
|
||||
ClientData clientData, /* Unused */
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int objc, /* Number of arguments */
|
||||
Tcl_Obj *CONST objv[] /* Command arguments */
|
||||
){
|
||||
char *zDb = 0;
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
|
||||
if( objc!=3 && objc!=2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB ?NAME?");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( objc==3 ){
|
||||
zDb = Tcl_GetString(objv[2]);
|
||||
}
|
||||
rc = sqlite3_wal_checkpoint(db, zDb);
|
||||
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** tcl_objproc COMMANDNAME ARGS...
|
||||
@ -5089,6 +5118,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
|
||||
{ "sqlite3_unlock_notify", test_unlock_notify, 0 },
|
||||
#endif
|
||||
{ "sqlite3_wal_checkpoint", test_wal_checkpoint, 0 },
|
||||
};
|
||||
static int bitmask_size = sizeof(Bitmask)*8;
|
||||
int i;
|
||||
|
@ -968,4 +968,86 @@ do_test wal-14 {
|
||||
|
||||
catch { db close }
|
||||
catch { db2 close }
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following block of tests - wal-15.* - focus on testing the
|
||||
# implementation of the sqlite3_wal_checkpoint() interface.
|
||||
#
|
||||
file delete -force test.db test.db-wal
|
||||
sqlite3 db test.db
|
||||
do_test wal-15.1 {
|
||||
execsql {
|
||||
PRAGMA page_size = 1024;
|
||||
PRAGMA journal_mode = WAL;
|
||||
}
|
||||
execsql {
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
}
|
||||
} {}
|
||||
|
||||
# Test that an error is returned if the database name is not recognized
|
||||
#
|
||||
do_test wal-15.2.1 {
|
||||
sqlite3_wal_checkpoint db aux
|
||||
} {SQLITE_ERROR}
|
||||
do_test wal-15.2.2 {
|
||||
sqlite3_errcode db
|
||||
} {SQLITE_ERROR}
|
||||
do_test wal-15.2.3 {
|
||||
sqlite3_errmsg db
|
||||
} {unknown database: aux}
|
||||
|
||||
# Test that an error is returned if an attempt is made to checkpoint
|
||||
# if a transaction is open on the database.
|
||||
#
|
||||
do_test wal-15.3.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
}
|
||||
sqlite3_wal_checkpoint db main
|
||||
} {SQLITE_LOCKED}
|
||||
do_test wal-15.3.2 {
|
||||
sqlite3_errcode db
|
||||
} {SQLITE_LOCKED}
|
||||
do_test wal-15.3.3 {
|
||||
sqlite3_errmsg db
|
||||
} {database table is locked}
|
||||
|
||||
# Also test that an error is returned if the db cannot be checkpointed
|
||||
# because of locks held by another connection.
|
||||
#
|
||||
sqlite3 db2 test.db
|
||||
do_test wal-15.4.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
} db2
|
||||
} {1 2}
|
||||
do_test wal-15.4.2 {
|
||||
execsql { COMMIT }
|
||||
sqlite3_wal_checkpoint db
|
||||
} {SQLITE_BUSY}
|
||||
do_test wal-15.4.3 {
|
||||
sqlite3_errmsg db
|
||||
} {database is locked}
|
||||
|
||||
# After [db2] drops its lock, [db] may checkpoint the db.
|
||||
#
|
||||
do_test wal-15.4.4 {
|
||||
execsql { COMMIT } db2
|
||||
sqlite3_wal_checkpoint db
|
||||
} {SQLITE_OK}
|
||||
do_test wal-15.4.5 {
|
||||
sqlite3_errmsg db
|
||||
} {not an error}
|
||||
do_test wal-15.4.6 {
|
||||
file size test.db
|
||||
} [expr 1024*2]
|
||||
|
||||
catch { db2 close }
|
||||
catch { db close }
|
||||
finish_test
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user