-C Call\squota\scallback\sdestructors\sfrom\swithin\ssqlite3_quota_shutdown().
-D 2010-09-01T16:19:57
+C Add\stests\sto\squota.test.
+D 2010-09-01T18:00:10
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
F src/test_osinst.c f408c6a181f2fb04c56273afd5c3e1e82f60392c
F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8
-F src/test_quota.c 6afa78d864509f490ffffd997761ebb2890478d0
+F src/test_quota.c 6d32dd5885777f432db91e3a6c9e39008dd67d86
F src/test_rtree.c e957a603a98871dcf005c1e96ae791cfe74eb7f6
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
-F test/quota.test f4028117363a4a42d5b45fc8f6f5ba34556062d4
+F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
F test/randexpr1.test 1084050991e9ba22c1c10edd8d84673b501cc25a
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 7f6072f0827e3aafd17f5f2bac9e3a3f8482e5f6
-R 683c19de50a702003d36bb4bcbf13d6b
+P fb80c6f3de73ed832faaeb8c4d83e1354f132b39
+R c08f0a6930588c34007d44f357699c43
U dan
-Z a5272a839c843ec4c6d420e66112a9e4
+Z efb044ac8547d8d2011ff96cf1ab3840
TclQuotaCallback *p; /* Callback object */
int nScript; /* Length of callback script */
void (*xDestroy)(void*); /* Optional destructor for pArg */
+ void (*xCallback)(const char *, sqlite3_int64 *, sqlite3_int64, void *);
/* Process arguments */
if( objc!=4 ){
Tcl_IncrRefCount(pScript);
p->pScript = pScript;
xDestroy = tclCallbackDestructor;
+ xCallback = tclQuotaCallback;
}else{
p = 0;
xDestroy = 0;
+ xCallback = 0;
}
/* Invoke sqlite3_quota_set() */
- rc = sqlite3_quota_set(zPattern, iLimit, tclQuotaCallback, (void*)p,xDestroy);
+ rc = sqlite3_quota_set(zPattern, iLimit, xCallback, (void*)p, xDestroy);
Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC);
return TCL_OK;
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
db close
# Try some tests with more than one connection to a database file. Still
# in rollback mode.
#
+# quota-3.1.*: Two connections to a single database file.
+#
+# quota-3.2.*: Two connections to each of several database files (that
+# are in the same quota group).
+#
proc quota_check {filename limitvar size} {
upvar $limitvar limit
lappend ::quota [set limit] $size
set ::quota_request_ok 1
execsql { CREATE TABLE t3(a, b) }
} {}
+do_test quota-3.1.6 {
+ db close
+ db2 close
+ sqlite3_quota_set *test.db 0 {}
+} {SQLITE_OK}
-do_test quota-3.X {
- catch { db close }
- catch { db2 close }
-} {0}
+do_test quota-3.2.1 {
+ file delete force test.db test2.db
+
+ sqlite3_quota_set * 4096 {}
+ sqlite3 db1a test.db
+ sqlite3 db2a test2.db
+
+ foreach db {db1a db2a} {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = delete;
+ PRAGMA auto_vacuum = off;
+ CREATE TABLE t1(a, b);
+ } $db
+ }
+
+ sqlite3 db1b test.db
+ sqlite3 db2b test2.db
+
+ list [file size test.db] [file size test2.db]
+} {2048 2048}
+
+catch { unset ::quota_request_ok }
+
+do_test quota-3.2.2 { execsql { INSERT INTO t1 VALUES('x', 'y') } db1a } {}
+do_test quota-3.2.3 { execsql { INSERT INTO t1 VALUES('v', 'w') } db1b } {}
+do_test quota-3.2.4 { execsql { INSERT INTO t1 VALUES('t', 'u') } db2a } {}
+do_test quota-3.2.5 { execsql { INSERT INTO t1 VALUES('r', 's') } db2b } {}
+
+do_test quota-3.2.6 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a
+} {1 {database or disk is full}}
+do_test quota-3.2.7 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b
+} {1 {database or disk is full}}
+do_test quota-3.2.8 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
+} {1 {database or disk is full}}
+do_test quota-3.2.9 {
+ catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
+} {1 {database or disk is full}}
+
+set ::quota [list]
+proc quota_callback {file limitvar size} {
+ upvar $limitvar limit
+ lappend ::quota $file $size
+ set limit 0
+}
+sqlite3_quota_set * 4096 quota_callback
+do_test quota-3.3.1 {
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
+ execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
+ set ::quota
+} [list [file join [pwd] test.db] 5120]
+
+do_test quota-3.2.X {
+ foreach db {db1a db2a db2b db1b} { catch { $db close } }
+ sqlite3_quota_set * 0 {}
+} {SQLITE_OK}
#-------------------------------------------------------------------------
# Quotas are deleted when unused and when there limit is set to zero
quota_list
} {}
+#-------------------------------------------------------------------------
+# The following tests test that the quota VFS handles malloc and IO
+# errors.
+#
+
+sqlite3_quota_initialize "" 1
+sqlite3_quota_set *test.db 4096 {}
+
+do_faultsim_test quota-5.1 -prep {
+ catch {db close}
+} -body {
+ sqlite3 db test2.db
+}
+do_faultsim_test quota-5.2 -prep {
+ catch {db close}
+} -body {
+ sqlite3 db test.db
+}
+
+catch { db close }
+file delete -force test.db
+
+do_test quota-5.3.prep {
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(10, zeroblob(1200));
+ }
+ faultsim_save_and_close
+} {}
+do_faultsim_test quota-5.3 -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { DELETE FROM t1 }
+}
+do_test quota-5.4.1 {
+ catch { db close }
+ file delete -force test.db
+ file mkdir test.db
+ list [catch { sqlite3 db test.db } msg] $msg
+} {1 {unable to open database file}}
+
+do_faultsim_test quota-5.5 -prep {
+ catch { sqlite3_quota_shutdown }
+} -body {
+ sqlite3_quota_initialize "" 1
+}
+
+do_faultsim_test quota-5.6 -prep {
+ catch { sqlite3_quota_shutdown }
+ sqlite3_quota_initialize "" 1
+} -body {
+ sqlite3_quota_set * 4096 {}
+}
catch { sqlite3_quota_shutdown }
finish_test