Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the sqlite3_quota_file() interface to test_quota.c. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2b7fe8e5b74c3504edd0e3ff78096e35 |
User & Date: | drh 2011-08-25 01:42:12.133 |
Context
2011-08-25
| ||
01:58 | Cherrypick the [d4f6437f8d] change so that SQLITE_FCNTL_SIZE_HINT is always honored and never undone by memory pressure on windows. (check-in: 67ff8d27f6 user: drh tags: trunk) | |
01:42 | Add the sqlite3_quota_file() interface to test_quota.c. (check-in: 2b7fe8e5b7 user: drh tags: trunk) | |
00:14 | Add the SQLITE_EXTRA_INIT macro. (check-in: a3220f36c1 user: drh tags: trunk) | |
Changes
Changes to src/test_quota.c.
︙ | ︙ | |||
790 791 792 793 794 795 796 797 798 799 800 801 802 803 | } pGroup->pArg = pArg; pGroup->xDestroy = xDestroy; quotaGroupDeref(pGroup); quotaLeave(); return SQLITE_OK; } /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST #include <tcl.h> /* | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } pGroup->pArg = pArg; pGroup->xDestroy = xDestroy; quotaGroupDeref(pGroup); quotaLeave(); return SQLITE_OK; } /* ** Bring the named file under quota management. Or if it is already under ** management, update its size. */ int sqlite3_quota_file(const char *zFilename){ char *zFull; sqlite3_file *fd; int rc; int outFlags = 0; sqlite3_int64 iSize; fd = sqlite3_malloc(gQuota.sThisVfs.szOsFile + gQuota.sThisVfs.mxPathname+1); if( fd==0 ) return SQLITE_NOMEM; zFull = gQuota.sThisVfs.szOsFile + (char*)fd; rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename, gQuota.sThisVfs.mxPathname+1, zFull); if( rc==SQLITE_OK ){ rc = quotaOpen(&gQuota.sThisVfs, zFull, fd, SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_DB, &outFlags); } if( rc==SQLITE_OK ){ quotaFileSize(fd, &iSize); quotaClose(fd); }else if( rc==SQLITE_CANTOPEN ){ quotaGroup *pGroup; quotaFile *pFile; quotaEnter(); pGroup = quotaGroupFind(zFull); if( pGroup ){ pFile = quotaFindFile(pGroup, zFull); if( pFile ) quotaRemoveFile(pFile); } quotaLeave(); } sqlite3_free(fd); return rc; } /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST #include <tcl.h> /* |
︙ | ︙ | |||
966 967 968 969 970 971 972 973 974 975 976 977 978 979 | /* Invoke sqlite3_quota_set() */ rc = sqlite3_quota_set(zPattern, iLimit, xCallback, (void*)p, xDestroy); Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); return TCL_OK; } /* ** tclcmd: sqlite3_quota_dump */ static int test_quota_dump( void * clientData, Tcl_Interp *interp, | > > > > > > > > > > > > > > > > > > > > > > > > > > | 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 | /* Invoke sqlite3_quota_set() */ rc = sqlite3_quota_set(zPattern, iLimit, xCallback, (void*)p, xDestroy); Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); return TCL_OK; } /* ** tclcmd: sqlite3_quota_file FILENAME */ static int test_quota_file( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ const char *zFilename; /* File pattern to configure */ int rc; /* Value returned by quota_file() */ /* Process arguments */ if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); return TCL_ERROR; } zFilename = Tcl_GetString(objv[1]); /* Invoke sqlite3_quota_file() */ rc = sqlite3_quota_file(zFilename); Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); return TCL_OK; } /* ** tclcmd: sqlite3_quota_dump */ static int test_quota_dump( void * clientData, Tcl_Interp *interp, |
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | static struct { char *zName; Tcl_ObjCmdProc *xProc; } aCmd[] = { { "sqlite3_quota_initialize", test_quota_initialize }, { "sqlite3_quota_shutdown", test_quota_shutdown }, { "sqlite3_quota_set", test_quota_set }, { "sqlite3_quota_dump", test_quota_dump }, }; int i; for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); } return TCL_OK; } #endif | > | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 | static struct { char *zName; Tcl_ObjCmdProc *xProc; } aCmd[] = { { "sqlite3_quota_initialize", test_quota_initialize }, { "sqlite3_quota_shutdown", test_quota_shutdown }, { "sqlite3_quota_set", test_quota_set }, { "sqlite3_quota_file", test_quota_file }, { "sqlite3_quota_dump", test_quota_dump }, }; int i; for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); } return TCL_OK; } #endif |
Changes to test/quota.test.
︙ | ︙ | |||
231 232 233 234 235 236 237 238 239 240 241 242 243 244 | proc quota_list {} { set allq {} foreach q [sqlite3_quota_dump] { lappend allq [lindex $q 0] } return [lsort $allq] } do_test quota-4.1.1 { sqlite3_quota_set *test.db 0 {} quota_list } {} do_test quota-4.1.2 { sqlite3_quota_set *test.db 4096 {} | > > > > > > > | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | proc quota_list {} { set allq {} foreach q [sqlite3_quota_dump] { lappend allq [lindex $q 0] } return [lsort $allq] } proc quota_size {name} { set allq {} foreach q [sqlite3_quota_dump] { if {[lindex $q 0]==$name} {return [lindex $q 2]} } return 0 } do_test quota-4.1.1 { sqlite3_quota_set *test.db 0 {} quota_list } {} do_test quota-4.1.2 { sqlite3_quota_set *test.db 4096 {} |
︙ | ︙ | |||
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | INSERT INTO t1 VALUES(randomblob(5000)); } quota_list } {*/quota-test-A?.db} do_test quota-4.4.4 { expr {$::quota!=""} } {1} do_test quota-4.9.1 { db close sqlite3_quota_set A 1000 quota_callback sqlite3_quota_shutdown } {SQLITE_OK} do_test quota-4.9.2 { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | INSERT INTO t1 VALUES(randomblob(5000)); } quota_list } {*/quota-test-A?.db} do_test quota-4.4.4 { expr {$::quota!=""} } {1} do_test quota-4.4.5 { db close sqlite3_quota_set */quota-test-A?.db 0 {} sqlite3_quota_dump } {} do_test quota-4.4.6 { sqlite3_quota_set */quota-test-A?.db 10000 quota_callback sqlite3 db quota-test-A1.db db eval {SELECT count(*) FROM sqlite_master} quota_size */quota-test-A?.db } [file size quota-test-A1.db] do_test quota-4.4.7 { sqlite3_quota_file quota-test-A2.db quota_size */quota-test-A?.db } [expr {[file size quota-test-A1.db]+[file size quota-test-A2.db]}] do_test quota-4.5.1 { foreach file [glob -nocomplain quota-test-B*] { forcedelete $file } sqlite3_quota_set */quota-test-B* 100000 quota_callback quota_size */quota-test-B* } {0} do_test quota-4.5.2 { sqlite3_quota_file quota-test-B1.txt quota_size */quota-test-B* } {0} proc add_to_file {name n} { set out [open $name a] fconfigure $out -translation binary puts -nonewline $out [string repeat x $n] close $out } do_test quota-4.5.3 { add_to_file quota-test-B1.txt 123 sqlite3_quota_file quota-test-B1.txt quota_size */quota-test-B* } {123} do_test quota-4.5.4 { add_to_file quota-test-B2.txt 234 sqlite3_quota_file quota-test-B2.txt quota_size */quota-test-B* } {357} do_test quota-4.5.5 { add_to_file quota-test-B1.txt 2000 sqlite3_quota_file quota-test-B1.txt quota_size */quota-test-B* } {2357} do_test quota-4.5.6 { forcedelete quota-test-B1.txt sqlite3_quota_file quota-test-B1.txt quota_size */quota-test-B* } {234} do_test quota-4.5.7 { forcedelete quota-test-B2.txt sqlite3_quota_file quota-test-B2.txt quota_size */quota-test-B* } {0} do_test quota-4.5.8 { add_to_file quota-test-B3.txt 1234 sqlite3_quota_file quota-test-B3.txt quota_size */quota-test-B* } {1234} do_test quota-4.5.9 { sqlite3_quota_set */quota-test-B* 0 {} quota_size */quota-test-B* } {0} do_test quota-4.9.1 { db close sqlite3_quota_set A 1000 quota_callback sqlite3_quota_shutdown } {SQLITE_OK} do_test quota-4.9.2 { |
︙ | ︙ |