Add compile-time define to indicate if the VFS supports the concept of a current directory (as WinCE and WinRT do not). Avoid using the GetTempPath and GetFullPathName APIs on WinRT. Some tests still need adjustments.

FossilOrigin-Name: 86c049a171acc3f4a43771f3e7176a90210d7799
This commit is contained in:
mistachkin 2012-03-05 22:52:33 +00:00
parent 9668e24e62
commit c548465435
10 changed files with 90 additions and 24 deletions

View File

@ -1,5 +1,5 @@
C When\screating\sthe\sevent\sused\sto\ssleep\son\sWinRT,\srequest\sthe\sminimum\saccess\srights\srequired\sfor\sthe\sdesired\soperations\son\sit\s(i.e.\sSYNCHRONIZE).
D 2012-03-04T02:56:10.693
C Add\scompile-time\sdefine\sto\sindicate\sif\sthe\sVFS\ssupports\sthe\sconcept\sof\sa\scurrent\sdirectory\s(as\sWinCE\sand\sWinRT\sdo\snot).\s\sAvoid\susing\sthe\sGetTempPath\sand\sGetFullPathName\sAPIs\son\sWinRT.\s\sSome\stests\sstill\sneed\sadjustments.
D 2012-03-05T22:52:33.397
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -131,7 +131,7 @@ F src/btreeInt.h 26d8ca625b141927fe6620c1d2cf58eaf494ca0c
F src/build.c c4d36e527f457f9992a6663365871dfa7c5094b8
F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33
F src/ctime.c 500d019da966631ad957c37705642be87524463b
F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
F src/delete.c 51d32f0a9c880663e54ce309f52e40c325d5e112
F src/expr.c 00675123e0beec98f999aa4594d2cbe1fec33c1b
@ -163,11 +163,11 @@ F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc
F src/mutex_w32.c ddd2a783230e22831ab44fca181b5904e48a7318
F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c
F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1
F src/os_win.c a6f5e7b3aaa40a0f6d48f80ba6a6154eea5524a4
F src/os_win.c 75d5de49067252dbd98fb8b1a2b2fabe7938e53c
F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e
@ -202,7 +202,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
F src/test_config.c a036a69b550ebc477ab9ca2b37269201f888436e
F src/test_config.c f82aa7dd51f42256ac18ffba3217ebffa9db85a3
F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_func.c 6232d722a4ddb193035aa13a03796bf57d6c12fd
@ -603,7 +603,7 @@ F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d
F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0
F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
F test/minmax4.test 536a3360470633a177e42fbc19660d146b51daef
F test/misc1.test 55cb2bfbf4a8cd61f4be1effc30426ad41696bff
F test/misc1.test 889b40722442380a2f6575f30831b32b2372d70e
F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d
F test/misc3.test fe55130a43e444ee75e2156ff75dc96e964b5738
F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6
@ -624,7 +624,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
F test/pager1.test efef0bb4035d7180ec58308f1d449475e4670b48
F test/pager1.test a306c33e6fbc4d0e5e22529381226fb71d2bef43
F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442
@ -718,7 +718,7 @@ F test/tclsqlite.test 1597d353308531527583481d14d9da52ea8ed0af
F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2
F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d
F test/tester.tcl 001051eaf28c1040800f588a64c63e0bd0e1f36b
F test/tester.tcl 31baf0d92ca1151903b56c0e137ef6a038597c21
F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@ -906,7 +906,7 @@ F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839
F test/wal.test edefe316b4125d7f68004ea53c5e73c398d436cc
F test/wal.test 396be04083914d3a2970d4a494e321545026c6e2
F test/wal2.test 8871e7fd2c86711ff415a5817d68ea3101a15312
F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 38df8fc1b49d55b61cb168a61134b4a314a62f21
R bea8bcdd3011a76417163c65bc816faf
P ed603d75941ace159773b1a22ace84d51b630ad5
R 8dc77ea6ed646d5c79820ac4402d9981
U mistachkin
Z e26bbcbaddc8562992c3187976bdb602
Z 687362d63f53a7c55f33c0c80d00dc38

View File

@ -1 +1 @@
ed603d75941ace159773b1a22ace84d51b630ad5
86c049a171acc3f4a43771f3e7176a90210d7799

View File

@ -48,6 +48,9 @@ static const char * const azCompileOpt[] = {
#ifdef SQLITE_COVERAGE_TEST
"COVERAGE_TEST",
#endif
#ifdef SQLITE_CURDIR
"CURDIR",
#endif
#ifdef SQLITE_DEBUG
"DEBUG",
#endif

View File

@ -123,6 +123,14 @@
# define SQLITE_OS_WINRT 0
#endif
/*
** When compiled for WinCE or WinRT, there is no concept of the current
** directory.
*/
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
# define SQLITE_CURDIR 1
#endif
/* If the SET_FULLSYNC macro is not defined above, then make it
** a no-op
*/

View File

@ -405,7 +405,7 @@ static struct win_syscall {
#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \
LPSTR*))aSyscall[24].pCurrent)
#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
{ "GetFullPathNameW", (SYSCALL)GetFullPathNameW, 0 },
#else
{ "GetFullPathNameW", (SYSCALL)0, 0 },
@ -455,7 +455,7 @@ static struct win_syscall {
#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
#if defined(SQLITE_WIN32_HAS_WIDE)
#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
{ "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
#else
{ "GetTempPathW", (SYSCALL)0, 0 },
@ -3123,9 +3123,13 @@ static int getTempname(int nBuf, char *zBuf){
*/
SimulateIOError( return SQLITE_IOERR );
memset(zTempPath, 0, MAX_PATH+2);
if( sqlite3_temp_directory ){
sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
}else if( isNT() ){
}
#if !SQLITE_OS_WINRT
else if( isNT() ){
char *zMulti;
WCHAR zWidePath[MAX_PATH];
osGetTempPathW(MAX_PATH-30, zWidePath);
@ -3150,6 +3154,7 @@ static int getTempname(int nBuf, char *zBuf){
return SQLITE_IOERR_NOMEM;
}
}
#endif
#endif
/* Check that the output buffer is large enough for the temporary file
@ -3552,7 +3557,7 @@ static int winFullPathname(
return SQLITE_OK;
#endif
#if SQLITE_OS_WINCE
#if SQLITE_OS_WINCE || SQLITE_OS_WINRT
SimulateIOError( return SQLITE_ERROR );
UNUSED_PARAMETER(nFull);
/* WinCE has no concept of a relative pathname, or so I am told. */
@ -3560,7 +3565,7 @@ static int winFullPathname(
return SQLITE_OK;
#endif
#if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
int nByte;
void *zConverted;
char *zOut;

View File

@ -57,6 +57,12 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options","casesensitivelike","0",TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_CURDIR
Tcl_SetVar2(interp, "sqlite_options", "curdir", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "curdir", "0", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_DEBUG
Tcl_SetVar2(interp, "sqlite_options", "debug", "1", TCL_GLOBAL_ONLY);
#else

View File

@ -472,6 +472,11 @@ ifcapable subquery {
} {1 2 3 4 5 6 7 8 9 10 11}
}
#
# The following tests can only work if the current SQLite VFS has the concept
# of a current directory.
#
ifcapable curdir {
# Make sure a database connection still works after changing the
# working directory.
#
@ -495,6 +500,7 @@ do_test misc1-14.3 {
execsql {COMMIT}
file exists ./test.db-journal
} {0}
}
# A failed create table should not leave the table in the internal
# data structures. Ticket #238.

View File

@ -524,18 +524,27 @@ db close
# file-system is saved just before the xDelete() call to remove the
# master journal file from the file-system.
#
set pwd [pwd]
testvfs tv -default 1
tv script copy_on_mj_delete
set ::mj_filename_length 0
proc copy_on_mj_delete {method filename args} {
if {[string match *mj* [file tail $filename]]} {
set ::mj_filename_length [string length $filename]
#
# NOTE: Is the file name relative? If so, add the length of the current
# directory.
#
if {[is_relative_file $filename]} {
set ::mj_filename_length \
[expr {[string length $filename] + [string length $::pwd]}]
} else {
set ::mj_filename_length [string length $filename]
}
faultsim_save
}
return SQLITE_OK
}
set pwd [pwd]
foreach {tn1 tcl} {
1 { set prefix "test.db" }
2 {
@ -1001,8 +1010,17 @@ do_test pager1-5.4.1 {
# the master-journal name encoded as utf-8 with no nul term.
#
set mj_pointer [expr {
20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"]
20 + [string length "test.db-mjXXXXXX9XX"]
}]
#
# NOTE: For item 3 above, if the current SQLite VFS lacks the concept of a
# current directory, the length of the current directory name plus 1
# character for the directory separator character are NOT counted as
# part of the total size; otherwise, they are.
#
ifcapable curdir {
set mj_pointer [expr {$mj_pointer + [string length [pwd]] + 1}]
}
expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)}
} 1
do_test pager1-5.4.2 {
@ -1020,8 +1038,17 @@ do_test pager1-5.4.2 {
# written starting at the next (in this case 512 byte) sector boundary.
#
set mj_pointer [expr {
20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"]
20 + [string length "test.db-mjXXXXXX9XX"]
}]
#
# NOTE: If the current SQLite VFS lacks the concept of a current directory,
# the length of the current directory name plus 1 character for the
# directory separator character are NOT counted as part of the total
# size; otherwise, they are.
#
ifcapable curdir {
set mj_pointer [expr {$mj_pointer + [string length [pwd]] + 1}]
}
expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)}
} 1
db close

View File

@ -19,6 +19,7 @@
#
# Commands to manipulate the db and the file-system at a high level:
#
# is_relative_file
# copy_file FROM TO
# delete_file FILENAME
# drop_all_tables ?DB?
@ -193,6 +194,12 @@ proc do_copy_file {force from to} {
}
}
# Check if a file name is relative
#
proc is_relative_file { file } {
return [expr {[file pathtype $file] != "absolute"}]
}
# Delete a file or directory
#
proc delete_file {args} {

View File

@ -1477,7 +1477,11 @@ foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} {
# Test that when 1 or more pages are recovered from a WAL file,
# sqlite3_log() is invoked to report this to the user.
#
set walfile [file nativename [file join [pwd] test.db-wal]]
ifcapable curdir {
set walfile [file nativename [file join [pwd] test.db-wal]]
} else {
set walfile test.db-wal
}
catch {db close}
forcedelete test.db
do_test wal-23.1 {