From c2d4f4b30db10079cff4d5cdea831475fbdcdebe Mon Sep 17 00:00:00 2001 From: Alexpux Date: Tue, 4 Nov 2014 18:27:43 +0300 Subject: [PATCH] sqlite: Update to 3.8.7 --- sqlite/PKGBUILD | 18 +- ...qlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch | 11 - ...-1.src.patch => sqlite3-3.8.7-1.src.patch} | 1735 ++++++++++++----- 3 files changed, 1202 insertions(+), 562 deletions(-) delete mode 100644 sqlite/sqlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch rename sqlite/{sqlite3-3.8.6-1.src.patch => sqlite3-3.8.7-1.src.patch} (89%) diff --git a/sqlite/PKGBUILD b/sqlite/PKGBUILD index c85e49fb..708485f3 100644 --- a/sqlite/PKGBUILD +++ b/sqlite/PKGBUILD @@ -2,9 +2,9 @@ pkgbase="sqlite" pkgname=('sqlite' 'libsqlite' 'libsqlite-devel' 'sqlite-doc') -_amalgamationver=3080600 +_amalgamationver=3080700 _docver=${_amalgamationver} -pkgver=3.8.6 +pkgver=3.8.7 pkgrel=1 pkgdesc="A C library that implements an SQL database engine" arch=('i686' 'x86_64') @@ -17,27 +17,25 @@ source=( # tarball containing the amalgamation for SQLite >= 3.7.5 together with http://www.sqlite.org/2014/sqlite-doc-${_docver}.zip license.txt 'sqlite-3.8.0.1-msys2.patch' - 'sqlite3-3.8.6-1.src.patch' - 'sqlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch') + 'sqlite3-3.8.7-1.src.patch') options=('!libtool' '!emptydirs') -sha1sums=('c4b2911bc4a6e1dc2b411aa21d8c4f524113eb64' - '8c3d3a9f97b10fb43d6fce61079ed1ab93472913' +sha1sums=('8b773b006db46f3ffcbabe065e927823d13bf5c0' + 'b091631340c051455e349e651d9c24579e00f669' 'f34f6daa4ab3073d74e774aad21d66878cf26853' '17b837df621e1471739e006397deec794b3d7aeb' - '60dd177220ac47cdba491e1a2d156264fdc26b78' - '2ff3db98562a0a5c556ed6d0125de878466a9554') + '4d2a00e19edc456261af7f87e0fbb69fd20815f3') prepare() { cd "$srcdir"/sqlite-autoconf-$_amalgamationver - patch -p2 -i ${srcdir}/sqlite3-3.8.6-1.src.patch - patch -p1 -i ${srcdir}/sqlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch + patch -p2 -i ${srcdir}/sqlite3-3.8.7-1.src.patch patch -p1 -i ${srcdir}/sqlite-3.8.0.1-msys2.patch autoreconf -fi } build() { export CPPFLAGS="$CPPFLAGS \ + -DHAVE_MALLOC_H \ -DHAVE_MALLOC_USABLE_SIZE \ -DSQLITE_ENABLE_COLUMN_METADATA=1 \ -DSQLITE_ENABLE_FTS4=1 \ diff --git a/sqlite/sqlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch b/sqlite/sqlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch deleted file mode 100644 index bfa6ee6f..00000000 --- a/sqlite/sqlite-3.8.3-cygwin-need-_XOPEN_SORCE.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- sqlite-autoconf-3080200/sqlite3.c.orig 2014-02-03 13:51:00.294600000 +0400 -+++ sqlite-autoconf-3080200/sqlite3.c 2014-02-03 13:51:09.436200000 +0400 -@@ -7822,7 +7822,7 @@ - ** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit - ** it. - */ --#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) -+#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && !defined(__CYGWIN__) - # define _XOPEN_SOURCE 600 - #endif - diff --git a/sqlite/sqlite3-3.8.6-1.src.patch b/sqlite/sqlite3-3.8.7-1.src.patch similarity index 89% rename from sqlite/sqlite3-3.8.6-1.src.patch rename to sqlite/sqlite3-3.8.7-1.src.patch index 07a65f14..122ea7e7 100644 --- a/sqlite/sqlite3-3.8.6-1.src.patch +++ b/sqlite/sqlite3-3.8.7-1.src.patch @@ -1,9 +1,9 @@ ---- origsrc/sqlite-autoconf-3080600/Makefile.am 2014-08-15 16:09:16.000000000 +0200 -+++ src/sqlite-autoconf-3080600/Makefile.am 2014-08-19 11:29:09.323220500 +0200 +--- origsrc/sqlite-autoconf-3080700/Makefile.am 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/Makefile.am 2014-10-21 17:51:18.660251100 +0200 @@ -1,14 +1,55 @@ -AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -+AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ -DUSE_SYSTEM_SQLITE=1 -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE ++AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ -DUSE_SYSTEM_SQLITE=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -lib_LTLIBRARIES = libsqlite3.la +lib_LTLIBRARIES = libsqlite3.la libsqlite3icu.la libsqlite3zlib.la \ @@ -61,8 +61,8 @@ include_HEADERS = sqlite3.h sqlite3ext.h ---- origsrc/sqlite-autoconf-3080600/amatch.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/amatch.c 2014-08-19 14:28:54.144076900 +0200 +--- origsrc/sqlite-autoconf-3080700/amatch.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/amatch.c 2014-10-21 17:53:40.950389600 +0200 @@ -0,0 +1,1502 @@ +/* +** 2013-03-14 @@ -1566,8 +1566,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/closure.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/closure.c 2014-08-19 14:28:54.176078800 +0200 +--- origsrc/sqlite-autoconf-3080700/closure.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/closure.c 2014-10-21 17:53:40.970390800 +0200 @@ -0,0 +1,973 @@ +/* +** 2013-04-16 @@ -2542,8 +2542,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/compress.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/compress.c 2014-08-19 14:28:54.196079900 +0200 +--- origsrc/sqlite-autoconf-3080700/compress.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/compress.c 2014-10-21 17:53:40.981391400 +0200 @@ -0,0 +1,125 @@ +/* +** 2014-06-13 @@ -2670,8 +2670,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/fileio.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/fileio.c 2014-08-19 14:28:54.212080800 +0200 +--- origsrc/sqlite-autoconf-3080700/fileio.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/fileio.c 2014-10-21 17:53:40.987391700 +0200 @@ -0,0 +1,118 @@ +/* +** 2014-06-13 @@ -2791,8 +2791,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/fuzzer.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/fuzzer.c 2014-08-19 14:28:54.235082100 +0200 +--- origsrc/sqlite-autoconf-3080700/fuzzer.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/fuzzer.c 2014-10-21 17:53:40.992392000 +0200 @@ -0,0 +1,1198 @@ +/* +** 2011 March 24 @@ -3992,8 +3992,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/ieee754.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/ieee754.c 2014-08-19 14:28:54.254083200 +0200 +--- origsrc/sqlite-autoconf-3080700/ieee754.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/ieee754.c 2014-10-21 17:53:41.002392600 +0200 @@ -0,0 +1,149 @@ +/* +** 2013-04-17 @@ -4144,8 +4144,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/nextchar.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/nextchar.c 2014-08-19 14:28:54.275084400 +0200 +--- origsrc/sqlite-autoconf-3080700/nextchar.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/nextchar.c 2014-10-21 17:53:41.007392900 +0200 @@ -0,0 +1,333 @@ +/* +** 2013-02-28 @@ -4480,8 +4480,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/percentile.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/percentile.c 2014-08-19 14:28:54.296085600 +0200 +--- origsrc/sqlite-autoconf-3080700/percentile.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/percentile.c 2014-10-21 17:53:41.014393300 +0200 @@ -0,0 +1,233 @@ +/* +** 2013-05-28 @@ -4716,8 +4716,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/regexp.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/regexp.c 2014-08-19 14:28:54.324087200 +0200 +--- origsrc/sqlite-autoconf-3080700/regexp.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/regexp.c 2014-10-21 17:53:41.021393700 +0200 @@ -0,0 +1,773 @@ +/* +** 2012-11-13 @@ -5492,8 +5492,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/rot13.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/rot13.c 2014-08-19 14:28:54.343088300 +0200 +--- origsrc/sqlite-autoconf-3080700/rot13.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/rot13.c 2014-10-21 17:53:41.037394600 +0200 @@ -0,0 +1,131 @@ +/* +** 2013-05-15 @@ -5626,9 +5626,86 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/shell.c 2014-08-15 16:09:16.000000000 +0200 -+++ src/sqlite-autoconf-3080600/shell.c 2014-08-19 12:53:07.630395100 +0200 -@@ -491,7 +491,7 @@ struct callback_data { +--- origsrc/sqlite-autoconf-3080700/shell.c 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/shell.c 2014-10-21 17:54:15.576370100 +0200 +@@ -33,7 +33,7 @@ + #include + #include + #include "sqlite3.h" +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + # include "sqlite3userauth.h" + #endif + #include +@@ -172,43 +172,14 @@ static HANDLE hProcess; + static FILETIME ftKernelBegin; + static FILETIME ftUserBegin; + static sqlite3_int64 ftWallBegin; +-typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME); +-static GETPROCTIMES getProcessTimesAddr = NULL; +- +-/* +-** Check to see if we have timer support. Return 1 if necessary +-** support found (or found previously). +-*/ +-static int hasTimer(void){ +- if( getProcessTimesAddr ){ +- return 1; +- } else { +- /* GetProcessTimes() isn't supported in WIN95 and some other Windows versions. +- ** See if the version we are running on has it, and if it does, save off +- ** a pointer to it and the current process handle. +- */ +- hProcess = GetCurrentProcess(); +- if( hProcess ){ +- HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll")); +- if( NULL != hinstLib ){ +- getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes"); +- if( NULL != getProcessTimesAddr ){ +- return 1; +- } +- FreeLibrary(hinstLib); +- } +- } +- } +- return 0; +-} + + /* + ** Begin timing an operation + */ + static void beginTimer(void){ +- if( enableTimer && getProcessTimesAddr ){ ++ if( enableTimer ){ + FILETIME ftCreation, ftExit; +- getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin); ++ GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin); + ftWallBegin = timeOfDay(); + } + } +@@ -224,10 +195,10 @@ static double timeDiff(FILETIME *pStart, + ** Print the timing results. + */ + static void endTimer(void){ +- if( enableTimer && getProcessTimesAddr){ ++ if( enableTimer){ + FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd; + sqlite3_int64 ftWallEnd = timeOfDay(); +- getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd); ++ GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd); + printf("Run Time: real %.3f user %f sys %f\n", + (ftWallEnd - ftWallBegin)*0.001, + timeDiff(&ftUserBegin, &ftUserEnd), +@@ -237,7 +208,7 @@ static void endTimer(void){ + + #define BEGIN_TIMER beginTimer() + #define END_TIMER endTimer() +-#define HAS_TIMER hasTimer() ++#define HAS_TIMER 1 + + #else + #define BEGIN_TIMER +@@ -505,7 +476,7 @@ struct ShellState { #define MODE_Csv 7 /* Quote strings, numbers are plain */ #define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */ @@ -5637,7 +5714,16 @@ "line", "column", "list", -@@ -1164,8 +1164,10 @@ static int display_stats( +@@ -882,7 +853,7 @@ static int shell_callback(void *pArg, in + } + fprintf(p->out,"%s",p->newline); + } +- if( azArg>0 ){ ++ if( nArg>0 ){ + for(i=0; iout, "Sort Operations: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset); fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur); @@ -5650,7 +5736,7 @@ } return 0; -@@ -1177,7 +1179,7 @@ static int display_stats( +@@ -1191,7 +1164,7 @@ static int display_stats( ** is equal, according to strcmp(), to any of the strings in the array. ** Otherwise, return zero. */ @@ -5659,7 +5745,7 @@ int i; for(i=0; azArray[i]; i++){ if( 0==strcmp(zStr, azArray[i]) ) return 1; -@@ -1210,10 +1212,10 @@ static void explain_data_prepare(struct +@@ -1224,10 +1197,10 @@ static void explain_data_prepare(ShellSt int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */ int iOp; /* Index of operation in p->aiIndent[] */ @@ -5674,7 +5760,25 @@ /* Try to figure out if this is really an EXPLAIN statement. If this ** cannot be verified, return early. */ -@@ -3280,7 +3282,12 @@ static int do_meta_command(char *zLine, +@@ -1353,6 +1326,17 @@ static int shell_exec( + sqlite3_free(zEQP); + } + ++#if USE_SYSTEM_SQLITE+0==1 ++ /* Output TESTCTRL_EXPLAIN text of requested */ ++ if( pArg && pArg->mode==MODE_Explain && sqlite3_libversion_number()<3008007 ){ ++ const char *zExplain = 0; ++ sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain); ++ if( zExplain && zExplain[0] ){ ++ fprintf(pArg->out, "%s", zExplain); ++ } ++ } ++#endif ++ + /* If the shell is currently in ".explain" mode, gather the extra + ** data required to add indents to the output.*/ + if( pArg && pArg->mode==MODE_Explain ){ +@@ -3298,7 +3282,13 @@ static int do_meta_command(char *zLine, { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS }, { "iskeyword", SQLITE_TESTCTRL_ISKEYWORD }, { "scratchmalloc", SQLITE_TESTCTRL_SCRATCHMALLOC }, @@ -5683,11 +5787,12 @@ + { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT }, + { "vdbe_coverage", SQLITE_TESTCTRL_VDBE_COVERAGE }, { "byteorder", SQLITE_TESTCTRL_BYTEORDER }, -+ { "isinit", SQLITE_TESTCTRL_ISINIT } ++ { "isinit", SQLITE_TESTCTRL_ISINIT }, ++ { "sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP }, }; int testctrl = -1; int rc = 0; -@@ -3376,6 +3383,11 @@ static int do_meta_command(char *zLine, +@@ -3394,6 +3384,12 @@ static int do_meta_command(char *zLine, case SQLITE_TESTCTRL_FAULT_INSTALL: case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: case SQLITE_TESTCTRL_SCRATCHMALLOC: @@ -5696,10 +5801,20 @@ + case SQLITE_TESTCTRL_NEVER_CORRUPT: + case SQLITE_TESTCTRL_VDBE_COVERAGE: + case SQLITE_TESTCTRL_ISINIT: ++ case SQLITE_TESTCTRL_SORTER_MMAP: default: fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n", azArg[1]); -@@ -3782,6 +3794,9 @@ static const char zOptions[] = +@@ -3438,7 +3434,7 @@ static int do_meta_command(char *zLine, + #endif + }else + +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + if( c=='u' && strncmp(azArg[0], "user", n)==0 ){ + if( nArg<2 ){ + fprintf(stderr, "Usage: .user SUBCOMMAND ...\n"); +@@ -3869,6 +3865,9 @@ static const char zOptions[] = " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" @@ -5709,15 +5824,16 @@ #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif -@@ -3813,6 +3828,7 @@ static void main_init(struct callback_da +@@ -3899,6 +3898,8 @@ static void main_init(ShellState *data) + sqlite3_config(SQLITE_CONFIG_URI, 1); + sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); + sqlite3_config(SQLITE_CONFIG_MULTITHREAD); ++ sqlite3_config(32); /* SQLITE_CONFIG_EXPLAIN_COMMENTS (old) */ ++ sqlite3_config(64); /* SQLITE_CONFIG_EXPLAIN_COMMENTS */ sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); - sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); -+ sqlite3_config(32); /* SQLITE_CONFIG_EXPLAIN_COMMENTS */ } - - /* -@@ -3848,6 +3864,10 @@ static char *cmdline_option_value(int ar +@@ -3936,6 +3937,10 @@ static char *cmdline_option_value(int ar return argv[i]; } @@ -5727,8 +5843,8 @@ + int main(int argc, char **argv){ char *zErrMsg = 0; - struct callback_data data; -@@ -3861,9 +3881,13 @@ int main(int argc, char **argv){ + ShellState data; +@@ -3949,9 +3954,13 @@ int main(int argc, char **argv){ if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); @@ -5743,7 +5859,7 @@ Argv0 = argv[0]; main_init(&data); stdin_is_interactive = isatty(0); -@@ -3921,6 +3945,11 @@ int main(int argc, char **argv){ +@@ -4009,6 +4018,11 @@ int main(int argc, char **argv){ if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); #endif @@ -5752,10 +5868,10 @@ + extern int sqlite3_register_vfslog(const char *); + sqlite3_register_vfslog(NULL); +#endif - #ifdef SQLITE_ENABLE_VFSTRACE - }else if( strcmp(z,"-vfstrace")==0 ){ - extern int vfstrace_register( -@@ -4040,6 +4069,10 @@ int main(int argc, char **argv){ + }else if( strcmp(z,"-scratch")==0 ){ + int n, sz; + sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); +@@ -4161,6 +4175,10 @@ int main(int argc, char **argv){ i++; }else if( strcmp(z,"-vfs")==0 ){ i++; @@ -5766,9 +5882,115 @@ #ifdef SQLITE_ENABLE_VFSTRACE }else if( strcmp(z,"-vfstrace")==0 ){ i++; ---- origsrc/sqlite-autoconf-3080600/spellfix.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/spellfix.c 2014-08-19 14:28:54.362089400 +0200 -@@ -0,0 +1,2879 @@ +--- origsrc/sqlite-autoconf-3080700/showauth.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/showauth.c 2014-10-21 17:53:41.107398600 +0200 +@@ -0,0 +1,103 @@ ++/* ++** 2014-09-21 ++** ++** The author disclaims copyright to this source code. In place of ++** a legal notice, here is a blessing: ++** ++** May you do good and not evil. ++** May you find forgiveness for yourself and forgive others. ++** May you share freely, never taking more than you give. ++** ++****************************************************************************** ++** ++** This SQLite extension adds a debug "authorizer" callback to the database ++** connection. The callback merely writes the authorization request to ++** standard output and returns SQLITE_OK. ++** ++** This extension can be used (for example) in the command-line shell to ++** trace the operation of the authorizer. ++*/ ++#include "sqlite3ext.h" ++SQLITE_EXTENSION_INIT1 ++#include ++ ++/* ++** Display the authorization request ++*/ ++static int authCallback( ++ void *pClientData, ++ int op, ++ const char *z1, ++ const char *z2, ++ const char *z3, ++ const char *z4 ++){ ++ const char *zOp; ++ char zOpSpace[50]; ++ switch( op ){ ++ case SQLITE_CREATE_INDEX: zOp = "CREATE_INDEX"; break; ++ case SQLITE_CREATE_TABLE: zOp = "CREATE_TABLE"; break; ++ case SQLITE_CREATE_TEMP_INDEX: zOp = "CREATE_TEMP_INDEX"; break; ++ case SQLITE_CREATE_TEMP_TABLE: zOp = "CREATE_TEMP_TABLE"; break; ++ case SQLITE_CREATE_TEMP_TRIGGER: zOp = "CREATE_TEMP_TRIGGER"; break; ++ case SQLITE_CREATE_TEMP_VIEW: zOp = "CREATE_TEMP_VIEW"; break; ++ case SQLITE_CREATE_TRIGGER: zOp = "CREATE_TRIGGER"; break; ++ case SQLITE_CREATE_VIEW: zOp = "CREATE_VIEW"; break; ++ case SQLITE_DELETE: zOp = "DELETE"; break; ++ case SQLITE_DROP_INDEX: zOp = "DROP_INDEX"; break; ++ case SQLITE_DROP_TABLE: zOp = "DROP_TABLE"; break; ++ case SQLITE_DROP_TEMP_INDEX: zOp = "DROP_TEMP_INDEX"; break; ++ case SQLITE_DROP_TEMP_TABLE: zOp = "DROP_TEMP_TABLE"; break; ++ case SQLITE_DROP_TEMP_TRIGGER: zOp = "DROP_TEMP_TRIGGER"; break; ++ case SQLITE_DROP_TEMP_VIEW: zOp = "DROP_TEMP_VIEW"; break; ++ case SQLITE_DROP_TRIGGER: zOp = "DROP_TRIGGER"; break; ++ case SQLITE_DROP_VIEW: zOp = "DROP_VIEW"; break; ++ case SQLITE_INSERT: zOp = "INSERT"; break; ++ case SQLITE_PRAGMA: zOp = "PRAGMA"; break; ++ case SQLITE_READ: zOp = "READ"; break; ++ case SQLITE_SELECT: zOp = "SELECT"; break; ++ case SQLITE_TRANSACTION: zOp = "TRANSACTION"; break; ++ case SQLITE_UPDATE: zOp = "UPDATE"; break; ++ case SQLITE_ATTACH: zOp = "ATTACH"; break; ++ case SQLITE_DETACH: zOp = "DETACH"; break; ++ case SQLITE_ALTER_TABLE: zOp = "ALTER_TABLE"; break; ++ case SQLITE_REINDEX: zOp = "REINDEX"; break; ++ case SQLITE_ANALYZE: zOp = "ANALYZE"; break; ++ case SQLITE_CREATE_VTABLE: zOp = "CREATE_VTABLE"; break; ++ case SQLITE_DROP_VTABLE: zOp = "DROP_VTABLE"; break; ++ case SQLITE_FUNCTION: zOp = "FUNCTION"; break; ++ case SQLITE_SAVEPOINT: zOp = "SAVEPOINT"; break; ++ case SQLITE_COPY: zOp = "COPY"; break; ++ case SQLITE_RECURSIVE: zOp = "RECURSIVE"; break; ++ ++ ++ default: { ++ sqlite3_snprintf(sizeof(zOpSpace), zOpSpace, "%d", op); ++ zOp = zOpSpace; ++ break; ++ } ++ } ++ if( z1==0 ) z1 = "NULL"; ++ if( z2==0 ) z2 = "NULL"; ++ if( z3==0 ) z3 = "NULL"; ++ if( z4==0 ) z4 = "NULL"; ++ printf("AUTH: %s,%s,%s,%s,%s\n", zOp, z1, z2, z3, z4); ++ return SQLITE_OK; ++} ++ ++ ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++int sqlite3_showauth_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ (void)pzErrMsg; /* Unused parameter */ ++ rc = sqlite3_set_authorizer(db, authCallback, 0); ++ return rc; ++} +--- origsrc/sqlite-autoconf-3080700/spellfix.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/spellfix.c 2014-10-21 17:53:41.125399600 +0200 +@@ -0,0 +1,2889 @@ +/* +** 2012 April 10 +** @@ -8507,12 +8729,22 @@ + return SQLITE_NOMEM; + } + if( sqlite3_value_type(argv[0])==SQLITE_NULL ){ -+ spellfix1DbExec(&rc, db, -+ "INSERT INTO \"%w\".\"%w_vocab\"(rank,langid,word,k1,k2) " -+ "VALUES(%d,%d,%Q,%Q,%Q)", -+ p->zDbName, p->zTableName, -+ iRank, iLang, zWord, zK1, zK2 -+ ); ++ if( sqlite3_value_type(argv[1])==SQLITE_NULL ){ ++ spellfix1DbExec(&rc, db, ++ "INSERT INTO \"%w\".\"%w_vocab\"(rank,langid,word,k1,k2) " ++ "VALUES(%d,%d,%Q,%Q,%Q)", ++ p->zDbName, p->zTableName, ++ iRank, iLang, zWord, zK1, zK2 ++ ); ++ }else{ ++ newRowid = sqlite3_value_int64(argv[1]); ++ spellfix1DbExec(&rc, db, ++ "INSERT INTO \"%w\".\"%w_vocab\"(id,rank,langid,word,k1,k2) " ++ "VALUES(%lld,%d,%d,%Q,%Q,%Q)", ++ p->zDbName, p->zTableName, ++ newRowid, iRank, iLang, zWord, zK1, zK2 ++ ); ++ } + *pRowid = sqlite3_last_insert_rowid(db); + }else{ + rowid = sqlite3_value_int64(argv[0]); @@ -8648,14 +8880,14 @@ + return SQLITE_OK; +} +#endif ---- origsrc/sqlite-autoconf-3080600/sqlite3.1 2014-08-15 16:09:16.000000000 +0200 -+++ src/sqlite-autoconf-3080600/sqlite3.1 2014-08-19 12:53:02.963128200 +0200 +--- origsrc/sqlite-autoconf-3080700/sqlite3.1 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/sqlite3.1 2014-10-28 16:46:25.434224700 +0100 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH SQLITE3 1 "Mon Jan 31 11:14:00 2014" -+.TH SQLITE3 1 "Mon Jul 27 23:13:00 2014" ++.TH SQLITE3 1 "Mon Aug 29 16:09:00 2014" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -8664,7 +8896,7 @@ .B sqlite3 mydata.db .br -SQLite version 3.8.3 -+SQLite version 3.8.6 ++SQLite version 3.8.7 .br Enter ".help" for instructions .br @@ -8731,7 +8963,19 @@ sqlite> |cc . .sp -@@ -219,6 +227,9 @@ Set default mmap size to +@@ -214,15 +222,39 @@ scripts or other programs + Query results will be displayed with the separator (|, by default) + character between each field value. The default. + .TP ++.BI \-lookaside\ SIZE N ++Use ++.I SIZE ++entries of ++.I N ++bytes for lookaside memory. ++.TP + .BI \-mmap\ N + Set default mmap size to .I N \. .TP @@ -8741,7 +8985,25 @@ .BI \-nullvalue\ string Set string used to represent NULL values. Default is '' (empty string). -@@ -236,6 +247,9 @@ Show SQLite version. + .TP ++.BI \-pagecache\ SIZE N ++Use ++.I SIZE ++entries of ++.I N ++bytes each for page cache memory. ++.TP ++.BI \-scratch\ SIZE N ++Use ++.I SIZE ++entries of ++.I N ++bytes each for scratch memory. ++.TP + .BI \-separator\ separator + Set output field separator. Default is '|'. + .TP +@@ -236,6 +268,9 @@ Show SQLite version. Use .I name as the default VFS. @@ -8751,9 +9013,9 @@ .SH INIT FILE ---- origsrc/sqlite-autoconf-3080600/sqlite3.c 2014-08-15 16:09:16.000000000 +0200 -+++ src/sqlite-autoconf-3080600/sqlite3.c 2014-08-19 12:53:00.623994400 +0200 -@@ -76,35 +76,19 @@ +--- origsrc/sqlite-autoconf-3080700/sqlite3.c 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/sqlite3.c 2014-10-28 16:46:17.734784300 +0100 +@@ -85,35 +85,19 @@ #endif /* @@ -8798,7 +9060,34 @@ #endif /* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear -@@ -7830,6 +7814,13 @@ struct sqlite3_rtree_query_info { +@@ -4244,6 +4228,8 @@ SQLITE_API int sqlite3_create_function( + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) + ); ++/* A macro is more efficient than a wrapped call */ ++#define sqlite3_create_function(a,b,c,d,e,f,g,h) sqlite3_create_function_v2(a,b,c,d,e,f,g,h,0) + SQLITE_API int sqlite3_create_function16( + sqlite3 *db, + const void *zFunctionName, +@@ -4728,6 +4714,8 @@ SQLITE_API int sqlite3_create_collation( + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*) + ); ++/* A macro is more efficient than a wrapped call */ ++#define sqlite3_create_collation(a,b,c,d,e) sqlite3_create_collation_v2(a,b,c,d,e,0) + SQLITE_API int sqlite3_create_collation_v2( + sqlite3*, + const char *zName, +@@ -7354,7 +7342,7 @@ SQLITE_API int sqlite3_wal_autocheckpoin + ** See also: [sqlite3_wal_checkpoint_v2()] + */ + SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); +- ++#define sqlite3_wal_checkpoint(a,b) sqlite3_wal_checkpoint_v2(a,b,SQLITE_CHECKPOINT_PASSIVE,0,0); + /* + ** CAPI3REF: Checkpoint a database + ** +@@ -7888,6 +7876,13 @@ struct sqlite3_rtree_query_info { # define SQLITE_MAX_TRIGGER_DEPTH 1000 #endif @@ -8812,7 +9101,7 @@ /************** End of sqliteLimit.h *****************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ -@@ -8636,7 +8627,7 @@ SQLITE_PRIVATE const int sqlite3one; +@@ -8723,7 +8718,7 @@ SQLITE_PRIVATE const int sqlite3one; #endif #ifndef SQLITE_MAX_MMAP_SIZE # if defined(__linux__) \ @@ -8821,7 +9110,7 @@ || (defined(__APPLE__) && defined(__MACH__)) \ || defined(__sun) # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */ -@@ -9152,7 +9143,7 @@ struct VdbeOp { +@@ -9252,7 +9247,7 @@ struct VdbeOp { SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ int (*xAdvance)(BtCursor *, int *); } p4; @@ -8830,20 +9119,16 @@ char *zComment; /* Comment to improve readability */ #endif #ifdef VDBE_PROFILE -@@ -9518,7 +9509,11 @@ SQLITE_PRIVATE void sqlite3VdbeLinkSubPr +@@ -9615,7 +9610,7 @@ SQLITE_PRIVATE void sqlite3VdbeLinkSubPr ** comments in VDBE programs that show key decision points in the code ** generator. */ -#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS -+ -+/* Unsupported as long as not accepted in upstream SQLite */ -+#define SQLITE_CONFIG_EXPLAIN_COMMENTS 32 -+ +#if 0 SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe*, const char*, ...); # define VdbeComment(X) sqlite3VdbeComment X SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); -@@ -9529,9 +9524,13 @@ SQLITE_PRIVATE void sqlite3VdbeNoopCom +@@ -9626,9 +9621,13 @@ SQLITE_PRIVATE void sqlite3VdbeNoopCom # define VdbeModuleComment(X) # endif #else @@ -8860,7 +9145,7 @@ #endif /* -@@ -10024,19 +10023,21 @@ SQLITE_PRIVATE void sqlite3PCacheSetDefa +@@ -10123,19 +10122,21 @@ SQLITE_PRIVATE void sqlite3PCacheSetDefa # endif #endif #if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER) @@ -8894,16 +9179,16 @@ #else # ifndef SQLITE_OS_WIN # define SQLITE_OS_WIN 0 -@@ -10277,7 +10278,7 @@ SQLITE_PRIVATE int sqlite3OsCloseFree(sq +@@ -10376,7 +10377,7 @@ SQLITE_PRIVATE int sqlite3OsCloseFree(sq # define SQLITE_MUTEX_OMIT #endif #if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) -# if SQLITE_OS_UNIX -+# if SQLITE_OS_UNIX || defined(__CYGWIN__) ++# if SQLITE_OS_UNIX || (defined(__CYGWIN__) && !defined(SQLITE_TEST)) # define SQLITE_MUTEX_PTHREADS # elif SQLITE_OS_WIN # define SQLITE_MUTEX_W32 -@@ -12214,6 +12215,7 @@ struct Sqlite3Config { +@@ -12370,6 +12371,7 @@ struct Sqlite3Config { sqlite3_mutex *pInitMutex; /* Mutex used by sqlite3_initialize() */ void (*xLog)(void*,int,const char*); /* Function for logging */ void *pLogArg; /* First argument to xLog() */ @@ -8911,7 +9196,7 @@ #ifdef SQLITE_ENABLE_SQLLOG void(*xSqllog)(void*,sqlite3*,const char*, int); void *pSqllogArg; -@@ -13361,6 +13363,11 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 +@@ -13523,6 +13525,11 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 0, /* pInitMutex */ 0, /* xLog */ 0, /* pLogArg */ @@ -8923,7 +9208,17 @@ #ifdef SQLITE_ENABLE_SQLLOG 0, /* xSqllog */ 0, /* pSqllogArg */ -@@ -14771,7 +14778,7 @@ static int parseHhMmSs(const char *zDate +@@ -13741,6 +13748,9 @@ static const char * const azCompileOpt[] + #ifdef SQLITE_MAX_SCHEMA_RETRY + "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY), + #endif ++#ifdef SQLITE_MAX_WORKER_THREADS ++ "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS), ++#endif + #ifdef SQLITE_MEMDEBUG + "MEMDEBUG", + #endif +@@ -14936,7 +14946,7 @@ static int parseHhMmSs(const char *zDate zDate += 5; if( *zDate==':' ){ zDate++; @@ -8932,7 +9227,7 @@ return 1; } zDate += 2; -@@ -16363,7 +16370,7 @@ static malloc_zone_t* _sqliteZone_; +@@ -16528,7 +16538,7 @@ static malloc_zone_t* _sqliteZone_; ** -DSQLITE_WITHOUT_MSIZE. Using the _msize() function also requires ** the malloc.h header file. */ @@ -8941,7 +9236,15 @@ # define SQLITE_USE_MALLOC_H # define SQLITE_USE_MSIZE #endif -@@ -19348,6 +19355,12 @@ SQLITE_API int sqlite3_open_file_count = +@@ -18616,6 +18626,7 @@ SQLITE_PRIVATE int sqlite3MutexEnd(void) + SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){ + #ifndef SQLITE_OMIT_AUTOINIT + if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0; ++ if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0; + #endif + return sqlite3GlobalConfig.mutex.xMutexAlloc(id); + } +@@ -19513,6 +19524,12 @@ SQLITE_API int sqlite3_open_file_count = #ifdef __CYGWIN__ # include # include /* amalgamator: dontcache */ @@ -8954,7 +9257,144 @@ #endif /* -@@ -24127,7 +24140,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode +@@ -19581,8 +19598,8 @@ SQLITE_API int sqlite3_open_file_count = + */ + struct sqlite3_mutex { + CRITICAL_SECTION mutex; /* Mutex controlling the lock */ +- int id; /* Mutex type */ + #ifdef SQLITE_DEBUG ++ int id; /* Mutex type */ + volatile int nRef; /* Number of enterances */ + volatile DWORD owner; /* Thread holding this mutex */ + volatile int trace; /* True to trace changes */ +@@ -19600,7 +19617,7 @@ struct sqlite3_mutex { + #define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, \ + 0L, (DWORD)0, 0 } + #else +-#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0 } ++#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER } + #endif + + #ifdef SQLITE_DEBUG +@@ -19638,7 +19655,6 @@ static sqlite3_mutex winMutex_staticMute + }; + + static int winMutex_isInit = 0; +-static int winMutex_isNt = -1; /* <0 means "need to query" */ + + /* As the winMutexInit() and winMutexEnd() functions are called as part + ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the +@@ -19646,7 +19662,9 @@ static int winMutex_isNt = -1; /* <0 mea + */ + static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0; + +-SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */ ++#if defined(__CYGWIN__) && defined(SQLITE_AMALGAMATION) ++static ++#endif + SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ + + static int winMutexInit(void){ +@@ -19832,30 +19850,15 @@ static int winMutexTry(sqlite3_mutex *p) + ** The sqlite3_mutex_try() routine is very rarely used, and when it + ** is used it is merely an optimization. So it is OK for it to always + ** fail. +- ** +- ** The TryEnterCriticalSection() interface is only available on WinNT. +- ** And some windows compilers complain if you try to use it without +- ** first doing some #defines that prevent SQLite from building on Win98. +- ** For that reason, we will omit this optimization for now. See +- ** ticket #2685. + */ +-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400 + assert( winMutex_isInit==1 ); +- assert( winMutex_isNt>=-1 && winMutex_isNt<=1 ); +- if( winMutex_isNt<0 ){ +- winMutex_isNt = sqlite3_win32_is_nt(); +- } +- assert( winMutex_isNt==0 || winMutex_isNt==1 ); +- if( winMutex_isNt && TryEnterCriticalSection(&p->mutex) ){ ++ if( TryEnterCriticalSection(&p->mutex) ){ + #ifdef SQLITE_DEBUG + p->owner = tid; + p->nRef++; + #endif + rc = SQLITE_OK; + } +-#else +- UNUSED_PARAMETER(p); +-#endif + #ifdef SQLITE_DEBUG + if( p->trace ){ + OSTRACE(("TRY-MUTEX tid=%lu, mutex=%p (%d), owner=%lu, nRef=%d, rc=%s\n", +@@ -20756,11 +20759,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite + ** the glibc version so the glibc version is definitely preferred. + */ + #if !defined(HAVE_STRCHRNUL) +-# if defined(linux) +-# define HAVE_STRCHRNUL 1 +-# else +-# define HAVE_STRCHRNUL 0 +-# endif ++# define HAVE_STRCHRNUL 0 + #endif + + +@@ -22025,7 +22024,8 @@ SQLITE_PRIVATE void sqlite3PrngRestoreSt + #if SQLITE_MAX_WORKER_THREADS>0 + + /********************************* Unix Pthreads ****************************/ +-#if SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0 ++#if (SQLITE_OS_UNIX || defined(__CYGWIN__)) && \ ++ defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0 + + #define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */ + /* #include */ +@@ -22088,12 +22088,14 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQL + return rc; + } + +-#endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */ ++#endif /* (SQLITE_OS_UNIX || defined(__CYGWIN__)) && \ ++ defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0 */ + /******************************** End Unix Pthreads *************************/ + + + /********************************* Win32 Threads ****************************/ +-#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_THREADSAFE>0 ++#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \ ++ SQLITE_THREADSAFE>0 && (defined(_MSC_VER) || defined(__MSVCRT__)) + + #define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */ + #include +@@ -22166,7 +22168,6 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HA + /* Get the results of the thread */ + SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ + DWORD rc; +- BOOL bRc; + + assert( ppOut!=0 ); + if( NEVER(p==0) ) return SQLITE_NOMEM; +@@ -22178,15 +22179,15 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQL + assert( p->id!=0 && p->id!=GetCurrentThreadId() ); + rc = sqlite3Win32Wait((HANDLE)p->tid); + assert( rc!=WAIT_IO_COMPLETION ); +- bRc = CloseHandle((HANDLE)p->tid); +- assert( bRc ); ++ CloseHandle((HANDLE)p->tid); + } + if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult; + sqlite3_free(p); + return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR; + } + +-#endif /* SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT */ ++#endif /* SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \ ++ SQLITE_THREADSAFE>0 && (defined(_MSC_VER) || defined(__MSVCRT__)) */ + /******************************** End Win32 Threads *************************/ + + +@@ -24661,7 +24662,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode ** where the database is located. */ #if !defined(SQLITE_ENABLE_LOCKING_STYLE) @@ -8963,7 +9403,7 @@ # define SQLITE_ENABLE_LOCKING_STYLE 1 # else # define SQLITE_ENABLE_LOCKING_STYLE 0 -@@ -24160,12 +24173,13 @@ SQLITE_PRIVATE const char *sqlite3Opcode +@@ -24694,12 +24695,13 @@ SQLITE_PRIVATE const char *sqlite3Opcode # include #endif @@ -8980,7 +9420,7 @@ # include # include # endif -@@ -24210,7 +24224,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode +@@ -24744,7 +24746,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode /* ** Maximum supported path-length. */ @@ -8989,7 +9429,7 @@ /* ** Only set the lastErrno if the error code is a real error and not -@@ -24268,7 +24282,7 @@ struct unixFile { +@@ -24802,7 +24804,7 @@ struct unixFile { #if SQLITE_ENABLE_LOCKING_STYLE int openFlags; /* The flags specified at open() */ #endif @@ -8998,7 +9438,7 @@ unsigned fsFlags; /* cached details from statfs() */ #endif #if OS_VXWORKS -@@ -24605,6 +24619,7 @@ static int unixGetpagesize(void); +@@ -25147,6 +25149,7 @@ static int unixGetpagesize(void); ** testing and sandboxing. The following array holds the names and pointers ** to all overrideable system calls. */ @@ -9006,7 +9446,7 @@ static struct unix_syscall { const char *zName; /* Name of the system call */ sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ -@@ -25094,7 +25109,9 @@ struct vxworksFileId { +@@ -25649,7 +25652,9 @@ struct vxworksFileId { ** variable: */ static struct vxworksFileId *vxworksFileList = 0; @@ -9016,7 +9456,7 @@ /* ** Simplify a filename into its canonical form ** by making the following changes: -@@ -25113,7 +25130,13 @@ static int vxworksSimplifyName(char *z, +@@ -25668,7 +25673,13 @@ static int vxworksSimplifyName(char *z, while( n>1 && z[n-1]=='/' ){ n--; } for(i=j=0; ipAppData==(void*)&autolockIoFinder ); #else -@@ -29521,7 +29621,7 @@ static int fillInUnixFile( +@@ -30084,7 +30173,7 @@ static int fillInUnixFile( } if( pLockingStyle == &posixIoMethods @@ -9260,7 +9701,7 @@ || pLockingStyle == &nfsIoMethods #endif ){ -@@ -29597,7 +29697,7 @@ static int fillInUnixFile( +@@ -30160,7 +30249,7 @@ static int fillInUnixFile( pNew->lockingContext = zLockFile; } @@ -9269,7 +9710,7 @@ else if( pLockingStyle == &semIoMethods ){ /* Named semaphore locking uses the file path so it needs to be ** included in the semLockingContext -@@ -29607,8 +29707,14 @@ static int fillInUnixFile( +@@ -30170,8 +30259,14 @@ static int fillInUnixFile( if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){ char *zSemName = pNew->pInode->aSemName; int n; @@ -9284,7 +9725,7 @@ for( n=1; zSemName[n]; n++ ) if( zSemName[n]=='/' ) zSemName[n] = '_'; pNew->pInode->pSem = sem_open(zSemName, O_CREAT, 0666, 1); -@@ -29620,6 +29726,15 @@ static int fillInUnixFile( +@@ -30183,6 +30278,15 @@ static int fillInUnixFile( unixLeaveMutex(); } #endif @@ -9300,7 +9741,7 @@ pNew->lastErrno = 0; #if OS_VXWORKS -@@ -29649,6 +29764,8 @@ static const char *unixTempFileDir(void) +@@ -30212,6 +30316,8 @@ static const char *unixTempFileDir(void) 0, 0, 0, @@ -9309,7 +9750,7 @@ "/var/tmp", "/usr/tmp", "/tmp", -@@ -29661,6 +29778,8 @@ static const char *unixTempFileDir(void) +@@ -30224,6 +30330,8 @@ static const char *unixTempFileDir(void) azDirs[0] = sqlite3_temp_directory; if( !azDirs[1] ) azDirs[1] = getenv("SQLITE_TMPDIR"); if( !azDirs[2] ) azDirs[2] = getenv("TMPDIR"); @@ -9318,7 +9759,7 @@ for(i=0; iopenFlags = openFlags; } -@@ -30067,7 +30186,7 @@ static int unixOpen( +@@ -30630,7 +30738,7 @@ static int unixOpen( noLock = eType!=SQLITE_OPEN_MAIN_DB; @@ -9358,7 +9799,7 @@ if( fstatfs(fd, &fsInfo) == -1 ){ ((unixFile*)pFile)->lastErrno = errno; robust_close(p, fd, __LINE__); -@@ -30085,7 +30204,7 @@ static int unixOpen( +@@ -30648,7 +30756,7 @@ static int unixOpen( if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC; if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI; @@ -9367,7 +9808,7 @@ #if SQLITE_PREFER_PROXY_LOCKING isAutoProxy = 1; #endif -@@ -30280,7 +30399,7 @@ static int unixFullPathname( +@@ -30843,7 +30951,7 @@ static int unixFullPathname( #include static void *unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename){ UNUSED_PARAMETER(NotUsed); @@ -9376,7 +9817,7 @@ } /* -@@ -30411,7 +30530,11 @@ static int unixSleep(sqlite3_vfs *NotUse +@@ -30974,7 +31082,11 @@ static int unixSleep(sqlite3_vfs *NotUse ** sqlite3OsCurrentTime() during testing. */ #ifdef SQLITE_TEST @@ -9388,7 +9829,7 @@ #endif /* -@@ -30638,7 +30761,7 @@ static int unixGetLastError(sqlite3_vfs +@@ -31201,7 +31313,7 @@ static int unixGetLastError(sqlite3_vfs /* ** Proxy locking is only available on MacOSX */ @@ -9397,7 +9838,7 @@ /* ** The proxyLockingContext has the path and file structures for the remote -@@ -30829,6 +30952,12 @@ end_create_proxy: +@@ -31392,6 +31504,12 @@ end_create_proxy: SQLITE_API int sqlite3_hostid_num = 0; #endif @@ -9410,7 +9851,7 @@ #define PROXY_HOSTIDLEN 16 /* conch file host id length */ /* Not always defined in the headers as it ought to be */ -@@ -31217,11 +31346,13 @@ static int proxyTakeConch(unixFile *pFil +@@ -31780,11 +31898,13 @@ static int proxyTakeConch(unixFile *pFil if( rc==SQLITE_OK ){ pCtx->conchHeld = 1; @@ -9424,7 +9865,7 @@ } else { conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK); } -@@ -31403,15 +31534,19 @@ static int proxyTransformUnixFile(unixFi +@@ -31966,15 +32086,19 @@ static int proxyTransformUnixFile(unixFi ** Ugh, since O_RDONLY==0x0000 we test for !O_RDWR since unixOpen asserts ** that openFlags will have only one of O_RDONLY or O_RDWR. */ @@ -9444,7 +9885,7 @@ } if( goLockless ){ pCtx->conchHeld = -1; /* read only FS/ lockless */ -@@ -31670,7 +31805,15 @@ static int proxyClose(sqlite3_file *id) +@@ -32233,7 +32357,15 @@ static int proxyClose(sqlite3_file *id) ** necessarily been initialized when this routine is called, and so they ** should not be used. */ @@ -9461,13 +9902,15 @@ /* ** The following macro defines an initializer for an sqlite3_vfs object. ** The name of the VFS is NAME. The pAppData is a pointer to a pointer -@@ -31724,25 +31867,30 @@ SQLITE_API int sqlite3_os_init(void){ +@@ -32287,25 +32419,32 @@ SQLITE_API int sqlite3_os_init(void){ ** array cannot be const. */ static sqlite3_vfs aVfs[] = { -#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__)) +#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__) || defined(__CYGWIN__)) UNIXVFS("unix", autolockIoFinder ), ++#elif defined(__CYGWIN__) ++ UNIXVFS("unix", cygwinIoFinder ), #else UNIXVFS("unix", posixIoFinder ), #endif @@ -9498,7 +9941,7 @@ UNIXVFS("unix-nfs", nfsIoFinder ), UNIXVFS("unix-proxy", proxyIoFinder ), #endif -@@ -31760,6 +31908,8 @@ SQLITE_API int sqlite3_os_init(void){ +@@ -32323,6 +32462,8 @@ SQLITE_API int sqlite3_os_init(void){ return SQLITE_OK; } @@ -9507,7 +9950,7 @@ /* ** Shutdown the operating system interface. ** -@@ -31770,6 +31920,7 @@ SQLITE_API int sqlite3_os_init(void){ +@@ -32333,6 +32474,7 @@ SQLITE_API int sqlite3_os_init(void){ SQLITE_API int sqlite3_os_end(void){ return SQLITE_OK; } @@ -9515,48 +9958,25 @@ #endif /* SQLITE_OS_UNIX */ -@@ -32021,7 +32172,8 @@ SQLITE_API int sqlite3_open_file_count = +@@ -32584,7 +32726,7 @@ SQLITE_API int sqlite3_open_file_count = ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions ** based on the sub-platform)? */ -#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI) -+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(_WIN32) \ -+ && !defined(_WIN64) && !defined(SQLITE_WIN32_NO_ANSI) ++#if 0 # define SQLITE_WIN32_HAS_ANSI #endif -@@ -32050,16 +32202,12 @@ SQLITE_API int sqlite3_open_file_count = - # define NTDDI_WIN8 0x06020000 - #endif - --#ifndef NTDDI_WINBLUE --# define NTDDI_WINBLUE 0x06030000 --#endif -- - /* - ** Check to see if the GetVersionEx[AW] functions are deprecated on the - ** target system. GetVersionEx was first deprecated in Win8.1. - */ - #ifndef SQLITE_WIN32_GETVERSIONEX --# if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE -+# if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8 - # define SQLITE_WIN32_GETVERSIONEX 0 /* GetVersionEx() is deprecated */ - # else - # define SQLITE_WIN32_GETVERSIONEX 1 /* GetVersionEx() is current */ -@@ -32393,9 +32541,9 @@ SQLITE_PRIVATE const sqlite3_mem_methods - ** can manually set this value to 1 to emulate Win98 behavior. +@@ -32957,8 +33099,6 @@ SQLITE_PRIVATE const sqlite3_mem_methods */ #ifdef SQLITE_TEST --SQLITE_API LONG volatile sqlite3_os_type = 0; + SQLITE_API LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0; -#else --static LONG volatile sqlite3_os_type = 0; -+SQLITE_API int sqlite3_os_type = 0; -+#elif !SQLITE_OS_WINRT && defined(SQLITE_WIN32_GETVERSIONEX) && SQLITE_WIN32_GETVERSIONEX -+static int sqlite3_os_type = 0; +-static LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0; #endif #ifndef SYSCALL -@@ -32489,7 +32637,7 @@ static struct win_syscall { +@@ -33052,7 +33192,7 @@ static struct win_syscall { #define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \ DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent) @@ -9565,7 +9985,7 @@ { "CreateMutexW", (SYSCALL)CreateMutexW, 0 }, #else { "CreateMutexW", (SYSCALL)0, 0 }, -@@ -32639,7 +32787,7 @@ static struct win_syscall { +@@ -33202,7 +33342,7 @@ static struct win_syscall { #define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent) @@ -9574,7 +9994,7 @@ #if SQLITE_OS_WINCE /* The GetProcAddressA() routine is only available on Windows CE. */ { "GetProcAddressA", (SYSCALL)GetProcAddressA, 0 }, -@@ -32798,7 +32946,7 @@ static struct win_syscall { +@@ -33361,7 +33501,7 @@ static struct win_syscall { #define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent) @@ -9583,7 +10003,7 @@ { "LockFile", (SYSCALL)LockFile, 0 }, #else { "LockFile", (SYSCALL)0, 0 }, -@@ -32870,16 +33018,14 @@ static struct win_syscall { +@@ -33433,7 +33573,7 @@ static struct win_syscall { #define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \ LPFILETIME))aSyscall[56].pCurrent) @@ -9592,16 +10012,7 @@ { "UnlockFile", (SYSCALL)UnlockFile, 0 }, #else { "UnlockFile", (SYSCALL)0, 0 }, - #endif - --#ifndef osUnlockFile - #define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ - DWORD))aSyscall[57].pCurrent) --#endif - - #if !SQLITE_OS_WINCE - { "UnlockFileEx", (SYSCALL)UnlockFileEx, 0 }, -@@ -32917,7 +33063,7 @@ static struct win_syscall { +@@ -33480,7 +33620,7 @@ static struct win_syscall { #define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \ DWORD,DWORD))aSyscall[62].pCurrent) @@ -9610,24 +10021,19 @@ { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, #else { "WaitForSingleObject", (SYSCALL)0, 0 }, -@@ -33036,12 +33182,74 @@ static struct win_syscall { +@@ -33594,6 +33734,7 @@ static struct win_syscall { + ** is really just a macro that uses a compiler intrinsic (e.g. x64). + ** So do not try to make this is into a redefinable interface. + */ ++#if 0 + #if defined(InterlockedCompareExchange) + { "InterlockedCompareExchange", (SYSCALL)0, 0 }, - #define osInterlockedCompareExchange InterlockedCompareExchange - #else -- { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 }, -+ { "InterlockedCompareExchange", (SYSCALL)0, 0 }, - - #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG volatile*, \ - LONG,LONG))aSyscall[76].pCurrent) +@@ -33604,6 +33745,61 @@ static struct win_syscall { + #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \ + SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent) #endif /* defined(InterlockedCompareExchange) */ - -+#if defined(SQLITE_WIN32_HAS_ANSI) && defined(_WIN32) -+ { "GetModuleHandleA", (SYSCALL)GetModuleHandleA, 0 }, -+#else -+ { "GetModuleHandleA", (SYSCALL)0, 0 }, -+#endif -+ -+#define osGetModuleHandleA ((HMODULE(*)(LPCSTR))aSyscall[77].pCurrent) ++#endif /* 0*/ + +#if defined(SQLITE_WIN32_HAS_WIDE) && defined(_WIN32) + { "GetModuleHandleW", (SYSCALL)GetModuleHandleW, 0 }, @@ -9635,7 +10041,7 @@ + { "GetModuleHandleW", (SYSCALL)0, 0 }, +#endif + -+#define osGetModuleHandleW ((HMODULE(*)(LPCWSTR))aSyscall[78].pCurrent) ++#define osGetModuleHandleW ((HMODULE(*)(LPCWSTR))aSyscall[76].pCurrent) + +#if defined(SQLITE_WIN32_HAS_WIDE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) + { "SetDllDirectoryW", (SYSCALL)SetDllDirectoryW, 0 }, @@ -9643,7 +10049,7 @@ + { "SetDllDirectoryW", (SYSCALL)0, 0 }, +#endif + -+#define osSetDllDirectoryW ((BOOL(*)(LPCWSTR))aSyscall[79].pCurrent) ++#define osSetDllDirectoryW ((BOOL(*)(LPCWSTR))aSyscall[77].pCurrent) + +#if defined(__CYGWIN__) + { "getenv", (SYSCALL)getenv, 0 }, @@ -9651,7 +10057,7 @@ + { "getenv", (SYSCALL)0, 0 }, +#endif + -+#define getenv ((const char *(*)(const char *))aSyscall[80].pCurrent) ++#define getenv ((const char *(*)(const char *))aSyscall[78].pCurrent) + +#if defined(__CYGWIN__) + { "getcwd", (SYSCALL)getcwd, 0 }, @@ -9659,7 +10065,7 @@ + { "getcwd", (SYSCALL)0, 0 }, +#endif + -+#define getcwd ((char*(*)(char*,size_t))aSyscall[81].pCurrent) ++#define getcwd ((char*(*)(char*,size_t))aSyscall[79].pCurrent) + +#if defined(__CYGWIN__) + { "__errno", (SYSCALL)__errno, 0 }, @@ -9667,7 +10073,7 @@ + { "__errno", (SYSCALL)0, 0 }, +#endif + -+#define osErrno (*((int*(*)(void))aSyscall[82].pCurrent)()) ++#define osErrno (*((int*(*)(void))aSyscall[80].pCurrent)()) + +#if defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE) + { "cygwin_conv_path", (SYSCALL)cygwin_conv_path, 0 }, @@ -9675,18 +10081,17 @@ + { "cygwin_conv_path", (SYSCALL)0, 0 }, +#endif + -+#define cygwin_conv_path ((ssize_t(*)(unsigned int, \ -+ const void *, void *, size_t))aSyscall[83].pCurrent) ++#define cygwin_conv_path ((size_t(*)(unsigned int, \ ++ const void *, void *, size_t))aSyscall[81].pCurrent) + + { "cygwin_conv_to_full_win32_path", (SYSCALL)0, 0 }, + +#define cygwin_conv_to_full_win32_path ((void(*)(const char *, \ -+ char *))aSyscall[84].pCurrent) -+ ++ char *))aSyscall[82].pCurrent) + }; /* End of the overrideable system calls */ - /* -@@ -33215,6 +33423,7 @@ SQLITE_API int sqlite3_win32_reset_heap( +@@ -33778,6 +33974,7 @@ SQLITE_API int sqlite3_win32_reset_heap( } #endif /* SQLITE_WIN32_MALLOC */ @@ -9694,7 +10099,7 @@ /* ** This function outputs the specified (ANSI) string to the Win32 debugger ** (if available). -@@ -33251,6 +33460,7 @@ SQLITE_API void sqlite3_win32_write_debu +@@ -33814,6 +34011,7 @@ SQLITE_API void sqlite3_win32_write_debu } #endif } @@ -9702,7 +10107,7 @@ /* ** The following routine suspends the current thread for at least ms -@@ -33260,6 +33470,9 @@ SQLITE_API void sqlite3_win32_write_debu +@@ -33823,6 +34021,9 @@ SQLITE_API void sqlite3_win32_write_debu static HANDLE sleepObj = NULL; #endif @@ -9712,47 +10117,23 @@ SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){ #if SQLITE_OS_WINRT if ( sleepObj==NULL ){ -@@ -33299,31 +33512,27 @@ SQLITE_API void sqlite3_win32_sleep(DWOR +@@ -33868,6 +34069,7 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HA + # define osIsNT() ((sqlite3_os_type==2) || sqlite3_win32_is_nt()) + #endif + ++#if 0 + /* ** This function determines if the machine is running a version of Windows ** based on the NT kernel. - */ -+#ifdef _WIN32 - SQLITE_API int sqlite3_win32_is_nt(void){ --#if defined(SQLITE_WIN32_GETVERSIONEX) && SQLITE_WIN32_GETVERSIONEX -- if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){ --#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \ -- defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8 -+#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_GETVERSIONEX) && SQLITE_WIN32_GETVERSIONEX -+ if( sqlite3_os_type==0 ){ -+#if !defined(SQLITE_WIN32_HAS_ANSI) - OSVERSIONINFOW sInfo; - sInfo.dwOSVersionInfoSize = sizeof(sInfo); - osGetVersionExW(&sInfo); -- osInterlockedCompareExchange(&sqlite3_os_type, -- (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); --#elif defined(SQLITE_WIN32_HAS_ANSI) -+#else - OSVERSIONINFOA sInfo; - sInfo.dwOSVersionInfoSize = sizeof(sInfo); - osGetVersionExA(&sInfo); -- osInterlockedCompareExchange(&sqlite3_os_type, -- (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); - #endif -+ sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1; - } -- return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; --#elif SQLITE_TEST -- return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; -+ return sqlite3_os_type==2; - #else +@@ -33906,6 +34108,7 @@ SQLITE_API int sqlite3_win32_is_nt(void) return 1; #endif } -+#endif /* _WIN32 */ ++#endif /* 0 */ #ifdef SQLITE_WIN32_MALLOC /* -@@ -33530,12 +33739,13 @@ SQLITE_PRIVATE void sqlite3MemSetDefault +@@ -34112,12 +34315,13 @@ SQLITE_PRIVATE void sqlite3MemSetDefault } #endif /* SQLITE_WIN32_MALLOC */ @@ -9767,14 +10148,14 @@ int nChar; LPWSTR zWideFilename; -@@ -33543,9 +33753,13 @@ static LPWSTR winUtf8ToUnicode(const cha +@@ -34125,9 +34329,13 @@ static LPWSTR winUtf8ToUnicode(const cha if( nChar==0 ){ return 0; } - zWideFilename = sqlite3MallocZero( nChar*sizeof(zWideFilename[0]) ); - if( zWideFilename==0 ){ - return 0; -+ if( buf && ((size_t)nChar<=MAX_PATH/sizeof(WCHAR)) ){ ++ if( buf && ((size_t)nChar<=MAX_PATH) ){ + zWideFilename = buf; + }else{ + zWideFilename = sqlite3Malloc( nChar*sizeof(WCHAR) ); @@ -9784,7 +10165,7 @@ } nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); -@@ -33555,6 +33769,7 @@ static LPWSTR winUtf8ToUnicode(const cha +@@ -34137,6 +34345,7 @@ static LPWSTR winUtf8ToUnicode(const cha } return zWideFilename; } @@ -9792,7 +10173,7 @@ /* ** Convert Microsoft Unicode to UTF-8. Space to hold the returned string is -@@ -33581,6 +33796,7 @@ static char *winUnicodeToUtf8(LPCWSTR zW +@@ -34163,6 +34372,7 @@ static char *winUnicodeToUtf8(LPCWSTR zW return zFilename; } @@ -9800,7 +10181,7 @@ /* ** Convert an ANSI string to Microsoft Unicode, based on the ** current codepage settings for file apis. -@@ -33594,7 +33810,7 @@ static LPWSTR winMbcsToUnicode(const cha +@@ -34176,7 +34386,7 @@ static LPWSTR winMbcsToUnicode(const cha int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP; nByte = osMultiByteToWideChar(codepage, 0, zFilename, -1, NULL, @@ -9809,11 +10190,11 @@ if( nByte==0 ){ return 0; } -@@ -33664,13 +33880,16 @@ SQLITE_API char *sqlite3_win32_mbcs_to_u +@@ -34246,13 +34456,16 @@ SQLITE_API char *sqlite3_win32_mbcs_to_u SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ char *zFilenameMbcs; LPWSTR zTmpWide; -+ WCHAR buf[MAX_PATH/sizeof(WCHAR)]; ++ WCHAR buf[MAX_PATH]; - zTmpWide = winUtf8ToUnicode(zFilename); + zTmpWide = winUtf8ToUnicode(zFilename, buf); @@ -9828,7 +10209,7 @@ return zFilenameMbcs; } -@@ -33696,7 +33915,7 @@ SQLITE_API int sqlite3_win32_set_directo +@@ -34278,7 +34491,7 @@ SQLITE_API int sqlite3_win32_set_directo || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ); assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) ); @@ -9837,7 +10218,7 @@ char *zValueUtf8 = 0; if( zValue && zValue[0] ){ zValueUtf8 = winUnicodeToUtf8(zValue); -@@ -33710,6 +33929,7 @@ SQLITE_API int sqlite3_win32_set_directo +@@ -34292,6 +34505,7 @@ SQLITE_API int sqlite3_win32_set_directo } return SQLITE_ERROR; } @@ -9845,18 +10226,18 @@ /* ** The return value of winGetLastErrorMsg -@@ -33974,8 +34194,9 @@ static int winceCreateLock(const char *z +@@ -34556,8 +34770,9 @@ static int winceCreateLock(const char *z DWORD lastErrno; BOOL bLogged = FALSE; BOOL bInit = TRUE; -+ WCHAR buf[MAX_PATH/sizeof(WCHAR)]; ++ WCHAR buf[MAX_PATH]; - zName = winUtf8ToUnicode(zFilename); + zName = winUtf8ToUnicode(zFilename, buf); if( zName==0 ){ /* out of memory */ return SQLITE_IOERR_NOMEM; -@@ -33995,7 +34216,9 @@ static int winceCreateLock(const char *z +@@ -34577,7 +34792,9 @@ static int winceCreateLock(const char *z pFile->hMutex = osCreateMutexW(NULL, FALSE, zName); if (!pFile->hMutex){ pFile->lastErrno = osGetLastError(); @@ -9867,7 +10248,7 @@ return winLogError(SQLITE_IOERR, pFile->lastErrno, "winceCreateLock1", zFilename); } -@@ -34019,7 +34242,9 @@ static int winceCreateLock(const char *z +@@ -34601,7 +34818,9 @@ static int winceCreateLock(const char *z bInit = FALSE; } @@ -9878,7 +10259,7 @@ /* If we succeeded in making the shared memory handle, map it. */ if( pFile->hShared ){ -@@ -34253,9 +34478,11 @@ static BOOL winLockFile( +@@ -34835,9 +35054,11 @@ static BOOL winLockFile( ovlp.Offset = offsetLow; ovlp.OffsetHigh = offsetHigh; return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp); @@ -9890,7 +10271,7 @@ } #endif } -@@ -34284,9 +34511,11 @@ static BOOL winUnlockFile( +@@ -34866,9 +35087,11 @@ static BOOL winUnlockFile( ovlp.Offset = offsetLow; ovlp.OffsetHigh = offsetHigh; return osUnlockFileEx(*phFile, 0, numBytesLow, numBytesHigh, &ovlp); @@ -9902,7 +10283,7 @@ } #endif } -@@ -34757,12 +34986,13 @@ static int winFileSize(sqlite3_file *id, +@@ -35339,12 +35562,13 @@ static int winFileSize(sqlite3_file *id, DWORD lastErrno; lowerBits = osGetFileSize(pFile->h, &upperBits); @@ -9917,15 +10298,15 @@ } } #endif -@@ -36092,6 +36322,7 @@ static int winFetch(sqlite3_file *fd, i6 - ** may now be invalid and should be unmapped. - */ - static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){ -+ UNUSED_PARAMETER(iOff); - #if SQLITE_MAX_MMAP_SIZE>0 - winFile *pFd = (winFile*)fd; /* The underlying database file */ +@@ -36701,6 +36925,7 @@ static int winUnfetch(sqlite3_file *fd, + assert( pFd->nFetchOut>=0 ); + #endif -@@ -36163,7 +36394,7 @@ static const sqlite3_io_methods winIoMet ++ UNUSED_PARAMETER(iOff); + OSTRACE(("UNFETCH pid=%lu, pFile=%p, rc=SQLITE_OK\n", + osGetCurrentProcessId(), fd)); + return SQLITE_OK; +@@ -36745,7 +36970,7 @@ static const sqlite3_io_methods winIoMet ** sqlite3_vfs object. */ @@ -9934,7 +10315,7 @@ /* ** Convert a filename from whatever the underlying operating system ** supports for filenames into UTF-8. Space to hold the result is -@@ -36188,14 +36419,119 @@ static char *winConvertToUtf8Filename(co +@@ -36770,12 +36995,106 @@ static char *winConvertToUtf8Filename(co ** Convert a UTF-8 filename into whatever form the underlying ** operating system wants filenames in. Space to hold the result ** is obtained from malloc and must be freed by the calling @@ -9971,7 +10352,7 @@ + int nByte; + int convertflag = CCP_POSIX_TO_WIN_W; + if( !strchr(zFilename, '/') ) convertflag |= CCP_RELATIVE; -+ nByte = cygwin_conv_path(convertflag, ++ nByte = (int) cygwin_conv_path(convertflag, + zFilename, 0, 0); + if( nByte>0 ){ + if( buf && (nByte<(MAX_PATH-12)) ){ @@ -10003,7 +10384,7 @@ + sqlite3_free(zConverted); + } + } -+#ifdef SQLITE_WIN32_HAS_ANSI ++#ifdef _WIN32 + }else if( (cygwin_conv_to_full_win32_path!=NULL) && + !(winIsDriveLetterAndColon(zFilename) && winIsDirSep(zFilename[2]))){ + char buf1[MAX_PATH]; @@ -10015,7 +10396,7 @@ + if( nChar==0 ){ + return 0; + } -+ if( buf && ((size_t)nChar<=MAX_PATH/sizeof(WCHAR)) ){ ++ if( buf && ((size_t)nChar<=MAX_PATH) ){ + zWideFilename = buf; + }else{ + zWideFilename = sqlite3Malloc( nChar*sizeof(WCHAR)+12 ); @@ -10043,21 +10424,8 @@ + zConverted = zWideFilename; } #ifdef SQLITE_WIN32_HAS_ANSI -+ else if( cygwin_conv_to_full_win32_path && -+ !(winIsDriveLetterAndColon(zFilename) && winIsDirSep(zFilename[2])) ){ -+ if( buf ){ -+ zConverted = buf; -+ }else{ -+ zConverted = sqlite3Malloc(MAX_PATH); -+ } -+ if( zConverted ){ -+ cygwin_conv_to_full_win32_path(zFilename, zConverted); -+ } -+ } else{ - zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); - } -@@ -36216,7 +36552,14 @@ static int winMakeEndInDirSep(int nBuf, +@@ -36798,7 +37117,14 @@ static int winMakeEndInDirSep(int nBuf, if( winIsDirSep(zBuf[nLen-1]) ){ return 1; }else if( nLen+1lastErrno = lastErrno; winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name); @@ -10211,7 +10579,7 @@ sqlite3_free(zTmpname); if( isReadWrite && !isExclusive ){ return winOpen(pVfs, zName, id, -@@ -36729,17 +37086,21 @@ static int winOpen( +@@ -37311,17 +37651,21 @@ static int winOpen( && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK ){ osCloseHandle(h); @@ -10236,11 +10604,11 @@ } sqlite3_free(zTmpname); -@@ -36788,13 +37149,14 @@ static int winDelete( +@@ -37370,13 +37714,14 @@ static int winDelete( DWORD attr; DWORD lastErrno = 0; void *zConverted; -+ WCHAR buf[MAX_PATH/sizeof(WCHAR)]; ++ WCHAR buf[MAX_PATH]; UNUSED_PARAMETER(pVfs); UNUSED_PARAMETER(syncDir); @@ -10252,7 +10620,7 @@ if( zConverted==0 ){ OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename)); return SQLITE_IOERR_NOMEM; -@@ -36878,7 +37240,9 @@ static int winDelete( +@@ -37460,7 +37805,9 @@ static int winDelete( }else{ winLogIoerr(cnt); } @@ -10263,11 +10631,11 @@ OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc))); return rc; } -@@ -36896,13 +37260,14 @@ static int winAccess( +@@ -37478,13 +37825,14 @@ static int winAccess( int rc = 0; DWORD lastErrno = 0; void *zConverted; -+ WCHAR buf[MAX_PATH/sizeof(WCHAR)]; ++ WCHAR buf[MAX_PATH]; UNUSED_PARAMETER(pVfs); SimulateIOError( return SQLITE_IOERR_ACCESS; ); @@ -10279,7 +10647,7 @@ if( zConverted==0 ){ OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename)); return SQLITE_IOERR_NOMEM; -@@ -36928,7 +37293,9 @@ static int winAccess( +@@ -37510,7 +37858,9 @@ static int winAccess( }else{ winLogIoerr(cnt); if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){ @@ -10290,7 +10658,7 @@ return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename); }else{ -@@ -36941,7 +37308,9 @@ static int winAccess( +@@ -37523,7 +37873,9 @@ static int winAccess( attr = osGetFileAttributesA((char*)zConverted); } #endif @@ -10301,7 +10669,7 @@ switch( flags ){ case SQLITE_ACCESS_READ: case SQLITE_ACCESS_EXISTS: -@@ -36970,6 +37339,7 @@ static BOOL winIsDriveLetterAndColon( +@@ -37552,6 +37904,7 @@ static BOOL winIsDriveLetterAndColon( return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' ); } @@ -10309,7 +10677,7 @@ /* ** Returns non-zero if the specified path name should be used verbatim. If ** non-zero is returned from this function, the calling function must simply -@@ -37006,6 +37376,42 @@ static BOOL winIsVerbatimPathname( +@@ -37588,6 +37941,42 @@ static BOOL winIsVerbatimPathname( */ return FALSE; } @@ -10352,7 +10720,7 @@ /* ** Turn a relative pathname into a full pathname. Write the full -@@ -37019,7 +37425,33 @@ static int winFullPathname( +@@ -37601,7 +37990,33 @@ static int winFullPathname( char *zFull /* Output buffer */ ){ @@ -10361,7 +10729,7 @@ + DWORD nByte; + void *zConverted; + char *zOut; -+ WCHAR buf[MAX_PATH/sizeof(WCHAR)]; ++ WCHAR buf[MAX_PATH]; +#endif + + SimulateIOError( return SQLITE_ERROR ); @@ -10387,7 +10755,25 @@ SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); assert( nFull>=pVfs->mxPathname ); -@@ -37077,7 +37509,6 @@ static int winFullPathname( +@@ -37616,7 +38031,7 @@ static int winFullPathname( + if( !zOut ){ + return SQLITE_IOERR_NOMEM; + } +- if( cygwin_conv_path( ++ if( (int) cygwin_conv_path( + (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) | + CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){ + sqlite3_free(zOut); +@@ -37638,7 +38053,7 @@ static int winFullPathname( + if( !zOut ){ + return SQLITE_IOERR_NOMEM; + } +- if( cygwin_conv_path( ++ if( (int) cygwin_conv_path( + (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A), + zRelative, zOut, pVfs->mxPathname+1)<0 ){ + sqlite3_free(zOut); +@@ -37659,7 +38074,6 @@ static int winFullPathname( #endif #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) @@ -10395,7 +10781,7 @@ /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ -@@ -37095,10 +37526,12 @@ static int winFullPathname( +@@ -37677,10 +38091,12 @@ static int winFullPathname( return SQLITE_OK; #endif @@ -10409,7 +10795,7 @@ /* If this path name begins with "/X:", where "X" is any alphabetic ** character, discard the initial "/" from the pathname. -@@ -37107,12 +37540,7 @@ static int winFullPathname( +@@ -37689,12 +38105,7 @@ static int winFullPathname( zRelative++; } @@ -10423,7 +10809,7 @@ if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data -@@ -37124,7 +37552,8 @@ static int winFullPathname( +@@ -37706,7 +38117,8 @@ static int winFullPathname( sqlite3_data_directory, winGetDirSep(), zRelative); return SQLITE_OK; } @@ -10433,7 +10819,7 @@ if( zConverted==0 ){ return SQLITE_IOERR_NOMEM; } -@@ -37132,24 +37561,32 @@ static int winFullPathname( +@@ -37714,24 +38126,32 @@ static int winFullPathname( LPWSTR zTemp; nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); if( nByte==0 ){ @@ -10471,43 +10857,7 @@ zOut = winUnicodeToUtf8(zTemp); sqlite3_free(zTemp); } -@@ -37158,30 +37595,53 @@ static int winFullPathname( - char *zTemp; - nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0); - if( nByte==0 ){ -- sqlite3_free(zConverted); -+ if( zConverted != buf ){ -+ sqlite3_free(zConverted); -+ } - return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(), - "winFullPathname3", zRelative); - } - nByte += 3; -- zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) ); -+ zTemp = sqlite3Malloc( nByte*sizeof(zTemp[0]) ); - if( zTemp==0 ){ -- sqlite3_free(zConverted); -+ if( zConverted != buf ){ -+ sqlite3_free(zConverted); -+ } - return SQLITE_IOERR_NOMEM; - } - nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0); - if( nByte==0 ){ -- sqlite3_free(zConverted); -+ if( zConverted != buf ){ -+ sqlite3_free(zConverted); -+ } - sqlite3_free(zTemp); - return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(), - "winFullPathname4", zRelative); - } -- sqlite3_free(zConverted); -+ if( zConverted != buf ){ -+ sqlite3_free(zConverted); -+ } - zOut = sqlite3_win32_mbcs_to_utf8(zTemp); - sqlite3_free(zTemp); +@@ -37763,7 +38183,22 @@ static int winFullPathname( } #endif if( zOut ){ @@ -10531,7 +10881,7 @@ sqlite3_free(zOut); return SQLITE_OK; }else{ -@@ -37197,7 +37657,7 @@ static int winFullPathname( +@@ -37779,7 +38214,7 @@ static int winFullPathname( */ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ HANDLE h; @@ -10540,17 +10890,17 @@ int nFull = pVfs->mxPathname+1; char *zFull = sqlite3MallocZero( nFull ); void *zConverted = 0; -@@ -37213,7 +37673,8 @@ static void *winDlOpen(sqlite3_vfs *pVfs +@@ -37795,7 +38230,8 @@ static void *winDlOpen(sqlite3_vfs *pVfs zConverted = winConvertFromUtf8Filename(zFull); sqlite3_free(zFull); #else - void *zConverted = winConvertFromUtf8Filename(zFilename); -+ WCHAR buf[MAX_PATH/sizeof(WCHAR)]; ++ WCHAR buf[MAX_PATH]; + void *zConverted = winConvertFromUtf8Filename(zFilename, buf); UNUSED_PARAMETER(pVfs); #endif if( zConverted==0 ){ -@@ -37233,7 +37694,9 @@ static void *winDlOpen(sqlite3_vfs *pVfs +@@ -37815,7 +38251,9 @@ static void *winDlOpen(sqlite3_vfs *pVfs } #endif OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)h)); @@ -10561,7 +10911,7 @@ return (void*)h; } static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ -@@ -37271,31 +37734,31 @@ static int winRandomness(sqlite3_vfs *pV +@@ -37853,31 +38291,31 @@ static int winRandomness(sqlite3_vfs *pV n = nBuf; memset(zBuf, 0, nBuf); #else @@ -10598,7 +10948,7 @@ LARGE_INTEGER i; osQueryPerformanceCounter(&i); memcpy(&zBuf[n], &i, sizeof(i)); -@@ -37422,6 +37885,10 @@ static int winGetLastError(sqlite3_vfs * +@@ -38004,6 +38442,10 @@ static int winGetLastError(sqlite3_vfs * return winGetLastErrorMsg(osGetLastError(), nBuf, zBuf); } @@ -10609,7 +10959,7 @@ /* ** Initialize and deinitialize the operating system interface. */ -@@ -37475,11 +37942,15 @@ SQLITE_API int sqlite3_os_init(void){ +@@ -38057,11 +38499,15 @@ SQLITE_API int sqlite3_os_init(void){ winGetSystemCall, /* xGetSystemCall */ winNextSystemCall, /* xNextSystemCall */ }; @@ -10622,30 +10972,21 @@ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==77 ); -+ assert( ArraySize(aSyscall)==85 ); ++ assert( ArraySize(aSyscall)==83 ); /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); -@@ -37491,8 +37962,43 @@ SQLITE_API int sqlite3_os_init(void){ +@@ -38073,8 +38519,43 @@ SQLITE_API int sqlite3_os_init(void){ assert( winSysInfo.dwAllocationGranularity>0 ); assert( winSysInfo.dwPageSize>0 ); +#ifdef _WIN32 -+ if( osIsNT() ){ -+ module = osGetModuleHandleW(L"CYGWIN1.DLL"); -+ if( !module){ -+ module = osGetModuleHandleW(L"MSYS-2.0.DLL"); -+ } -+#ifdef SQLITE_WIN32_HAS_ANSI -+ }else{ -+ module = osGetModuleHandleA("CYGWIN1.DLL"); -+ if( !module){ -+ module = osGetModuleHandleA("MSYS-2.0.DLL"); -+ } -+#endif ++ module = osGetModuleHandleW(L"CYGWIN1.DLL"); ++ if( !module){ ++ module = osGetModuleHandleW(L"MSYS-1.0.DLL"); + } + if( module ){ -+ for( i=80; i=0) buf[i] = buf1[i]; ++ osSetDllDirectoryW(buf); ++#endif + } +#endif + #if defined(SQLITE_WIN32_HAS_WIDE) sqlite3_vfs_register(&winLongPathVfs, 0); #endif -@@ -37501,6 +38007,19 @@ SQLITE_API int sqlite3_os_init(void){ +@@ -38083,6 +38564,19 @@ SQLITE_API int sqlite3_os_init(void){ } SQLITE_API int sqlite3_os_end(void){ @@ -10678,19 +11028,68 @@ + int i; +#endif +#if !defined(SQLITE_OMIT_LOAD_EXTENSION) -+ if( osIsNT() && cygwin_conv_path ){ ++ if( cygwin_conv_path || cygwin_conv_to_full_win32_path){ + osSetDllDirectoryW(0); + } +#endif +#ifdef _WIN32 -+ for( i=80; ijfd, 0); ++ if( rc==SQLITE_OK && pPager->fullSync ){ ++ /* Make sure the new file size is written into the inode right away. ++ ** Otherwise the journal might resurrect following a power loss and ++ ** cause the last transaction to roll back. See ++ ** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773 ++ */ ++ rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags); ++ } + } + pPager->journalOff = 0; + }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST +@@ -54293,7 +54795,7 @@ static int removeFromSharingList(BtShare + */ + static void allocateTempSpace(BtShared *pBt){ + if( !pBt->pTmpSpace ){ +- pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize ); ++ u8 *pTmpSpace = sqlite3PageMalloc( pBt->pageSize ); + + /* One of the uses of pBt->pTmpSpace is to format cells before + ** inserting them into a leaf page (function fillInCell()). If +@@ -54310,10 +54812,11 @@ static void allocateTempSpace(BtShared * + ** beginning of pTmpSpace as an area available to prepend the + ** left-child pointer to the beginning of a cell. + */ +- if( pBt->pTmpSpace ){ +- memset(pBt->pTmpSpace, 0, 8); +- pBt->pTmpSpace += 4; ++ if( pTmpSpace ){ ++ memset(pTmpSpace, 0, 8); ++ pTmpSpace += 4; + } ++ pBt->pTmpSpace = pTmpSpace; + } + } + +@@ -54322,8 +54825,7 @@ static void allocateTempSpace(BtShared * + */ + static void freeTempSpace(BtShared *pBt){ + if( pBt->pTmpSpace ){ +- pBt->pTmpSpace -= 4; +- sqlite3PageFree(pBt->pTmpSpace); ++ sqlite3PageFree(pBt->pTmpSpace - 4); + pBt->pTmpSpace = 0; + } + } +@@ -63357,7 +63859,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdb pOp->p3 = p3; pOp->p4.p = 0; pOp->p4type = P4_NOTUSED; @@ -10699,7 +11098,7 @@ pOp->zComment = 0; #endif #ifdef SQLITE_DEBUG -@@ -62794,7 +63313,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOpList( +@@ -63768,7 +64270,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOpList( pOut->p4type = P4_NOTUSED; pOut->p4.p = 0; pOut->p5 = 0; @@ -10708,7 +11107,7 @@ pOut->zComment = 0; #endif #ifdef SQLITE_VDBE_COVERAGE -@@ -62935,7 +63454,7 @@ static void vdbeFreeOpArray(sqlite3 *db, +@@ -63909,7 +64411,7 @@ static void vdbeFreeOpArray(sqlite3 *db, Op *pOp; for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ freeP4(db, pOp->p4type, pOp->p4.p); @@ -10717,7 +11116,7 @@ sqlite3DbFree(db, pOp->zComment); #endif } -@@ -63057,7 +63576,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyI +@@ -64032,7 +64534,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyI P4_KEYINFO); } @@ -10726,7 +11125,7 @@ /* ** Change the comment on the most recently coded instruction. Or ** insert a No-op and add the comment to that new instruction. This -@@ -63130,7 +63649,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp( +@@ -64105,7 +64607,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp( } } @@ -10735,7 +11134,7 @@ /* ** Return an integer value for one of the parameters to the opcode pOp ** determined by character c. -@@ -63419,8 +63938,12 @@ SQLITE_PRIVATE void sqlite3VdbePrintOp(F +@@ -64394,8 +64896,12 @@ SQLITE_PRIVATE void sqlite3VdbePrintOp(F static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n"; if( pOut==0 ) pOut = stdout; zP4 = displayP4(pOp, zPtr, sizeof(zPtr)); @@ -10750,19 +11149,19 @@ #else zCom[0] = 0; #endif -@@ -63665,15 +64188,19 @@ SQLITE_PRIVATE int sqlite3VdbeList( +@@ -64640,15 +65146,19 @@ SQLITE_PRIVATE int sqlite3VdbeList( sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */ pMem->enc = SQLITE_UTF8; pMem++; - -#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS -- if( sqlite3VdbeMemGrow(pMem, 500, 0) ){ +- if( sqlite3VdbeMemClearAndResize(pMem, 500) ){ - assert( p->db->mallocFailed ); - return SQLITE_ERROR; + +#if 1 + if( sqlite3GlobalConfig.bVdbeComments ){ -+ if( sqlite3VdbeMemGrow(pMem, 500, 0) ){ ++ if( sqlite3VdbeMemClearAndResize(pMem, 500) ){ + assert( p->db->mallocFailed ); + return SQLITE_ERROR; + } @@ -10778,26 +11177,85 @@ #else pMem->flags = MEM_Null; /* Comment */ #endif -@@ -97221,6 +97748,9 @@ struct sqlite3_api_routines { - const char *(*uri_parameter)(const char*,const char*); - char *(*vsnprintf)(int,char*,const char*,va_list); - int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); -+ /* Cyqlite 3.8.6 and later */ -+ int (*auto_extension)(void (*xInit)(void)); -+ int (*cancel_auto_extension)(void (*xInit)(void)); - }; +@@ -76540,7 +77050,7 @@ static int vdbeSorterMapFile(SortSubtask + int rc = SQLITE_OK; + if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){ + sqlite3_file *pFd = pFile->pFd; +- if( pFd->pMethods->iVersion>=3 ){ ++ if( pFd->pMethods->iVersion>=3 && pFd->pMethods->xFetch ){ + rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp); + testcase( rc!=SQLITE_OK ); + } +@@ -88658,7 +89168,7 @@ SQLITE_PRIVATE void sqlite3FinishCoding( + while( sqlite3VdbeDeletePriorOpcode(v, OP_Close) ){} + sqlite3VdbeAddOp0(v, OP_Halt); +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + if( pParse->nTableLock>0 && db->init.busy==0 ){ + sqlite3UserAuthInit(db); + if( db->auth.authLevelnested--; + } + +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION /* -@@ -97438,6 +97968,8 @@ struct sqlite3_api_routines { - #define sqlite3_uri_parameter sqlite3_api->uri_parameter - #define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf - #define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 -+#define sqlite3_auto_extension sqlite3_api->auto_extension -+#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension - #endif /* SQLITE_CORE */ - - #ifndef SQLITE_CORE -@@ -97461,7 +97993,7 @@ struct sqlite3_api_routines { + ** Return TRUE if zTable is the name of the system table that stores the + ** list of users and their access credentials. +@@ -88812,7 +89322,7 @@ SQLITE_PRIVATE Table *sqlite3FindTable(s + assert( zName!=0 ); + /* All mutexes are required for schema access. Make sure we hold them. */ + assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) ); +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + /* Only the admin user is allowed to know that the sqlite_user table + ** exists */ + if( db->auth.authLevelnErr==0 ); + if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 + && db->init.busy==0 +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + && sqlite3UserAuthTable(pTab->zName)==0 + #endif + && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){ +@@ -95847,7 +96357,7 @@ SQLITE_PRIVATE void sqlite3RegisterGloba + FUNCTION(sqlite_version, 0, 0, 0, versionFunc ), + FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), + FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + FUNCTION(sqlite_crypt, 2, 0, 0, sqlite3CryptFunc ), + #endif + #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS +@@ -99784,9 +100294,11 @@ struct sqlite3_api_routines { + #define sqlite3_commit_hook sqlite3_api->commit_hook + #define sqlite3_complete sqlite3_api->complete + #define sqlite3_complete16 sqlite3_api->complete16 +-#define sqlite3_create_collation sqlite3_api->create_collation ++#undef sqlite3_create_collation ++#define sqlite3_create_collation(a,b,c,d,e) sqlite3_create_collation_v2(a,b,c,d,e,0) + #define sqlite3_create_collation16 sqlite3_api->create_collation16 +-#define sqlite3_create_function sqlite3_api->create_function ++#undef sqlite3_create_function ++#define sqlite3_create_function(a,b,c,d,e,f,g,h) sqlite3_create_function_v2(a,b,c,d,e,f,g,h,0) + #define sqlite3_create_function16 sqlite3_api->create_function16 + #define sqlite3_create_module sqlite3_api->create_module + #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 +@@ -99923,7 +100435,8 @@ struct sqlite3_api_routines { + #define sqlite3_strnicmp sqlite3_api->strnicmp + #define sqlite3_unlock_notify sqlite3_api->unlock_notify + #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint +-#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint ++#undef sqlite3_wal_checkpoint ++#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint; + #define sqlite3_wal_hook sqlite3_api->wal_hook + #define sqlite3_blob_reopen sqlite3_api->blob_reopen + #define sqlite3_vtab_config sqlite3_api->vtab_config +@@ -99978,7 +100491,7 @@ struct sqlite3_api_routines { /************** Continuing where we left off in loadext.c ********************/ /* #include */ @@ -10806,17 +11264,21 @@ /* ** Some API routines are omitted when various features are -@@ -97831,9 +98363,16 @@ static const sqlite3_api_routines sqlite - sqlite3_uri_int64, - sqlite3_uri_parameter, - sqlite3_vsnprintf, -- sqlite3_wal_checkpoint_v2 -+ sqlite3_wal_checkpoint_v2, -+ /* -+ ** Added for Cyqlite 3.8.6 -+ */ -+ sqlite3_auto_extension, -+ sqlite3_cancel_auto_extension +@@ -100354,7 +100867,11 @@ static const sqlite3_api_routines sqlite + sqlite3_bind_blob64, + sqlite3_bind_text64, + sqlite3_cancel_auto_extension, ++#ifndef SQLITE_OMIT_LOAD_EXTENSION + sqlite3_load_extension, ++#else ++ 0, ++#endif + sqlite3_malloc64, + sqlite3_msize, + sqlite3_realloc64, +@@ -100363,7 +100880,9 @@ static const sqlite3_api_routines sqlite + sqlite3_result_text64, + sqlite3_strglob }; +#endif @@ -10824,47 +11286,64 @@ /* ** Attempt to load an SQLite extension library contained in the file ** zFile. The entry point is zProc. zProc may be 0 in which case a -@@ -97863,7 +98402,7 @@ static int sqlite3LoadExtension( - int ii; +@@ -100390,18 +100909,17 @@ static int sqlite3LoadExtension( + char *zAltEntry = 0; + void **aHandle; + int nMsg = 300 + sqlite3Strlen30(zFile); +- int ii; /* Shared library endings to try if zFile cannot be loaded as written */ - static const char *azEndings[] = { -+ static const char *const azEndings[] = { - #if SQLITE_OS_WIN +-#if SQLITE_OS_WIN ++ static const char azEnding[] = ++#if SQLITE_OS_WIN || defined(__CYGWIN__) "dll" #elif defined(__APPLE__) -@@ -97892,14 +98431,28 @@ static int sqlite3LoadExtension( + "dylib" + #else + "so" + #endif +- }; ++ ; + + + if( pzErrMsg ) *pzErrMsg = 0; +@@ -100422,14 +100940,30 @@ static int sqlite3LoadExtension( zEntry = zProc ? zProc : "sqlite3_extension_init"; handle = sqlite3OsDlOpen(pVfs, zFile); -#if SQLITE_OS_UNIX || SQLITE_OS_WIN - for(ii=0; iiauth.authLevel==UAUTH_User ){ + /* Do not allow non-admin users to modify the schema arbitrarily */ + mask &= ~(SQLITE_WriteSchema); +@@ -105194,7 +105713,7 @@ static void generateSortTail( + int nSortData; /* Trailing values to read from sorter */ + int i; + int bSeq; /* True if sorter record includes seq. no. */ +-#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS ++#if 1 + struct ExprList_item *aOutEx = p->pEList->a; + #endif + +@@ -110496,7 +111015,7 @@ static int codeTriggerProgram( return 0; } @@ -10918,12 +11415,13 @@ /* ** This function is used to add VdbeComment() annotations to a VDBE ** program. It is not used in production code, only for debugging. -@@ -122677,6 +123215,12 @@ SQLITE_API int sqlite3_config(int op, .. +@@ -125427,6 +125946,13 @@ SQLITE_API int sqlite3_config(int op, .. } #endif -+ case SQLITE_CONFIG_EXPLAIN_COMMENTS: { -+ /* Enable VDBE commenting */ ++ case 32: /* SQLITE_CONFIG_EXPLAIN_COMMENTS */ ++ case 64: /* SQLITE_CONFIG_EXPLAIN_COMMENTS */ { ++ /* Enable VDBE commenting (cannot be switched off) */ + sqlite3GlobalConfig.bVdbeComments = 1; + break; + } @@ -10931,7 +11429,40 @@ default: { rc = SQLITE_ERROR; break; -@@ -130640,6 +131184,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlit +@@ -125897,7 +126423,7 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAnd + sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */ + sqlite3ValueFree(db->pErr); + sqlite3CloseExtensions(db); +-#if SQLITE_USER_AUTHENTICATION ++#ifdef SQLITE_USER_AUTHENTICATION + sqlite3_free(db->auth.zAuthUser); + sqlite3_free(db->auth.zAuthPW); + #endif +@@ -126367,6 +126893,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc( + /* + ** Create new user functions. + */ ++#undef sqlite3_create_function + SQLITE_API int sqlite3_create_function( + sqlite3 *db, + const char *zFunc, +@@ -126686,6 +127213,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2 + ** to contains a zero-length string, all attached databases are + ** checkpointed. + */ ++#undef sqlite3_wal_checkpoint + SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){ + return sqlite3_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, 0, 0); + } +@@ -127651,6 +128179,7 @@ SQLITE_API int sqlite3_open16( + /* + ** Register a new collation sequence with the database handle db. + */ ++#undef sqlite3_create_collation + SQLITE_API int sqlite3_create_collation( + sqlite3* db, + const char *zName, +@@ -133392,6 +133921,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlit #ifndef SQLITE_DISABLE_FTS3_UNICODE || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode) @@ -10939,7 +11470,24 @@ #endif #ifdef SQLITE_ENABLE_ICU || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu)) -@@ -135967,7 +136512,6 @@ SQLITE_PRIVATE int sqlite3Fts3InitHashTa +@@ -137206,12 +137736,12 @@ exprtest_out: + ** with database connection db. + */ + SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){ +- int rc = sqlite3_create_function( +- db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0 ++ int rc = sqlite3_create_function_v2( ++ db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0, 0 + ); + if( rc==SQLITE_OK ){ +- rc = sqlite3_create_function(db, "fts3_exprtest_rebalance", +- -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0 ++ rc = sqlite3_create_function_v2(db, "fts3_exprtest_rebalance", ++ -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0, 0 + ); + } + return rc; +@@ -138719,7 +139249,6 @@ SQLITE_PRIVATE int sqlite3Fts3InitHashTa ){ int rc = SQLITE_OK; void *p = (void *)pHash; @@ -10947,29 +11495,29 @@ #ifdef SQLITE_TEST char *zTest = 0; -@@ -135981,17 +136525,17 @@ SQLITE_PRIVATE int sqlite3Fts3InitHashTa +@@ -138733,17 +139262,17 @@ SQLITE_PRIVATE int sqlite3Fts3InitHashTa #endif if( SQLITE_OK==rc ){ - rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0); -+ rc = sqlite3_create_function(db, zName, 1, SQLITE_UTF8, p, scalarFunc, 0, 0); ++ rc = sqlite3_create_function_v2(db, zName, 1, SQLITE_UTF8, p, scalarFunc, 0, 0, 0); } if( SQLITE_OK==rc ){ - rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0); -+ rc = sqlite3_create_function(db, zName, 2, SQLITE_UTF8, p, scalarFunc, 0, 0); ++ rc = sqlite3_create_function_v2(db, zName, 2, SQLITE_UTF8, p, scalarFunc, 0, 0, 0); } #ifdef SQLITE_TEST if( SQLITE_OK==rc ){ - rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0); -+ rc = sqlite3_create_function(db, zTest, -1, SQLITE_UTF8, p, testFunc, 0, 0); ++ rc = sqlite3_create_function_v2(db, zTest, -1, SQLITE_UTF8, p, testFunc, 0, 0, 0); } if( SQLITE_OK==rc ){ - rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0); -+ rc = sqlite3_create_function(db, zTest2, 0, SQLITE_UTF8, pdb, intTestFunc, 0, 0); ++ rc = sqlite3_create_function_v2(db, zTest2, 0, SQLITE_UTF8, pdb, intTestFunc, 0, 0, 0); } #endif -@@ -144323,84 +144867,91 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal +@@ -147075,84 +147604,91 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal 0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01, 0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401, 0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01, @@ -11135,7 +11683,7 @@ }; static const unsigned int aAscii[4] = { 0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001, -@@ -144439,7 +144990,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal +@@ -147191,7 +147727,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal ** uppercase letter are undefined. */ static int remove_diacritic(int c){ @@ -11144,7 +11692,7 @@ 0, 1797, 1848, 1859, 1891, 1928, 1940, 1995, 2024, 2040, 2060, 2110, 2168, 2206, 2264, 2286, 2344, 2383, 2472, 2488, 2516, 2596, 2668, 2732, -@@ -144454,7 +145005,7 @@ static int remove_diacritic(int c){ +@@ -147206,7 +147742,7 @@ static int remove_diacritic(int c){ 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62924, 63050, 63082, 63274, 63390, }; @@ -11153,7 +11701,7 @@ '\0', 'a', 'c', 'e', 'i', 'n', 'o', 'u', 'y', 'y', 'a', 'c', 'd', 'e', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'w', 'y', 'z', 'o', 'u', 'a', 'i', 'o', -@@ -144532,8 +145083,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +@@ -147284,8 +147820,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold } aEntry[] = { {65, 14, 26}, {181, 64, 1}, {192, 14, 23}, {216, 14, 7}, {256, 1, 48}, {306, 1, 6}, @@ -11164,7 +11712,7 @@ {386, 1, 4}, {390, 44, 1}, {391, 0, 1}, {393, 42, 2}, {395, 0, 1}, {398, 32, 1}, {399, 38, 1}, {400, 40, 1}, {401, 0, 1}, -@@ -144546,44 +145097,46 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +@@ -147298,44 +147834,46 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold {440, 0, 1}, {444, 0, 1}, {452, 2, 1}, {453, 0, 1}, {455, 2, 1}, {456, 0, 1}, {458, 2, 1}, {459, 1, 18}, {478, 1, 18}, @@ -11247,7 +11795,7 @@ {65313, 14, 26}, }; static const unsigned short aiOff[] = { -@@ -144591,12 +145144,13 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +@@ -147343,12 +147881,13 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold 37, 38, 40, 48, 63, 64, 69, 71, 79, 80, 116, 202, 203, 205, 206, 207, 209, 210, 211, 213, 214, 217, 218, 219, @@ -11267,7 +11815,7 @@ }; int ret = c; -@@ -144637,6 +145191,9 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +@@ -147389,6 +147928,9 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold else if( c>=66560 && c<66600 ){ ret = c + 40; } @@ -11277,7 +11825,19 @@ return ret; } -@@ -148570,7 +149127,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite +@@ -150728,9 +151270,9 @@ SQLITE_PRIVATE int sqlite3RtreeInit(sqli + const int utf8 = SQLITE_UTF8; + int rc; + +- rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0); ++ rc = sqlite3_create_function_v2(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0, 0); + if( rc==SQLITE_OK ){ +- rc = sqlite3_create_function(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0); ++ rc = sqlite3_create_function_v2(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0, 0); + } + if( rc==SQLITE_OK ){ + #ifdef SQLITE_RTREE_INT_ONLY +@@ -151322,7 +151864,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite void *pContext; /* sqlite3_user_data() context */ void (*xFunc)(sqlite3_context*,int,sqlite3_value**); } scalars[] = { @@ -11286,19 +11846,83 @@ {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16}, {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16}, ---- origsrc/sqlite-autoconf-3080600/sqlite3.h 2014-08-15 16:09:16.000000000 +0200 -+++ src/sqlite-autoconf-3080600/sqlite3.h 2014-08-19 18:33:37.871850700 +0200 +@@ -151345,8 +151887,8 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite + + for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){ + struct IcuScalar *p = &scalars[i]; +- rc = sqlite3_create_function( +- db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0 ++ rc = sqlite3_create_function_v2( ++ db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0, 0 + ); + } + +--- origsrc/sqlite-autoconf-3080700/sqlite3.h 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/sqlite3.h 2014-10-28 16:49:46.116272000 +0100 @@ -108,7 +108,7 @@ extern "C" { ** [sqlite_version()] and [sqlite_source_id()]. */ - #define SQLITE_VERSION "3.8.6" --#define SQLITE_VERSION_NUMBER 3008006 -+#define SQLITE_VERSION_NUMBER 3008005 - #define SQLITE_SOURCE_ID "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e" + #define SQLITE_VERSION "3.8.7" +-#define SQLITE_VERSION_NUMBER 3008007 ++#define SQLITE_VERSION_NUMBER 3008006 + #define SQLITE_SOURCE_ID "2014-10-17 11:24:17 e4ab094f8afce0817f4074e823fabe59fc29ebb4" /* ---- origsrc/sqlite-autoconf-3080600/sqlite3icu.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/sqlite3icu.c 2014-08-19 11:29:09.496230400 +0200 +@@ -4120,6 +4120,8 @@ SQLITE_API int sqlite3_create_function( + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) + ); ++/* A macro is more efficient than a wrapped call */ ++#define sqlite3_create_function(a,b,c,d,e,f,g,h) sqlite3_create_function_v2(a,b,c,d,e,f,g,h,0) + SQLITE_API int sqlite3_create_function16( + sqlite3 *db, + const void *zFunctionName, +@@ -4604,6 +4606,8 @@ SQLITE_API int sqlite3_create_collation( + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*) + ); ++/* A macro is more efficient than a wrapped call */ ++#define sqlite3_create_collation(a,b,c,d,e) sqlite3_create_collation_v2(a,b,c,d,e,0) + SQLITE_API int sqlite3_create_collation_v2( + sqlite3*, + const char *zName, +@@ -7230,7 +7234,7 @@ SQLITE_API int sqlite3_wal_autocheckpoin + ** See also: [sqlite3_wal_checkpoint_v2()] + */ + SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); +- ++#define sqlite3_wal_checkpoint(a,b) sqlite3_wal_checkpoint_v2(a,b,SQLITE_CHECKPOINT_PASSIVE,0,0); + /* + ** CAPI3REF: Checkpoint a database + ** +--- origsrc/sqlite-autoconf-3080700/sqlite3ext.h 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/sqlite3ext.h 2014-10-28 17:41:53.238636200 +0100 +@@ -326,9 +326,11 @@ struct sqlite3_api_routines { + #define sqlite3_commit_hook sqlite3_api->commit_hook + #define sqlite3_complete sqlite3_api->complete + #define sqlite3_complete16 sqlite3_api->complete16 +-#define sqlite3_create_collation sqlite3_api->create_collation ++#undef sqlite3_create_collation ++#define sqlite3_create_collation(a,b,c,d,e) sqlite3_create_collation_v2(a,b,c,d,e,0) + #define sqlite3_create_collation16 sqlite3_api->create_collation16 +-#define sqlite3_create_function sqlite3_api->create_function ++#undef sqlite3_create_function ++#define sqlite3_create_function(a,b,c,d,e,f,g,h) sqlite3_create_function_v2(a,b,c,d,e,f,g,h,0) + #define sqlite3_create_function16 sqlite3_api->create_function16 + #define sqlite3_create_module sqlite3_api->create_module + #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 +@@ -465,7 +467,8 @@ struct sqlite3_api_routines { + #define sqlite3_strnicmp sqlite3_api->strnicmp + #define sqlite3_unlock_notify sqlite3_api->unlock_notify + #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint +-#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint ++#undef sqlite3_wal_checkpoint ++#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint; + #define sqlite3_wal_hook sqlite3_api->wal_hook + #define sqlite3_blob_reopen sqlite3_api->blob_reopen + #define sqlite3_vtab_config sqlite3_api->vtab_config +--- origsrc/sqlite-autoconf-3080700/sqlite3icu.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/sqlite3icu.c 2014-10-21 17:57:13.890569100 +0200 @@ -0,0 +1,517 @@ +/****************************************************************************** +** This file is an amalgamation of separate C source files from the SQLite @@ -11308,7 +11932,7 @@ +** that would not be possible if the files were compiled separately. It also +** makes the code easier to import into other projects. +** -+** This amalgamation was generated on 2014-07-07 07:51:16 UTC. ++** This amalgamation was generated on 2014-10-21 15:56:37 UTC. +*/ +/************** Begin file icu.c *********************************************/ +/* @@ -11633,7 +12257,7 @@ +** of upper() or lower(). +** +** lower('I', 'en_us') -> 'i' -+** lower('I', 'tr_tr') -> 'ı' (small dotless i) ++** lower('I', 'tr_tr') -> 'ı' (small dotless i) +** +** http://www.icu-project.org/userguide/posix.html#case_mappings +*/ @@ -11817,23 +12441,34 @@ +#endif + +/************** End of icu.c *************************************************/ ---- origsrc/sqlite-autoconf-3080600/tea/configure.in 2014-08-15 16:09:18.000000000 +0200 -+++ src/sqlite-autoconf-3080600/tea/configure.in 2014-08-19 11:29:09.505230900 +0200 -@@ -166,8 +166,10 @@ AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stu +--- origsrc/sqlite-autoconf-3080700/tea/configure.in 2014-10-17 13:38:34.000000000 +0200 ++++ src/sqlite-autoconf-3080700/tea/configure.in 2014-10-28 17:26:30.091917700 +0100 +@@ -79,6 +79,9 @@ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS3=1]) + TEA_ADD_CFLAGS([-DSQLITE_3_SUFFIX_ONLY=1]) + TEA_ADD_CFLAGS([-DSQLITE_ENABLE_RTREE=1]) + TEA_ADD_CFLAGS([-DSQLITE_OMIT_DEPRECATED=1]) ++TEA_ADD_CFLAGS([-DSQLITE_MAX_PATH_LENGTH=4096]) ++TEA_ADD_CFLAGS([-DSQLITE_WIN32_NO_ANSI=1]) ++TEA_ADD_CFLAGS([-DSQLITE_WIN32_GETVERSIONEX=0]) + TEA_ADD_STUB_SOURCES([]) + TEA_ADD_TCL_SOURCES([]) + +@@ -166,10 +169,10 @@ AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stu #-------------------------------------------------------------------- # Redefine fdatasync as fsync on systems that lack fdatasync #-------------------------------------------------------------------- -- --AC_CHECK_FUNC(fdatasync, , AC_DEFINE(fdatasync, fsync)) -+# -+#AC_CHECK_FUNC(fdatasync, , AC_DEFINE(fdatasync, fsync)) -+# Check for library functions that SQLite can optionally use. -+AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r]) +-# +-#AC_CHECK_FUNC(fdatasync, , AC_DEFINE(fdatasync, fsync)) ++ ++AC_CHECK_FUNC(fdatasync, , AC_DEFINE(fdatasync, fsync)) + # Check for library functions that SQLite can optionally use. +-AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r]) ++AC_CHECK_FUNCS([strchrnul usleep utime localtime_r gmtime_r]) AC_FUNC_STRERROR_R ---- origsrc/sqlite-autoconf-3080600/tea/generic/tclsqlite3.c 2014-08-15 16:09:18.000000000 +0200 -+++ src/sqlite-autoconf-3080600/tea/generic/tclsqlite3.c 2014-08-19 11:29:09.516231500 +0200 +--- origsrc/sqlite-autoconf-3080700/tea/generic/tclsqlite3.c 2014-10-17 13:38:34.000000000 +0200 ++++ src/sqlite-autoconf-3080700/tea/generic/tclsqlite3.c 2014-10-28 17:24:33.025683700 +0100 @@ -174,6 +174,10 @@ static int strlen30(const char *z){ return 0x3fffffff & (int)(z2 - z); } @@ -11845,18 +12480,33 @@ #ifndef SQLITE_OMIT_INCRBLOB /* -@@ -2386,7 +2390,7 @@ static int DbObjCmd(void *cd, Tcl_Interp - - if( rc==TCL_OK ){ - rc = createIncrblobChannel( -- interp, pDb, zDb, zTable, zColumn, iRow, isReadonly -+ interp, pDb, zDb, zTable, zColumn, (sqlite_int64)iRow, isReadonly - ); +@@ -261,7 +265,7 @@ static int incrblobInput( + */ + static int incrblobOutput( + ClientData instanceData, +- CONST char *buf, ++ const char *buf, + int toWrite, + int *errorCodePtr + ){ +@@ -1909,8 +1913,8 @@ static int DbObjCmd(void *cd, Tcl_Interp + pCollate->zScript = (char*)&pCollate[1]; + pDb->pCollate = pCollate; + memcpy(pCollate->zScript, zScript, nScript+1); +- if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, +- pCollate, tclSqlCollate) ){ ++ if( sqlite3_create_collation_v2(pDb->db, zName, SQLITE_UTF8, ++ pCollate, tclSqlCollate, 0) ){ + Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); + return TCL_ERROR; } - #endif -@@ -3074,6 +3078,18 @@ static int DbMain(void *cd, Tcl_Interp * +@@ -3080,9 +3084,21 @@ static int DbMain(void *cd, Tcl_Interp * + ** Provide a dummy Tcl_InitStubs if we are using this as a static + ** library. + */ ++#undef Tcl_InitStubs #ifndef USE_TCL_STUBS - # undef Tcl_InitStubs +-# undef Tcl_InitStubs # define Tcl_InitStubs(a,b,c) TCL_VERSION +#else +# define Tcl_InitStubs staticTclInitStubs @@ -11873,8 +12523,51 @@ #endif /* ---- origsrc/sqlite-autoconf-3080600/tea/tclconfig/tcl.m4 2014-08-15 16:09:16.000000000 +0200 -+++ src/sqlite-autoconf-3080600/tea/tclconfig/tcl.m4 2014-08-19 11:29:09.526232100 +0200 +@@ -3103,9 +3119,9 @@ static int DbMain(void *cd, Tcl_Interp * + ** used to open a new SQLite database. See the DbMain() routine above + ** for additional information. + ** +-** The EXTERN macros are required by TCL in order to work on windows. ++** The DLLEXPORT macros are required by TCL in order to work on windows. + */ +-EXTERN int Sqlite3_Init(Tcl_Interp *interp){ ++DLLEXPORT int Sqlite3_Init(Tcl_Interp *interp){ + int rc = Tcl_InitStubs(interp, "8.4", 0)==0 ? TCL_ERROR : TCL_OK; + if( rc==TCL_OK ){ + Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0); +@@ -3119,9 +3135,9 @@ EXTERN int Sqlite3_Init(Tcl_Interp *inte + } + return rc; + } +-EXTERN int Tclsqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } +-EXTERN int Sqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } +-EXTERN int Tclsqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } ++DLLEXPORT int Tclsqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); } ++DLLEXPORT int Sqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } ++DLLEXPORT int Tclsqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; } + + /* Because it accesses the file-system and uses persistent state, SQLite + ** is not considered appropriate for safe interpreters. Hence, we deliberately +@@ -3591,7 +3607,7 @@ static int init_all_cmd( + ClientData cd, + Tcl_Interp *interp, + int objc, +- Tcl_Obj *CONST objv[] ++ Tcl_Obj *const objv[] + ){ + + Tcl_Interp *slave; +@@ -3621,7 +3637,7 @@ static int db_use_legacy_prepare_cmd( + ClientData cd, + Tcl_Interp *interp, + int objc, +- Tcl_Obj *CONST objv[] ++ Tcl_Obj *const objv[] + ){ + Tcl_CmdInfo cmdInfo; + SqliteDb *pDb; +--- origsrc/sqlite-autoconf-3080700/tea/tclconfig/tcl.m4 2014-10-17 13:38:32.000000000 +0200 ++++ src/sqlite-autoconf-3080700/tea/tclconfig/tcl.m4 2014-10-21 18:00:09.487612700 +0200 @@ -1344,7 +1344,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [ fi @@ -11892,47 +12585,7 @@ CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" ;; -@@ -1641,6 +1642,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [ - SHLIB_CFLAGS="-fPIC" - SHLIB_LD="${CC} -shared" - TCL_SHLIB_LD_EXTRAS="-Wl,-soname=\$[@]" -+ TK_SHLIB_LD_EXTRAS="-Wl,-soname,\$[@]" - SHLIB_SUFFIX=".so" - LDFLAGS="" - AS_IF([test $doRpath = yes], [ -@@ -1651,11 +1653,15 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [ - LIBS=`echo $LIBS | sed s/-pthread//` - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LDFLAGS="$LDFLAGS $PTHREAD_LIBS"]) -- # Version numbers are dot-stripped by system policy. -- TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` -- UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' -- SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' -- TCL_LIB_VERSIONS_OK=nodots -+ case $system in -+ FreeBSD-3.*) -+ # Version numbers are dot-stripped by system policy. -+ TCL_TRIM_DOTS=`echo ${VERSION} | tr -d .` -+ UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' -+ SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so' -+ TCL_LIB_VERSIONS_OK=nodots -+ ;; -+ esac - ;; - Darwin-*) - CFLAGS_OPTIMIZE="-Os" -@@ -1826,8 +1832,8 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [ - SHLIB_CFLAGS="-fPIC -melf" - LDFLAGS="$LDFLAGS -melf -Wl,-Bexport" - ], [ -- SHLIB_CFLAGS="-Kpic -belf" -- LDFLAGS="$LDFLAGS -belf -Wl,-Bexport" -+ SHLIB_CFLAGS="-Kpic -belf" -+ LDFLAGS="$LDFLAGS -belf -Wl,-Bexport" - ]) - SHLIB_LD="ld -G" - SHLIB_LD_LIBS="" -@@ -3352,7 +3358,7 @@ print("manifest needed") +@@ -3357,7 +3358,7 @@ print("manifest needed") if test "$GCC" = "yes"; then SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -static-libgcc" fi @@ -11941,7 +12594,7 @@ else eval eval "PKG_LIB_FILE=${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" if test "$GCC" = "yes"; then -@@ -3374,7 +3380,7 @@ print("manifest needed") +@@ -3379,7 +3380,7 @@ print("manifest needed") if test x"${TK_BIN_DIR}" != x ; then SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}" fi @@ -11950,8 +12603,8 @@ RANLIB=: else eval eval "PKG_LIB_FILE=lib${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" ---- origsrc/sqlite-autoconf-3080600/totype.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/totype.c 2014-08-19 14:28:54.374090100 +0200 +--- origsrc/sqlite-autoconf-3080700/totype.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/totype.c 2014-10-21 17:53:41.137400300 +0200 @@ -0,0 +1,530 @@ +/* +** 2013-10-14 @@ -12483,8 +13136,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/vfslog.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/vfslog.c 2014-08-19 14:28:54.395091300 +0200 +--- origsrc/sqlite-autoconf-3080700/vfslog.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/vfslog.c 2014-10-21 17:53:41.147400900 +0200 @@ -0,0 +1,852 @@ +/* +** 2013-10-09 @@ -13338,8 +13991,8 @@ + vlog_vfs.base.mxPathname = vlog_vfs.pVfs->mxPathname; + return sqlite3_vfs_register(&vlog_vfs.base, 1); +} ---- origsrc/sqlite-autoconf-3080600/vtshim.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/vtshim.c 2014-08-19 14:28:54.412092300 +0200 +--- origsrc/sqlite-autoconf-3080700/vtshim.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/vtshim.c 2014-10-21 17:53:41.159401600 +0200 @@ -0,0 +1,561 @@ +/* +** 2013-06-12 @@ -13902,8 +14555,8 @@ + return SQLITE_OK; +} +#endif ---- origsrc/sqlite-autoconf-3080600/wholenumber.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/wholenumber.c 2014-08-19 14:28:54.433093500 +0200 +--- origsrc/sqlite-autoconf-3080700/wholenumber.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/wholenumber.c 2014-10-21 17:53:41.166402000 +0200 @@ -0,0 +1,288 @@ +/* +** 2011 April 02 @@ -14193,8 +14846,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3080600/zlib.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3080600/zlib.c 2014-08-19 14:28:54.456094800 +0200 +--- origsrc/sqlite-autoconf-3080700/zlib.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3080700/zlib.c 2014-10-21 17:53:41.174402400 +0200 @@ -0,0 +1,129 @@ +/* +** 2014 January 6