Merge the changes need to compile on WinRT into trunk.

FossilOrigin-Name: 61360ca6ca3448477d5c662d3642beef6dd2079e
This commit is contained in:
drh 2012-06-06 23:23:23 +00:00
commit cc71645bf7
25 changed files with 1141 additions and 332 deletions

View File

@ -15,6 +15,12 @@ USE_AMALGAMATION = 1
#
USE_ICU = 0
# Set this non-0 to compile binaries suitable for the WinRT environment.
# This setting does not apply to any binaries that require Tcl to operate
# properly (i.e. the text fixture, etc).
#
FOR_WINRT = 0
# Set this to non-0 to create and use PDBs.
#
SYMBOLS = 1
@ -32,16 +38,10 @@ SYMBOLS = 1
#
DEBUG = 0
# Version numbers and release number for the SQLite being compiled.
#
VERSION = 3.7
VERSION_NUMBER = 3007009
RELEASE = 3.7.9
# C Compiler and options for use in building executables that
# will run on the platform that is doing the build.
#
BCC = cl.exe
BCC = cl.exe -W3
# C Compile and options for use in building executables that
# will run on the target platform. (BCC and TCC are usually the
@ -49,7 +49,18 @@ BCC = cl.exe
#
TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise
# The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in
# When compiling the library for use in the WinRT environment,
# the following compile-time options must be used as well to
# disable use of Win32 APIs that are not available and to enable
# use of Win32 APIs that are specific to Windows 8 and/or WinRT.
# Also, we need to dynamically link to the MSVC runtime when
# compiling for WinRT.
#
!IF $(FOR_WINRT)!=0
TCC = $(TCC) -DSQLITE_OS_WINRT=1 -MD
!ENDIF
# The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in
# any extension header files by default. For non-amalgamation
# builds, we need to make sure the compiler can find these.
#
@ -64,6 +75,7 @@ TCC = $(TCC) -I$(TOP)\ext\rtree
#
!IF $(DEBUG)==0
TCC = $(TCC) -DNDEBUG
BCC = $(BCC) -DNDEBUG
!ENDIF
!IF $(DEBUG)>1
@ -82,6 +94,7 @@ TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE
# Prevent warnings about "insecure" runtime library functions being used.
#
TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
#
# Use native Win32 heap instead of malloc/free?
@ -194,12 +207,15 @@ TCC = $(TCC) $(OPTS)
# If debugging is enabled, disable all optimizations and enable PDBs.
!IF $(DEBUG)>0
TCC = $(TCC) -Od -D_DEBUG
BCC = $(BCC) -Od -D_DEBUG
!ELSE
TCC = $(TCC) -O2
BCC = $(BCC) -O2
!ENDIF
!IF $(DEBUG)>0 || $(SYMBOLS)!=0
TCC = $(TCC) -Zi
BCC = $(BCC) -Zi
!ENDIF
# If ICU support is enabled, add the compiler options for it.
@ -223,9 +239,18 @@ LTLINKOPTS = /MACHINE:$(PLATFORM)
LTLIBOPTS = /MACHINE:$(PLATFORM)
!ENDIF
# If debugging is enabled, enable PDBs.
# When compiling for use in the WinRT environment, the following
# linker option must be used to mark the executable as runnable
# only in the context of an application container.
#
!IF $(FOR_WINRT)!=0
LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
!ENDIF
# If either debugging or symbols are enabled, enable PDBs.
!IF $(DEBUG)>0 || $(SYMBOLS)!=0
LTLINKOPTS = $(LTLINKOPTS) /DEBUG
BCC = $(BCC) /DEBUG
!ENDIF
# Start with the Tcl related linker options.

View File

@ -1,9 +1,9 @@
C Disable\sFTS\sunicode61\sby\sdefault.\sIt\sis\senabled\sby\sspecifying\scompile\stime\soption\sSQLITE_ENABLE_FTS4_UNICODE61.
D 2012-06-06T19:51:27.734
C Merge\sthe\schanges\sneed\sto\scompile\son\sWinRT\sinto\strunk.
D 2012-06-06T23:23:23.374
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc 0891f992d012d6b2976f86e80a82ae6839fa9ded
F Makefile.msc fd86027849a59a2f621b791b79eabf3f8ffbd684
F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca
F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6
F VERSION 3e857b9b826e818eec9411eafe2c3fa22c1dbb8a
@ -129,7 +129,7 @@ F src/btreeInt.h 38a639c0542c29fe8331a221c4aed0cb8686249e
F src/build.c 47c4506afe4bcb4ed1f4b5357582d1cb3402f8ad
F src/callback.c 0cb4228cdcd827dcc5def98fb099edcc9142dbcd
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33
F src/ctime.c 500d019da966631ad957c37705642be87524463b
F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e
F src/expr.c 06a7733d19dc725dc46ba51afd9feadb4b85d991
@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416
F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d
F src/main.c 41bfe7e14319b44f6322332bce2b48599e524f75
F src/main.c 81e75dd5b37122369927b400b9e1322b73d725a7
F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1
@ -158,21 +158,21 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e
F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553
F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f
F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc
F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33
F src/mutex_w32.c 1170f64d08dc35cd43f6d0bfa833cac5da979279
F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
F src/os.h 59beba555b65a450bd1d804220532971d4299f60
F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757
F src/os_win.c 412d6434133c7c81dc48b7702f3ea5e61c309e5c
F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b
F src/pager.c 9d4d6406512002d9a243ec27b9c01e93fda43e36
F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5
F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60
F src/pragma.c 28d7955a9e9a27d41cb462690228d39e3cec231c
F src/pragma.c eee3e3161f82a1e06f632a8d2a82b29ba3c45889
F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5
F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@ -180,14 +180,14 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd
F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1
F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d
F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b
F src/sqlite.h.in 922d2907cc2b0177b2c4a3b462f04937750d6edd
F src/sqlite.h.in f801a04e1ebd1c7f958017661545422ada06b9ce
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
F src/sqliteInt.h 29b5348f0056d9b46d0bb94d4853db21568afde9
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c fe5406573e1527957e00dcaf51edd9d8bd31b918
F src/test1.c a808bfa548a501b513579bdbaf83901c98e059c9
F src/test1.c fc2acf0a2db517c8d19e5e55bda8e1237db77378
F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf
F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d
F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7
@ -200,7 +200,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16
F src/test_config.c 86c4b1897fab385c949db398995eef3b75a2f1ad
F src/test_config.c 4f7b8030287d62fe56a1d99e68b41760feae381a
F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_func.c 090f2c3339e85c2c964435f99aed6f3da9d59525
@ -296,8 +296,8 @@ F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f
F test/bc_common.tcl 5c8689cc6d2fb44b7c0968ae4f85eb26d50022fa
F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070
F test/bigfile.test 82dfe93ee7eb9e2e05641afa2b39ffd947a92ff1
F test/bigfile2.test 852f948cb492aadab45b58f4d2f3b0832a115cb0
F test/bigfile.test 8f88b5ef065e31c615c49d725ede94155fbe9609
F test/bigfile2.test 8a3c242c3c3481e7cde5a6ef2a66fdc367a095f7
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bind.test 3c7b320969000c441a70952b0b15938fbb66237c
F test/bindxfer.test efecd12c580c14df5f4ad3b3e83c667744a4f7e0
@ -389,7 +389,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6
F test/e_select.test f5d4b81205701deacfae42051ae200969c41d2c0
F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92
F test/e_update.test 161d5dc6a3ed9dd08f5264d13e20735d7a89f00c
F test/e_uri.test cd2ddb4494c7ebf30b6e3539645bb4e54c0104b9
F test/e_uri.test 32b8e0b99a0e215f25996516c64b90c525810d02
F test/e_vacuum.test 331da289ae186656cf5f2eb27f577a89c0c221af
F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
F test/enc2.test 796c59832e2b9a52842f382ffda8f3e989db03ad
@ -611,7 +611,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
@ -632,7 +632,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 31fef8ff6d5cbb4643f430e31756312d361ecfdf
F test/pager1.test 2163c6ef119f497a71a84137c957c63763e640ab
F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442
@ -643,15 +643,15 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/permutations.test ea7b6948eaa22993fcfa662eb704ce29ddb24b2a
F test/pragma.test c51c148defe32bf4a419a522f95d26838d5cf677
F test/pragma.test cb736bcc75b8b629af21ac0ad83ba1d054a2107b
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26
F test/quota.test c2f778dab4c7fb07bcfa962cc5c762f36d8061dc
F test/quota2.test 52175f1c94fb01711da38095a7d3988d0c7d6575
F test/quota.test b5b3eec55a059e0fe493c66c6e27bd2c07676cfd
F test/quota2.test 6d2bd57e8a4da28817f46db9da18551211cd325f
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df
@ -689,7 +689,7 @@ F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977
F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118
F test/shared.test 64fe647f17b2de0622437829a9e9823c20439fce
F test/shared.test 1acdf03fef43ea13604786424de8c4908170eece
F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879
F test/shared3.test ebf77f023f4bdaa8f74f65822b559e86ce5c6257
F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d
@ -698,7 +698,7 @@ F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e
F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d
F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de
F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf
F test/shell1.test 6e3013bc50e2b73f00d17e491f776decc82a71c8
F test/shell1.test 9895ee3013742a02e5afd8d77793729967ffd195
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
@ -734,7 +734,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 a55e066251bc05e26f9da00e76644ab649b26f3c
F test/tester.tcl 2665f64c9ce71944b4d41269114e658fb81bda05
F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@ -898,7 +898,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2
F test/unixexcl.test a9870e46cc6f8390a494513d4f2bf55b5a8b3e46
F test/unordered.test f53095cee37851bf30130fa1bf299a8845e837bb
F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172
F test/uri.test 78e869db1ff6331157b08ef089b1b3e65819c74c
F test/uri.test 63e03df051620a18f794b4f4adcdefb3c23b6751
F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae
F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d
F test/vacuum2.test af432e6e3bfc0ea20a80cb86a03c7d9876d38324
@ -925,7 +925,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 b3d28d655371bf3f6500c679f526e9860544fe70
F test/wal.test a040047d7f2b9f34bc4d597964e5e7c09609c635
F test/wal2.test d5021064bebfc717fe2bf4db2536ea030b76a773
F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 790f76a5898dad1a955d40edddf11f7b0fec0ccd
R b3b020dfaa40a6b886085c7104befb05
U dan
Z abcc18c27a4be2466863f9b79938e60e
P eccd6b6580637084495b80e9232262188ba0cf8d 8e8590a4dc8d9b0fa12ce288cdfd0146223fee6c
R e54f5d64d1e08d0a0f77f7e82ee4ca4c
U drh
Z b901cb0ca598db2780e99899aea938ab

View File

@ -1 +1 @@
eccd6b6580637084495b80e9232262188ba0cf8d
61360ca6ca3448477d5c662d3642beef6dd2079e

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

@ -74,6 +74,15 @@ void (*sqlite3IoTrace)(const char*, ...) = 0;
*/
char *sqlite3_temp_directory = 0;
/*
** If the following global variable points to a string which is the
** name of a directory, then that directory will be used to store
** all database files specified with a relative pathname.
**
** See also the "PRAGMA data_store_directory" SQL command.
*/
char *sqlite3_data_directory = 0;
/*
** Initialize SQLite.
**
@ -272,6 +281,18 @@ int sqlite3_shutdown(void){
if( sqlite3GlobalConfig.isMallocInit ){
sqlite3MallocEnd();
sqlite3GlobalConfig.isMallocInit = 0;
#ifndef SQLITE_OMIT_SHUTDOWN_DIRECTORIES
/* The heap subsystem has now been shutdown and these values are supposed
** to be NULL or point to memory that was obtained from sqlite3_malloc(),
** which would rely on that heap subsystem; therefore, make sure these
** values cannot refer to heap memory that was just invalidated when the
** heap subsystem was shutdown. This is only done if the current call to
** this function resulted in the heap subsystem actually being shutdown.
*/
sqlite3_data_directory = 0;
sqlite3_temp_directory = 0;
#endif
}
if( sqlite3GlobalConfig.isMutexInit ){
sqlite3MutexEnd();

View File

@ -109,18 +109,24 @@ static int winMutex_isInit = 0;
*/
static long winMutex_lock = 0;
extern void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
static int winMutexInit(void){
/* The first to increment to 1 does actual initialization */
if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
int i;
for(i=0; i<ArraySize(winMutex_staticMutexes); i++){
#if SQLITE_OS_WINRT
InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);
#else
InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);
#endif
}
winMutex_isInit = 1;
}else{
/* Someone else is in the process of initing the static mutexes */
while( !winMutex_isInit ){
Sleep(1);
sqlite3_win32_sleep(1);
}
}
return SQLITE_OK;
@ -194,7 +200,11 @@ static sqlite3_mutex *winMutexAlloc(int iType){
#ifdef SQLITE_DEBUG
p->id = iType;
#endif
#if SQLITE_OS_WINRT
InitializeCriticalSectionEx(&p->mutex, 0, 0);
#else
InitializeCriticalSection(&p->mutex);
#endif
}
break;
}

View File

@ -65,13 +65,11 @@
# endif
#endif
/*
** Define the maximum size of a temporary filename
*/
#if SQLITE_OS_WIN
# include <windows.h>
# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50)
#elif SQLITE_OS_OS2
#endif
#if SQLITE_OS_OS2
# if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY)
# include <os2safe.h> /* has to be included before os2.h for linking to work */
# endif
@ -84,9 +82,6 @@
# define INCL_DOSSEMAPHORES
# include <os2.h>
# include <uconv.h>
# define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP)
#else
# define SQLITE_TEMPNAME_SIZE 200
#endif
/*
@ -120,6 +115,22 @@
# define SQLITE_OS_WINCE 0
#endif
/*
** Determine if we are dealing with WindowsRT (Metro) as this has a different and
** incompatible API from win32.
*/
#if !defined(SQLITE_OS_WINRT)
# 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
*/

File diff suppressed because it is too large Load Diff

View File

@ -804,6 +804,50 @@ void sqlite3Pragma(
}
}else
#if SQLITE_OS_WIN
/*
** PRAGMA data_store_directory
** PRAGMA data_store_directory = ""|"directory_name"
**
** Return or set the local value of the data_store_directory flag. Changing
** the value sets a specific directory to be used for database files that
** were specified with a relative pathname. Setting to a null string reverts
** to the default database directory, which for database files specified with
** a relative path will probably be based on the current directory for the
** process. Database file specified with an absolute path are not impacted
** by this setting, regardless of its value.
**
*/
if( sqlite3StrICmp(zLeft, "data_store_directory")==0 ){
if( !zRight ){
if( sqlite3_data_directory ){
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME,
"data_store_directory", SQLITE_STATIC);
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_data_directory, 0);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
}
}else{
#ifndef SQLITE_OMIT_WSD
if( zRight[0] ){
int res;
rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
if( rc!=SQLITE_OK || res==0 ){
sqlite3ErrorMsg(pParse, "not a writable directory");
goto pragma_out;
}
}
sqlite3_free(sqlite3_data_directory);
if( zRight[0] ){
sqlite3_data_directory = sqlite3_mprintf("%s", zRight);
}else{
sqlite3_data_directory = 0;
}
#endif /* SQLITE_OMIT_WSD */
}
}else
#endif
#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
# if defined(__APPLE__)
# define SQLITE_ENABLE_LOCKING_STYLE 1

View File

@ -2165,12 +2165,12 @@ char *sqlite3_vsnprintf(int,char*,const char*, va_list);
** implementation of these routines to be omitted. That capability
** is no longer provided. Only built-in memory allocators can be used.
**
** The Windows OS interface layer calls
** Prior to SQLite version 3.7.10, the Windows OS interface layer called
** the system malloc() and free() directly when converting
** filenames between the UTF-8 encoding used by SQLite
** and whatever filename encoding is used by the particular Windows
** installation. Memory allocation errors are detected, but
** they are reported back as [SQLITE_CANTOPEN] or
** installation. Memory allocation errors were detected, but
** they were reported back as [SQLITE_CANTOPEN] or
** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
**
** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
@ -4447,6 +4447,42 @@ int sqlite3_sleep(int);
*/
SQLITE_EXTERN char *sqlite3_temp_directory;
/*
** CAPI3REF: Name Of The Folder Holding Database Files
**
** ^(If this global variable is made to point to a string which is
** the name of a folder (a.k.a. directory), then all database files
** specified with a relative pathname and created or accessed by
** SQLite when using a built-in [sqlite3_vfs | VFS] will be assumed
** to be relative to that directory.)^ ^If this variable is a NULL
** pointer, then SQLite assumes that all database files specified
** with a relative pathname are relative to the current directory
** for the process.
**
** Changing the value of this variable while a database connection is
** open can result in a corrupt database.
**
** It is not safe to read or modify this variable in more than one
** thread at a time. It is not safe to read or modify this variable
** if a [database connection] is being used at the same time in a separate
** thread.
** It is intended that this variable be set once
** as part of process initialization and before any SQLite interface
** routines have been called and that this variable remain unchanged
** thereafter.
**
** ^The [data_store_directory pragma] may modify this variable and cause
** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
** the [data_store_directory pragma] always assumes that any string
** that this variable points to is held in memory obtained from
** [sqlite3_malloc] and the pragma may attempt to free that memory
** using [sqlite3_free].
** Hence, if this variable is modified directly, either it should be
** made NULL or made to point to memory obtained from [sqlite3_malloc]
** or else the use of the [data_store_directory pragma] should be avoided.
*/
SQLITE_EXTERN char *sqlite3_data_directory;
/*
** CAPI3REF: Test For Auto-Commit Mode
** KEYWORDS: {autocommit mode}

View File

@ -6287,6 +6287,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
(char*)&sqlite_static_bind_nbyte, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_temp_directory",
(char*)&sqlite3_temp_directory, TCL_LINK_STRING);
Tcl_LinkVar(interp, "sqlite_data_directory",
(char*)&sqlite3_data_directory, TCL_LINK_STRING);
Tcl_LinkVar(interp, "bitmask_size",
(char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY);
Tcl_LinkVar(interp, "sqlite_sync_count",

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

@ -15,6 +15,8 @@
# $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $
#
if {[file exists skip-big-file]} return
set testdir [file dirname $argv0]
source $testdir/tester.tcl

View File

@ -13,6 +13,8 @@
# files larger than 4GB.
#
if {[file exists skip-big-file]} return
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix bigfile2

View File

@ -131,10 +131,10 @@ sqlite3_config_uri 1
if {$tcl_platform(platform) == "unix"} {
set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
foreach {tn uri error} "
1 {file://localhost[get_pwd]/test.db} {not an error}
2 {file://[get_pwd]/test.db} {not an error}
3 {file://x[get_pwd]/test.db} {invalid uri authority: x}
4 {file://invalid[get_pwd]/test.db} {invalid uri authority: invalid}
1 {file://localhost[test_pwd /]test.db} {not an error}
2 {file://[test_pwd /]test.db} {not an error}
3 {file://x[test_pwd /]test.db} {invalid uri authority: x}
4 {file://invalid[test_pwd /]test.db} {invalid uri authority: invalid}
" {
do_test 2.$tn {
set DB [sqlite3_open_v2 $uri $flags ""]
@ -153,9 +153,9 @@ if {$tcl_platform(platform) == "unix"} {
# parameters passed through to the VFS xOpen() methods.
#
foreach {tn uri parse} "
1 {file:test.db#abc} {[get_pwd]/test.db {}}
2 {file:test.db?a=b#abc} {[get_pwd]/test.db {a b}}
3 {file:test.db?a=b#?c=d} {[get_pwd]/test.db {a b}}
1 {file:test.db#abc} {[test_pwd / {}]test.db {}}
2 {file:test.db?a=b#abc} {[test_pwd / {}]test.db {a b}}
3 {file:test.db?a=b#?c=d} {[test_pwd / {}]test.db {a b}}
" {
do_filepath_test 3.$tn { parse_uri $uri } $parse
}
@ -171,7 +171,7 @@ foreach {tn uri parse} "
# path is interpreted as a relative path.
#
foreach {tn uri parse} "
1 {file:test.db} {[get_pwd]/test.db {}}
1 {file:test.db} {[test_pwd / {}]test.db {}}
2 {file:/test.db} {/test.db {}}
3 {file:///test.db} {/test.db {}}
4 {file://localhost/test.db} {/test.db {}}

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 [get_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 [get_pwd]
foreach {tn1 tcl} {
1 { set prefix "test.db" }
2 {
@ -1019,8 +1028,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 [get_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 [get_pwd]] + 1}]
}
expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)}
} 1
do_test pager1-5.4.2 {
@ -1038,8 +1056,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 [get_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 [get_pwd]] + 1}]
}
expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)}
} 1
db close

View File

@ -40,6 +40,7 @@ do_not_use_codec
# pragma-15.*: Test that the value set using the cache_size pragma is not
# reset when the schema is reloaded.
# pragma-16.*: Test proxy locking
# pragma-20.*: Test data_store_directory.
#
ifcapable !pragma {
@ -1510,5 +1511,47 @@ do_test pragma-19.5 {
file tail [lindex [execsql {PRAGMA filename}] 0]
} {test.db}
if {$tcl_platform(platform)=="windows"} {
# Test data_store_directory pragma
#
db close
sqlite3 db test.db
file mkdir data_dir
do_test pragma-20.1 {
catchsql {PRAGMA data_store_directory}
} {0 {}}
do_test pragma-20.2 {
set pwd [string map {' ''} [file nativename [get_pwd]]]
catchsql "PRAGMA data_store_directory='$pwd';"
} {0 {}}
do_test pragma-20.3 {
catchsql {PRAGMA data_store_directory}
} [list 0 [list [file nativename [get_pwd]]]]
do_test pragma-20.4 {
set pwd [string map {' ''} [file nativename \
[file join [get_pwd] data_dir]]]
catchsql "PRAGMA data_store_directory='$pwd';"
} {0 {}}
do_test pragma-20.5 {
sqlite3 db2 test2.db
catchsql "PRAGMA database_list;" db2
} [list 0 [list 0 main [file nativename \
[file join [get_pwd] data_dir test2.db]]]]
catch {db2 close}
do_test pragma-20.6 {
sqlite3 db2 [file join [get_pwd] test2.db]
catchsql "PRAGMA database_list;" db2
} [list 0 [list 0 main [file nativename \
[file join [get_pwd] test2.db]]]]
catch {db2 close}
do_test pragma-20.7 {
catchsql "PRAGMA data_store_directory='';"
} {0 {}}
do_test pragma-20.8 {
catchsql {PRAGMA data_store_directory}
} {0 {}}
forcedelete data_dir
} ;# endif windows
finish_test

View File

@ -12,6 +12,13 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_CURDIR is not defined, omit this file.
ifcapable !curdir {
finish_test
return
}
source $testdir/malloc_common.tcl
unset -nocomplain defaultVfs

View File

@ -12,6 +12,13 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_CURDIR is not defined, omit this file.
ifcapable !curdir {
finish_test
return
}
source $testdir/malloc_common.tcl
db close

View File

@ -904,9 +904,11 @@ do_test shared-$av.11.8 {
set res
} {1 4 {} 7}
if {[llength [info command sqlite3_shared_cache_report]]==1} {
do_test shared-$av.11.9 {
string tolower [sqlite3_shared_cache_report]
} [string tolower [list [file nativename [file normalize test.db]] 2]]
ifcapable curdir {
do_test shared-$av.11.9 {
string tolower [sqlite3_shared_cache_report]
} [string tolower [list [file nativename [file normalize test.db]] 2]]
}
}
do_test shared-$av.11.11 {

View File

@ -283,7 +283,7 @@ do_test shell1-3.2.4 {
# .databases List names and files of attached databases
do_test shell1-3.3.1 {
catchcmd "-csv test.db" ".databases"
} "/0 +.*main +[string map {/ .} [string range [pwd] 0 10]].*/"
} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/"
do_test shell1-3.3.2 {
# too many arguments
catchcmd "test.db" ".databases BAD"

View File

@ -19,6 +19,8 @@
#
# Commands to manipulate the db and the file-system at a high level:
#
# is_relative_file
# test_pwd
# get_pwd
# copy_file FROM TO
# delete_file FILENAME
@ -212,6 +214,34 @@ 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"}]
}
# If the VFS supports using the current directory, returns [pwd];
# otherwise, it returns only the provided suffix string (which is
# empty by default).
#
proc test_pwd { args } {
if {[llength $args] > 0} {
set suffix1 [lindex $args 0]
if {[llength $args] > 1} {
set suffix2 [lindex $args 1]
} else {
set suffix2 $suffix1
}
} else {
set suffix1 ""; set suffix2 ""
}
ifcapable curdir {
return "[get_pwd]$suffix1"
} else {
return $suffix2
}
}
# Delete a file or directory
#
proc delete_file {args} {

View File

@ -52,11 +52,24 @@ foreach {tn uri file} {
16 file://localhostPWD/test.db%3Fhello test.db?hello
} {
ifcapable !curdir { if {$tn==3} break }
if {$tcl_platform(platform)=="windows"} {
#
# NOTE: Due to limits on legal characters for file names imposed by
# Windows, we must skip the final two tests here (i.e. the
# question mark is illegal in a file name on Windows).
#
if {$tn>14} break
set uri [string map [list PWD /[get_pwd]] $uri]
#
# NOTE: On Windows, we need to account for the fact that the current
# directory does not start with a forward slash.
#
set uri [string map [list PWD/ /[test_pwd /]] $uri]
} else {
set uri [string map [list PWD [get_pwd]] $uri]
set uri [string map [list PWD/ [test_pwd /]] $uri]
}
if {[file isdir $file]} {error "$file is a directory"}

View File

@ -1478,7 +1478,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 [get_pwd] test.db-wal]]
ifcapable curdir {
set walfile [file nativename [file join [get_pwd] test.db-wal]]
} else {
set walfile test.db-wal
}
catch {db close}
forcedelete test.db
do_test wal-23.1 {