From 3dcf39afa0ae211375511a04b730142fe1faf172 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Jun 2011 03:36:06 +0000 Subject: [PATCH 01/16] Add a new AWK script in the tool/ folder for converting text files into C string literals. Use it for building sqlite3_analyzer. FossilOrigin-Name: dcb46d3f68e219a84c67c7ffef26fd2076a0ba28 --- Makefile.msc | 2 +- main.mk | 9 ++------- manifest | 15 ++++++++------- manifest.uuid | 2 +- tool/tostr.awk | 9 +++++++++ 5 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 tool/tostr.awk diff --git a/Makefile.msc b/Makefile.msc index 1de682b854..1d936f6696 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -837,7 +837,7 @@ test: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\veryquick.test spaceanal_tcl.h: $(TOP)\tool\spaceanal.tcl - $(NAWK) "/^[^#]/ { gsub(/\\/,\"\\\\\\\\\");gsub(/\\\"/,\"\\\\\\\"\");gsub(/^/,\"\\\"\");gsub(/$$/,\"\\n\\\"\");print }" \ + $(NAWK) -f $(TOP)/tool/tostr.awk \ $(TOP)\tool\spaceanal.tcl >spaceanal_tcl.h sqlite3_analyzer.exe: $(TESTFIXTURE_SRC) spaceanal_tcl.h diff --git a/main.mk b/main.mk index ec743be439..24e54ad83d 100644 --- a/main.mk +++ b/main.mk @@ -550,13 +550,8 @@ threadtest: threadtest3$(EXE) sqlite3_analyzer$(EXE): $(TOP)/src/tclsqlite.c sqlite3.c $(TESTSRC) \ $(TOP)/tool/spaceanal.tcl - sed \ - -e '/^#/d' \ - -e 's,\\,\\\\,g' \ - -e 's,",\\",g' \ - -e 's,^,",' \ - -e 's,$$,\\n",' \ - $(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h + $(NAWK) -f $(TOP)/tool/tostr.awk $(TOP)/tool/spaceanal.tcl \ + >spaceanal_tcl.h $(TCCX) $(TCL_FLAGS) -DTCLSH=2 $(TESTFIXTURE_FLAGS) \ -DSQLITE_TEST=1 -DSQLITE_PRIVATE="" \ $(TESTSRC) $(TOP)/src/tclsqlite.c sqlite3.c \ diff --git a/manifest b/manifest index 42f907d912..337be6a351 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C More\stypo\sfixes\sin\sevidence\smarks.\s\sNo\scode\schanges. -D 2011-06-20T23:51:33.581 +C Add\sa\snew\sAWK\sscript\sin\sthe\stool/\sfolder\sfor\sconverting\stext\sfiles\sinto\nC\sstring\sliterals.\s\sUse\sit\sfor\sbuilding\ssqlite3_analyzer. +D 2011-06-21T03:36:06.406 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc c942f2ceb9385d6c75b01ee3d38d8a189fb76e8c +F Makefile.msc 341373786f1481b6027e26162d2a73db4ad12306 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION 3fcdd7fbe3eb282df3978fe77288544543767961 @@ -104,7 +104,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 6de0d92dcae3d399a6bafaeb23b57f6ef0f41955 +F main.mk 4918ba9d27921895ddc6abaeebb43a633f5d23c7 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -944,9 +944,10 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 +F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P bd980be471b185e2dc45875804103d5afc8f78cf -R 129d3396a51cd277a2cd5fd90ed058d9 +P e60eefc76fa5066720d76858f6cfca56365330ee +R 6bcbb640ed0444c63b52a62d6c605768 U drh -Z c467af82d7eff2f784ff6186e148e641 +Z 23ac254af253dc4e456f23427954539d diff --git a/manifest.uuid b/manifest.uuid index df26e53231..55c06d5f0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e60eefc76fa5066720d76858f6cfca56365330ee \ No newline at end of file +dcb46d3f68e219a84c67c7ffef26fd2076a0ba28 \ No newline at end of file diff --git a/tool/tostr.awk b/tool/tostr.awk new file mode 100644 index 0000000000..83c6cc1a50 --- /dev/null +++ b/tool/tostr.awk @@ -0,0 +1,9 @@ +#!/usr/bin/awk +# +# Convert input text into a C string +# +{ + gsub(/\\/,"\\\\"); + gsub(/\"/,"\\\""); + print "\"" $0 "\\n\""; +} From c17d696c14fe0a60c5e75bec3ba85ce0b89a7ee7 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jun 2011 12:47:30 +0000 Subject: [PATCH 02/16] Return an error if localtime_r() fails within one of the date/time functions. Fix for [bd484a090c]. FossilOrigin-Name: 76ae8257efc1df6e20ce5718d4824adbbde423ec --- manifest | 23 ++++---- manifest.uuid | 2 +- src/date.c | 110 ++++++++++++++++++++++++++++++--------- src/main.c | 11 ++++ src/sqlite.h.in | 3 +- src/sqliteInt.h | 1 + src/test1.c | 49 +++++++++++++++++ test/tkt-bd484a090c.test | 42 +++++++++++++++ 8 files changed, 203 insertions(+), 38 deletions(-) create mode 100644 test/tkt-bd484a090c.test diff --git a/manifest b/manifest index 337be6a351..0e3ef5b900 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\sAWK\sscript\sin\sthe\stool/\sfolder\sfor\sconverting\stext\sfiles\sinto\nC\sstring\sliterals.\s\sUse\sit\sfor\sbuilding\ssqlite3_analyzer. -D 2011-06-21T03:36:06.406 +C Return\san\serror\sif\slocaltime_r()\sfails\swithin\sone\sof\sthe\sdate/time\sfunctions.\sFix\sfor\s[bd484a090c]. +D 2011-06-21T12:47:30.109 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b +F src/date.c 1b23db78863495e7ef2f670f6929de43e025d32c F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -146,7 +146,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c d67ea48933e4d63abba00578224a3319e6fbcbe1 +F src/main.c fa654e1802e14a5f6c09c37971c3b69c1001d9c8 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -181,14 +181,14 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 0e0173b3e79d956368013e759f084caa7995ecb1 -F src/sqlite.h.in a4d0baabe4f86b3ab9cf56eda23dfd9d022ece0a +F src/sqlite.h.in 4b7255c10d39c5faf089dbd29cde7c367ff39f1f F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h 7b7ec2394b94fc4516930cd9dae37af0f9312215 +F src/sqliteInt.h a9248d3b0d2b1cf428d8642320fb13044a8888e0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 5db825be61708b1a2b3f8f6e185e9b753829acef -F src/test1.c efca486a25fb894988e7a82e84579a4e57388a02 +F src/test1.c ce2fab9e36932f5771c35291539366c9af229df3 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 @@ -729,6 +729,7 @@ F test/tkt-94c04eaadb.test be5ea61cb04dfdc047d19b5c5a9e75fa3da67a7f F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 F test/tkt-b72787b1.test e6b62b2b2785c04d0d698d6a603507e384165049 +F test/tkt-bd484a090c.test 6db2d385ad47004e091bdda0d7da083365bb10ec F test/tkt-cbd054fa6b.test f14f97ea43662e6f70c9e63287081e8be5d9d589 F test/tkt-d11f09d36e.test fb44f7961aa6d4b632fb7b9768239832210b5fc7 F test/tkt-d82e3f3721.test 731359dfdcdb36fea0559cd33fec39dd0ceae8e6 @@ -947,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P e60eefc76fa5066720d76858f6cfca56365330ee -R 6bcbb640ed0444c63b52a62d6c605768 -U drh -Z 23ac254af253dc4e456f23427954539d +P dcb46d3f68e219a84c67c7ffef26fd2076a0ba28 +R 39f3065d8d058f3e7825e8ebdae8b8f0 +U dan +Z b8411c557308c2ef01e76215d689a36d diff --git a/manifest.uuid b/manifest.uuid index 55c06d5f0e..d75772612e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dcb46d3f68e219a84c67c7ffef26fd2076a0ba28 \ No newline at end of file +76ae8257efc1df6e20ce5718d4824adbbde423ec \ No newline at end of file diff --git a/src/date.c b/src/date.c index b81049aa65..3953b02c71 100644 --- a/src/date.c +++ b/src/date.c @@ -412,12 +412,54 @@ static void clearYMD_HMS_TZ(DateTime *p){ } #ifndef SQLITE_OMIT_LOCALTIME + /* -** Compute the difference (in milliseconds) -** between localtime and UTC (a.k.a. GMT) -** for the time value p where p is in UTC. +** The following three functions - osLocaltime_r(), osLocaltime_s() and +** osLocaltime() - are wrappers around system functions localtime_r(), +** localtime_s() and localtime(), respectively. +** +** If the sqlite3GlobalConfig.bLocaltimeFault variable is true when one +** of the following wrappers is called, it returns an error. */ -static sqlite3_int64 localtimeOffset(DateTime *p){ +#ifndef SQLITE_OMIT_BUILTIN_TEST + +#ifdef HAVE_LOCALTIME_R +static struct tm * osLocaltime_r(time_t *t, struct tm *pTm){ + if( sqlite3GlobalConfig.bLocaltimeFault ) return 0; + return localtime_r(t); +} +#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S +static int osLocaltime_s(time_t *t, struct tm *pTm){ + if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; + return (int)localtime_s(t, pTm); +} +#else +static struct tm * osLocaltime(time_t *t){ + if( sqlite3GlobalConfig.bLocaltimeFault ) return 0; + return localtime(t); +} +#endif + +#else +# define osLocaltime_r(x,y) localtime_r(x,y) +# define osLocaltime_s(x,y) localtime_s(x,y) +# define osLocaltime(x) localtime(x) +#endif + + +/* +** Compute the difference (in milliseconds) between localtime and UTC +** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, +** return this value and set *pRc to SQLITE_OK. +** +** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value +** is undefined in this case. +*/ +static sqlite3_int64 localtimeOffset( + DateTime *p, /* Date at which to calculate offset */ + sqlite3_context *pCtx, /* Write error here if one occurs */ + int *pRc /* OUT: Error code. SQLITE_OK or ERROR */ +){ DateTime x, y; time_t t; x = *p; @@ -440,7 +482,11 @@ static sqlite3_int64 localtimeOffset(DateTime *p){ #ifdef HAVE_LOCALTIME_R { struct tm sLocal; - localtime_r(&t, &sLocal); + if( 0==osLocaltime_r(&t, &sLocal) ){ + sqlite3_result_error(pCtx, "error in localtime_r()", -1); + *pRc = SQLITE_ERROR; + return 0; + } y.Y = sLocal.tm_year + 1900; y.M = sLocal.tm_mon + 1; y.D = sLocal.tm_mday; @@ -451,7 +497,11 @@ static sqlite3_int64 localtimeOffset(DateTime *p){ #elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S { struct tm sLocal; - localtime_s(&sLocal, &t); + if( 0!=osLocaltime_s(&t, &sLocal) ){ + sqlite3_result_error(pCtx, "error in localtime_s()", -1); + *pRc = SQLITE_ERROR; + return 0; + } y.Y = sLocal.tm_year + 1900; y.M = sLocal.tm_mon + 1; y.D = sLocal.tm_mday; @@ -463,14 +513,21 @@ static sqlite3_int64 localtimeOffset(DateTime *p){ { struct tm *pTm; sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); - pTm = localtime(&t); - y.Y = pTm->tm_year + 1900; - y.M = pTm->tm_mon + 1; - y.D = pTm->tm_mday; - y.h = pTm->tm_hour; - y.m = pTm->tm_min; - y.s = pTm->tm_sec; + pTm = osLocaltime(&t); + if( pTm ){ + y.Y = pTm->tm_year + 1900; + y.M = pTm->tm_mon + 1; + y.D = pTm->tm_mday; + y.h = pTm->tm_hour; + y.m = pTm->tm_min; + y.s = pTm->tm_sec; + } sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); + if( !pTm ){ + sqlite3_result_error(pCtx, "error in localtime()", -1); + *pRc = SQLITE_ERROR; + return 0; + } } #endif y.validYMD = 1; @@ -478,6 +535,7 @@ static sqlite3_int64 localtimeOffset(DateTime *p){ y.validJD = 0; y.validTZ = 0; computeJD(&y); + *pRc = SQLITE_OK; return y.iJD - x.iJD; } #endif /* SQLITE_OMIT_LOCALTIME */ @@ -501,9 +559,12 @@ static sqlite3_int64 localtimeOffset(DateTime *p){ ** localtime ** utc ** -** Return 0 on success and 1 if there is any kind of error. +** Return 0 on success and 1 if there is any kind of error. If the error +** is in a system call (i.e. localtime()), then an error message is written +** to context pCtx. If the error is an unrecognized modifier, no error is +** written to pCtx. */ -static int parseModifier(const char *zMod, DateTime *p){ +static int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTime *p){ int rc = 1; int n; double r; @@ -523,9 +584,8 @@ static int parseModifier(const char *zMod, DateTime *p){ */ if( strcmp(z, "localtime")==0 ){ computeJD(p); - p->iJD += localtimeOffset(p); + p->iJD += localtimeOffset(p, pCtx, &rc); clearYMD_HMS_TZ(p); - rc = 0; } break; } @@ -546,11 +606,12 @@ static int parseModifier(const char *zMod, DateTime *p){ else if( strcmp(z, "utc")==0 ){ sqlite3_int64 c1; computeJD(p); - c1 = localtimeOffset(p); - p->iJD -= c1; - clearYMD_HMS_TZ(p); - p->iJD += c1 - localtimeOffset(p); - rc = 0; + c1 = localtimeOffset(p, pCtx, &rc); + if( rc==SQLITE_OK ){ + p->iJD -= c1; + clearYMD_HMS_TZ(p); + p->iJD += c1 - localtimeOffset(p, pCtx, &rc); + } } #endif break; @@ -731,9 +792,8 @@ static int isDate( } } for(i=1; i Date: Tue, 21 Jun 2011 12:53:14 +0000 Subject: [PATCH 03/16] Fix an error made in the previous commit. The parameters to localtime_s() were accidentally reversed. FossilOrigin-Name: 97e86ec6df4d893527fe9f43eb46163d9b06416a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/date.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 0e3ef5b900..e8a4ded64c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\san\serror\sif\slocaltime_r()\sfails\swithin\sone\sof\sthe\sdate/time\sfunctions.\sFix\sfor\s[bd484a090c]. -D 2011-06-21T12:47:30.109 +C Fix\san\serror\smade\sin\sthe\sprevious\scommit.\sThe\sparameters\sto\slocaltime_s()\swere\saccidentally\sreversed. +D 2011-06-21T12:53:14.904 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 1b23db78863495e7ef2f670f6929de43e025d32c +F src/date.c f3711b130f0a95d9b92733dbdaecdacc4ba71f35 F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P dcb46d3f68e219a84c67c7ffef26fd2076a0ba28 -R 39f3065d8d058f3e7825e8ebdae8b8f0 +P 76ae8257efc1df6e20ce5718d4824adbbde423ec +R 9f3386b83f2229ba9b1f406ebc50b4c5 U dan -Z b8411c557308c2ef01e76215d689a36d +Z 7625d40f524bfcbd49390918c2896fb2 diff --git a/manifest.uuid b/manifest.uuid index d75772612e..a80623a83c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76ae8257efc1df6e20ce5718d4824adbbde423ec \ No newline at end of file +97e86ec6df4d893527fe9f43eb46163d9b06416a \ No newline at end of file diff --git a/src/date.c b/src/date.c index 3953b02c71..0bb73560d1 100644 --- a/src/date.c +++ b/src/date.c @@ -429,9 +429,9 @@ static struct tm * osLocaltime_r(time_t *t, struct tm *pTm){ return localtime_r(t); } #elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S -static int osLocaltime_s(time_t *t, struct tm *pTm){ +static int osLocaltime_s(struct tm *pTm, time_t *t){ if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; - return (int)localtime_s(t, pTm); + return (int)localtime_s(pTm, t); } #else static struct tm * osLocaltime(time_t *t){ @@ -497,7 +497,7 @@ static sqlite3_int64 localtimeOffset( #elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S { struct tm sLocal; - if( 0!=osLocaltime_s(&t, &sLocal) ){ + if( 0!=osLocaltime_s(&sLocal, &t) ){ sqlite3_result_error(pCtx, "error in localtime_s()", -1); *pRc = SQLITE_ERROR; return 0; From 7c8b355e65b1749e64330e6d8d602d5d3b1a4192 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jun 2011 13:46:11 +0000 Subject: [PATCH 04/16] Change the error message returned when localtime_r() fails to "local time unavailable". FossilOrigin-Name: 0e82175fd86f0ca5da90676aaee3118a70264d85 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 6 +++--- test/tkt-bd484a090c.test | 12 ++++-------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index e8a4ded64c..3b86500f0f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\serror\smade\sin\sthe\sprevious\scommit.\sThe\sparameters\sto\slocaltime_s()\swere\saccidentally\sreversed. -D 2011-06-21T12:53:14.904 +C Change\sthe\serror\smessage\sreturned\swhen\slocaltime_r()\sfails\sto\s"local\stime\sunavailable". +D 2011-06-21T13:46:11.287 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c f3711b130f0a95d9b92733dbdaecdacc4ba71f35 +F src/date.c 193172e7a5e46b710bbf0f4211583ff6c23c7e21 F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -729,7 +729,7 @@ F test/tkt-94c04eaadb.test be5ea61cb04dfdc047d19b5c5a9e75fa3da67a7f F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 F test/tkt-b72787b1.test e6b62b2b2785c04d0d698d6a603507e384165049 -F test/tkt-bd484a090c.test 6db2d385ad47004e091bdda0d7da083365bb10ec +F test/tkt-bd484a090c.test 60460bf946f79a79712b71f202eda501ca99b898 F test/tkt-cbd054fa6b.test f14f97ea43662e6f70c9e63287081e8be5d9d589 F test/tkt-d11f09d36e.test fb44f7961aa6d4b632fb7b9768239832210b5fc7 F test/tkt-d82e3f3721.test 731359dfdcdb36fea0559cd33fec39dd0ceae8e6 @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 76ae8257efc1df6e20ce5718d4824adbbde423ec -R 9f3386b83f2229ba9b1f406ebc50b4c5 +P 97e86ec6df4d893527fe9f43eb46163d9b06416a +R e0015d917e226c6056689f5a9862debe U dan -Z 7625d40f524bfcbd49390918c2896fb2 +Z 66bfa4b384ab8dfebefd27a1fbb7cf7e diff --git a/manifest.uuid b/manifest.uuid index a80623a83c..d35b4bff4d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -97e86ec6df4d893527fe9f43eb46163d9b06416a \ No newline at end of file +0e82175fd86f0ca5da90676aaee3118a70264d85 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 0bb73560d1..1cf51183e9 100644 --- a/src/date.c +++ b/src/date.c @@ -483,7 +483,7 @@ static sqlite3_int64 localtimeOffset( { struct tm sLocal; if( 0==osLocaltime_r(&t, &sLocal) ){ - sqlite3_result_error(pCtx, "error in localtime_r()", -1); + sqlite3_result_error(pCtx, "local time unavailable", -1); *pRc = SQLITE_ERROR; return 0; } @@ -498,7 +498,7 @@ static sqlite3_int64 localtimeOffset( { struct tm sLocal; if( 0!=osLocaltime_s(&sLocal, &t) ){ - sqlite3_result_error(pCtx, "error in localtime_s()", -1); + sqlite3_result_error(pCtx, "local time unavailable", -1); *pRc = SQLITE_ERROR; return 0; } @@ -524,7 +524,7 @@ static sqlite3_int64 localtimeOffset( } sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); if( !pTm ){ - sqlite3_result_error(pCtx, "error in localtime()", -1); + sqlite3_result_error(pCtx, "local time unavailable", -1); *pRc = SQLITE_ERROR; return 0; } diff --git a/test/tkt-bd484a090c.test b/test/tkt-bd484a090c.test index f917a6946f..3d2b599958 100644 --- a/test/tkt-bd484a090c.test +++ b/test/tkt-bd484a090c.test @@ -27,15 +27,11 @@ do_test 1.2 { sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 1 do_test 2.1 { - foreach {rc msg} [catchsql { SELECT datetime('now', 'localtime') }] {} - set res [string match {error in localtime*()} $msg] - list $rc $res -} {1 1} + catchsql { SELECT datetime('now', 'localtime') } +} {1 {local time unavailable}} do_test 2.2 { - foreach {rc msg} [catchsql { SELECT datetime('now', 'utc') }] {} - set res [string match {error in localtime*()} $msg] - list $rc $res -} {1 1} + catchsql { SELECT datetime('now', 'utc') } +} {1 {local time unavailable}} sqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0 From 8720aeb56415dc9fd985465890fa92766a8ce7e3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Jun 2011 14:35:30 +0000 Subject: [PATCH 05/16] Simplifications to the localtime() interface. Fix the case where localtime_r() is available so that it works. Ticket [bd484a090c8077]. FossilOrigin-Name: 5b68dae320d0fa3dc433826811e5018a47461de7 --- manifest | 14 +++---- manifest.uuid | 2 +- src/date.c | 112 +++++++++++++++++--------------------------------- 3 files changed, 45 insertions(+), 83 deletions(-) diff --git a/manifest b/manifest index 3b86500f0f..c16e50aa12 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\serror\smessage\sreturned\swhen\slocaltime_r()\sfails\sto\s"local\stime\sunavailable". -D 2011-06-21T13:46:11.287 +C Simplifications\sto\sthe\slocaltime()\sinterface.\s\sFix\sthe\scase\swhere\nlocaltime_r()\sis\savailable\sso\sthat\sit\sworks.\s\sTicket\s[bd484a090c8077]. +D 2011-06-21T14:35:30.890 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 193172e7a5e46b710bbf0f4211583ff6c23c7e21 +F src/date.c 2c5b336a05029c1647f7a4fe03d7ee50b9747bba F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 97e86ec6df4d893527fe9f43eb46163d9b06416a -R e0015d917e226c6056689f5a9862debe -U dan -Z 66bfa4b384ab8dfebefd27a1fbb7cf7e +P 0e82175fd86f0ca5da90676aaee3118a70264d85 +R 39249556a57f6de5d465bb75e25a77c9 +U drh +Z f3f5de06e02a4cdc489a3c883165212f diff --git a/manifest.uuid b/manifest.uuid index d35b4bff4d..11d082e2ed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e82175fd86f0ca5da90676aaee3118a70264d85 \ No newline at end of file +5b68dae320d0fa3dc433826811e5018a47461de7 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 1cf51183e9..36503420cd 100644 --- a/src/date.c +++ b/src/date.c @@ -412,41 +412,41 @@ static void clearYMD_HMS_TZ(DateTime *p){ } #ifndef SQLITE_OMIT_LOCALTIME - /* -** The following three functions - osLocaltime_r(), osLocaltime_s() and -** osLocaltime() - are wrappers around system functions localtime_r(), -** localtime_s() and localtime(), respectively. +** The following routine implements the rough equivalent of localtime_r() +** using whatever operating-system specific localtime facility that +** is available. This routine returns 0 on success and +** non-zero on any kind of error. ** -** If the sqlite3GlobalConfig.bLocaltimeFault variable is true when one -** of the following wrappers is called, it returns an error. +** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this +** routine will always fail. */ +int osLocaltime(time_t *t, struct tm *pTm){ + int rc; #ifndef SQLITE_OMIT_BUILTIN_TEST - -#ifdef HAVE_LOCALTIME_R -static struct tm * osLocaltime_r(time_t *t, struct tm *pTm){ - if( sqlite3GlobalConfig.bLocaltimeFault ) return 0; - return localtime_r(t); -} -#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S -static int osLocaltime_s(struct tm *pTm, time_t *t){ if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; - return (int)localtime_s(pTm, t); -} -#else -static struct tm * osLocaltime(time_t *t){ - if( sqlite3GlobalConfig.bLocaltimeFault ) return 0; - return localtime(t); -} #endif - +#ifdef HAVE_LOCALTIME_R + rc = localtime_r(t, pTm)==0; +#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S + rc = localtime_s(pTm, t); #else -# define osLocaltime_r(x,y) localtime_r(x,y) -# define osLocaltime_s(x,y) localtime_s(x,y) -# define osLocaltime(x) localtime(x) + { + struct tm *pX; + sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex_enter(mutex); + pX = localtime(t); + if( pX ) *pTm = *pX; + sqlite3_mutex_leave(mutex); + rc = pX==0; + } #endif + return rc; +} +#endif /* SQLITE_OMIT_LOCALTIME */ +#ifndef SQLITE_OMIT_LOCALTIME /* ** Compute the difference (in milliseconds) between localtime and UTC ** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, @@ -462,6 +462,8 @@ static sqlite3_int64 localtimeOffset( ){ DateTime x, y; time_t t; + struct tm sLocal; + x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ @@ -479,57 +481,17 @@ static sqlite3_int64 localtimeOffset( x.validJD = 0; computeJD(&x); t = (time_t)(x.iJD/1000 - 21086676*(i64)10000); -#ifdef HAVE_LOCALTIME_R - { - struct tm sLocal; - if( 0==osLocaltime_r(&t, &sLocal) ){ - sqlite3_result_error(pCtx, "local time unavailable", -1); - *pRc = SQLITE_ERROR; - return 0; - } - y.Y = sLocal.tm_year + 1900; - y.M = sLocal.tm_mon + 1; - y.D = sLocal.tm_mday; - y.h = sLocal.tm_hour; - y.m = sLocal.tm_min; - y.s = sLocal.tm_sec; + if( osLocaltime(&t, &sLocal) ){ + sqlite3_result_error(pCtx, "local time unavailable", -1); + *pRc = SQLITE_ERROR; + return 0; } -#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S - { - struct tm sLocal; - if( 0!=osLocaltime_s(&sLocal, &t) ){ - sqlite3_result_error(pCtx, "local time unavailable", -1); - *pRc = SQLITE_ERROR; - return 0; - } - y.Y = sLocal.tm_year + 1900; - y.M = sLocal.tm_mon + 1; - y.D = sLocal.tm_mday; - y.h = sLocal.tm_hour; - y.m = sLocal.tm_min; - y.s = sLocal.tm_sec; - } -#else - { - struct tm *pTm; - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); - pTm = osLocaltime(&t); - if( pTm ){ - y.Y = pTm->tm_year + 1900; - y.M = pTm->tm_mon + 1; - y.D = pTm->tm_mday; - y.h = pTm->tm_hour; - y.m = pTm->tm_min; - y.s = pTm->tm_sec; - } - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); - if( !pTm ){ - sqlite3_result_error(pCtx, "local time unavailable", -1); - *pRc = SQLITE_ERROR; - return 0; - } - } -#endif + y.Y = sLocal.tm_year + 1900; + y.M = sLocal.tm_mon + 1; + y.D = sLocal.tm_mday; + y.h = sLocal.tm_hour; + y.m = sLocal.tm_min; + y.s = sLocal.tm_sec; y.validYMD = 1; y.validHMS = 1; y.validJD = 0; From a924acad0fa0cf48026a30093d9c18eae45011be Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Jun 2011 15:01:25 +0000 Subject: [PATCH 06/16] Rework the localtime logic yet again in order to make all branches reachable and to follow GNU standards for HAVE_LOCALTIME_R-type macros. Ticket [bd484a090c8077]. FossilOrigin-Name: 176248095b8056443ebcbff819e575bd100f5e50 --- manifest | 12 +++++----- manifest.uuid | 2 +- src/date.c | 63 +++++++++++++++++++++++++++------------------------ 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index c16e50aa12..a3e25b1a10 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\slocaltime()\sinterface.\s\sFix\sthe\scase\swhere\nlocaltime_r()\sis\savailable\sso\sthat\sit\sworks.\s\sTicket\s[bd484a090c8077]. -D 2011-06-21T14:35:30.890 +C Rework\sthe\slocaltime\slogic\syet\sagain\sin\sorder\sto\smake\sall\sbranches\sreachable\nand\sto\sfollow\sGNU\sstandards\sfor\sHAVE_LOCALTIME_R-type\smacros.\nTicket\s[bd484a090c8077]. +D 2011-06-21T15:01:25.129 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 2c5b336a05029c1647f7a4fe03d7ee50b9747bba +F src/date.c 8eb16dd5c0fea761f65f1ed98b2c2e8fbaea800c F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 0e82175fd86f0ca5da90676aaee3118a70264d85 -R 39249556a57f6de5d465bb75e25a77c9 +P 5b68dae320d0fa3dc433826811e5018a47461de7 +R ed41c3134b790559b6de3aa9dbc8d008 U drh -Z f3f5de06e02a4cdc489a3c883165212f +Z 9cf1abaccd2a2f678b16a61368320667 diff --git a/manifest.uuid b/manifest.uuid index 11d082e2ed..fd448c5742 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5b68dae320d0fa3dc433826811e5018a47461de7 \ No newline at end of file +176248095b8056443ebcbff819e575bd100f5e50 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 36503420cd..c5291b270e 100644 --- a/src/date.c +++ b/src/date.c @@ -50,22 +50,6 @@ #ifndef SQLITE_OMIT_DATETIME_FUNCS -/* -** On recent Windows platforms, the localtime_s() function is available -** as part of the "Secure CRT". It is essentially equivalent to -** localtime_r() available under most POSIX platforms, except that the -** order of the parameters is reversed. -** -** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. -** -** If the user has not indicated to use localtime_r() or localtime_s() -** already, check for an MSVC build environment that provides -** localtime_s(). -*/ -#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ - defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) -#define HAVE_LOCALTIME_S 1 -#endif /* ** A structure for holding a single date and time. @@ -411,6 +395,23 @@ static void clearYMD_HMS_TZ(DateTime *p){ p->validTZ = 0; } +/* +** On recent Windows platforms, the localtime_s() function is available +** as part of the "Secure CRT". It is essentially equivalent to +** localtime_r() available under most POSIX platforms, except that the +** order of the parameters is reversed. +** +** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. +** +** If the user has not indicated to use localtime_r() or localtime_s() +** already, check for an MSVC build environment that provides +** localtime_s(). +*/ +#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \ + defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE) +#define HAVE_LOCALTIME_S 1 +#endif + #ifndef SQLITE_OMIT_LOCALTIME /* ** The following routine implements the rough equivalent of localtime_r() @@ -423,24 +424,28 @@ static void clearYMD_HMS_TZ(DateTime *p){ */ int osLocaltime(time_t *t, struct tm *pTm){ int rc; +#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ + && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) + struct tm *pX; + sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + sqlite3_mutex_enter(mutex); + pX = localtime(t); +#ifndef SQLITE_OMIT_BUILTIN_TEST + if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0; +#endif + if( pX ) *pTm = *pX; + sqlite3_mutex_leave(mutex); + rc = pX==0; +#else #ifndef SQLITE_OMIT_BUILTIN_TEST if( sqlite3GlobalConfig.bLocaltimeFault ) return 1; #endif -#ifdef HAVE_LOCALTIME_R +#if defined(HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R rc = localtime_r(t, pTm)==0; -#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S - rc = localtime_s(pTm, t); #else - { - struct tm *pX; - sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); - sqlite3_mutex_enter(mutex); - pX = localtime(t); - if( pX ) *pTm = *pX; - sqlite3_mutex_leave(mutex); - rc = pX==0; - } -#endif + rc = localtime_s(pTm, t); +#endif /* HAVE_LOCALTIME_R */ +#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */ return rc; } #endif /* SQLITE_OMIT_LOCALTIME */ From 188829b4915be78ead831b9c3d09978cd10351cc Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jun 2011 15:24:30 +0000 Subject: [PATCH 07/16] Fix main.mk so that the "amalgamation-testfixture" target works again. FossilOrigin-Name: 22265323f7785ec5e2afc14a989d53dcbbd36250 --- main.mk | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/main.mk b/main.mk index 24e54ad83d..33b2e6ec14 100644 --- a/main.mk +++ b/main.mk @@ -220,6 +220,7 @@ SRC += \ # Source code to the test files. # TESTSRC = \ + $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c \ $(TOP)/src/test1.c \ $(TOP)/src/test2.c \ @@ -300,7 +301,6 @@ TESTSRC2 = \ $(TOP)/ext/fts3/fts3.c \ $(TOP)/ext/fts3/fts3_aux.c \ $(TOP)/ext/fts3/fts3_expr.c \ - $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_write.c \ $(TOP)/ext/async/sqlite3async.c diff --git a/manifest b/manifest index a3e25b1a10..829d0e7b9f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sthe\slocaltime\slogic\syet\sagain\sin\sorder\sto\smake\sall\sbranches\sreachable\nand\sto\sfollow\sGNU\sstandards\sfor\sHAVE_LOCALTIME_R-type\smacros.\nTicket\s[bd484a090c8077]. -D 2011-06-21T15:01:25.129 +C Fix\smain.mk\sso\sthat\sthe\s"amalgamation-testfixture"\starget\sworks\sagain. +D 2011-06-21T15:24:30.118 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -104,7 +104,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 4918ba9d27921895ddc6abaeebb43a633f5d23c7 +F main.mk d799fb600383cee11fed58876a7cccb749dd2614 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 5b68dae320d0fa3dc433826811e5018a47461de7 -R ed41c3134b790559b6de3aa9dbc8d008 -U drh -Z 9cf1abaccd2a2f678b16a61368320667 +P 176248095b8056443ebcbff819e575bd100f5e50 +R a2592e3234167f1d411e9fcd7ca02e75 +U dan +Z 059270d02719ec3f38fe6aac1552df07 diff --git a/manifest.uuid b/manifest.uuid index fd448c5742..4330c57526 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -176248095b8056443ebcbff819e575bd100f5e50 \ No newline at end of file +22265323f7785ec5e2afc14a989d53dcbbd36250 \ No newline at end of file From dec6f79d40ae55450583d268583c164289dd8274 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jun 2011 15:27:54 +0000 Subject: [PATCH 08/16] Add a missing initializer for sqlite3GlobalConfig.bLocaltimeFault. FossilOrigin-Name: 7fe8ba2ec762d258b04e775766c82e5e541ab5d1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/global.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 829d0e7b9f..a3c39c6b24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smain.mk\sso\sthat\sthe\s"amalgamation-testfixture"\starget\sworks\sagain. -D 2011-06-21T15:24:30.118 +C Add\sa\smissing\sinitializer\sfor\ssqlite3GlobalConfig.bLocaltimeFault. +D 2011-06-21T15:27:54.672 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -137,7 +137,7 @@ F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 9fabba17a4d4778dc660f0cb9d781fc86d7b9d41 F src/func.c 59bb046d7e3df1ab512ac339ccb0a6f996a17cb7 -F src/global.c 29bfb85611dd816b04f10fba0ca910366e128d38 +F src/global.c c70a46f28680f8d7c097dbc0430ccf3b932e90b0 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 176248095b8056443ebcbff819e575bd100f5e50 -R a2592e3234167f1d411e9fcd7ca02e75 +P 22265323f7785ec5e2afc14a989d53dcbbd36250 +R cc5ee80d3aa17b5739adb078a4e9f0a0 U dan -Z 059270d02719ec3f38fe6aac1552df07 +Z 62c65b0f07c403eb99ee87579e49f66f diff --git a/manifest.uuid b/manifest.uuid index 4330c57526..38c6fb4401 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -22265323f7785ec5e2afc14a989d53dcbbd36250 \ No newline at end of file +7fe8ba2ec762d258b04e775766c82e5e541ab5d1 \ No newline at end of file diff --git a/src/global.c b/src/global.c index f01eaa8f4a..69daa5e9f8 100644 --- a/src/global.c +++ b/src/global.c @@ -169,6 +169,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { 0, /* nRefInitMutex */ 0, /* xLog */ 0, /* pLogArg */ + 0, /* bLocaltimeFault */ }; From 0d37f58184fda43edd940f1253f9048db78e4a48 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jun 2011 15:38:05 +0000 Subject: [PATCH 09/16] Initialize a variable introduced as part of the fix for [bd484a090c8077] in order to silence a compiler warning. FossilOrigin-Name: 6b9877fa43bf29a9740285f0c40a6e6cf21f8190 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/date.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index a3c39c6b24..c3455967e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\sinitializer\sfor\ssqlite3GlobalConfig.bLocaltimeFault. -D 2011-06-21T15:27:54.672 +C Initialize\sa\svariable\sintroduced\sas\spart\sof\sthe\sfix\sfor\s[bd484a090c8077]\sin\sorder\sto\ssilence\sa\scompiler\swarning. +D 2011-06-21T15:38:05.427 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 8eb16dd5c0fea761f65f1ed98b2c2e8fbaea800c +F src/date.c e4df48782b3fa3d99ed6c842d45645e22347b1d4 F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 22265323f7785ec5e2afc14a989d53dcbbd36250 -R cc5ee80d3aa17b5739adb078a4e9f0a0 +P 7fe8ba2ec762d258b04e775766c82e5e541ab5d1 +R 7279502c00f0720017c3da8a6b7b8429 U dan -Z 62c65b0f07c403eb99ee87579e49f66f +Z f96fb31e69ea5b6b58c1071e1a171626 diff --git a/manifest.uuid b/manifest.uuid index 38c6fb4401..aacf143b55 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fe8ba2ec762d258b04e775766c82e5e541ab5d1 \ No newline at end of file +6b9877fa43bf29a9740285f0c40a6e6cf21f8190 \ No newline at end of file diff --git a/src/date.c b/src/date.c index c5291b270e..3065a320d5 100644 --- a/src/date.c +++ b/src/date.c @@ -469,6 +469,9 @@ static sqlite3_int64 localtimeOffset( time_t t; struct tm sLocal; + /* Initialize the contents of sLocal to avoid a compiler warning. */ + memset(&sLocal, 0, sizeof(sLocal)); + x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ From 1f93a0807079f7242a2ee63045ec47492348ff9b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 21 Jun 2011 15:54:24 +0000 Subject: [PATCH 10/16] Give the osLocaltime() function file scope in date.c. FossilOrigin-Name: 1577484595b5e5aab93722d76b273c911a04dc2c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c3455967e0..ec98e9f825 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initialize\sa\svariable\sintroduced\sas\spart\sof\sthe\sfix\sfor\s[bd484a090c8077]\sin\sorder\sto\ssilence\sa\scompiler\swarning. -D 2011-06-21T15:38:05.427 +C Give\sthe\sosLocaltime()\sfunction\sfile\sscope\sin\sdate.c. +D 2011-06-21T15:54:24.112 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c e4df48782b3fa3d99ed6c842d45645e22347b1d4 +F src/date.c d3c11de76392ea62637bfac0f4655889fc2f5a85 F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21 F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 7fe8ba2ec762d258b04e775766c82e5e541ab5d1 -R 7279502c00f0720017c3da8a6b7b8429 -U dan -Z f96fb31e69ea5b6b58c1071e1a171626 +P 6b9877fa43bf29a9740285f0c40a6e6cf21f8190 +R 3fbca61c030ab09b1bb1127ca7da2d34 +U drh +Z fa6d47f6a0dfe450fcd5e2c9c8154b97 diff --git a/manifest.uuid b/manifest.uuid index aacf143b55..d848315029 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b9877fa43bf29a9740285f0c40a6e6cf21f8190 \ No newline at end of file +1577484595b5e5aab93722d76b273c911a04dc2c \ No newline at end of file diff --git a/src/date.c b/src/date.c index 3065a320d5..c0744e8c72 100644 --- a/src/date.c +++ b/src/date.c @@ -422,7 +422,7 @@ static void clearYMD_HMS_TZ(DateTime *p){ ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this ** routine will always fail. */ -int osLocaltime(time_t *t, struct tm *pTm){ +static int osLocaltime(time_t *t, struct tm *pTm){ int rc; #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \ && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S) From 29ebea863ced1bf5f0ed28413d274b058d44abaf Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 21 Jun 2011 18:12:07 +0000 Subject: [PATCH 11/16] Updates to nmake makefile to allow options to be passed to lib.exe. FossilOrigin-Name: 9eac4a6bbe111d951ad23395ba82c868473c5b9b --- Makefile.msc | 7 ++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 1d936f6696..a6d1bf4c2f 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -114,6 +114,7 @@ LTLINK = $(TCC) -Fe$@ # to deduce the binary type based on the object files. !IF "$(PLATFORM)"!="" LTLINKOPTS = /MACHINE:$(PLATFORM) +LTLIBOPTS = /MACHINE:$(PLATFORM) !ENDIF # nawk compatible awk. @@ -441,10 +442,10 @@ EXTHDR = $(EXTHDR) \ all: libsqlite3.lib sqlite3.exe libtclsqlite3.lib libsqlite3.lib: $(LIBOBJ) - $(LTLIB) -OUT:$@ $(LIBOBJ) $(TLIBS) + $(LTLIB) $(LTLIBOPTS) /OUT:$@ $(LIBOBJ) $(TLIBS) libtclsqlite3.lib: tclsqlite.lo libsqlite3.lib - $(LTLIB) /LIBPATH:$(TCLLIBDIR) -OUT:$@ tclsqlite.lo libsqlite3.lib $(LIBTCL:tcl=tclstub) $(TLIBS) + $(LTLIB) $(LTLIBOPTS) /LIBPATH:$(TCLLIBDIR) /OUT:$@ tclsqlite.lo libsqlite3.lib $(LIBTCL:tcl=tclstub) $(TLIBS) sqlite3.exe: $(TOP)\src\shell.c libsqlite3.lib sqlite3.h $(LTLINK) $(READLINE_FLAGS) \ @@ -871,4 +872,4 @@ sqlite3.def: libsqlite3.lib | sort >>sqlite3.def sqlite3.dll: $(LIBOBJ) sqlite3.def - link /DLL /OUT:$@ /DEF:sqlite3.def $(LIBOBJ) + link $(LTLINKOPTS) /DLL /DEF:sqlite3.def /OUT:$@ $(LIBOBJ) diff --git a/manifest b/manifest index ec98e9f825..b2e0dd90ab 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Give\sthe\sosLocaltime()\sfunction\sfile\sscope\sin\sdate.c. -D 2011-06-21T15:54:24.112 +C Updates\sto\snmake\smakefile\sto\sallow\soptions\sto\sbe\spassed\sto\slib.exe. +D 2011-06-21T18:12:07.861 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 341373786f1481b6027e26162d2a73db4ad12306 +F Makefile.msc 11082f65b452b908d93013292c17850378c39284 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION 3fcdd7fbe3eb282df3978fe77288544543767961 @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 6b9877fa43bf29a9740285f0c40a6e6cf21f8190 -R 3fbca61c030ab09b1bb1127ca7da2d34 -U drh -Z fa6d47f6a0dfe450fcd5e2c9c8154b97 +P 1577484595b5e5aab93722d76b273c911a04dc2c +R f7161c21d188b4f81e0b1fd792d695ed +U shaneh +Z e880ef5fa1c4608e76d3b05c69240aa9 diff --git a/manifest.uuid b/manifest.uuid index d848315029..7b2af80620 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1577484595b5e5aab93722d76b273c911a04dc2c \ No newline at end of file +9eac4a6bbe111d951ad23395ba82c868473c5b9b \ No newline at end of file From 5550517e2b594688055cbaab90ae5dcae5734315 Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 21 Jun 2011 19:30:19 +0000 Subject: [PATCH 12/16] Update a few of the uri tests to work on Windows. FossilOrigin-Name: a2a0cd4aa4a6723a849bbba590c22fd065fab55e --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/e_uri.test | 46 ++++++++++++++++++++++------------------------ test/tester.tcl | 13 +++++++++++++ 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index b2e0dd90ab..3a9e0a51a3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\snmake\smakefile\sto\sallow\soptions\sto\sbe\spassed\sto\slib.exe. -D 2011-06-21T18:12:07.861 +C Update\sa\sfew\sof\sthe\suri\stests\sto\swork\son\sWindows. +D 2011-06-21T19:30:19.621 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -382,7 +382,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test 7ac53674e822d4d77bbb4a9a4aaefa5fdc9e493f F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test b926341a65955d69a6375c9eb4fd82e7089bc83a -F test/e_uri.test 8b943bc63cd1abb037430214cdb618422e6bf7d6 +F test/e_uri.test 6f35b491f80dac005c8144f38b2dfb4d96483596 F test/e_vacuum.test 6c09c2af7f2f140518f371c5342100118f779dcf F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 @@ -695,7 +695,7 @@ F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 -F test/tester.tcl 78e63a11eaaec5c2b3c74977d61bf70666d8393f +F test/tester.tcl 7c02f342a92aa161d13ab5241413e341039c14d7 F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 1577484595b5e5aab93722d76b273c911a04dc2c -R f7161c21d188b4f81e0b1fd792d695ed +P 9eac4a6bbe111d951ad23395ba82c868473c5b9b +R cb165167c8ffaaf3fa41940019e90c06 U shaneh -Z e880ef5fa1c4608e76d3b05c69240aa9 +Z 2a57b2d9aba31bd124d18eb8ab4bf292 diff --git a/manifest.uuid b/manifest.uuid index 7b2af80620..40cb51dc84 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9eac4a6bbe111d951ad23395ba82c868473c5b9b \ No newline at end of file +a2a0cd4aa4a6723a849bbba590c22fd065fab55e \ No newline at end of file diff --git a/test/e_uri.test b/test/e_uri.test index b6ad54ea03..5275ec1b54 100644 --- a/test/e_uri.test +++ b/test/e_uri.test @@ -121,6 +121,10 @@ if {$tcl_platform(platform) == "unix"} { sqlite3_close $DB } +# ensure uri processing enabled for the rest of the tests +sqlite3_shutdown +sqlite3_config_uri 1 + # EVIDENCE-OF: R-17482-00398 If the authority is not an empty string or # "localhost", an error is returned to the caller. # @@ -144,18 +148,16 @@ if {$tcl_platform(platform) == "unix"} { # EVIDENCE-OF: R-45981-25528 The fragment component of a URI, if # present, is ignored. # -# It is difficult to test that something is ignore correctly. So these tests +# It is difficult to test that something is ignored correctly. So these tests # just show that adding a fragment does not interfere with the pathname or # parameters passed through to the VFS xOpen() methods. # -if {$tcl_platform(platform) == "unix"} { - foreach {tn uri parse} " - 1 {file:test.db#abc} {[pwd]/test.db {}} - 2 {file:test.db?a=b#abc} {[pwd]/test.db {a b}} - 3 {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}} - " { - do_test 3.$tn { parse_uri $uri } $parse - } +foreach {tn uri parse} " + 1 {file:test.db#abc} {[pwd]/test.db {}} + 2 {file:test.db?a=b#abc} {[pwd]/test.db {a b}} + 3 {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}} +" { + do_filepath_test 3.$tn { parse_uri $uri } $parse } # EVIDENCE-OF: R-62557-09390 SQLite uses the path component of the URI @@ -168,16 +170,14 @@ if {$tcl_platform(platform) == "unix"} { # (meaning that the authority section is omitted from the URI) then the # path is interpreted as a relative path. # -if {$tcl_platform(platform) == "unix"} { - foreach {tn uri parse} " - 1 {file:test.db} {[pwd]/test.db {}} - 2 {file:/test.db} {/test.db {}} - 3 {file:///test.db} {/test.db {}} - 4 {file://localhost/test.db} {/test.db {}} - 5 {file:/a/b/c/test.db} {/a/b/c/test.db {}} - " { - do_test 4.$tn { parse_uri $uri } $parse - } +foreach {tn uri parse} " + 1 {file:test.db} {[pwd]/test.db {}} + 2 {file:/test.db} {/test.db {}} + 3 {file:///test.db} {/test.db {}} + 4 {file://localhost/test.db} {/test.db {}} + 5 {file:/a/b/c/test.db} {/a/b/c/test.db {}} +" { + do_filepath_test 4.$tn { parse_uri $uri } $parse } # EVIDENCE-OF: R-01612-30877 The "vfs" parameter may be used to specify @@ -270,8 +270,6 @@ foreach {tn uri error} " # EVIDENCE-OF: R-26845-32976 Value "rwc" is equivalent to setting both # SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. # -sqlite3_shutdown -sqlite3_config_uri 1 foreach {tn uri read write create} { 1 {file:test.db?mode=ro} 1 0 0 2 {file:test.db?mode=rw} 1 1 0 @@ -429,10 +427,10 @@ sqlite3_enable_shared_cache $orig # EVIDENCE-OF: R-63472-46769 Specifying an unknown parameter in the # query component of a URI is not an error. # -do_test 12.1 { +do_filepath_test 12.1 { parse_uri file://localhost/test.db?an=unknown¶meter=is&ok= } {/test.db {an unknown parameter is ok {}}} -do_test 12.2 { +do_filepath_test 12.2 { parse_uri file://localhost/test.db?an&unknown¶meter&is&ok } {/test.db {an {} unknown {} parameter {} is {} ok {}}} @@ -452,7 +450,7 @@ foreach {tn uri parse} " 2 {file:/test.db?%68%65%6c%6c%6f=%77%6f%72%6c%64} {/test.db {hello world}} 3 {file:/%C3%BF.db} {/\xFF.db {}} " { - do_test 13.$tn { parse_uri $uri } $parse + do_filepath_test 13.$tn { parse_uri $uri } $parse } finish_test diff --git a/test/tester.tcl b/test/tester.tcl index 5a936bd9c9..6d84949f76 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -354,6 +354,19 @@ proc do_test {name cmd expected} { flush stdout } +proc filepath_normalize {p} { + # test cases should be written to assume "unix"-like file paths + if {$::tcl_platform(platform)!="unix"} { + # lreverse*2 as a hack to remove any unneeded {} after the string map + lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]] + } +} +proc do_filepath_test {name cmd expected} { + uplevel [list do_test $name [ + subst -nocommands { filepath_normalize [ $cmd ] } + ] [filepath_normalize $expected]] +} + proc realnum_normalize {r} { # different TCL versions display floating point values differently. string map {1.#INF inf Inf inf .0e e} [regsub -all {(e[+-])0+} $r {\1}] From c48964077993ee2d49e4d9c873cfd624a0cd228a Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 21 Jun 2011 19:38:16 +0000 Subject: [PATCH 13/16] Update filepath_normalize for unix. FossilOrigin-Name: 30dd4f887989354b5d01cc80bd9c4bd3528d3ae1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/tester.tcl | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 3a9e0a51a3..b6a14c3913 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\sfew\sof\sthe\suri\stests\sto\swork\son\sWindows. -D 2011-06-21T19:30:19.621 +C Update\sfilepath_normalize\sfor\sunix. +D 2011-06-21T19:38:16.805 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -695,7 +695,7 @@ F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 -F test/tester.tcl 7c02f342a92aa161d13ab5241413e341039c14d7 +F test/tester.tcl 6be56c3d428d37b1d9281adc4c2b81e135c07773 F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 9eac4a6bbe111d951ad23395ba82c868473c5b9b -R cb165167c8ffaaf3fa41940019e90c06 +P a2a0cd4aa4a6723a849bbba590c22fd065fab55e +R 8d007d7bee1018ae9fbc8ca3a0089039 U shaneh -Z 2a57b2d9aba31bd124d18eb8ab4bf292 +Z 6fcb3eb81cefe51f562056bbdbe8ba89 diff --git a/manifest.uuid b/manifest.uuid index 40cb51dc84..0207d8f772 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a2a0cd4aa4a6723a849bbba590c22fd065fab55e \ No newline at end of file +30dd4f887989354b5d01cc80bd9c4bd3528d3ae1 \ No newline at end of file diff --git a/test/tester.tcl b/test/tester.tcl index 6d84949f76..972973cdaf 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -356,9 +356,11 @@ proc do_test {name cmd expected} { proc filepath_normalize {p} { # test cases should be written to assume "unix"-like file paths - if {$::tcl_platform(platform)!="unix"} { + if {$::tcl_platform(platform)=="unix"} { # lreverse*2 as a hack to remove any unneeded {} after the string map lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]] + } { + set p } } proc do_filepath_test {name cmd expected} { From 285a18fa45057c9da9b9df457bb551bf60587f11 Mon Sep 17 00:00:00 2001 From: shaneh Date: Tue, 21 Jun 2011 19:39:59 +0000 Subject: [PATCH 14/16] Fix typo in previous tester.tcl commit. FossilOrigin-Name: c2e5faca144d2c25aada2a77b4ddefa5ca6ea925 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/tester.tcl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b6a14c3913..babaee7a38 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sfilepath_normalize\sfor\sunix. -D 2011-06-21T19:38:16.805 +C Fix\stypo\sin\sprevious\stester.tcl\scommit. +D 2011-06-21T19:39:59.899 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -695,7 +695,7 @@ F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 -F test/tester.tcl 6be56c3d428d37b1d9281adc4c2b81e135c07773 +F test/tester.tcl 7d3d17914ca5397a82f801db733b81d4a82f50c3 F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P a2a0cd4aa4a6723a849bbba590c22fd065fab55e -R 8d007d7bee1018ae9fbc8ca3a0089039 +P 30dd4f887989354b5d01cc80bd9c4bd3528d3ae1 +R 084de3a15eae3d4856b5e83a7233fad0 U shaneh -Z 6fcb3eb81cefe51f562056bbdbe8ba89 +Z cacbdaf793f85a27b495ae7addf7022f diff --git a/manifest.uuid b/manifest.uuid index 0207d8f772..ceabdb0962 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -30dd4f887989354b5d01cc80bd9c4bd3528d3ae1 \ No newline at end of file +c2e5faca144d2c25aada2a77b4ddefa5ca6ea925 \ No newline at end of file diff --git a/test/tester.tcl b/test/tester.tcl index 972973cdaf..8624821a5e 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -356,7 +356,7 @@ proc do_test {name cmd expected} { proc filepath_normalize {p} { # test cases should be written to assume "unix"-like file paths - if {$::tcl_platform(platform)=="unix"} { + if {$::tcl_platform(platform)!="unix"} { # lreverse*2 as a hack to remove any unneeded {} after the string map lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]] } { From 328876c0accfa783b1678724f6f476c2d6a938f9 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 22 Jun 2011 10:37:19 +0000 Subject: [PATCH 15/16] Modify the implementation of the test code in test_vfs.c so that test VFS objects may be invoked recursively. FossilOrigin-Name: 065e5a5ea4f82f0d3fbb2e80d3a977af96c95683 --- manifest | 14 ++++++------- manifest.uuid | 2 +- src/test_vfs.c | 54 +++++++++++++------------------------------------- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/manifest b/manifest index babaee7a38..ed1edf5af3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\sprevious\stester.tcl\scommit. -D 2011-06-21T19:39:59.899 +C Modify\sthe\simplementation\sof\sthe\stest\scode\sin\stest_vfs.c\sso\sthat\stest\sVFS\sobjects\smay\sbe\sinvoked\srecursively. +D 2011-06-22T10:37:19.411 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c 162c4ec0137a549c009bb9ecab550527743cfc5d F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c fe9a7803fc1d69cccb60f016f28c1cedf2d9fcfa -F src/test_vfs.c e7855568dfa1e0ba73668d273b65605d9f8b77e8 +F src/test_vfs.c 1d82aee93e644188179da2165f4fe3ad6b62782c F src/test_vfstrace.c 0b884e06094a746da729119a2cabdc7aa790063d F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P 30dd4f887989354b5d01cc80bd9c4bd3528d3ae1 -R 084de3a15eae3d4856b5e83a7233fad0 -U shaneh -Z cacbdaf793f85a27b495ae7addf7022f +P c2e5faca144d2c25aada2a77b4ddefa5ca6ea925 +R a4cd5b97b8672366dadaf62699ff3d86 +U dan +Z 076f8a98bd958dd0f5e07208d97aac36 diff --git a/manifest.uuid b/manifest.uuid index ceabdb0962..fdfa5cf352 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c2e5faca144d2c25aada2a77b4ddefa5ca6ea925 \ No newline at end of file +065e5a5ea4f82f0d3fbb2e80d3a977af96c95683 \ No newline at end of file diff --git a/src/test_vfs.c b/src/test_vfs.c index 696321d26e..bc8c4d3260 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -79,8 +79,6 @@ struct Testvfs { sqlite3_vfs *pVfs; /* The testvfs registered with SQLite */ Tcl_Interp *interp; /* Interpreter to run script in */ Tcl_Obj *pScript; /* Script to execute */ - int nScript; /* Number of elements in array apScript */ - Tcl_Obj **apScript; /* Array version of pScript */ TestvfsBuffer *pBuffer; /* List of shared buffers */ int isNoshm; @@ -267,48 +265,26 @@ static void tvfsExecTcl( Tcl_Obj *arg3 ){ int rc; /* Return code from Tcl_EvalObj() */ - int nArg; /* Elements in eval'd list */ - int nScript; - Tcl_Obj ** ap; - + Tcl_Obj *pEval; assert( p->pScript ); - if( !p->apScript ){ - int nByte; - int i; - if( TCL_OK!=Tcl_ListObjGetElements(p->interp, p->pScript, &nScript, &ap) ){ - Tcl_BackgroundError(p->interp); - Tcl_ResetResult(p->interp); - return; - } - p->nScript = nScript; - nByte = (nScript+TESTVFS_MAX_ARGS)*sizeof(Tcl_Obj *); - p->apScript = (Tcl_Obj **)ckalloc(nByte); - memset(p->apScript, 0, nByte); - for(i=0; iapScript[i] = ap[i]; - } - } + assert( zMethod ); + assert( p ); + assert( arg2==0 || arg1!=0 ); + assert( arg3==0 || arg2!=0 ); - p->apScript[p->nScript] = Tcl_NewStringObj(zMethod, -1); - p->apScript[p->nScript+1] = arg1; - p->apScript[p->nScript+2] = arg2; - p->apScript[p->nScript+3] = arg3; + pEval = Tcl_DuplicateObj(p->pScript); + Tcl_IncrRefCount(p->pScript); + Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zMethod, -1)); + if( arg1 ) Tcl_ListObjAppendElement(p->interp, pEval, arg1); + if( arg2 ) Tcl_ListObjAppendElement(p->interp, pEval, arg2); + if( arg3 ) Tcl_ListObjAppendElement(p->interp, pEval, arg3); - for(nArg=p->nScript; p->apScript[nArg]; nArg++){ - Tcl_IncrRefCount(p->apScript[nArg]); - } - - rc = Tcl_EvalObjv(p->interp, nArg, p->apScript, TCL_EVAL_GLOBAL); + rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL); if( rc!=TCL_OK ){ Tcl_BackgroundError(p->interp); Tcl_ResetResult(p->interp); } - - for(nArg=p->nScript; p->apScript[nArg]; nArg++){ - Tcl_DecrRefCount(p->apScript[nArg]); - p->apScript[nArg] = 0; - } } @@ -1094,10 +1070,8 @@ static int testvfs_obj_cmd( if( objc==3 ){ int nByte; if( p->pScript ){ + int i; Tcl_DecrRefCount(p->pScript); - ckfree((char *)p->apScript); - p->apScript = 0; - p->nScript = 0; p->pScript = 0; } Tcl_GetStringFromObj(objv[2], &nByte); @@ -1249,9 +1223,9 @@ static int testvfs_obj_cmd( static void testvfs_obj_del(ClientData cd){ Testvfs *p = (Testvfs *)cd; + int i; if( p->pScript ) Tcl_DecrRefCount(p->pScript); sqlite3_vfs_unregister(p->pVfs); - ckfree((char *)p->apScript); ckfree((char *)p->pVfs); ckfree((char *)p); } From 0c13e9c77ee61a62dc216e95cef54c40f4de2397 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 22 Jun 2011 10:56:54 +0000 Subject: [PATCH 16/16] Change a test case in types3.test slightly so that it works with the latest versions of Tcl. FossilOrigin-Name: 6e1f4df51ad32e36715cba16f9df0d17a08dc653 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/types3.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ed1edf5af3..bb6eff7db1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\simplementation\sof\sthe\stest\scode\sin\stest_vfs.c\sso\sthat\stest\sVFS\sobjects\smay\sbe\sinvoked\srecursively. -D 2011-06-22T10:37:19.411 +C Change\sa\stest\scase\sin\stypes3.test\sslightly\sso\sthat\sit\sworks\swith\sthe\slatest\sversions\sof\sTcl. +D 2011-06-22T10:56:54.742 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -843,7 +843,7 @@ F test/triggerD.test c6add3817351451e419f6ff9e9a259b02b6e2de7 F test/tt3_checkpoint.c 415eccce672d681b297485fc20f44cdf0eac93af F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff F test/types2.test 3555aacf8ed8dc883356e59efc314707e6247a84 -F test/types3.test a0f66bf12f80fad89493535474f7a6d16fa58150 +F test/types3.test 99e009491a54f4dc02c06bdbc0c5eea56ae3e25a F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P c2e5faca144d2c25aada2a77b4ddefa5ca6ea925 -R a4cd5b97b8672366dadaf62699ff3d86 +P 065e5a5ea4f82f0d3fbb2e80d3a977af96c95683 +R bb24e8ea6743b27a72518b27f4017512 U dan -Z 076f8a98bd958dd0f5e07208d97aac36 +Z 83a2b05b96f2ad1cc32e9a94b3d4ad63 diff --git a/manifest.uuid b/manifest.uuid index fdfa5cf352..9ca9b68227 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -065e5a5ea4f82f0d3fbb2e80d3a977af96c95683 \ No newline at end of file +6e1f4df51ad32e36715cba16f9df0d17a08dc653 \ No newline at end of file diff --git a/test/types3.test b/test/types3.test index 33f2595cb9..807ae84f9d 100644 --- a/test/types3.test +++ b/test/types3.test @@ -21,7 +21,7 @@ source $testdir/tester.tcl # A variable with only a string representation comes in as TEXT do_test types3-1.1 { set V {} - append V {} + append V x concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] } {string text}