-C Make\ssure\sthe\squota\slogic\sis\susable\sas\sC++.
-D 2011-12-12T19:47:25.223
+C Enhancements\sto\stest_quota.c:\s\sRemove\sthe\sexternal\sdependency\son\s\nsqlite3_win32_utf8_to_msbc().\s\sAdd\san\sextra\sparameter\sto\squota_fflush()\nthat\swill\salso\sdo\san\sfsync\s(or\sthe\sequivalent).
+D 2011-12-13T23:26:10.637
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
F src/test_osinst.c 62b0b8ef21ce754cc94e17bb42377ed8795dba32
F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
-F src/test_quota.c 5259eaa0c98b1f55cbce1f34ed7043ae9538911e
-F src/test_quota.h 98cb0cdc4b4c0fa917f7f43734127f6d182e94fa
+F src/test_quota.c fc7d4c4f8538396c1b0116efef695f9f33f984e7
+F src/test_quota.h 9ffa1d3ad6d0a6a24e8670ea64b909c717ec3358
F src/test_rtree.c 6d06306e29946dc36f528a3a2cdc3add794656f1
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 46e6571b45c3c58ac131cc38f7d600aa9f75974d
-F test/quota2.test 562b27570d1e0d0606c3769b648e23c72fa3859b
+F test/quota2.test 1b8df088e604f2df573f96e726b5e518cb0cddaa
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
F test/randexpr1.test 1084050991e9ba22c1c10edd8d84673b501cc25a
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P abcb65af4cdd192beaccdbc2109ad45b9e7f9d00
-R 219a0e733f4a37c7491a23e5eb8ab5d1
+P f4534bd3023a599691018f35389a76045e49d831
+R 47ed3793a4d313cda8ae0615d4d258b5
U drh
-Z ccc24742bcaed950386a7bec659a920b
+Z a4d5e00fab55c6c4275b01f8f924030e
-f4534bd3023a599691018f35389a76045e49d831
\ No newline at end of file
+92f4188f90e3cdd71f1457a6e0eb22615e4a54f4
\ No newline at end of file
# endif
#endif
+#if SQLITE_OS_UNIX
+# include <unistd.h>
+#endif
+#if SQLITE_OS_WIN
+# include <windows.h>
+#endif
/*
** Translate UTF8 to MBCS for use in fopen() calls. Return a pointer to the
*/
static char *quota_utf8_to_mbcs(const char *zUtf8){
#if SQLITE_OS_WIN
- extern char *sqlite3_win32_utf8_to_mbcs(const char*);
- return sqlite3_win32_utf8_to_mbcs(zUtf8);
+ int n; /* Bytes in zUtf8 */
+ int nWide; /* number of UTF-16 characters */
+ int nMbcs; /* Bytes of MBCS */
+ LPWSTR zTmpWide; /* The UTF16 text */
+ char *zMbcs; /* The MBCS text */
+ int codepage; /* Code page used by fopen() */
+
+ n = strlen(zUtf8);
+ nWide = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);
+ zTmpWide = sqlite3_malloc( nWide*sizeof(zTmpWide[0]) );
+ if( zTmpWide==0 ) return 0;
+ MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zTmpWide, nWide);
+ codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
+ nMbcs = WideCharToMultiByte(codepage, 0, zTmpWide, nWide, 0, 0, 0, 0);
+ zMbcs = sqlite3_malloc( nMbcs+1 );
+ if( zMbcs ){
+ WideCharToMultiByte(codepage, 0, zTmpWide, nWide, zMbcs, nMbcs, 0, 0);
+ }
+ sqlite3_free(zTmpWide);
+ return zMbcs;
#else
return (char*)zUtf8; /* No-op on unix */
#endif
/*
** Flush memory buffers for a quota_FILE to disk.
*/
-int sqlite3_quota_fflush(quota_FILE *p){
- return fflush(p->f);
+int sqlite3_quota_fflush(quota_FILE *p, int doFsync){
+ int rc;
+ rc = fflush(p->f);
+ if( rc==0 && doFsync ){
+#if SQLITE_OS_UNIX
+ rc = fsync(fileno(p->f));
+#endif
+#if SQLITE_OS_WIN
+ rc = 0==FlushFileBuffers((HANDLE)_fileno(p->f));
+#endif
+ }
+ return rc;
}
/*
}
/*
-** tclcmd: sqlite3_quota_fflush HANDLE
+** tclcmd: sqlite3_quota_fflush HANDLE ?HARDSYNC?
*/
static int test_quota_fflush(
void * clientData,
){
quota_FILE *p;
int rc;
+ int doSync = 0;
- if( objc!=2 ){
- Tcl_WrongNumArgs(interp, 1, objv, "HANDLE");
+ if( objc!=2 && objc!=3 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "HANDLE ?HARDSYNC?");
return TCL_ERROR;
}
p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
- rc = sqlite3_quota_fflush(p);
+ if( objc==3 ){
+ if( Tcl_GetBooleanFromObj(interp, objv[2], &doSync) ) return TCL_ERROR;
+ }
+ rc = sqlite3_quota_fflush(p, doSync);
Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
return TCL_OK;
}
/*
** Flush all written content held in memory buffers out to disk.
-** This is the equivalent of fflush() in the standard library - not
-** an fsync().
+** This is the equivalent of fflush() in the standard library.
+**
+** If the hardSync parameter is true (non-zero) then this routine
+** also forces OS buffers to disk - the equivalent of fsync().
+**
+** This routine return zero on success and non-zero if something goes
+** wrong.
*/
-int sqlite3_quota_fflush(quota_FILE*);
+int sqlite3_quota_fflush(quota_FILE*, int hardSync);
/*
** Close a quota_FILE object and free all associated resources. The
do_test quota2-3.2 {
standard_path [sqlite3_quota_dump]
} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
-do_test quota2-3.3 {
+do_test quota2-3.3a {
+ sqlite3_quota_fflush $::h1 0
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
+do_test quota2-3.3b {
+ sqlite3_quota_fflush $::h1 1
+ standard_path [sqlite3_quota_dump]
+} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}
+do_test quota2-3.3c {
sqlite3_quota_fflush $::h1
standard_path [sqlite3_quota_dump]
} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}