-C Avoid\scalling\sfchown()\sif\sthe\sprocess\sis\snot\srunning\sas\sroot.
-D 2012-05-31T13:10:49.376
+C Add\ssqlite3_quota_ferror()\sand\ssqlite3_quota_file_available()\sinterfaces\sto\ntest_quota.c.\s\sChange\ssqlite3_quota_fwrite()\sto\suse\sa\sconst\sinput\sbuffer.
+D 2012-06-05T13:56:15.352
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25
F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba
F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
-F src/test_quota.c 47cb7b606160ce8f603a7d47143dd1f74de09058
-F src/test_quota.h ee5da2ae7f84d1c8e0e0e2ab33f01d69f10259b5
+F src/test_quota.c 0af3e1e9a1f22bc5f431dd3efcc32762f4109f58
+F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb
F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26
F test/quota.test c2f778dab4c7fb07bcfa962cc5c762f36d8061dc
-F test/quota2.test bc9fdb2e46aace691c1a01a9cc8d097bd4d7c1ab
+F test/quota2.test 52175f1c94fb01711da38095a7d3988d0c7d6575
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P 07935d10d341fe6265cfd3b09e2c4ef4005c4826
-R db0f48be730e02610af744a3fe432e51
+P 70c419a434be77b042a23174483d6a411899eb5d
+R 6f34bdd03e1922ea3b6cb56fd9309a2c
U drh
-Z a3e118b76a7afa02078e1c319e3927b5
+Z 1b017ff1370375c5086bff54a1d45078
-70c419a434be77b042a23174483d6a411899eb5d
\ No newline at end of file
+61669c95859e187618fb2fb4249306a947ae8d26
\ No newline at end of file
** the write if we exceed quota.
*/
size_t sqlite3_quota_fwrite(
- void *pBuf, /* Take content to write from here */
+ const void *pBuf, /* Take content to write from here */
size_t size, /* Size of each element */
size_t nmemb, /* Number of elements */
quota_FILE *p /* Write to this quota_FILE objecct */
sqlite3_int64 szNew;
quotaFile *pFile;
size_t rc;
-
+
iOfst = ftell(p->f);
iEnd = iOfst + size*nmemb;
pFile = p->pFile;
pFile->iSize = iNewEnd;
quotaLeave();
}
- return rc;
+ return rc;
}
/*
return ftell(p->f);
}
+/*
+** Test the error indicator for the given file.
+*/
+int sqlite3_quota_ferror(quota_FILE *p){
+ return ferror(p->f);
+}
+
/*
** Truncate a file to szNew bytes.
*/
sqlite3_int64 sqlite3_quota_file_size(quota_FILE *p){
return p->pFile ? p->pFile->iSize : -1;
}
+
+/*
+** Determine the amount of data in bytes available for reading
+** in the given file.
+*/
+long sqlite3_quota_file_available(quota_FILE *p){
+ FILE* f = p->f;
+ long pos1, pos2;
+ int rc;
+ pos1 = ftell(f);
+ if ( pos1 < 0 ) return -1;
+ rc = fseek(f, 0, SEEK_END);
+ if ( rc != 0 ) return -1;
+ pos2 = ftell(f);
+ if ( pos2 < 0 ) return -1;
+ rc = fseek(f, pos1, SEEK_SET);
+ if ( rc != 0 ) return -1;
+ return pos2 - pos1;
+}
/*
** Remove a managed file. Update quotas accordingly.
return TCL_OK;
}
+/*
+** tclcmd: sqlite3_quota_file_available HANDLE
+**
+** Return the number of bytes from the current file point to the end of
+** the file.
+*/
+static int test_quota_file_available(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ quota_FILE *p;
+ sqlite3_int64 x;
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "HANDLE");
+ return TCL_ERROR;
+ }
+ p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
+ x = sqlite3_quota_file_available(p);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
+ return TCL_OK;
+}
+
+/*
+** tclcmd: sqlite3_quota_ferror HANDLE
+**
+** Return true if the file handle is in the error state.
+*/
+static int test_quota_ferror(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ quota_FILE *p;
+ int x;
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "HANDLE");
+ return TCL_ERROR;
+ }
+ p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
+ x = sqlite3_quota_ferror(p);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ return TCL_OK;
+}
+
/*
** This routine registers the custom TCL commands defined in this
** module. This should be the only procedure visible from outside
{ "sqlite3_quota_file_mtime", test_quota_file_mtime },
{ "sqlite3_quota_remove", test_quota_remove },
{ "sqlite3_quota_glob", test_quota_glob },
+ { "sqlite3_quota_file_available",test_quota_file_available },
+ { "sqlite3_quota_ferror", test_quota_ferror },
};
int i;
** the sum of sizes of all files from going over quota.
*/
size_t sqlite3_quota_fread(void*, size_t, size_t, quota_FILE*);
-size_t sqlite3_quota_fwrite(void*, size_t, size_t, quota_FILE*);
+size_t sqlite3_quota_fwrite(const void*, size_t, size_t, quota_FILE*);
/*
** Flush all written content held in memory buffers out to disk.
void sqlite3_quota_rewind(quota_FILE*);
long sqlite3_quota_ftell(quota_FILE*);
+/*
+** Test the error indicator for the given file.
+**
+** Return non-zero if the error indicator is set.
+*/
+int sqlite3_quota_ferror(quota_FILE*);
+
/*
** Truncate a file previously opened by sqlite3_quota_fopen(). Return
** zero on success and non-zero on any kind of failure.
** Any attempt to "truncate" a file to a larger size results in
** undefined behavior.
*/
-int sqlite3_quota_ftrunate(quota_FILE*, sqlite3_int64 newSize);
+int sqlite3_quota_ftruncate(quota_FILE*, sqlite3_int64 newSize);
/*
** Return the last modification time of the opened file, in seconds
*/
sqlite3_int64 sqlite3_quota_file_truesize(quota_FILE*);
+/*
+** Determine the amount of data in bytes available for reading
+** in the given file.
+**
+** Return -1 if the amount cannot be determined for some reason.
+*/
+long sqlite3_quota_file_available(quota_FILE*);
+
/*
** Delete a file from the disk, if that file is under quota management.
** Adjust quotas accordingly.
do_test quota2-2.2 {
set ::quota
} {}
-do_test quota2-2.3 {
+do_test quota2-2.3.1 {
sqlite3_quota_rewind $::h1
+ sqlite3_quota_file_available $::h1
+} {7000}
+do_test quota2-2.3.2 {
set ::x [sqlite3_quota_fread $::h1 1001 7]
string length $::x
} {6006}
+do_test quota2-2.3.3 {
+ sqlite3_quota_file_available $::h1
+} {0}
do_test quota2-2.4 {
string match $::x [string range $::bigtext 0 6005]
} {1}
sqlite3_quota_fseek $::h1 -100 SEEK_END
sqlite3_quota_ftell $::h1
} {6900}
+do_test quota2-2.6.1 {
+ sqlite3_quota_file_available $::h1
+} {100}
do_test quota2-2.7 {
sqlite3_quota_fseek $::h1 -100 SEEK_CUR
sqlite3_quota_ftell $::h1
} {6800}
+do_test quota2-2.7.1 {
+ sqlite3_quota_file_available $::h1
+} {200}
do_test quota2-2.8 {
sqlite3_quota_fseek $::h1 50 SEEK_CUR
sqlite3_quota_ftell $::h1
} {6850}
+do_test quota2-2.8.1 {
+ sqlite3_quota_file_available $::h1
+} {150}
do_test quota2-2.9 {
sqlite3_quota_fseek $::h1 50 SEEK_SET
sqlite3_quota_ftell $::h1
} {50}
+do_test quota2-2.9.1 {
+ sqlite3_quota_file_available $::h1
+} {6950}
do_test quota2-2.10 {
sqlite3_quota_rewind $::h1
sqlite3_quota_ftell $::h1
} {0}
+do_test quota2-2.10.1 {
+ sqlite3_quota_file_available $::h1
+} {7000}
+do_test quota2-2.10.2 {
+ sqlite3_quota_ferror $::h1
+} {0}
do_test quota2-2.11 {
standard_path [sqlite3_quota_dump]
} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}