diff --git a/sqlite/PKGBUILD b/sqlite/PKGBUILD index a519827f..c3e46fe5 100644 --- a/sqlite/PKGBUILD +++ b/sqlite/PKGBUILD @@ -3,9 +3,9 @@ pkgbase="sqlite" pkgname=('sqlite' 'libsqlite' 'libsqlite-devel' 'sqlite-doc') -_amalgamationver=3100000 +_amalgamationver=3180000 _docver=${_amalgamationver} -pkgver=3.10.0.0 +pkgver=3.18.0.0 pkgrel=1 pkgdesc="A C library that implements an SQL database engine" arch=('i686' 'x86_64') @@ -14,26 +14,23 @@ url="https://www.sqlite.org/" depends=('libreadline' 'icu' 'zlib') makedepends=('libreadline-devel' 'icu-devel' 'zlib-devel') source=( # tarball containing the amalgamation for SQLite >= 3.7.5 together with a configure script and makefile for building it; includes now also the Tcl Extension Architecture (TEA) - https://www.sqlite.org/2016/sqlite-autoconf-${_amalgamationver}.tar.gz - https://www.sqlite.org/2016/sqlite-doc-${_docver}.zip + https://www.sqlite.org/2017/sqlite-autoconf-${_amalgamationver}.tar.gz + https://www.sqlite.org/2017/sqlite-doc-${_docver}.zip LICENSE - 'sqlite-3.8.0.1-msys2.patch' - 'sqlite3-3.10.0-1.src.patch' - 'sqlite3-cygwin-msys.patch') + 'sqlite-3.18.0.0-msys2.patch' + 'sqlite3-3.18.0-1.src.patch') options=('!libtool' '!emptydirs' '!debug' 'strip') -sha256sums=('43cc292d70711fa7580250c8a1cd7c64813a4a0a479dbd502cce5f10b5d91042' - '40af646d8c2109e5a15b1787e53524ed16c8e0d1705dda5f005b6186f18c2f2a' +sha256sums=('3757612463976e7d08c5e9f0af3021613fc24bbcfe1c51197d6776b9ece9ac5c' + '6f763eba9f51cb1096d1d40fbdd7ff974203060ddb892fc735adb2d7d42f1dad' '1e188e0cf2088da923bff80c76a9f13b7028d4688d2d49cdb10562718068ee98' - 'f2297a0ac50d9671cd2488e5cf17a60f2cfac268617626c89067fa4695bf47cd' - '714d0d253446f70d0c9e4fb3556e486c802a2d24d6b7f7532aebc86494eb7dc7' - '42bb44129a5dc7c23601911fc05e445b933b723e955636f8186e3077a77d1ba6') + '247e3c49e55015e534562ade0b7a89cc309040f1eb372bbd57aefab9c494fb51' + 'e650434adf7e022d28d04911442a2a5730b1bab6cc8861e9582668cf98afc4e2') prepare() { cd "${srcdir}"/sqlite-autoconf-${_amalgamationver} - patch -p2 -i ${srcdir}/sqlite3-3.10.0-1.src.patch - patch -p1 -i ${srcdir}/sqlite3-cygwin-msys.patch - patch -p1 -i ${srcdir}/sqlite-3.8.0.1-msys2.patch + patch -p2 -i ${srcdir}/sqlite3-3.18.0-1.src.patch + patch -p1 -i ${srcdir}/sqlite-3.18.0.0-msys2.patch autoreconf -fi } diff --git a/sqlite/sqlite-3.18.0.0-msys2.patch b/sqlite/sqlite-3.18.0.0-msys2.patch new file mode 100644 index 00000000..d0bdb3e0 --- /dev/null +++ b/sqlite/sqlite-3.18.0.0-msys2.patch @@ -0,0 +1,689 @@ +diff -durN sqlite-autoconf-3180000.orig/aclocal.m4 sqlite-autoconf-3180000/aclocal.m4 +--- sqlite-autoconf-3180000.orig/aclocal.m4 2017-03-30 22:26:50.000000000 +0800 ++++ sqlite-autoconf-3180000/aclocal.m4 2017-05-18 09:41:10.203125000 +0800 +@@ -1706,7 +1706,7 @@ + lt_cv_sys_max_cmd_len=-1; + ;; + +- cygwin* | mingw* | cegcc*) ++ cygwin* | msys* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, +@@ -1954,7 +1954,7 @@ + lt_cv_dlopen_libs= + ;; + +- cygwin*) ++ cygwin* | msys*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; +@@ -2535,7 +2535,7 @@ + # libtool to hard-code these into programs + ;; + +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no +@@ -2567,6 +2567,12 @@ + m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; ++ msys*) ++ # Msys DLLs use 'msys-' prefix rather than 'lib' ++ soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ++m4_if([$1], [],[ ++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ++ ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' +@@ -2601,7 +2607,7 @@ + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; +- cygwin*) ++ cygwin* | msys*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... +@@ -3379,7 +3385,7 @@ + esac + reload_cmds='$LD$reload_flag -o $output$reload_objs' + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi +@@ -3472,7 +3478,7 @@ + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +-cygwin*) ++cygwin* | msys*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' +@@ -3785,7 +3791,7 @@ + [lt_cv_sharedlib_from_linklib_cmd='unknown' + + case $host_os in +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in +@@ -3855,7 +3861,7 @@ + [AC_REQUIRE([AC_CANONICAL_HOST])dnl + LIBM= + case $host in +-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) ++*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; + *-ncr-sysv4.3*) +@@ -3930,7 +3936,7 @@ + aix*) + symcode='[[BCDT]]' + ;; +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; + hpux*) +@@ -4236,7 +4242,7 @@ + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; +- mingw* | cygwin* | os2* | pw32* | cegcc*) ++ mingw* | cygwin* | msys* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style +@@ -4312,7 +4318,7 @@ + ;; + esac + ;; +- mingw* | cygwin* | os2* | pw32* | cegcc*) ++ mingw* | cygwin* | msys* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], +@@ -4560,7 +4566,7 @@ + # PIC is the default for these OSes. + ;; + +- mingw* | cygwin* | pw32* | os2* | cegcc*) ++ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style +@@ -4664,7 +4670,7 @@ + esac + ;; + +- mingw* | cygwin* | pw32* | os2* | cegcc*) ++ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], +@@ -4939,7 +4945,7 @@ + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds + ;; +- cygwin* | mingw* | cegcc*) ++ cygwin* | msys* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' +@@ -4997,7 +5003,7 @@ + extract_expsyms_cmds= + + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. +@@ -5112,7 +5118,7 @@ + fi + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' +@@ -5568,7 +5574,7 @@ + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is +@@ -6639,7 +6645,7 @@ + esac + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC +@@ -8317,7 +8323,7 @@ + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys*) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix +@@ -8325,12 +8331,12 @@ + ;; + esac + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys*) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys*) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix +@@ -8495,7 +8501,7 @@ + [enable_win32_dll=yes + + case $host in +-*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) ++*-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) +diff -durN sqlite-autoconf-3180000.orig/compile sqlite-autoconf-3180000/compile +--- sqlite-autoconf-3180000.orig/compile 2017-03-30 22:26:52.000000000 +0800 ++++ sqlite-autoconf-3180000/compile 2017-05-18 09:43:08.500000000 +0800 +@@ -53,7 +53,7 @@ + MINGW*) + file_conv=mingw + ;; +- CYGWIN*) ++ CYGWIN* | MSYS*) + file_conv=cygwin + ;; + *) +@@ -67,7 +67,7 @@ + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; +- cygwin/*) ++ cygwin/* | msys/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) +diff -durN sqlite-autoconf-3180000.orig/config.guess sqlite-autoconf-3180000/config.guess +--- sqlite-autoconf-3180000.orig/config.guess 2017-03-30 22:26:52.000000000 +0800 ++++ sqlite-autoconf-3180000/config.guess 2017-05-18 09:44:16.890625000 +0800 +@@ -867,6 +867,9 @@ + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; ++ amd64:MSYS*:*:* | x86_64:MSYS*:*:*) ++ echo x86_64-unknown-msys ++ exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; +diff -durN sqlite-autoconf-3180000.orig/configure sqlite-autoconf-3180000/configure +--- sqlite-autoconf-3180000.orig/configure 2017-03-30 22:26:52.000000000 +0800 ++++ sqlite-autoconf-3180000/configure 2017-05-18 09:48:32.500000000 +0800 +@@ -5682,7 +5682,7 @@ + lt_cv_sys_max_cmd_len=-1; + ;; + +- cygwin* | mingw* | cegcc*) ++ cygwin* | msys* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, +@@ -5848,7 +5848,7 @@ + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys*) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix +@@ -5856,12 +5856,12 @@ + ;; + esac + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys*) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys*) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix +@@ -5927,7 +5927,7 @@ + esac + reload_cmds='$LD$reload_flag -o $output$reload_objs' + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi +@@ -6085,7 +6085,7 @@ + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +-cygwin*) ++cygwin* | msys*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' +@@ -6404,7 +6404,7 @@ + lt_cv_sharedlib_from_linklib_cmd='unknown' + + case $host_os in +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in +@@ -6896,7 +6896,7 @@ + aix*) + symcode='[BCDT]' + ;; +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; + hpux*) +@@ -9241,7 +9241,7 @@ + # PIC is the default for these OSes. + ;; + +- mingw* | cygwin* | pw32* | os2* | cegcc*) ++ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style +@@ -9344,7 +9344,7 @@ + esac + ;; + +- mingw* | cygwin* | pw32* | os2* | cegcc*) ++ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' +@@ -9846,7 +9846,7 @@ + extract_expsyms_cmds= + + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. +@@ -9961,7 +9961,7 @@ + fi + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' +@@ -10501,7 +10501,7 @@ + export_dynamic_flag_spec=-rdynamic + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is +@@ -11536,7 +11536,7 @@ + # libtool to hard-code these into programs + ;; + +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no +@@ -11568,6 +11568,12 @@ + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; ++ msys*) ++ # Msys DLLs use 'msys-' prefix rather than 'lib' ++ soname_spec='`echo ${libname} | sed -e 's/^lib/msys-/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ++ ++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ++ ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' +@@ -11602,7 +11608,7 @@ + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; +- cygwin*) ++ cygwin* | msys*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... +@@ -12304,7 +12310,7 @@ + lt_cv_dlopen_libs= + ;; + +- cygwin*) ++ cygwin* | msys*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; +diff -durN sqlite-autoconf-3180000.orig/ltmain.sh sqlite-autoconf-3180000/ltmain.sh +--- sqlite-autoconf-3180000.orig/ltmain.sh 2017-03-30 22:26:51.000000000 +0800 ++++ sqlite-autoconf-3180000/ltmain.sh 2017-05-18 09:54:56.593750000 +0800 +@@ -2418,7 +2418,7 @@ + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 +- *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) ++ *cygwin* | *msys* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; +@@ -3439,7 +3439,7 @@ + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in +- cygwin* | mingw* | pw32* | os2* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac +@@ -4313,7 +4313,7 @@ + 'exit $?' + tstripme=$stripme + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme= +@@ -4426,7 +4426,7 @@ + + # Do a test to see if this is really a libtool program. + case $host in +- *cygwin* | *mingw*) ++ *cygwin* | *msys* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result +@@ -4501,7 +4501,7 @@ + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in +- */usr/bin/install*,*cygwin*) ++ */usr/bin/install*,*cygwin* | */usr/bin/install*,*msys*) + case $file:$destfile in + *.exe:*.exe) + # this is ok +@@ -4654,7 +4654,7 @@ + $RM $export_symbols + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; +@@ -4666,7 +4666,7 @@ + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; +@@ -4680,7 +4680,7 @@ + func_basename "$dlprefile" + name=$func_basename_result + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" +@@ -4855,7 +4855,7 @@ + # Transform the symbol file into the correct name. + symfileobj=$output_objdir/${my_outputname}S.$objext + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` +@@ -5753,7 +5753,7 @@ + { + EOF + case $host in +- *mingw* | *cygwin* ) ++ *mingw* | *cygwin* | *msys*) + # make stdout use "unix" line endings + echo " setmode(1,_O_BINARY);" + ;; +@@ -6492,7 +6492,7 @@ + $debug_cmd + + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # what system we are compiling for in order to pass an extra +@@ -6991,7 +6991,7 @@ + ;; + esac + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; +@@ -7011,7 +7011,7 @@ + -l*) + if test X-lc = "X$arg" || test X-lm = "X$arg"; then + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; +@@ -7094,7 +7094,7 @@ + + -no-install) + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "'-no-install' is ignored for $host" +@@ -7988,7 +7988,7 @@ + fi + case $host in + # special handling for platforms with PE-DLLs. +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + # Linker will automatically link against shared library if both + # static and shared are present. Therefore, ensure we extract + # symbols from the import library if a shared library is present +@@ -8132,7 +8132,7 @@ + if test -n "$library_names" && + { test no = "$use_static_libs" || test -z "$old_library"; }; then + case $host in +- *cygwin* | *mingw* | *cegcc* | *os2*) ++ *cygwin* | *msys* | *mingw* | *cegcc* | *os2*) + # No point in relinking DLLs because paths are not encoded + func_append notinst_deplibs " $lib" + need_relink=no +@@ -8202,7 +8202,7 @@ + elif test -n "$soname_spec"; then + # bleh windows + case $host in +- *cygwin* | mingw* | *cegcc* | *os2*) ++ *cygwin* | *msys* | mingw* | *cegcc* | *os2*) + func_arith $current - $age + major=$func_arith_result + versuffix=-$major +@@ -9112,7 +9112,7 @@ + if test yes = "$build_libtool_libs"; then + if test -n "$rpath"; then + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) +@@ -9626,7 +9626,7 @@ + + orig_export_symbols= + case $host_os in +- cygwin* | mingw* | cegcc*) ++ cygwin* | msys* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + func_dll_def_p "$export_symbols" || { +@@ -10185,7 +10185,7 @@ + + prog) + case $host in +- *cygwin*) func_stripname '' '.exe' "$output" ++ *cygwin* | *msys*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ +@@ -10296,7 +10296,7 @@ + esac + fi + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; +@@ -10374,7 +10374,7 @@ + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=false + ;; +- *cygwin* | *mingw* ) ++ *cygwin* | *msys* | *mingw* ) + test yes = "$build_libtool_libs" || wrappers_required=false + ;; + *) +@@ -10520,14 +10520,14 @@ + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in +- *cygwin*) ++ *cygwin* | *msys*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in +- *cygwin* | *mingw* ) ++ *cygwin* | *msys* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result +@@ -10859,7 +10859,7 @@ + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in +- *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) ++ *cygwin*,*lai,yes,no,*.dll | *msys*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test -n "$bindir"; then + func_relative_path "$install_libdir" "$bindir" +diff -durN sqlite-autoconf-3180000.orig/tea/configure sqlite-autoconf-3180000/tea/configure +--- sqlite-autoconf-3180000.orig/tea/configure 2017-03-30 22:26:52.000000000 +0800 ++++ sqlite-autoconf-3180000/tea/configure 2017-05-18 09:57:58.187500000 +0800 +@@ -2292,7 +2292,7 @@ + EXEEXT=".exe" + TEA_PLATFORM="windows" + ;; +- *CYGWIN_*) ++ *CYGWIN_* | *MSYS_*) + CYGPATH=echo + EXEEXT=".exe" + # TEA_PLATFORM is determined later in LOAD_TCLCONFIG +@@ -6907,7 +6907,7 @@ + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; +- CYGWIN_*) ++ CYGWIN_* | MSYS_*) + SHLIB_CFLAGS="" + SHLIB_LD='${CC} -shared' + SHLIB_SUFFIX=".dll" +@@ -7916,7 +7916,7 @@ + case $system in + AIX-*) ;; + BSD/OS*) ;; +- CYGWIN_*|MINGW32_*) ;; ++ CYGWIN_*|MSYS_*|MINGW32_*) ;; + IRIX*) ;; + NetBSD-*|FreeBSD-*|OpenBSD-*) ;; + Darwin-*) ;; +diff -durN sqlite-autoconf-3180000.orig/tea/tclconfig/tcl.m4 sqlite-autoconf-3180000/tea/tclconfig/tcl.m4 +--- sqlite-autoconf-3180000.orig/tea/tclconfig/tcl.m4 2017-03-30 22:26:48.000000000 +0800 ++++ sqlite-autoconf-3180000/tea/tclconfig/tcl.m4 2017-05-18 09:59:34.812500000 +0800 +@@ -1423,7 +1423,7 @@ + CC_SEARCH_FLAGS="" + LD_SEARCH_FLAGS="" + ;; +- CYGWIN_*) ++ CYGWIN_* | MSYS_*) + SHLIB_CFLAGS="" + SHLIB_LD='${CC} -shared' + SHLIB_SUFFIX=".dll" +@@ -1997,7 +1997,7 @@ + case $system in + AIX-*) ;; + BSD/OS*) ;; +- CYGWIN_*|MINGW32_*) ;; ++ CYGWIN_*|MSYS_*|MINGW32_*) ;; + IRIX*) ;; + NetBSD-*|FreeBSD-*|OpenBSD-*) ;; + Darwin-*) ;; +@@ -2870,7 +2870,7 @@ + EXEEXT=".exe" + TEA_PLATFORM="windows" + ;; +- *CYGWIN_*) ++ *CYGWIN_*|*MSYS_*) + CYGPATH=echo + EXEEXT=".exe" + # TEA_PLATFORM is determined later in LOAD_TCLCONFIG diff --git a/sqlite/sqlite-3.8.0.1-msys2.patch b/sqlite/sqlite-3.8.0.1-msys2.patch deleted file mode 100644 index 8a7a1e66..00000000 --- a/sqlite/sqlite-3.8.0.1-msys2.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff -Naur sqlite-autoconf-3080001-orig/config.guess sqlite-autoconf-3080001/config.guess ---- sqlite-autoconf-3080001-orig/config.guess 2013-08-29 21:47:30.000000000 +0400 -+++ sqlite-autoconf-3080001/config.guess 2013-08-30 13:09:08.752929700 +0400 -@@ -844,6 +844,9 @@ - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; -+ amd64:MSYS*:*:* | x86_64:MSYS*:*:*) -+ echo x86_64-unknown-msys -+ exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; -diff -Naur sqlite-autoconf-3080001-orig/tea/tclconfig/tcl.m4 sqlite-autoconf-3080001/tea/tclconfig/tcl.m4 ---- sqlite-autoconf-3080001-orig/tea/tclconfig/tcl.m4 2013-08-29 21:47:30.000000000 +0400 -+++ sqlite-autoconf-3080001/tea/tclconfig/tcl.m4 2013-08-30 13:04:21.379882800 +0400 -@@ -1423,7 +1423,7 @@ - CC_SEARCH_FLAGS="" - LD_SEARCH_FLAGS="" - ;; -- CYGWIN_*) -+ CYGWIN_* | *MSYS_*) - SHLIB_CFLAGS="" - SHLIB_LD='${CC} -shared' - SHLIB_SUFFIX=".dll" -@@ -1997,7 +1997,7 @@ - case $system in - AIX-*) ;; - BSD/OS*) ;; -- CYGWIN_*|MINGW32_*) ;; -+ CYGWIN_*|MINGW32_*|MSYS_*) ;; - IRIX*) ;; - NetBSD-*|FreeBSD-*|OpenBSD-*) ;; - Darwin-*) ;; -@@ -2870,7 +2870,7 @@ - EXEEXT=".exe" - TEA_PLATFORM="windows" - ;; -- *CYGWIN_*) -+ *CYGWIN_* | *MSYS_*) - CYGPATH=echo - EXEEXT=".exe" - # TEA_PLATFORM is determined later in LOAD_TCLCONFIG diff --git a/sqlite/sqlite3-3.10.0-1.src.patch b/sqlite/sqlite3-3.18.0-1.src.patch similarity index 57% rename from sqlite/sqlite3-3.10.0-1.src.patch rename to sqlite/sqlite3-3.18.0-1.src.patch index 23ddd4c5..9a61d070 100644 --- a/sqlite/sqlite3-3.10.0-1.src.patch +++ b/sqlite/sqlite3-3.18.0-1.src.patch @@ -1,28 +1,34 @@ ---- origsrc/sqlite-autoconf-3100000/Makefile.am 2016-01-06 13:03:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/Makefile.am 2016-01-06 16:30:03.315880000 +0100 -@@ -1,16 +1,75 @@ +--- origsrc/sqlite-autoconf-3180000/Makefile.am 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/Makefile.am 2017-04-19 16:20:01.526891300 +0200 +@@ -1,16 +1,89 @@ --AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -+AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ -DUSE_SYSTEM_SQLITE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 -DSQLITE_OMIT_LOOKASIDE=1 -DSQLITE_SECURE_DELETE=1 +-AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE ++AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @SESSION_FLAGS@ -DUSE_SYSTEM_SQLITE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 -DSQLITE_OMIT_LOOKASIDE=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_USE_ALLOCA=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_MAX_SCHEMA_RETRY=25 -lib_LTLIBRARIES = libsqlite3.la -+lib_LTLIBRARIES = libsqlite3.la libsqlite3amatch.la libsqlite3closure.la \ -+ libsqlite3compress.la libsqlite3eval.la libsqlite3fileio.la \ -+ libsqlite3fuzzer.la libsqlite3icu.la \ -+ libsqlite3ieee754.la libsqlite3nextchar.la \ ++ ++lib_LTLIBRARIES = libsqlite3.la libsqlite3amatch.la libsqlite3carray.la \ ++ libsqlite3closure.la libsqlite3compress.la libsqlite3csv.la \ ++ libsqlite3eval.la libsqlite3fileio.la libsqlite3fuzzer.la \ ++ libsqlite3ieee754.la libsqlite3memvfs.la libsqlite3nextchar.la \ + libsqlite3percentile.la libsqlite3rbu.la libsqlite3regexp.la \ -+ libsqlite3rot13.la libsqlite3series.la libsqlite3showauth.la \ -+ libsqlite3spellfix.la libsqlite3totype.la libsqlite3vfslog.la \ -+ libsqlite3vtshim.la libsqlite3wholenumber.la ++ libsqlite3remember.la libsqlite3rot13.la libsqlite3series.la \ ++ libsqlite3showauth.la libsqlite3spellfix.la libsqlite3totype.la \ ++ libsqlite3vfslog.la libsqlite3vfsstat.la libsqlite3vtshim.la \ ++ libsqlite3wholenumber.la libsqlite3icu.la libsqlite3sha1.la libsqlite3_la_SOURCES = sqlite3.c -libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8 +libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3amatch_la_SOURCES = amatch.c +libsqlite3amatch_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc ++libsqlite3carray_la_SOURCES = carray.c ++libsqlite3carray_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3closure_la_SOURCES = closure.c +libsqlite3closure_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3compress_la_SOURCES = compress.c +libsqlite3compress_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc -lz ++libsqlite3csv_la_SOURCES = csv.c ++libsqlite3csv_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3eval_la_SOURCES = eval.c +libsqlite3eval_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3fileio_la_SOURCES = fileio.c @@ -33,6 +39,8 @@ +libsqlite3icu_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc -licui18n -licuuc +libsqlite3ieee754_la_SOURCES = ieee754.c +libsqlite3ieee754_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc ++libsqlite3memvfs_la_SOURCES = memvfs.c ++libsqlite3memvfs_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3nextchar_la_SOURCES = nextchar.c +libsqlite3nextchar_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3percentile_la_SOURCES = percentile.c @@ -43,8 +51,12 @@ +libsqlite3rbu_la_DEPENDENCIES = $(top_builddir)/libsqlite3.la +libsqlite3regexp_la_SOURCES = regexp.c +libsqlite3regexp_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc ++libsqlite3remember_la_SOURCES = remember.c ++libsqlite3remember_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3rot13_la_SOURCES = rot13.c +libsqlite3rot13_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc ++libsqlite3sha1_la_SOURCES = sha1.c ++libsqlite3sha1_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3series_la_SOURCES = series.c +libsqlite3series_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3showauth_la_SOURCES = showauth.c @@ -59,6 +71,8 @@ +libsqlite3vfslog_la_DEPENDENCIES = $(top_builddir)/libsqlite3.la +libsqlite3vtshim_la_SOURCES = vtshim.c +libsqlite3vtshim_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc ++libsqlite3vfsstat_la_SOURCES = vfsstat.c ++libsqlite3vfsstat_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc +libsqlite3wholenumber_la_SOURCES = wholenumber.c +libsqlite3wholenumber_la_LDFLAGS = -no-undefined -version-info 8:6:8 -static-libgcc @@ -70,7 +84,7 @@ -sqlite3_DEPENDENCIES = @EXTRA_SHELL_OBJ@ +sqlite3_LDADD = $(top_builddir)/libsqlite3vfslog.la @EXTRA_SHELL_OBJ@ @READLINE_LIBS@ +sqlite3_DEPENDENCIES = $(top_builddir)/libsqlite3vfslog.la @EXTRA_SHELL_OBJ@ - sqlite3_CFLAGS = $(AM_CFLAGS) + sqlite3_CFLAGS = $(AM_CFLAGS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS +sqldiff_SOURCES = sqldiff.c sqlite3.h +sqldiff_LDADD = @EXTRA_SHELL_OBJ@ +sqldiff_DEPENDENCIES = @EXTRA_SHELL_OBJ@ @@ -82,8 +96,307 @@ include_HEADERS = sqlite3.h sqlite3ext.h ---- origsrc/sqlite-autoconf-3100000/amatch.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/amatch.c 2016-01-06 16:30:42.469119500 +0100 +--- origsrc/sqlite-autoconf-3180000/Makefile.msc 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/Makefile.msc 2017-04-19 16:20:01.536892300 +0200 +@@ -24,27 +24,6 @@ TOP = . + USE_FULLWARN = 0 + !ENDIF + +-# Set this non-0 to enable treating warnings as errors (-WX, etc) when +-# compiling. +-# +-!IFNDEF USE_FATAL_WARN +-USE_FATAL_WARN = 0 +-!ENDIF +- +-# Set this non-0 to enable full runtime error checks (-RTC1, etc). This +-# has no effect if (any) optimizations are enabled. +-# +-!IFNDEF USE_RUNTIME_CHECKS +-USE_RUNTIME_CHECKS = 0 +-!ENDIF +- +-# Set this non-0 to create a SQLite amalgamation file that excludes the +-# various built-in extensions. +-# +-!IFNDEF MINIMAL_AMALGAMATION +-MINIMAL_AMALGAMATION = 0 +-!ENDIF +- + # Set this non-0 to use "stdcall" calling convention for the core library + # and shell executable. + # +@@ -204,12 +183,6 @@ DEBUG = 0 + OPTIMIZATIONS = 2 + !ENDIF + +-# Set this to non-0 to enable support for the session extension. +-# +-!IFNDEF SESSION +-SESSION = 0 +-!ENDIF +- + # Set the source code file to be used by executables and libraries when + # they need the amalgamation. + # +@@ -231,64 +204,37 @@ SQLITE3H = sqlite3.h + # This is the name to use for the SQLite dynamic link library (DLL). + # + !IFNDEF SQLITE3DLL +-!IF $(FOR_WIN10)!=0 +-SQLITE3DLL = winsqlite3.dll +-!ELSE + SQLITE3DLL = sqlite3.dll + !ENDIF +-!ENDIF + + # This is the name to use for the SQLite import library (LIB). + # + !IFNDEF SQLITE3LIB +-!IF $(FOR_WIN10)!=0 +-SQLITE3LIB = winsqlite3.lib +-!ELSE + SQLITE3LIB = sqlite3.lib + !ENDIF +-!ENDIF + + # This is the name to use for the SQLite shell executable (EXE). + # + !IFNDEF SQLITE3EXE +-!IF $(FOR_WIN10)!=0 +-SQLITE3EXE = winsqlite3shell.exe +-!ELSE + SQLITE3EXE = sqlite3.exe + !ENDIF +-!ENDIF + + # This is the argument used to set the program database (PDB) file for the + # SQLite shell executable (EXE). + # + !IFNDEF SQLITE3EXEPDB +-!IF $(FOR_WIN10)!=0 +-SQLITE3EXEPDB = +-!ELSE + SQLITE3EXEPDB = /pdb:sqlite3sh.pdb + !ENDIF +-!ENDIF +- + + # These are the "standard" SQLite compilation options used when compiling for + # the Windows platform. + # + !IFNDEF OPT_FEATURE_FLAGS +-!IF $(MINIMAL_AMALGAMATION)==0 + OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1 + OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1 +-!ENDIF + OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 + !ENDIF + +-# Should the session extension be enabled? If so, add compilation options +-# to enable it. +-# +-!IF $(SESSION)!=0 +-OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1 +-OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1 +-!ENDIF +- + # These are the "extended" SQLite compilation options used when compiling for + # the Windows 10 platform. + # +@@ -329,14 +275,6 @@ PROGRAMFILES_X86 = $(PROGRAMFILES_X86:\\ + CC = cl.exe + !ENDIF + +-# Check for the predefined command macro CSC. This should point to a working +-# C Sharp compiler binary. If it is not defined, simply define it to the +-# legacy default value 'csc.exe'. +-# +-!IFNDEF CSC +-CSC = csc.exe +-!ENDIF +- + # Check for the command macro LD. This should point to the linker binary for + # the target platform. If it is not defined, simply define it to the legacy + # default value 'link.exe'. +@@ -461,15 +399,18 @@ TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H + TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS) + !ENDIF + +-# Check if warnings should be treated as errors when compiling. +-# +-!IF $(USE_FATAL_WARN)!=0 +-TCC = $(TCC) -WX +-!ENDIF +- + TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise + RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS) + ++# Adjust the names of the primary targets for use with Windows 10. ++# ++!IF $(FOR_WIN10)!=0 ++SQLITE3DLL = winsqlite3.dll ++SQLITE3LIB = winsqlite3.lib ++SQLITE3EXE = winsqlite3shell.exe ++SQLITE3EXEPDB = ++!ENDIF ++ + # Check if we want to use the "stdcall" calling convention when compiling. + # This is not supported by the compilers for non-x86 platforms. It should + # also be noted here that building any target with these "stdcall" options +@@ -479,12 +420,12 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TO + # + !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0 + !IF "$(PLATFORM)"=="x86" +-CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +-SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall ++CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall ++SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall + !ELSE + !IFNDEF PLATFORM +-CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +-SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall ++CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall ++SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall + !ELSE + CORE_CCONV_OPTS = + SHELL_CCONV_OPTS = +@@ -509,10 +450,8 @@ CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) + # when linking. + # + !IFNDEF CORE_LINK_DEP +-!IF $(DYNAMIC_SHELL)!=0 ++!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 + CORE_LINK_DEP = +-!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86" +-CORE_LINK_DEP = sqlite3.def + !ELSE + CORE_LINK_DEP = + !ENDIF +@@ -521,10 +460,8 @@ CORE_LINK_DEP = + # These are additional linker options used for the core library. + # + !IFNDEF CORE_LINK_OPTS +-!IF $(DYNAMIC_SHELL)!=0 ++!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 + CORE_LINK_OPTS = +-!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86" +-CORE_LINK_OPTS = /DEF:sqlite3.def + !ELSE + CORE_LINK_OPTS = + !ENDIF +@@ -644,7 +581,6 @@ RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1 + + !IF $(DEBUG)>2 + TCC = $(TCC) -DSQLITE_DEBUG=1 +-TCC = $(TCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE + RCC = $(RCC) -DSQLITE_DEBUG=1 + !ENDIF + +@@ -771,10 +707,6 @@ RCC = $(RCC) -D_DEBUG + !IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0 + TCC = $(TCC) -Od + BCC = $(BCC) -Od +-!IF $(USE_RUNTIME_CHECKS)!=0 +-TCC = $(TCC) -RTC1 +-BCC = $(BCC) -RTC1 +-!ENDIF + !ELSEIF $(OPTIMIZATIONS)>=3 + TCC = $(TCC) -Ox + BCC = $(BCC) -Ox +@@ -931,28 +863,23 @@ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPT + # This is the default Makefile target. The objects listed here + # are what get build when you type just "make" with no arguments. + # +-all: dll shell ++all: dll libsqlite3.lib shell + + # Dynamic link library section. + # +-dll: $(SQLITE3DLL) ++dll: $(SQLITE3DLL) + + # Shell executable. + # +-shell: $(SQLITE3EXE) ++shell: $(SQLITE3EXE) + ++libsqlite3.lib: $(LIBOBJ) ++ $(LTLIB) $(LTLIBOPTS) /OUT:$@ $(LIBOBJ) $(TLIBS) + +-$(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP) +- $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + +-Replace.exe: +- $(CSC) /target:exe $(TOP)\Replace.cs ++$(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP) ++ $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + +-sqlite3.def: Replace.exe $(LIBOBJ) +- echo EXPORTS > sqlite3.def +- dumpbin /all $(LIBOBJ) \ +- | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \ +- | sort >> sqlite3.def + + $(SQLITE3EXE): $(TOP)\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H) + $(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\shell.c $(SHELL_CORE_SRC) \ +@@ -991,5 +918,4 @@ $(LIBRESOBJS): $(TOP)\sqlite3.rc rcver.v + + clean: + del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL +- del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL +- del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL ++ del /Q *.bsc *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL +--- origsrc/sqlite-autoconf-3180000/README 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/README 2017-04-20 17:56:14.890763200 +0200 +@@ -0,0 +1,32 @@ ++ ++This package contains: ++ ++ * the SQLite library amalgamation (single file) source code distribution, ++ * the shell.c file used to build the sqlite3 shell too, and ++ * the sqlite3.h and sqlite3ext.h header files required to link programs ++ and sqlite extensions against the installed libary. ++ * autoconf/automake installation infrastucture. ++ ++The generic installation instructions for autoconf/automake are found ++in the INSTALL file. ++ ++The following SQLite specific boolean options are supported: ++ ++ --enable-readline use readline in shell tool [default=yes] ++ --enable-threadsafe build a thread-safe library [default=yes] ++ --enable-dynamic-extensions support loadable extensions [default=yes] ++ ++The default value for the CFLAGS variable (options passed to the C ++compiler) includes debugging symbols in the build, resulting in larger ++binaries than are necessary. Override it on the configure command ++line like this: ++ ++ $ CFLAGS="-Os" ./configure ++ ++to produce a smaller installation footprint. ++ ++Other SQLite compilation parameters can also be set using CFLAGS. For ++example: ++ ++ $ CFLAGS="-Os -DSQLITE_OMIT_TRIGGERS" ./configure ++ +--- origsrc/sqlite-autoconf-3180000/README.txt 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/README.txt 2017-04-19 16:20:01.554894100 +0200 +@@ -6,8 +6,8 @@ This package contains: + * the shell.c file used to build the sqlite3 command-line shell program + * autoconf/automake installation infrastucture for building on POSIX + compliant systems +- * a Makefile.msc, sqlite3.rc, and Replace.cs for building with Microsoft +- Visual C++ on Windows ++ * a Makefile.msc and sqlite3.rc for building with Microsoft Visual C++ on ++ Windows + + SUMMARY OF HOW TO BUILD + ======================= +--- origsrc/sqlite-autoconf-3180000/amatch.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/amatch.c 2017-04-19 16:20:01.571895800 +0200 @@ -0,0 +1,1520 @@ +/* +** 2013-03-14 @@ -712,10 +1025,10 @@ + }else{ + memset(pRule, 0, sizeof(*pRule)); + pRule->zFrom = &pRule->zTo[nTo+1]; -+ pRule->nFrom = nFrom; ++ pRule->nFrom = (amatch_len)nFrom; + memcpy(pRule->zFrom, zFrom, nFrom+1); + memcpy(pRule->zTo, zTo, nTo+1); -+ pRule->nTo = nTo; ++ pRule->nTo = (amatch_len)nTo; + pRule->rCost = rCost; + pRule->iLang = (int)iLang; + } @@ -1168,7 +1481,7 @@ + pWord->rCost = rCost; + pWord->iSeq = pCur->nWord++; + amatchWriteCost(pWord); -+ pWord->nMatch = nMatch; ++ pWord->nMatch = (short)nMatch; + pWord->pNext = pCur->pAllWords; + pCur->pAllWords = pWord; + pWord->sCost.zKey = pWord->zCost; @@ -1249,7 +1562,7 @@ +#endif + nWord = (int)strlen(pWord->zWord+2); + if( nWord+20>nBuf ){ -+ nBuf = nWord+100; ++ nBuf = (char)(nWord+100); + zBuf = sqlite3_realloc(zBuf, nBuf); + if( zBuf==0 ) return SQLITE_NOMEM; + } @@ -1605,8 +1918,389 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/closure.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/closure.c 2016-01-06 16:30:42.472119600 +0100 +--- origsrc/sqlite-autoconf-3180000/carray.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/carray.c 2017-04-19 16:20:01.582896900 +0200 +@@ -0,0 +1,378 @@ ++/* ++** 2016-06-29 ++** ++** 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 file demonstrates how to create a table-valued-function that ++** returns the values in a C-language array. ++** Examples: ++** ++** SELECT * FROM carray($ptr,5) ++** ++** The query above returns 5 integers contained in a C-language array ++** at the address $ptr. $ptr is a pointer to the array of integers that ++** has been cast to an integer. ++** ++** There is an optional third parameter to determine the datatype of ++** the C-language array. Allowed values of the third parameter are ++** 'int32', 'int64', 'double', 'char*'. Example: ++** ++** SELECT * FROM carray($ptr,10,'char*'); ++** ++** HOW IT WORKS ++** ++** The carray "function" is really a virtual table with the ++** following schema: ++** ++** CREATE TABLE carray( ++** value, ++** pointer HIDDEN, ++** count HIDDEN, ++** ctype TEXT HIDDEN ++** ); ++** ++** If the hidden columns "pointer" and "count" are unconstrained, then ++** the virtual table has no rows. Otherwise, the virtual table interprets ++** the integer value of "pointer" as a pointer to the array and "count" ++** as the number of elements in the array. The virtual table steps through ++** the array, element by element. ++*/ ++#include "sqlite3ext.h" ++SQLITE_EXTENSION_INIT1 ++#include ++#include ++ ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ ++/* ++** Allowed datatypes ++*/ ++#define CARRAY_INT32 0 ++#define CARRAY_INT64 1 ++#define CARRAY_DOUBLE 2 ++#define CARRAY_TEXT 3 ++ ++/* ++** Names of types ++*/ ++static const char *azType[] = { "int32", "int64", "double", "char*" }; ++ ++ ++/* carray_cursor is a subclass of sqlite3_vtab_cursor which will ++** serve as the underlying representation of a cursor that scans ++** over rows of the result ++*/ ++typedef struct carray_cursor carray_cursor; ++struct carray_cursor { ++ sqlite3_vtab_cursor base; /* Base class - must be first */ ++ sqlite3_int64 iRowid; /* The rowid */ ++ size_t iPtr; /* Pointer to array of values */ ++ size_t iCnt; /* Number of integers in the array */ ++ unsigned char eType; /* One of the CARRAY_type values */ ++}; ++ ++/* ++** The carrayConnect() method is invoked to create a new ++** carray_vtab that describes the carray virtual table. ++** ++** Think of this routine as the constructor for carray_vtab objects. ++** ++** All this routine needs to do is: ++** ++** (1) Allocate the carray_vtab object and initialize all fields. ++** ++** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the ++** result set of queries against carray will look like. ++*/ ++static int carrayConnect( ++ sqlite3 *db, ++ void *pAux, ++ int argc, const char *const*argv, ++ sqlite3_vtab **ppVtab, ++ char **pzErr ++){ ++ sqlite3_vtab *pNew; ++ int rc; ++ ++/* Column numbers */ ++#define CARRAY_COLUMN_VALUE 0 ++#define CARRAY_COLUMN_POINTER 1 ++#define CARRAY_COLUMN_COUNT 2 ++#define CARRAY_COLUMN_CTYPE 3 ++ ++ rc = sqlite3_declare_vtab(db, ++ "CREATE TABLE x(value,pointer hidden,count hidden,ctype hidden)"); ++ if( rc==SQLITE_OK ){ ++ pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); ++ if( pNew==0 ) return SQLITE_NOMEM; ++ memset(pNew, 0, sizeof(*pNew)); ++ } ++ return rc; ++} ++ ++/* ++** This method is the destructor for carray_cursor objects. ++*/ ++static int carrayDisconnect(sqlite3_vtab *pVtab){ ++ sqlite3_free(pVtab); ++ return SQLITE_OK; ++} ++ ++/* ++** Constructor for a new carray_cursor object. ++*/ ++static int carrayOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ ++ carray_cursor *pCur; ++ pCur = sqlite3_malloc( sizeof(*pCur) ); ++ if( pCur==0 ) return SQLITE_NOMEM; ++ memset(pCur, 0, sizeof(*pCur)); ++ *ppCursor = &pCur->base; ++ return SQLITE_OK; ++} ++ ++/* ++** Destructor for a carray_cursor. ++*/ ++static int carrayClose(sqlite3_vtab_cursor *cur){ ++ sqlite3_free(cur); ++ return SQLITE_OK; ++} ++ ++ ++/* ++** Advance a carray_cursor to its next row of output. ++*/ ++static int carrayNext(sqlite3_vtab_cursor *cur){ ++ carray_cursor *pCur = (carray_cursor*)cur; ++ pCur->iRowid++; ++ return SQLITE_OK; ++} ++ ++/* ++** Return values of columns for the row at which the carray_cursor ++** is currently pointing. ++*/ ++static int carrayColumn( ++ sqlite3_vtab_cursor *cur, /* The cursor */ ++ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ ++ int i /* Which column to return */ ++){ ++ carray_cursor *pCur = (carray_cursor*)cur; ++ sqlite3_int64 x = 0; ++ switch( i ){ ++ case CARRAY_COLUMN_POINTER: x = pCur->iPtr; break; ++ case CARRAY_COLUMN_COUNT: x = pCur->iCnt; break; ++ case CARRAY_COLUMN_CTYPE: { ++ sqlite3_result_text(ctx, azType[pCur->eType], -1, SQLITE_STATIC); ++ return SQLITE_OK; ++ } ++ default: { ++ switch( pCur->eType ){ ++ case CARRAY_INT32: { ++ int *p = (int*)pCur->iPtr; ++ sqlite3_result_int(ctx, p[pCur->iRowid-1]); ++ return SQLITE_OK; ++ } ++ case CARRAY_INT64: { ++ sqlite3_int64 *p = (sqlite3_int64*)pCur->iPtr; ++ sqlite3_result_int64(ctx, p[pCur->iRowid-1]); ++ return SQLITE_OK; ++ } ++ case CARRAY_DOUBLE: { ++ double *p = (double*)pCur->iPtr; ++ sqlite3_result_double(ctx, p[pCur->iRowid-1]); ++ return SQLITE_OK; ++ } ++ case CARRAY_TEXT: { ++ const char **p = (const char**)pCur->iPtr; ++ sqlite3_result_text(ctx, p[pCur->iRowid-1], -1, SQLITE_TRANSIENT); ++ return SQLITE_OK; ++ } ++ } ++ } ++ } ++ sqlite3_result_int64(ctx, x); ++ return SQLITE_OK; ++} ++ ++/* ++** Return the rowid for the current row. In this implementation, the ++** rowid is the same as the output value. ++*/ ++static int carrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ ++ carray_cursor *pCur = (carray_cursor*)cur; ++ *pRowid = pCur->iRowid; ++ return SQLITE_OK; ++} ++ ++/* ++** Return TRUE if the cursor has been moved off of the last ++** row of output. ++*/ ++static int carrayEof(sqlite3_vtab_cursor *cur){ ++ carray_cursor *pCur = (carray_cursor*)cur; ++ return pCur->iRowid>pCur->iCnt; ++} ++ ++/* ++** This method is called to "rewind" the carray_cursor object back ++** to the first row of output. ++*/ ++static int carrayFilter( ++ sqlite3_vtab_cursor *pVtabCursor, ++ int idxNum, const char *idxStr, ++ int argc, sqlite3_value **argv ++){ ++ carray_cursor *pCur = (carray_cursor *)pVtabCursor; ++ if( idxNum ){ ++ pCur->iPtr = sqlite3_value_int64(argv[0]); ++ pCur->iCnt = sqlite3_value_int64(argv[1]); ++ if( idxNum<3 ){ ++ pCur->eType = CARRAY_INT32; ++ }else{ ++ unsigned char i; ++ const char *zType = (const char*)sqlite3_value_text(argv[2]); ++ for(i=0; i=sizeof(azType)/sizeof(azType[0]) ){ ++ pVtabCursor->pVtab->zErrMsg = sqlite3_mprintf( ++ "unknown datatype: %Q", zType); ++ return SQLITE_ERROR; ++ }else{ ++ pCur->eType = i; ++ } ++ } ++ }else{ ++ pCur->iPtr = 0; ++ pCur->iCnt = 0; ++ } ++ pCur->iRowid = 1; ++ return SQLITE_OK; ++} ++ ++/* ++** SQLite will invoke this method one or more times while planning a query ++** that uses the carray virtual table. This routine needs to create ++** a query plan for each invocation and compute an estimated cost for that ++** plan. ++** ++** In this implementation idxNum is used to represent the ++** query plan. idxStr is unused. ++** ++** idxNum is 2 if the pointer= and count= constraints exist, ++** 3 if the ctype= constraint also exists, and is 0 otherwise. ++** If idxNum is 0, then carray becomes an empty table. ++*/ ++static int carrayBestIndex( ++ sqlite3_vtab *tab, ++ sqlite3_index_info *pIdxInfo ++){ ++ int i; /* Loop over constraints */ ++ int ptrIdx = -1; /* Index of the pointer= constraint, or -1 if none */ ++ int cntIdx = -1; /* Index of the count= constraint, or -1 if none */ ++ int ctypeIdx = -1; /* Index of the ctype= constraint, or -1 if none */ ++ ++ const struct sqlite3_index_constraint *pConstraint; ++ pConstraint = pIdxInfo->aConstraint; ++ for(i=0; inConstraint; i++, pConstraint++){ ++ if( pConstraint->usable==0 ) continue; ++ if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; ++ switch( pConstraint->iColumn ){ ++ case CARRAY_COLUMN_POINTER: ++ ptrIdx = i; ++ break; ++ case CARRAY_COLUMN_COUNT: ++ cntIdx = i; ++ break; ++ case CARRAY_COLUMN_CTYPE: ++ ctypeIdx = i; ++ break; ++ } ++ } ++ if( ptrIdx>=0 && cntIdx>=0 ){ ++ pIdxInfo->aConstraintUsage[ptrIdx].argvIndex = 1; ++ pIdxInfo->aConstraintUsage[ptrIdx].omit = 1; ++ pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2; ++ pIdxInfo->aConstraintUsage[cntIdx].omit = 1; ++ pIdxInfo->estimatedCost = (double)1; ++ pIdxInfo->estimatedRows = 100; ++ pIdxInfo->idxNum = 2; ++ if( ctypeIdx>=0 ){ ++ pIdxInfo->aConstraintUsage[ctypeIdx].argvIndex = 3; ++ pIdxInfo->aConstraintUsage[ctypeIdx].omit = 1; ++ pIdxInfo->idxNum = 3; ++ } ++ }else{ ++ pIdxInfo->estimatedCost = (double)2147483647; ++ pIdxInfo->estimatedRows = 2147483647; ++ pIdxInfo->idxNum = 0; ++ } ++ return SQLITE_OK; ++} ++ ++/* ++** This following structure defines all the methods for the ++** carray virtual table. ++*/ ++static const sqlite3_module carrayModule = { ++ 0, /* iVersion */ ++ 0, /* xCreate */ ++ carrayConnect, /* xConnect */ ++ carrayBestIndex, /* xBestIndex */ ++ carrayDisconnect, /* xDisconnect */ ++ 0, /* xDestroy */ ++ carrayOpen, /* xOpen - open a cursor */ ++ carrayClose, /* xClose - close a cursor */ ++ carrayFilter, /* xFilter - configure scan constraints */ ++ carrayNext, /* xNext - advance a cursor */ ++ carrayEof, /* xEof - check for end of scan */ ++ carrayColumn, /* xColumn - read data */ ++ carrayRowid, /* xRowid - read data */ ++ 0, /* xUpdate */ ++ 0, /* xBegin */ ++ 0, /* xSync */ ++ 0, /* xCommit */ ++ 0, /* xRollback */ ++ 0, /* xFindMethod */ ++ 0, /* xRename */ ++}; ++ ++#endif /* SQLITE_OMIT_VIRTUALTABLE */ ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++int sqlite3_carray_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ rc = sqlite3_create_module(db, "carray", &carrayModule, 0); ++#endif ++ return rc; ++} ++#if !defined(_WIN32) && !defined(SQLITE_TEST) ++int sqlite3_extension_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ rc = sqlite3_create_module(db, "carray", &carrayModule, 0); ++#endif ++ return rc; ++} ++#endif +--- origsrc/sqlite-autoconf-3180000/closure.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/closure.c 2017-04-19 16:20:01.596898300 +0200 @@ -0,0 +1,973 @@ +/* +** 2013-04-16 @@ -2581,8 +3275,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/compress.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/compress.c 2016-01-06 16:30:42.475119800 +0100 +--- origsrc/sqlite-autoconf-3180000/compress.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/compress.c 2017-04-19 16:20:01.606899300 +0200 @@ -0,0 +1,178 @@ +/* +** 2014-06-13 @@ -2762,20 +3456,998 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/configure.ac 2016-01-06 13:03:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/configure.ac 2016-01-06 16:39:33.339483500 +0100 -@@ -24,7 +24,8 @@ AC_PROG_LIBTOOL +--- origsrc/sqlite-autoconf-3180000/configure.ac 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/configure.ac 2017-04-19 16:20:01.614900100 +0200 +@@ -24,14 +24,15 @@ AC_PROG_LIBTOOL AC_PROG_MKDIR_P # Check for library functions that SQLite can optionally use. -AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r]) +AC_CHECK_HEADERS([malloc.h]) -+AC_CHECK_FUNCS([fdatasync usleep strchrnul localtime_r gmtime_r localtime_s malloc_usable_size utime flock]) ++AC_CHECK_FUNCS([fdatasync usleep strchrnul localtime_r gmtime_r localtime_s malloc_usable_size utime flock readlink lstat pread pread64 pwrite pwrite64 rand_s]) AC_FUNC_STRERROR_R AC_CONFIG_FILES([Makefile sqlite3.pc]) ---- origsrc/sqlite-autoconf-3100000/eval.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/eval.c 2016-01-06 16:30:42.500121200 +0100 + AC_SUBST(BUILD_CFLAGS) + + #------------------------------------------------------------------------- +-# Two options to enable readline compatible libraries: ++# Two options to enable readline compatible libraries: + # + # --enable-editline + # --enable-readline +@@ -42,7 +43,7 @@ AC_SUBST(BUILD_CFLAGS) + # user must pass "--disable-editline". To disable command line editing + # support altogether, "--disable-editline --disable-readline". + # +-# When searching for either library, check for headers before libraries ++# When searching for either library, check for headers before libraries + # as some distros supply packages that contain libraries but not header + # files, which come as a separate development package. + # +@@ -55,9 +56,9 @@ AS_IF([ test x"$enable_editline" != xno + LIBS="" + AC_SEARCH_LIBS([readline],[edit],[ + AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) +- READLINE_LIBS="$LIBS -ltinfo" ++ READLINE_LIBS=$LIBS + enable_readline=no +- ],[],[-ltinfo]) ++ ]) + AS_UNSET(ac_cv_search_readline) + LIBS=$sLIBS + ]) +@@ -83,7 +84,7 @@ AC_SUBST(READLINE_LIBS) + # --enable-threadsafe + # + AC_ARG_ENABLE(threadsafe, [AS_HELP_STRING( +- [--enable-threadsafe], [build a thread-safe library [default=yes]])], ++ [--enable-threadsafe], [build a thread-safe library [default=yes]])], + [], [enable_threadsafe=yes]) + THREADSAFE_FLAGS=-DSQLITE_THREADSAFE=0 + if test x"$enable_threadsafe" != "xno"; then +@@ -98,7 +99,7 @@ AC_SUBST(THREADSAFE_FLAGS) + # --enable-dynamic-extensions + # + AC_ARG_ENABLE(dynamic-extensions, [AS_HELP_STRING( +- [--enable-dynamic-extensions], [support loadable extensions [default=yes]])], ++ [--enable-dynamic-extensions], [support loadable extensions [default=yes]])], + [], [enable_dynamic_extensions=yes]) + if test x"$enable_dynamic_extensions" != "xno"; then + AC_SEARCH_LIBS(dlopen, dl) +@@ -114,7 +115,7 @@ AC_SUBST(DYNAMIC_EXTENSION_FLAGS) + # --enable-fts5 + # + AC_ARG_ENABLE(fts5, [AS_HELP_STRING( +- [--enable-fts5], [include fts5 support [default=no]])], ++ [--enable-fts5], [include fts5 support [default=no]])], + [], [enable_fts5=no]) + if test x"$enable_fts5" = "xyes"; then + AC_SEARCH_LIBS(log, m) +@@ -127,7 +128,7 @@ AC_SUBST(FTS5_FLAGS) + # --enable-json1 + # + AC_ARG_ENABLE(json1, [AS_HELP_STRING( +- [--enable-json1], [include json1 support [default=no]])], ++ [--enable-json1], [include json1 support [default=no]])], + [], [enable_json1=no]) + if test x"$enable_json1" = "xyes"; then + JSON1_FLAGS=-DSQLITE_ENABLE_JSON1 +@@ -139,7 +140,7 @@ AC_SUBST(JSON1_FLAGS) + # --enable-session + # + AC_ARG_ENABLE(session, [AS_HELP_STRING( +- [--enable-session], [enable the session extension [default=no]])], ++ [--enable-session], [enable the session extension [default=no]])], + [], [enable_session=no]) + if test x"$enable_session" = "xyes"; then + SESSION_FLAGS="-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK" +@@ -151,8 +152,8 @@ AC_SUBST(SESSION_FLAGS) + # --enable-static-shell + # + AC_ARG_ENABLE(static-shell, [AS_HELP_STRING( +- [--enable-static-shell], +- [statically link libsqlite3 into shell tool [default=yes]])], ++ [--enable-static-shell], ++ [statically link libsqlite3 into shell tool [default=yes]])], + [], [enable_static_shell=yes]) + if test x"$enable_static_shell" = "xyes"; then + EXTRA_SHELL_OBJ=sqlite3-sqlite3.$OBJEXT +@@ -171,8 +172,8 @@ AC_CHECK_FUNCS(posix_fallocate) + # --enable-tempstore + # + # AC_ARG_ENABLE(tempstore, [AS_HELP_STRING( +-# [--enable-tempstore], +-# [in-memory temporary tables (never, no, yes, always) [default=no]])], ++# [--enable-tempstore], ++# [in-memory temporary tables (never, no, yes, always) [default=no]])], + # [], [enable_tempstore=no]) + # AC_MSG_CHECKING([for whether or not to store temp tables in-memory]) + # case "$enable_tempstore" in +--- origsrc/sqlite-autoconf-3180000/csv.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/csv.c 2017-04-19 16:20:01.629901600 +0200 +@@ -0,0 +1,879 @@ ++/* ++** 2016-05-28 ++** ++** 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 file contains the implementation of an SQLite virtual table for ++** reading CSV files. ++** ++** Usage: ++** ++** .load ./csv ++** CREATE VIRTUAL TABLE temp.csv USING csv(filename=FILENAME); ++** SELECT * FROM csv; ++** ++** The columns are named "c1", "c2", "c3", ... by default. But the ++** application can define its own CREATE TABLE statement as an additional ++** parameter. For example: ++** ++** CREATE VIRTUAL TABLE temp.csv2 USING csv( ++** filename = "../http.log", ++** schema = "CREATE TABLE x(date,ipaddr,url,referrer,userAgent)" ++** ); ++** ++** Instead of specifying a file, the text of the CSV can be loaded using ++** the data= parameter. ++** ++** If the columns=N parameter is supplied, then the CSV file is assumed to have ++** N columns. If the columns parameter is omitted, the CSV file is opened ++** as soon as the virtual table is constructed and the first row of the CSV ++** is read in order to count the tables. ++** ++** Some extra debugging features (used for testing virtual tables) are available ++** if this module is compiled with -DSQLITE_TEST. ++*/ ++#include ++SQLITE_EXTENSION_INIT1 ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ ++/* ++** A macro to hint to the compiler that a function should not be ++** inlined. ++*/ ++#if defined(__GNUC__) ++# define CSV_NOINLINE __attribute__((noinline)) ++#elif defined(_MSC_VER) && _MSC_VER>=1310 ++# define CSV_NOINLINE __declspec(noinline) ++#else ++# define CSV_NOINLINE ++#endif ++ ++ ++/* Max size of the error message in a CsvReader */ ++#define CSV_MXERR 200 ++ ++/* Size of the CsvReader input buffer */ ++#define CSV_INBUFSZ 1024 ++ ++/* A context object used when read a CSV file. */ ++typedef struct CsvReader CsvReader; ++struct CsvReader { ++ FILE *in; /* Read the CSV text from this input stream */ ++ char *z; /* Accumulated text for a field */ ++ int n; /* Number of bytes in z */ ++ int nAlloc; /* Space allocated for z[] */ ++ int nLine; /* Current line number */ ++ char cTerm; /* Character that terminated the most recent field */ ++ size_t iIn; /* Next unread character in the input buffer */ ++ size_t nIn; /* Number of characters in the input buffer */ ++ char *zIn; /* The input buffer */ ++ char zErr[CSV_MXERR]; /* Error message */ ++}; ++ ++/* Initialize a CsvReader object */ ++static void csv_reader_init(CsvReader *p){ ++ p->in = 0; ++ p->z = 0; ++ p->n = 0; ++ p->nAlloc = 0; ++ p->nLine = 0; ++ p->nIn = 0; ++ p->zIn = 0; ++ p->zErr[0] = 0; ++} ++ ++/* Close and reset a CsvReader object */ ++static void csv_reader_reset(CsvReader *p){ ++ if( p->in ){ ++ fclose(p->in); ++ sqlite3_free(p->zIn); ++ } ++ sqlite3_free(p->z); ++ csv_reader_init(p); ++} ++ ++/* Report an error on a CsvReader */ ++static void csv_errmsg(CsvReader *p, const char *zFormat, ...){ ++ va_list ap; ++ va_start(ap, zFormat); ++ sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap); ++ va_end(ap); ++} ++ ++/* Open the file associated with a CsvReader ++** Return the number of errors. ++*/ ++static int csv_reader_open( ++ CsvReader *p, /* The reader to open */ ++ const char *zFilename, /* Read from this filename */ ++ const char *zData /* ... or use this data */ ++){ ++ if( zFilename ){ ++ p->zIn = sqlite3_malloc( CSV_INBUFSZ ); ++ if( p->zIn==0 ){ ++ csv_errmsg(p, "out of memory"); ++ return 1; ++ } ++ p->in = fopen(zFilename, "rb"); ++ if( p->in==0 ){ ++ csv_reader_reset(p); ++ csv_errmsg(p, "cannot open '%s' for reading", zFilename); ++ return 1; ++ } ++ }else{ ++ assert( p->in==0 ); ++ p->zIn = (char*)zData; ++ p->nIn = strlen(zData); ++ } ++ return 0; ++} ++ ++/* The input buffer has overflowed. Refill the input buffer, then ++** return the next character ++*/ ++static CSV_NOINLINE int csv_getc_refill(CsvReader *p){ ++ size_t got; ++ ++ assert( p->iIn>=p->nIn ); /* Only called on an empty input buffer */ ++ assert( p->in!=0 ); /* Only called if reading froma file */ ++ ++ got = fread(p->zIn, 1, CSV_INBUFSZ, p->in); ++ if( got==0 ) return EOF; ++ p->nIn = got; ++ p->iIn = 1; ++ return p->zIn[0]; ++} ++ ++/* Return the next character of input. Return EOF at end of input. */ ++static int csv_getc(CsvReader *p){ ++ if( p->iIn >= p->nIn ){ ++ if( p->in!=0 ) return csv_getc_refill(p); ++ return EOF; ++ } ++ return p->zIn[p->iIn++]; ++} ++ ++/* Increase the size of p->z and append character c to the end. ++** Return 0 on success and non-zero if there is an OOM error */ ++static CSV_NOINLINE int csv_resize_and_append(CsvReader *p, char c){ ++ char *zNew; ++ int nNew = p->nAlloc*2 + 100; ++ zNew = sqlite3_realloc(p->z, nNew); ++ if( zNew ){ ++ p->z = zNew; ++ p->nAlloc = nNew; ++ p->z[p->n++] = c; ++ return 0; ++ }else{ ++ csv_errmsg(p, "out of memory"); ++ return 1; ++ } ++} ++ ++/* Append a single character to the CsvReader.z[] array. ++** Return 0 on success and non-zero if there is an OOM error */ ++static int csv_append(CsvReader *p, char c){ ++ if( p->n>=p->nAlloc-1 ) return csv_resize_and_append(p, c); ++ p->z[p->n++] = c; ++ return 0; ++} ++ ++/* Read a single field of CSV text. Compatible with rfc4180 and extended ++** with the option of having a separator other than ",". ++** ++** + Input comes from p->in. ++** + Store results in p->z of length p->n. Space to hold p->z comes ++** from sqlite3_malloc64(). ++** + Keep track of the line number in p->nLine. ++** + Store the character that terminates the field in p->cTerm. Store ++** EOF on end-of-file. ++** ++** Return "" at EOF. Return 0 on an OOM error. ++*/ ++static const char *csv_read_one_field(CsvReader *p){ ++ int c; ++ p->n = 0; ++ c = csv_getc(p); ++ if( c==EOF ){ ++ p->cTerm = EOF; ++ return ""; ++ } ++ if( c=='"' ){ ++ int pc, ppc; ++ int startLine = p->nLine; ++ pc = ppc = 0; ++ while( 1 ){ ++ c = csv_getc(p); ++ if( c<='"' || pc=='"' ){ ++ if( c=='\n' ) p->nLine++; ++ if( c=='"' ){ ++ if( pc=='"' ){ ++ pc = 0; ++ continue; ++ } ++ } ++ if( (c==',' && pc=='"') ++ || (c=='\n' && pc=='"') ++ || (c=='\n' && pc=='\r' && ppc=='"') ++ || (c==EOF && pc=='"') ++ ){ ++ do{ p->n--; }while( p->z[p->n]!='"' ); ++ p->cTerm = (char)c; ++ break; ++ } ++ if( pc=='"' && c!='\r' ){ ++ csv_errmsg(p, "line %d: unescaped %c character", p->nLine, '"'); ++ break; ++ } ++ if( c==EOF ){ ++ csv_errmsg(p, "line %d: unterminated %c-quoted field\n", ++ startLine, '"'); ++ p->cTerm = (char)c; ++ break; ++ } ++ } ++ if( csv_append(p, (char)c) ) return 0; ++ ppc = pc; ++ pc = c; ++ } ++ }else{ ++ while( c>',' || (c!=EOF && c!=',' && c!='\n') ){ ++ if( csv_append(p, (char)c) ) return 0; ++ c = csv_getc(p); ++ } ++ if( c=='\n' ){ ++ p->nLine++; ++ if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--; ++ } ++ p->cTerm = (char)c; ++ } ++ if( p->z ) p->z[p->n] = 0; ++ return p->z; ++} ++ ++ ++/* Forward references to the various virtual table methods implemented ++** in this file. */ ++static int csvtabCreate(sqlite3*, void*, int, const char*const*, ++ sqlite3_vtab**,char**); ++static int csvtabConnect(sqlite3*, void*, int, const char*const*, ++ sqlite3_vtab**,char**); ++static int csvtabBestIndex(sqlite3_vtab*,sqlite3_index_info*); ++static int csvtabDisconnect(sqlite3_vtab*); ++static int csvtabOpen(sqlite3_vtab*, sqlite3_vtab_cursor**); ++static int csvtabClose(sqlite3_vtab_cursor*); ++static int csvtabFilter(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, ++ int argc, sqlite3_value **argv); ++static int csvtabNext(sqlite3_vtab_cursor*); ++static int csvtabEof(sqlite3_vtab_cursor*); ++static int csvtabColumn(sqlite3_vtab_cursor*,sqlite3_context*,int); ++static int csvtabRowid(sqlite3_vtab_cursor*,sqlite3_int64*); ++ ++/* An instance of the CSV virtual table */ ++typedef struct CsvTable { ++ sqlite3_vtab base; /* Base class. Must be first */ ++ char *zFilename; /* Name of the CSV file */ ++ char *zData; /* Raw CSV data in lieu of zFilename */ ++ long iStart; /* Offset to start of data in zFilename */ ++ int nCol; /* Number of columns in the CSV file */ ++ unsigned int tstFlags; /* Bit values used for testing */ ++} CsvTable; ++ ++/* Allowed values for tstFlags */ ++#define CSVTEST_FIDX 0x0001 /* Pretend that constrained searchs cost less*/ ++ ++/* A cursor for the CSV virtual table */ ++typedef struct CsvCursor { ++ sqlite3_vtab_cursor base; /* Base class. Must be first */ ++ CsvReader rdr; /* The CsvReader object */ ++ char **azVal; /* Value of the current row */ ++ int *aLen; /* Length of each entry */ ++ sqlite3_int64 iRowid; /* The current rowid. Negative for EOF */ ++} CsvCursor; ++ ++/* Transfer error message text from a reader into a CsvTable */ ++static void csv_xfer_error(CsvTable *pTab, CsvReader *pRdr){ ++ sqlite3_free(pTab->base.zErrMsg); ++ pTab->base.zErrMsg = sqlite3_mprintf("%s", pRdr->zErr); ++} ++ ++/* ++** This method is the destructor fo a CsvTable object. ++*/ ++static int csvtabDisconnect(sqlite3_vtab *pVtab){ ++ CsvTable *p = (CsvTable*)pVtab; ++ sqlite3_free(p->zFilename); ++ sqlite3_free(p->zData); ++ sqlite3_free(p); ++ return SQLITE_OK; ++} ++ ++/* Skip leading whitespace. Return a pointer to the first non-whitespace ++** character, or to the zero terminator if the string has only whitespace */ ++static const char *csv_skip_whitespace(const char *z){ ++ while( isspace((unsigned char)z[0]) ) z++; ++ return z; ++} ++ ++/* Remove trailing whitespace from the end of string z[] */ ++static void csv_trim_whitespace(char *z){ ++ size_t n = strlen(z); ++ while( n>0 && isspace((unsigned char)z[n]) ) n--; ++ z[n] = 0; ++} ++ ++/* Dequote the string */ ++static void csv_dequote(char *z){ ++ int j; ++ char cQuote = z[0]; ++ size_t i, n; ++ ++ if( cQuote!='\'' && cQuote!='"' ) return; ++ n = strlen(z); ++ if( n<2 || z[n-1]!=z[0] ) return; ++ for(i=1, j=0; izErr. If there are no errors, p->zErr[0]==0. ++*/ ++static int csv_string_parameter( ++ CsvReader *p, /* Leave the error message here, if there is one */ ++ const char *zParam, /* Parameter we are checking for */ ++ const char *zArg, /* Raw text of the virtual table argment */ ++ char **pzVal /* Write the dequoted string value here */ ++){ ++ const char *zValue; ++ zValue = csv_parameter(zParam,(int)strlen(zParam),zArg); ++ if( zValue==0 ) return 0; ++ p->zErr[0] = 0; ++ if( *pzVal ){ ++ csv_errmsg(p, "more than one '%s' parameter", zParam); ++ return 1; ++ } ++ *pzVal = sqlite3_mprintf("%s", zValue); ++ if( *pzVal==0 ){ ++ csv_errmsg(p, "out of memory"); ++ return 1; ++ } ++ csv_trim_whitespace(*pzVal); ++ csv_dequote(*pzVal); ++ return 1; ++} ++ ++ ++/* Return 0 if the argument is false and 1 if it is true. Return -1 if ++** we cannot really tell. ++*/ ++static int csv_boolean(const char *z){ ++ if( sqlite3_stricmp("yes",z)==0 ++ || sqlite3_stricmp("on",z)==0 ++ || sqlite3_stricmp("true",z)==0 ++ || (z[0]=='1' && z[1]==0) ++ ){ ++ return 1; ++ } ++ if( sqlite3_stricmp("no",z)==0 ++ || sqlite3_stricmp("off",z)==0 ++ || sqlite3_stricmp("false",z)==0 ++ || (z[0]=='0' && z[1]==0) ++ ){ ++ return 0; ++ } ++ return -1; ++} ++ ++ ++/* ++** Parameters: ++** filename=FILENAME Name of file containing CSV content ++** data=TEXT Direct CSV content. ++** schema=SCHEMA Alternative CSV schema. ++** header=YES|NO First row of CSV defines the names of ++** columns if "yes". Default "no". ++** columns=N Assume the CSV file contains N columns. ++** ++** Only available if compiled with SQLITE_TEST: ++** ++** testflags=N Bitmask of test flags. Optional ++** ++** If schema= is omitted, then the columns are named "c0", "c1", "c2", ++** and so forth. If columns=N is omitted, then the file is opened and ++** the number of columns in the first row is counted to determine the ++** column count. If header=YES, then the first row is skipped. ++*/ ++static int csvtabConnect( ++ sqlite3 *db, ++ void *pAux, ++ int argc, const char *const*argv, ++ sqlite3_vtab **ppVtab, ++ char **pzErr ++){ ++ CsvTable *pNew = 0; /* The CsvTable object to construct */ ++ int bHeader = -1; /* header= flags. -1 means not seen yet */ ++ int rc = SQLITE_OK; /* Result code from this routine */ ++ int i, j; /* Loop counters */ ++#ifdef SQLITE_TEST ++ int tstFlags = 0; /* Value for testflags=N parameter */ ++#endif ++ int nCol = -99; /* Value of the columns= parameter */ ++ CsvReader sRdr; /* A CSV file reader used to store an error ++ ** message and/or to count the number of columns */ ++ static const char *azParam[] = { ++ "filename", "data", "schema", ++ }; ++ char *azPValue[3]; /* Parameter values */ ++# define CSV_FILENAME (azPValue[0]) ++# define CSV_DATA (azPValue[1]) ++# define CSV_SCHEMA (azPValue[2]) ++ ++ ++ assert( sizeof(azPValue)==sizeof(azParam) ); ++ memset(&sRdr, 0, sizeof(sRdr)); ++ memset(azPValue, 0, sizeof(azPValue)); ++ for(i=3; i=0 ){ ++ csv_errmsg(&sRdr, "more than one 'header' parameter"); ++ goto csvtab_connect_error; ++ } ++ x = csv_boolean(zValue); ++ if( x==1 ){ ++ bHeader = 1; ++ }else if( x==0 ){ ++ bHeader = 0; ++ }else{ ++ csv_errmsg(&sRdr, "unrecognized argument to 'header': %s", zValue); ++ goto csvtab_connect_error; ++ } ++ }else ++#ifdef SQLITE_TEST ++ if( (zValue = csv_parameter("testflags",9,z))!=0 ){ ++ tstFlags = (unsigned int)atoi(zValue); ++ }else ++#endif ++ if( (zValue = csv_parameter("columns",7,z))!=0 ){ ++ if( nCol>0 ){ ++ csv_errmsg(&sRdr, "more than one 'columns' parameter"); ++ goto csvtab_connect_error; ++ } ++ nCol = atoi(zValue); ++ if( nCol<=0 ){ ++ csv_errmsg(&sRdr, "must have at least one column"); ++ goto csvtab_connect_error; ++ } ++ }else ++ { ++ csv_errmsg(&sRdr, "unrecognized parameter '%s'", z); ++ goto csvtab_connect_error; ++ } ++ } ++ if( (CSV_FILENAME==0)==(CSV_DATA==0) ){ ++ csv_errmsg(&sRdr, "must either filename= or data= but not both"); ++ goto csvtab_connect_error; ++ } ++ if( nCol<=0 && csv_reader_open(&sRdr, CSV_FILENAME, CSV_DATA) ){ ++ goto csvtab_connect_error; ++ } ++ pNew = sqlite3_malloc( sizeof(*pNew) ); ++ *ppVtab = (sqlite3_vtab*)pNew; ++ if( pNew==0 ) goto csvtab_connect_oom; ++ memset(pNew, 0, sizeof(*pNew)); ++ if( nCol>0 ){ ++ pNew->nCol = nCol; ++ }else{ ++ do{ ++ const char *z = csv_read_one_field(&sRdr); ++ if( z==0 ) goto csvtab_connect_oom; ++ pNew->nCol++; ++ }while( sRdr.cTerm==',' ); ++ } ++ pNew->zFilename = CSV_FILENAME; CSV_FILENAME = 0; ++ pNew->zData = CSV_DATA; CSV_DATA = 0; ++#ifdef SQLITE_TEST ++ pNew->tstFlags = tstFlags; ++#endif ++ pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0; ++ csv_reader_reset(&sRdr); ++ if( CSV_SCHEMA==0 ){ ++ const char *zSep = ""; ++ CSV_SCHEMA = sqlite3_mprintf("CREATE TABLE x("); ++ if( CSV_SCHEMA==0 ) goto csvtab_connect_oom; ++ for(i=0; inCol; i++){ ++ CSV_SCHEMA = sqlite3_mprintf("%z%sc%d TEXT",CSV_SCHEMA, zSep, i); ++ zSep = ","; ++ } ++ CSV_SCHEMA = sqlite3_mprintf("%z);", CSV_SCHEMA); ++ } ++ rc = sqlite3_declare_vtab(db, CSV_SCHEMA); ++ if( rc ) goto csvtab_connect_error; ++ for(i=0; ibase); ++ for(i=0; ibase.pVtab; ++ int i; ++ for(i=0; inCol; i++){ ++ sqlite3_free(pCur->azVal[i]); ++ pCur->azVal[i] = 0; ++ pCur->aLen[i] = 0; ++ } ++} ++ ++/* ++** The xConnect and xCreate methods do the same thing, but they must be ++** different so that the virtual table is not an eponymous virtual table. ++*/ ++static int csvtabCreate( ++ sqlite3 *db, ++ void *pAux, ++ int argc, const char *const*argv, ++ sqlite3_vtab **ppVtab, ++ char **pzErr ++){ ++ return csvtabConnect(db, pAux, argc, argv, ppVtab, pzErr); ++} ++ ++/* ++** Destructor for a CsvCursor. ++*/ ++static int csvtabClose(sqlite3_vtab_cursor *cur){ ++ CsvCursor *pCur = (CsvCursor*)cur; ++ csvtabCursorRowReset(pCur); ++ csv_reader_reset(&pCur->rdr); ++ sqlite3_free(cur); ++ return SQLITE_OK; ++} ++ ++/* ++** Constructor for a new CsvTable cursor object. ++*/ ++static int csvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ ++ CsvTable *pTab = (CsvTable*)p; ++ CsvCursor *pCur; ++ size_t nByte; ++ nByte = sizeof(*pCur) + (sizeof(char*)+sizeof(int))*pTab->nCol; ++ pCur = sqlite3_malloc( nByte ); ++ if( pCur==0 ) return SQLITE_NOMEM; ++ memset(pCur, 0, nByte); ++ pCur->azVal = (char**)&pCur[1]; ++ pCur->aLen = (int*)&pCur->azVal[pTab->nCol]; ++ *ppCursor = &pCur->base; ++ if( csv_reader_open(&pCur->rdr, pTab->zFilename, pTab->zData) ){ ++ csv_xfer_error(pTab, &pCur->rdr); ++ return SQLITE_ERROR; ++ } ++ return SQLITE_OK; ++} ++ ++ ++/* ++** Advance a CsvCursor to its next row of input. ++** Set the EOF marker if we reach the end of input. ++*/ ++static int csvtabNext(sqlite3_vtab_cursor *cur){ ++ CsvCursor *pCur = (CsvCursor*)cur; ++ CsvTable *pTab = (CsvTable*)cur->pVtab; ++ int i = 0; ++ const char *z; ++ do{ ++ z = csv_read_one_field(&pCur->rdr); ++ if( z==0 ){ ++ csv_xfer_error(pTab, &pCur->rdr); ++ break; ++ } ++ if( inCol ){ ++ if( pCur->aLen[i] < pCur->rdr.n+1 ){ ++ char *zNew = sqlite3_realloc(pCur->azVal[i], pCur->rdr.n+1); ++ if( zNew==0 ){ ++ csv_errmsg(&pCur->rdr, "out of memory"); ++ csv_xfer_error(pTab, &pCur->rdr); ++ break; ++ } ++ pCur->azVal[i] = zNew; ++ pCur->aLen[i] = pCur->rdr.n+1; ++ } ++ memcpy(pCur->azVal[i], z, pCur->rdr.n+1); ++ i++; ++ } ++ }while( pCur->rdr.cTerm==',' ); ++ while( inCol ){ ++ sqlite3_free(pCur->azVal[i]); ++ pCur->azVal[i] = 0; ++ pCur->aLen[i] = 0; ++ i++; ++ } ++ if( z==0 || pCur->rdr.cTerm==EOF ){ ++ pCur->iRowid = -1; ++ }else{ ++ pCur->iRowid++; ++ } ++ return SQLITE_OK; ++} ++ ++/* ++** Return values of columns for the row at which the CsvCursor ++** is currently pointing. ++*/ ++static int csvtabColumn( ++ sqlite3_vtab_cursor *cur, /* The cursor */ ++ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ ++ int i /* Which column to return */ ++){ ++ CsvCursor *pCur = (CsvCursor*)cur; ++ CsvTable *pTab = (CsvTable*)cur->pVtab; ++ if( i>=0 && inCol && pCur->azVal[i]!=0 ){ ++ sqlite3_result_text(ctx, pCur->azVal[i], -1, SQLITE_STATIC); ++ } ++ return SQLITE_OK; ++} ++ ++/* ++** Return the rowid for the current row. ++*/ ++static int csvtabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ ++ CsvCursor *pCur = (CsvCursor*)cur; ++ *pRowid = pCur->iRowid; ++ return SQLITE_OK; ++} ++ ++/* ++** Return TRUE if the cursor has been moved off of the last ++** row of output. ++*/ ++static int csvtabEof(sqlite3_vtab_cursor *cur){ ++ CsvCursor *pCur = (CsvCursor*)cur; ++ return pCur->iRowid<0; ++} ++ ++/* ++** Only a full table scan is supported. So xFilter simply rewinds to ++** the beginning. ++*/ ++static int csvtabFilter( ++ sqlite3_vtab_cursor *pVtabCursor, ++ int idxNum, const char *idxStr, ++ int argc, sqlite3_value **argv ++){ ++ CsvCursor *pCur = (CsvCursor*)pVtabCursor; ++ CsvTable *pTab = (CsvTable*)pVtabCursor->pVtab; ++ pCur->iRowid = 0; ++ if( pCur->rdr.in==0 ){ ++ assert( pCur->rdr.zIn==pTab->zData ); ++ assert( pTab->iStart>=0 ); ++ assert( (size_t)pTab->iStart<=pCur->rdr.nIn ); ++ pCur->rdr.iIn = pTab->iStart; ++ }else{ ++ fseek(pCur->rdr.in, pTab->iStart, SEEK_SET); ++ pCur->rdr.iIn = 0; ++ pCur->rdr.nIn = 0; ++ } ++ return csvtabNext(pVtabCursor); ++} ++ ++/* ++** Only a forward full table scan is supported. xBestIndex is mostly ++** a no-op. If CSVTEST_FIDX is set, then the presence of equality ++** constraints lowers the estimated cost, which is fiction, but is useful ++** for testing certain kinds of virtual table behavior. ++*/ ++static int csvtabBestIndex( ++ sqlite3_vtab *tab, ++ sqlite3_index_info *pIdxInfo ++){ ++ pIdxInfo->estimatedCost = 1000000; ++#ifdef SQLITE_TEST ++ if( (((CsvTable*)tab)->tstFlags & CSVTEST_FIDX)!=0 ){ ++ /* The usual (and sensible) case is to always do a full table scan. ++ ** The code in this branch only runs when testflags=1. This code ++ ** generates an artifical and unrealistic plan which is useful ++ ** for testing virtual table logic but is not helpful to real applications. ++ ** ++ ** Any ==, LIKE, or GLOB constraint is marked as usable by the virtual ++ ** table (even though it is not) and the cost of running the virtual table ++ ** is reduced from 1 million to just 10. The constraints are *not* marked ++ ** as omittable, however, so the query planner should still generate a ++ ** plan that gives a correct answer, even if they plan is not optimal. ++ */ ++ int i; ++ int nConst = 0; ++ for(i=0; inConstraint; i++){ ++ unsigned char op; ++ if( pIdxInfo->aConstraint[i].usable==0 ) continue; ++ op = pIdxInfo->aConstraint[i].op; ++ if( op==SQLITE_INDEX_CONSTRAINT_EQ ++ || op==SQLITE_INDEX_CONSTRAINT_LIKE ++ || op==SQLITE_INDEX_CONSTRAINT_GLOB ++ ){ ++ pIdxInfo->estimatedCost = 10; ++ pIdxInfo->aConstraintUsage[nConst].argvIndex = nConst+1; ++ nConst++; ++ } ++ } ++ } ++#endif ++ return SQLITE_OK; ++} ++ ++ ++static const sqlite3_module CsvModule = { ++ 0, /* iVersion */ ++ csvtabCreate, /* xCreate */ ++ csvtabConnect, /* xConnect */ ++ csvtabBestIndex, /* xBestIndex */ ++ csvtabDisconnect, /* xDisconnect */ ++ csvtabDisconnect, /* xDestroy */ ++ csvtabOpen, /* xOpen - open a cursor */ ++ csvtabClose, /* xClose - close a cursor */ ++ csvtabFilter, /* xFilter - configure scan constraints */ ++ csvtabNext, /* xNext - advance a cursor */ ++ csvtabEof, /* xEof - check for end of scan */ ++ csvtabColumn, /* xColumn - read data */ ++ csvtabRowid, /* xRowid - read data */ ++ 0, /* xUpdate */ ++ 0, /* xBegin */ ++ 0, /* xSync */ ++ 0, /* xCommit */ ++ 0, /* xRollback */ ++ 0, /* xFindMethod */ ++ 0, /* xRename */ ++}; ++ ++#ifdef SQLITE_TEST ++/* ++** For virtual table testing, make a version of the CSV virtual table ++** available that has an xUpdate function. But the xUpdate always returns ++** SQLITE_READONLY since the CSV file is not really writable. ++*/ ++static int csvtabUpdate(sqlite3_vtab *p,int n,sqlite3_value**v,sqlite3_int64*x){ ++ return SQLITE_READONLY; ++} ++static const sqlite3_module CsvModuleFauxWrite = { ++ 0, /* iVersion */ ++ csvtabCreate, /* xCreate */ ++ csvtabConnect, /* xConnect */ ++ csvtabBestIndex, /* xBestIndex */ ++ csvtabDisconnect, /* xDisconnect */ ++ csvtabDisconnect, /* xDestroy */ ++ csvtabOpen, /* xOpen - open a cursor */ ++ csvtabClose, /* xClose - close a cursor */ ++ csvtabFilter, /* xFilter - configure scan constraints */ ++ csvtabNext, /* xNext - advance a cursor */ ++ csvtabEof, /* xEof - check for end of scan */ ++ csvtabColumn, /* xColumn - read data */ ++ csvtabRowid, /* xRowid - read data */ ++ csvtabUpdate, /* xUpdate */ ++ 0, /* xBegin */ ++ 0, /* xSync */ ++ 0, /* xCommit */ ++ 0, /* xRollback */ ++ 0, /* xFindMethod */ ++ 0, /* xRename */ ++}; ++#endif /* SQLITE_TEST */ ++ ++#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */ ++ ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++/* ++** This routine is called when the extension is loaded. The new ++** CSV virtual table module is registered with the calling database ++** connection. ++*/ ++int sqlite3_csv_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ int rc; ++ SQLITE_EXTENSION_INIT2(pApi); ++ rc = sqlite3_create_module(db, "csv", &CsvModule, 0); ++#ifdef SQLITE_TEST ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_create_module(db, "csv_wr", &CsvModuleFauxWrite, 0); ++ } ++#endif ++ return rc; ++#else ++ return SQLITE_OK; ++#endif ++} ++#if !defined(_WIN32) && !defined(SQLITE_TEST) ++int sqlite3_extension_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ SQLITE_EXTENSION_INIT2(pApi); ++ return sqlite3_create_module(db, "csv", &CsvModule, 0); ++} ++#endif +--- origsrc/sqlite-autoconf-3180000/eval.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/eval.c 2017-04-19 16:20:01.640902700 +0200 @@ -0,0 +1,140 @@ +/* +** 2014-11-10 @@ -2917,8 +4589,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/fileio.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/fileio.c 2016-01-06 16:30:42.501121300 +0100 +--- origsrc/sqlite-autoconf-3180000/fileio.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/fileio.c 2017-04-19 16:20:01.648903500 +0200 @@ -0,0 +1,118 @@ +/* +** 2014-06-13 @@ -3038,8 +4710,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/fuzzer.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/fuzzer.c 2016-01-06 16:30:42.503121400 +0100 +--- origsrc/sqlite-autoconf-3180000/fuzzer.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/fuzzer.c 2017-04-19 16:20:01.661904800 +0200 @@ -0,0 +1,1199 @@ +/* +** 2011 March 24 @@ -3387,10 +5059,10 @@ + memset(pRule, 0, sizeof(*pRule)); + pRule->zFrom = pRule->zTo; + pRule->zFrom += nTo + 1; -+ pRule->nFrom = nFrom; ++ pRule->nFrom = (fuzzer_len)nFrom; + memcpy(pRule->zFrom, zFrom, nFrom+1); + memcpy(pRule->zTo, zTo, nTo+1); -+ pRule->nTo = nTo; ++ pRule->nTo = (fuzzer_len)nTo; + pRule->rCost = nCost; + pRule->iRuleset = (int)iRuleset; + } @@ -4240,9 +5912,9 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/icu.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/icu.c 2016-01-06 16:30:35.371713500 +0100 -@@ -0,0 +1,514 @@ +--- origsrc/sqlite-autoconf-3180000/icu.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/icu.c 2017-04-19 16:20:01.673906000 +0200 +@@ -0,0 +1,558 @@ +/* +** 2007 May 6 +** @@ -4306,6 +5978,38 @@ +} + +/* ++** This lookup table is used to help decode the first byte of ++** a multi-byte UTF8 character. It is copied here from SQLite source ++** code file utf8.c. ++*/ ++static const unsigned char icuUtf8Trans1[] = { ++ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ++ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ++ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, ++ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, ++ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ++ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ++ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, ++ 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, ++}; ++ ++#define SQLITE_ICU_READ_UTF8(zIn, c) \ ++ c = *(zIn++); \ ++ if( c>=0xc0 ){ \ ++ c = icuUtf8Trans1[c-0xc0]; \ ++ while( (*zIn & 0xc0)==0x80 ){ \ ++ c = (c<<6) + (0x3f & *(zIn++)); \ ++ } \ ++ } ++ ++#define SQLITE_ICU_SKIP_UTF8(zIn) \ ++ assert( *zIn ); \ ++ if( *(zIn++)>=0xc0 ){ \ ++ while( (*zIn & 0xc0)==0x80 ){zIn++;} \ ++ } ++ ++ ++/* +** Compare two UTF-8 strings for equality where the first string is +** a "LIKE" expression. Return true (1) if they are the same and +** false (0) if they are different. @@ -4318,16 +6022,14 @@ + static const int MATCH_ONE = (UChar32)'_'; + static const int MATCH_ALL = (UChar32)'%'; + -+ int iPattern = 0; /* Current byte index in zPattern */ -+ int iString = 0; /* Current byte index in zString */ -+ + int prevEscape = 0; /* True if the previous character was uEsc */ + -+ while( zPattern[iPattern]!=0 ){ ++ while( 1 ){ + + /* Read (and consume) the next character from the input pattern. */ + UChar32 uPattern; -+ U8_NEXT_UNSAFE(zPattern, iPattern, uPattern); ++ SQLITE_ICU_READ_UTF8(zPattern, uPattern); ++ if( uPattern==0 ) break; + + /* There are now 4 possibilities: + ** @@ -4344,28 +6046,28 @@ + ** MATCH_ALL. For each MATCH_ONE, skip one character in the + ** test string. + */ -+ while( (c=zPattern[iPattern]) == MATCH_ALL || c == MATCH_ONE ){ ++ while( (c=*zPattern) == MATCH_ALL || c == MATCH_ONE ){ + if( c==MATCH_ONE ){ -+ if( zString[iString]==0 ) return 0; -+ U8_FWD_1_UNSAFE(zString, iString); ++ if( *zString==0 ) return 0; ++ SQLITE_ICU_SKIP_UTF8(zString); + } -+ iPattern++; ++ zPattern++; + } + -+ if( zPattern[iPattern]==0 ) return 1; ++ if( *zPattern==0 ) return 1; + -+ while( zString[iString] ){ -+ if( icuLikeCompare(&zPattern[iPattern], &zString[iString], uEsc) ){ ++ while( *zString ){ ++ if( icuLikeCompare(zPattern, zString, uEsc) ){ + return 1; + } -+ U8_FWD_1_UNSAFE(zString, iString); ++ SQLITE_ICU_SKIP_UTF8(zString); + } + return 0; + + }else if( !prevEscape && uPattern==MATCH_ONE ){ + /* Case 2. */ -+ if( zString[iString]==0 ) return 0; -+ U8_FWD_1_UNSAFE(zString, iString); ++ if( *zString==0 ) return 0; ++ SQLITE_ICU_SKIP_UTF8(zString); + + }else if( !prevEscape && uPattern==uEsc){ + /* Case 3. */ @@ -4374,7 +6076,7 @@ + }else{ + /* Case 4. */ + UChar32 uString; -+ U8_NEXT_UNSAFE(zString, iString, uString); ++ SQLITE_ICU_READ_UTF8(zString, uString); + uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT); + uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT); + if( uString!=uPattern ){ @@ -4384,7 +6086,7 @@ + } + } + -+ return zString[iString]==0; ++ return *zString==0; +} + +/* @@ -4564,20 +6266,22 @@ +** of upper() or lower(). +** +** lower('I', 'en_us') -> 'i' -+** lower('I', 'tr_tr') -> 'ı' (small dotless i) ++** lower('I', 'tr_tr') -> '\u131' (small dotless i) +** +** http://www.icu-project.org/userguide/posix.html#case_mappings +*/ +static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){ -+ const UChar *zInput; -+ UChar *zOutput; -+ size_t nInput; -+ size_t nOutput; -+ -+ UErrorCode status = U_ZERO_ERROR; ++ const UChar *zInput; /* Pointer to input string */ ++ UChar *zOutput = 0; /* Pointer to output buffer */ ++ size_t nInput; /* Size of utf-16 input string in bytes */ ++ size_t nOut; /* Size of output buffer in bytes */ ++ int cnt; ++ int bToUpper; /* True for toupper(), false for tolower() */ ++ UErrorCode status; + const char *zLocale = 0; + + assert(nArg==1 || nArg==2); ++ bToUpper = (sqlite3_user_data(p)!=0); + if( nArg==2 ){ + zLocale = (const char *)sqlite3_value_text(apArg[1]); + } @@ -4586,26 +6290,38 @@ + if( !zInput ){ + return; + } -+ nInput = sqlite3_value_bytes16(apArg[0]); -+ -+ nOutput = nInput * 2 + 2; -+ zOutput = sqlite3_malloc(nOutput); -+ if( !zOutput ){ ++ nOut = nInput = sqlite3_value_bytes16(apArg[0]); ++ if( nOut==0 ){ ++ sqlite3_result_text16(p, "", 0, SQLITE_STATIC); + return; + } + -+ if( sqlite3_user_data(p) ){ -+ u_strToUpper(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status); -+ }else{ -+ u_strToLower(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status); -+ } ++ for(cnt=0; cnt<2; cnt++){ ++ UChar *zNew = sqlite3_realloc(zOutput, nOut); ++ if( zNew==0 ){ ++ sqlite3_free(zOutput); ++ sqlite3_result_error_nomem(p); ++ return; ++ } ++ zOutput = zNew; ++ status = U_ZERO_ERROR; ++ if( bToUpper ){ ++ nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status); ++ }else{ ++ nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status); ++ } + -+ if( !U_SUCCESS(status) ){ -+ icuFunctionError(p, "u_strToLower()/u_strToUpper", status); ++ if( U_SUCCESS(status) ){ ++ sqlite3_result_text16(p, zOutput, nOut, xFree); ++ }else if( status==U_BUFFER_OVERFLOW_ERROR ){ ++ assert( cnt==0 ); ++ continue; ++ }else{ ++ icuFunctionError(p, bToUpper ? "u_strToUpper" : "u_strToLower", status); ++ } + return; + } -+ -+ sqlite3_result_text16(p, zOutput, -1, xFree); ++ assert( 0 ); /* Unreachable */ +} + +/* @@ -4701,20 +6417,20 @@ + void *pContext; /* sqlite3_user_data() context */ + void (*xFunc)(sqlite3_context*,int,sqlite3_value**); + } scalars[] = { -+ {"regexp", 2, SQLITE_UTF8, 0, icuRegexpFunc}, ++ {"regexp", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuRegexpFunc}, + -+ {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16}, -+ {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16}, -+ {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16}, -+ {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16}, ++ {"lower", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16}, ++ {"lower", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16}, ++ {"upper", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, (void*)1, icuCaseFunc16}, ++ {"upper", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, (void*)1, icuCaseFunc16}, + -+ {"lower", 1, SQLITE_UTF8, 0, icuCaseFunc16}, -+ {"lower", 2, SQLITE_UTF8, 0, icuCaseFunc16}, -+ {"upper", 1, SQLITE_UTF8, (void*)1, icuCaseFunc16}, -+ {"upper", 2, SQLITE_UTF8, (void*)1, icuCaseFunc16}, ++ {"lower", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuCaseFunc16}, ++ {"lower", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuCaseFunc16}, ++ {"upper", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, (void*)1, icuCaseFunc16}, ++ {"upper", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, (void*)1, icuCaseFunc16}, + -+ {"like", 2, SQLITE_UTF8, 0, icuLikeFunc}, -+ {"like", 3, SQLITE_UTF8, 0, icuLikeFunc}, ++ {"like", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc}, ++ {"like", 3, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc}, + + {"icu_load_collation", 2, SQLITE_UTF8, (void*)db, icuLoadCollation}, + }; @@ -4757,8 +6473,8 @@ +#endif + +#endif ---- origsrc/sqlite-autoconf-3100000/ieee754.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/ieee754.c 2016-01-06 16:30:42.504121500 +0100 +--- origsrc/sqlite-autoconf-3180000/ieee754.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/ieee754.c 2017-04-19 16:20:01.682906900 +0200 @@ -0,0 +1,149 @@ +/* +** 2013-04-17 @@ -4909,8 +6625,2754 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/nextchar.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/nextchar.c 2016-01-06 16:30:42.508121700 +0100 +--- origsrc/sqlite-autoconf-3180000/json1.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/json1.c 2017-04-19 16:20:01.700908700 +0200 +@@ -0,0 +1,2229 @@ ++/* ++** 2015-08-12 ++** ++** 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 implements JSON functions. The interface is ++** modeled after MySQL JSON functions: ++** ++** https://dev.mysql.com/doc/refman/5.7/en/json.html ++** ++** For the time being, all JSON is stored as pure text. (We might add ++** a JSONB type in the future which stores a binary encoding of JSON in ++** a BLOB, but there is no support for JSONB in the current implementation. ++** This implementation parses JSON text at 250 MB/s, so it is hard to see ++** how JSONB might improve on that.) ++*/ ++#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) ++#if !defined(SQLITEINT_H) ++#include "sqlite3ext.h" ++#endif ++SQLITE_EXTENSION_INIT1 ++#include ++#include ++#include ++#include ++ ++/* Mark a function parameter as unused, to suppress nuisance compiler ++** warnings. */ ++#ifndef UNUSED_PARAM ++# define UNUSED_PARAM(X) (void)(X) ++#endif ++ ++#ifndef LARGEST_INT64 ++# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) ++# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) ++#endif ++ ++/* ++** Versions of isspace(), isalnum() and isdigit() to which it is safe ++** to pass signed char values. ++*/ ++#ifdef sqlite3Isdigit ++ /* Use the SQLite core versions if this routine is part of the ++ ** SQLite amalgamation */ ++# define safe_isdigit(x) sqlite3Isdigit(x) ++# define safe_isalnum(x) sqlite3Isalnum(x) ++# define safe_isxdigit(x) sqlite3Isxdigit(x) ++#else ++ /* Use the standard library for separate compilation */ ++#include /* amalgamator: keep */ ++# define safe_isdigit(x) isdigit((unsigned char)(x)) ++# define safe_isalnum(x) isalnum((unsigned char)(x)) ++# define safe_isxdigit(x) isxdigit((unsigned char)(x)) ++#endif ++ ++/* ++** Growing our own isspace() routine this way is twice as fast as ++** the library isspace() function, resulting in a 7% overall performance ++** increase for the parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). ++*/ ++static const char jsonIsSpace[] = { ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++}; ++#define safe_isspace(x) (jsonIsSpace[(unsigned char)x]) ++ ++#ifndef SQLITE_AMALGAMATION ++ /* Unsigned integer types. These are already defined in the sqliteInt.h, ++ ** but the definitions need to be repeated for separate compilation. */ ++ typedef unsigned int u32; ++ typedef unsigned char u8; ++#endif ++ ++/* Objects */ ++typedef struct JsonString JsonString; ++typedef struct JsonNode JsonNode; ++typedef struct JsonParse JsonParse; ++ ++/* An instance of this object represents a JSON string ++** under construction. Really, this is a generic string accumulator ++** that can be and is used to create strings other than JSON. ++*/ ++struct JsonString { ++ sqlite3_context *pCtx; /* Function context - put error messages here */ ++ char *zBuf; /* Append JSON content here */ ++ size_t nAlloc; /* Bytes of storage available in zBuf[] */ ++ size_t nUsed; /* Bytes of zBuf[] currently used */ ++ u8 bStatic; /* True if zBuf is static space */ ++ u8 bErr; /* True if an error has been encountered */ ++ char zSpace[100]; /* Initial static space */ ++}; ++ ++/* JSON type values ++*/ ++#define JSON_NULL 0 ++#define JSON_TRUE 1 ++#define JSON_FALSE 2 ++#define JSON_INT 3 ++#define JSON_REAL 4 ++#define JSON_STRING 5 ++#define JSON_ARRAY 6 ++#define JSON_OBJECT 7 ++ ++/* The "subtype" set for JSON values */ ++#define JSON_SUBTYPE 74 /* Ascii for "J" */ ++ ++/* ++** Names of the various JSON types: ++*/ ++static const char jsonType[][8] = { ++ "null", "true", "false", "integer", "real", "text", "array", "object" ++}; ++ ++/* Bit values for the JsonNode.jnFlag field ++*/ ++#define JNODE_RAW 0x01 /* Content is raw, not JSON encoded */ ++#define JNODE_ESCAPE 0x02 /* Content is text with \ escapes */ ++#define JNODE_REMOVE 0x04 /* Do not output */ ++#define JNODE_REPLACE 0x08 /* Replace with JsonNode.iVal */ ++#define JNODE_APPEND 0x10 /* More ARRAY/OBJECT entries at u.iAppend */ ++#define JNODE_LABEL 0x20 /* Is a label of an object */ ++ ++ ++/* A single node of parsed JSON ++*/ ++struct JsonNode { ++ u8 eType; /* One of the JSON_ type values */ ++ u8 jnFlags; /* JNODE flags */ ++ u8 iVal; /* Replacement value when JNODE_REPLACE */ ++ u32 n; /* Bytes of content, or number of sub-nodes */ ++ union { ++ const char *zJContent; /* Content for INT, REAL, and STRING */ ++ u32 iAppend; /* More terms for ARRAY and OBJECT */ ++ u32 iKey; /* Key for ARRAY objects in json_tree() */ ++ } u; ++}; ++ ++/* A completely parsed JSON string ++*/ ++struct JsonParse { ++ u32 nNode; /* Number of slots of aNode[] used */ ++ u32 nAlloc; /* Number of slots of aNode[] allocated */ ++ JsonNode *aNode; /* Array of nodes containing the parse */ ++ const char *zJson; /* Original JSON string */ ++ u32 *aUp; /* Index of parent of each node */ ++ u8 oom; /* Set to true if out of memory */ ++ u8 nErr; /* Number of errors seen */ ++}; ++ ++/************************************************************************** ++** Utility routines for dealing with JsonString objects ++**************************************************************************/ ++ ++/* Set the JsonString object to an empty string ++*/ ++static void jsonZero(JsonString *p){ ++ p->zBuf = p->zSpace; ++ p->nAlloc = sizeof(p->zSpace); ++ p->nUsed = 0; ++ p->bStatic = 1; ++} ++ ++/* Initialize the JsonString object ++*/ ++static void jsonInit(JsonString *p, sqlite3_context *pCtx){ ++ p->pCtx = pCtx; ++ p->bErr = 0; ++ jsonZero(p); ++} ++ ++ ++/* Free all allocated memory and reset the JsonString object back to its ++** initial state. ++*/ ++static void jsonReset(JsonString *p){ ++ if( !p->bStatic ) sqlite3_free(p->zBuf); ++ jsonZero(p); ++} ++ ++ ++/* Report an out-of-memory (OOM) condition ++*/ ++static void jsonOom(JsonString *p){ ++ p->bErr = 1; ++ sqlite3_result_error_nomem(p->pCtx); ++ jsonReset(p); ++} ++ ++/* Enlarge pJson->zBuf so that it can hold at least N more bytes. ++** Return zero on success. Return non-zero on an OOM error ++*/ ++static int jsonGrow(JsonString *p, u32 N){ ++ size_t nTotal = NnAlloc ? p->nAlloc*2 : p->nAlloc+N+10; ++ char *zNew; ++ if( p->bStatic ){ ++ if( p->bErr ) return 1; ++ zNew = sqlite3_malloc(nTotal); ++ if( zNew==0 ){ ++ jsonOom(p); ++ return SQLITE_NOMEM; ++ } ++ memcpy(zNew, p->zBuf, (size_t)p->nUsed); ++ p->zBuf = zNew; ++ p->bStatic = 0; ++ }else{ ++ zNew = sqlite3_realloc(p->zBuf, nTotal); ++ if( zNew==0 ){ ++ jsonOom(p); ++ return SQLITE_NOMEM; ++ } ++ p->zBuf = zNew; ++ } ++ p->nAlloc = nTotal; ++ return SQLITE_OK; ++} ++ ++/* Append N bytes from zIn onto the end of the JsonString string. ++*/ ++static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){ ++ if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return; ++ memcpy(p->zBuf+p->nUsed, zIn, N); ++ p->nUsed += N; ++} ++ ++/* Append formatted text (not to exceed N bytes) to the JsonString. ++*/ ++static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){ ++ va_list ap; ++ if( (p->nUsed + N >= p->nAlloc) && jsonGrow(p, N) ) return; ++ va_start(ap, zFormat); ++ sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap); ++ va_end(ap); ++ p->nUsed += (int)strlen(p->zBuf+p->nUsed); ++} ++ ++/* Append a single character ++*/ ++static void jsonAppendChar(JsonString *p, char c){ ++ if( p->nUsed>=p->nAlloc && jsonGrow(p,1)!=0 ) return; ++ p->zBuf[p->nUsed++] = c; ++} ++ ++/* Append a comma separator to the output buffer, if the previous ++** character is not '[' or '{'. ++*/ ++static void jsonAppendSeparator(JsonString *p){ ++ char c; ++ if( p->nUsed==0 ) return; ++ c = p->zBuf[p->nUsed-1]; ++ if( c!='[' && c!='{' ) jsonAppendChar(p, ','); ++} ++ ++/* Append the N-byte string in zIn to the end of the JsonString string ++** under construction. Enclose the string in "..." and escape ++** any double-quotes or backslash characters contained within the ++** string. ++*/ ++static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ ++ u32 i; ++ if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return; ++ p->zBuf[p->nUsed++] = '"'; ++ for(i=0; inUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return; ++ p->zBuf[p->nUsed++] = '\\'; ++ }else if( c<=0x1f ){ ++ static const char aSpecial[] = { ++ 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ++ }; ++ assert( sizeof(aSpecial)==32 ); ++ assert( aSpecial['\b']=='b' ); ++ assert( aSpecial['\f']=='f' ); ++ assert( aSpecial['\n']=='n' ); ++ assert( aSpecial['\r']=='r' ); ++ assert( aSpecial['\t']=='t' ); ++ if( aSpecial[c] ){ ++ c = aSpecial[c]; ++ goto json_simple_escape; ++ } ++ if( (p->nUsed+N+7+i > p->nAlloc) && jsonGrow(p,N+7-i)!=0 ) return; ++ p->zBuf[p->nUsed++] = '\\'; ++ p->zBuf[p->nUsed++] = 'u'; ++ p->zBuf[p->nUsed++] = '0'; ++ p->zBuf[p->nUsed++] = '0'; ++ p->zBuf[p->nUsed++] = '0' + (c>>4); ++ c = "0123456789abcdef"[c&0xf]; ++ } ++ p->zBuf[p->nUsed++] = c; ++ } ++ p->zBuf[p->nUsed++] = '"'; ++ assert( p->nUsednAlloc ); ++} ++ ++/* ++** Append a function parameter value to the JSON string under ++** construction. ++*/ ++static void jsonAppendValue( ++ JsonString *p, /* Append to this JSON string */ ++ sqlite3_value *pValue /* Value to append */ ++){ ++ switch( sqlite3_value_type(pValue) ){ ++ case SQLITE_NULL: { ++ jsonAppendRaw(p, "null", 4); ++ break; ++ } ++ case SQLITE_INTEGER: ++ case SQLITE_FLOAT: { ++ const char *z = (const char*)sqlite3_value_text(pValue); ++ u32 n = (u32)sqlite3_value_bytes(pValue); ++ jsonAppendRaw(p, z, n); ++ break; ++ } ++ case SQLITE_TEXT: { ++ const char *z = (const char*)sqlite3_value_text(pValue); ++ u32 n = (u32)sqlite3_value_bytes(pValue); ++ if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){ ++ jsonAppendRaw(p, z, n); ++ }else{ ++ jsonAppendString(p, z, n); ++ } ++ break; ++ } ++ default: { ++ if( p->bErr==0 ){ ++ sqlite3_result_error(p->pCtx, "JSON cannot hold BLOB values", -1); ++ p->bErr = 2; ++ jsonReset(p); ++ } ++ break; ++ } ++ } ++} ++ ++ ++/* Make the JSON in p the result of the SQL function. ++*/ ++static void jsonResult(JsonString *p){ ++ if( p->bErr==0 ){ ++ sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, ++ p->bStatic ? SQLITE_TRANSIENT : sqlite3_free, ++ SQLITE_UTF8); ++ jsonZero(p); ++ } ++ assert( p->bStatic ); ++} ++ ++/************************************************************************** ++** Utility routines for dealing with JsonNode and JsonParse objects ++**************************************************************************/ ++ ++/* ++** Return the number of consecutive JsonNode slots need to represent ++** the parsed JSON at pNode. The minimum answer is 1. For ARRAY and ++** OBJECT types, the number might be larger. ++** ++** Appended elements are not counted. The value returned is the number ++** by which the JsonNode counter should increment in order to go to the ++** next peer value. ++*/ ++static u32 jsonNodeSize(JsonNode *pNode){ ++ return pNode->eType>=JSON_ARRAY ? pNode->n+1 : 1; ++} ++ ++/* ++** Reclaim all memory allocated by a JsonParse object. But do not ++** delete the JsonParse object itself. ++*/ ++static void jsonParseReset(JsonParse *pParse){ ++ sqlite3_free(pParse->aNode); ++ pParse->aNode = 0; ++ pParse->nNode = 0; ++ pParse->nAlloc = 0; ++ sqlite3_free(pParse->aUp); ++ pParse->aUp = 0; ++} ++ ++/* ++** Convert the JsonNode pNode into a pure JSON string and ++** append to pOut. Subsubstructure is also included. Return ++** the number of JsonNode objects that are encoded. ++*/ ++static void jsonRenderNode( ++ JsonNode *pNode, /* The node to render */ ++ JsonString *pOut, /* Write JSON here */ ++ sqlite3_value **aReplace /* Replacement values */ ++){ ++ switch( pNode->eType ){ ++ default: { ++ assert( pNode->eType==JSON_NULL ); ++ jsonAppendRaw(pOut, "null", 4); ++ break; ++ } ++ case JSON_TRUE: { ++ jsonAppendRaw(pOut, "true", 4); ++ break; ++ } ++ case JSON_FALSE: { ++ jsonAppendRaw(pOut, "false", 5); ++ break; ++ } ++ case JSON_STRING: { ++ if( pNode->jnFlags & JNODE_RAW ){ ++ jsonAppendString(pOut, pNode->u.zJContent, pNode->n); ++ break; ++ } ++ /* Fall through into the next case */ ++ } ++ case JSON_REAL: ++ case JSON_INT: { ++ jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); ++ break; ++ } ++ case JSON_ARRAY: { ++ u32 j = 1; ++ jsonAppendChar(pOut, '['); ++ for(;;){ ++ while( j<=pNode->n ){ ++ if( pNode[j].jnFlags & (JNODE_REMOVE|JNODE_REPLACE) ){ ++ if( pNode[j].jnFlags & JNODE_REPLACE ){ ++ jsonAppendSeparator(pOut); ++ jsonAppendValue(pOut, aReplace[pNode[j].iVal]); ++ } ++ }else{ ++ jsonAppendSeparator(pOut); ++ jsonRenderNode(&pNode[j], pOut, aReplace); ++ } ++ j += jsonNodeSize(&pNode[j]); ++ } ++ if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; ++ pNode = &pNode[pNode->u.iAppend]; ++ j = 1; ++ } ++ jsonAppendChar(pOut, ']'); ++ break; ++ } ++ case JSON_OBJECT: { ++ u32 j = 1; ++ jsonAppendChar(pOut, '{'); ++ for(;;){ ++ while( j<=pNode->n ){ ++ if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 ){ ++ jsonAppendSeparator(pOut); ++ jsonRenderNode(&pNode[j], pOut, aReplace); ++ jsonAppendChar(pOut, ':'); ++ if( pNode[j+1].jnFlags & JNODE_REPLACE ){ ++ jsonAppendValue(pOut, aReplace[pNode[j+1].iVal]); ++ }else{ ++ jsonRenderNode(&pNode[j+1], pOut, aReplace); ++ } ++ } ++ j += 1 + jsonNodeSize(&pNode[j+1]); ++ } ++ if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; ++ pNode = &pNode[pNode->u.iAppend]; ++ j = 1; ++ } ++ jsonAppendChar(pOut, '}'); ++ break; ++ } ++ } ++} ++ ++/* ++** Return a JsonNode and all its descendents as a JSON string. ++*/ ++static void jsonReturnJson( ++ JsonNode *pNode, /* Node to return */ ++ sqlite3_context *pCtx, /* Return value for this function */ ++ sqlite3_value **aReplace /* Array of replacement values */ ++){ ++ JsonString s; ++ jsonInit(&s, pCtx); ++ jsonRenderNode(pNode, &s, aReplace); ++ jsonResult(&s); ++ sqlite3_result_subtype(pCtx, JSON_SUBTYPE); ++} ++ ++/* ++** Make the JsonNode the return value of the function. ++*/ ++static void jsonReturn( ++ JsonNode *pNode, /* Node to return */ ++ sqlite3_context *pCtx, /* Return value for this function */ ++ sqlite3_value **aReplace /* Array of replacement values */ ++){ ++ switch( pNode->eType ){ ++ default: { ++ assert( pNode->eType==JSON_NULL ); ++ sqlite3_result_null(pCtx); ++ break; ++ } ++ case JSON_TRUE: { ++ sqlite3_result_int(pCtx, 1); ++ break; ++ } ++ case JSON_FALSE: { ++ sqlite3_result_int(pCtx, 0); ++ break; ++ } ++ case JSON_INT: { ++ sqlite3_int64 i = 0; ++ const char *z = pNode->u.zJContent; ++ if( z[0]=='-' ){ z++; } ++ while( z[0]>='0' && z[0]<='9' ){ ++ unsigned v = *(z++) - '0'; ++ if( i>=LARGEST_INT64/10 ){ ++ if( i>LARGEST_INT64/10 ) goto int_as_real; ++ if( z[0]>='0' && z[0]<='9' ) goto int_as_real; ++ if( v==9 ) goto int_as_real; ++ if( v==8 ){ ++ if( pNode->u.zJContent[0]=='-' ){ ++ sqlite3_result_int64(pCtx, SMALLEST_INT64); ++ goto int_done; ++ }else{ ++ goto int_as_real; ++ } ++ } ++ } ++ i = i*10 + v; ++ } ++ if( pNode->u.zJContent[0]=='-' ){ i = -i; } ++ sqlite3_result_int64(pCtx, i); ++ int_done: ++ break; ++ int_as_real: /* fall through to real */; ++ } ++ case JSON_REAL: { ++ double r; ++#ifdef SQLITE_AMALGAMATION ++ const char *z = pNode->u.zJContent; ++ sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); ++#else ++ r = strtod(pNode->u.zJContent, 0); ++#endif ++ sqlite3_result_double(pCtx, r); ++ break; ++ } ++ case JSON_STRING: { ++#if 0 /* Never happens because JNODE_RAW is only set by json_set(), ++ ** json_insert() and json_replace() and those routines do not ++ ** call jsonReturn() */ ++ if( pNode->jnFlags & JNODE_RAW ){ ++ sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, ++ SQLITE_TRANSIENT); ++ }else ++#endif ++ assert( (pNode->jnFlags & JNODE_RAW)==0 ); ++ if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ ++ /* JSON formatted without any backslash-escapes */ ++ sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, ++ SQLITE_TRANSIENT); ++ }else{ ++ /* Translate JSON formatted string into raw text */ ++ u32 i; ++ u32 n = pNode->n; ++ const char *z = pNode->u.zJContent; ++ char *zOut; ++ u32 j; ++ zOut = sqlite3_malloc( n+1 ); ++ if( zOut==0 ){ ++ sqlite3_result_error_nomem(pCtx); ++ break; ++ } ++ for(i=1, j=0; i>6)); ++ zOut[j++] = 0x80 | (v&0x3f); ++ }else{ ++ zOut[j++] = (char)(0xe0 | (v>>12)); ++ zOut[j++] = 0x80 | ((v>>6)&0x3f); ++ zOut[j++] = 0x80 | (v&0x3f); ++ } ++ }else{ ++ if( c=='b' ){ ++ c = '\b'; ++ }else if( c=='f' ){ ++ c = '\f'; ++ }else if( c=='n' ){ ++ c = '\n'; ++ }else if( c=='r' ){ ++ c = '\r'; ++ }else if( c=='t' ){ ++ c = '\t'; ++ } ++ zOut[j++] = c; ++ } ++ } ++ } ++ zOut[j] = 0; ++ sqlite3_result_text(pCtx, zOut, j, sqlite3_free); ++ } ++ break; ++ } ++ case JSON_ARRAY: ++ case JSON_OBJECT: { ++ jsonReturnJson(pNode, pCtx, aReplace); ++ break; ++ } ++ } ++} ++ ++/* Forward reference */ ++static int jsonParseAddNode(JsonParse*,u32,u32,const char*); ++ ++/* ++** A macro to hint to the compiler that a function should not be ++** inlined. ++*/ ++#if defined(__GNUC__) ++# define JSON_NOINLINE __attribute__((noinline)) ++#elif defined(_MSC_VER) && _MSC_VER>=1310 ++# define JSON_NOINLINE __declspec(noinline) ++#else ++# define JSON_NOINLINE ++#endif ++ ++ ++static JSON_NOINLINE int jsonParseAddNodeExpand( ++ JsonParse *pParse, /* Append the node to this object */ ++ u32 eType, /* Node type */ ++ u32 n, /* Content size or sub-node count */ ++ const char *zContent /* Content */ ++){ ++ u32 nNew; ++ JsonNode *pNew; ++ assert( pParse->nNode>=pParse->nAlloc ); ++ if( pParse->oom ) return -1; ++ nNew = pParse->nAlloc*2 + 10; ++ pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew); ++ if( pNew==0 ){ ++ pParse->oom = 1; ++ return -1; ++ } ++ pParse->nAlloc = nNew; ++ pParse->aNode = pNew; ++ assert( pParse->nNodenAlloc ); ++ return jsonParseAddNode(pParse, eType, n, zContent); ++} ++ ++/* ++** Create a new JsonNode instance based on the arguments and append that ++** instance to the JsonParse. Return the index in pParse->aNode[] of the ++** new node, or -1 if a memory allocation fails. ++*/ ++static int jsonParseAddNode( ++ JsonParse *pParse, /* Append the node to this object */ ++ u32 eType, /* Node type */ ++ u32 n, /* Content size or sub-node count */ ++ const char *zContent /* Content */ ++){ ++ JsonNode *p; ++ if( pParse->nNode>=pParse->nAlloc ){ ++ return jsonParseAddNodeExpand(pParse, eType, n, zContent); ++ } ++ p = &pParse->aNode[pParse->nNode]; ++ p->eType = (u8)eType; ++ p->jnFlags = 0; ++ p->iVal = 0; ++ p->n = n; ++ p->u.zJContent = zContent; ++ return pParse->nNode++; ++} ++ ++/* ++** Return true if z[] begins with 4 (or more) hexadecimal digits ++*/ ++static int jsonIs4Hex(const char *z){ ++ int i; ++ for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0; ++ return 1; ++} ++ ++/* ++** Parse a single JSON value which begins at pParse->zJson[i]. Return the ++** index of the first character past the end of the value parsed. ++** ++** Return negative for a syntax error. Special cases: return -2 if the ++** first non-whitespace character is '}' and return -3 if the first ++** non-whitespace character is ']'. ++*/ ++static int jsonParseValue(JsonParse *pParse, u32 i){ ++ char c; ++ u32 j; ++ int iThis; ++ int x; ++ JsonNode *pNode; ++ while( safe_isspace(pParse->zJson[i]) ){ i++; } ++ if( (c = pParse->zJson[i])=='{' ){ ++ /* Parse object */ ++ iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); ++ if( iThis<0 ) return -1; ++ for(j=i+1;;j++){ ++ while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ x = jsonParseValue(pParse, j); ++ if( x<0 ){ ++ if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; ++ return -1; ++ } ++ if( pParse->oom ) return -1; ++ pNode = &pParse->aNode[pParse->nNode-1]; ++ if( pNode->eType!=JSON_STRING ) return -1; ++ pNode->jnFlags |= JNODE_LABEL; ++ j = x; ++ while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ if( pParse->zJson[j]!=':' ) return -1; ++ j++; ++ x = jsonParseValue(pParse, j); ++ if( x<0 ) return -1; ++ j = x; ++ while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ c = pParse->zJson[j]; ++ if( c==',' ) continue; ++ if( c!='}' ) return -1; ++ break; ++ } ++ pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; ++ return j+1; ++ }else if( c=='[' ){ ++ /* Parse array */ ++ iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); ++ if( iThis<0 ) return -1; ++ for(j=i+1;;j++){ ++ while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ x = jsonParseValue(pParse, j); ++ if( x<0 ){ ++ if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; ++ return -1; ++ } ++ j = x; ++ while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ c = pParse->zJson[j]; ++ if( c==',' ) continue; ++ if( c!=']' ) return -1; ++ break; ++ } ++ pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; ++ return j+1; ++ }else if( c=='"' ){ ++ /* Parse string */ ++ u8 jnFlags = 0; ++ j = i+1; ++ for(;;){ ++ c = pParse->zJson[j]; ++ if( c==0 ) return -1; ++ if( c=='\\' ){ ++ c = pParse->zJson[++j]; ++ if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' ++ || c=='n' || c=='r' || c=='t' ++ || (c=='u' && jsonIs4Hex(pParse->zJson+j+1)) ){ ++ jnFlags = JNODE_ESCAPE; ++ }else{ ++ return -1; ++ } ++ }else if( c=='"' ){ ++ break; ++ } ++ j++; ++ } ++ jsonParseAddNode(pParse, JSON_STRING, j+1-i, &pParse->zJson[i]); ++ if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags; ++ return j+1; ++ }else if( c=='n' ++ && strncmp(pParse->zJson+i,"null",4)==0 ++ && !safe_isalnum(pParse->zJson[i+4]) ){ ++ jsonParseAddNode(pParse, JSON_NULL, 0, 0); ++ return i+4; ++ }else if( c=='t' ++ && strncmp(pParse->zJson+i,"true",4)==0 ++ && !safe_isalnum(pParse->zJson[i+4]) ){ ++ jsonParseAddNode(pParse, JSON_TRUE, 0, 0); ++ return i+4; ++ }else if( c=='f' ++ && strncmp(pParse->zJson+i,"false",5)==0 ++ && !safe_isalnum(pParse->zJson[i+5]) ){ ++ jsonParseAddNode(pParse, JSON_FALSE, 0, 0); ++ return i+5; ++ }else if( c=='-' || (c>='0' && c<='9') ){ ++ /* Parse number */ ++ u8 seenDP = 0; ++ u8 seenE = 0; ++ j = i+1; ++ for(;; j++){ ++ c = pParse->zJson[j]; ++ if( c>='0' && c<='9' ) continue; ++ if( c=='.' ){ ++ if( pParse->zJson[j-1]=='-' ) return -1; ++ if( seenDP ) return -1; ++ seenDP = 1; ++ continue; ++ } ++ if( c=='e' || c=='E' ){ ++ if( pParse->zJson[j-1]<'0' ) return -1; ++ if( seenE ) return -1; ++ seenDP = seenE = 1; ++ c = pParse->zJson[j+1]; ++ if( c=='+' || c=='-' ){ ++ j++; ++ c = pParse->zJson[j+1]; ++ } ++ if( c<'0' || c>'9' ) return -1; ++ continue; ++ } ++ break; ++ } ++ if( pParse->zJson[j-1]<'0' ) return -1; ++ jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT, ++ j - i, &pParse->zJson[i]); ++ return j; ++ }else if( c=='}' ){ ++ return -2; /* End of {...} */ ++ }else if( c==']' ){ ++ return -3; /* End of [...] */ ++ }else if( c==0 ){ ++ return 0; /* End of file */ ++ }else{ ++ return -1; /* Syntax error */ ++ } ++} ++ ++/* ++** Parse a complete JSON string. Return 0 on success or non-zero if there ++** are any errors. If an error occurs, free all memory associated with ++** pParse. ++** ++** pParse is uninitialized when this routine is called. ++*/ ++static int jsonParse( ++ JsonParse *pParse, /* Initialize and fill this JsonParse object */ ++ sqlite3_context *pCtx, /* Report errors here */ ++ const char *zJson /* Input JSON text to be parsed */ ++){ ++ int i; ++ memset(pParse, 0, sizeof(*pParse)); ++ if( zJson==0 ) return 1; ++ pParse->zJson = zJson; ++ i = jsonParseValue(pParse, 0); ++ if( pParse->oom ) i = -1; ++ if( i>0 ){ ++ while( safe_isspace(zJson[i]) ) i++; ++ if( zJson[i] ) i = -1; ++ } ++ if( i<=0 ){ ++ if( pCtx!=0 ){ ++ if( pParse->oom ){ ++ sqlite3_result_error_nomem(pCtx); ++ }else{ ++ sqlite3_result_error(pCtx, "malformed JSON", -1); ++ } ++ } ++ jsonParseReset(pParse); ++ return 1; ++ } ++ return 0; ++} ++ ++/* Mark node i of pParse as being a child of iParent. Call recursively ++** to fill in all the descendants of node i. ++*/ ++static void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){ ++ JsonNode *pNode = &pParse->aNode[i]; ++ u32 j; ++ pParse->aUp[i] = iParent; ++ switch( pNode->eType ){ ++ case JSON_ARRAY: { ++ for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j)){ ++ jsonParseFillInParentage(pParse, i+j, i); ++ } ++ break; ++ } ++ case JSON_OBJECT: { ++ for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j+1)+1){ ++ pParse->aUp[i+j] = i; ++ jsonParseFillInParentage(pParse, i+j+1, i); ++ } ++ break; ++ } ++ default: { ++ break; ++ } ++ } ++} ++ ++/* ++** Compute the parentage of all nodes in a completed parse. ++*/ ++static int jsonParseFindParents(JsonParse *pParse){ ++ u32 *aUp; ++ assert( pParse->aUp==0 ); ++ aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode ); ++ if( aUp==0 ){ ++ pParse->oom = 1; ++ return SQLITE_NOMEM; ++ } ++ jsonParseFillInParentage(pParse, 0, 0); ++ return SQLITE_OK; ++} ++ ++/* ++** Compare the OBJECT label at pNode against zKey,nKey. Return true on ++** a match. ++*/ ++static int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){ ++ if( pNode->jnFlags & JNODE_RAW ){ ++ if( pNode->n!=nKey ) return 0; ++ return strncmp(pNode->u.zJContent, zKey, nKey)==0; ++ }else{ ++ if( pNode->n!=nKey+2 ) return 0; ++ return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; ++ } ++} ++ ++/* forward declaration */ ++static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**); ++ ++/* ++** Search along zPath to find the node specified. Return a pointer ++** to that node, or NULL if zPath is malformed or if there is no such ++** node. ++** ++** If pApnd!=0, then try to append new nodes to complete zPath if it is ++** possible to do so and if no existing node corresponds to zPath. If ++** new nodes are appended *pApnd is set to 1. ++*/ ++static JsonNode *jsonLookupStep( ++ JsonParse *pParse, /* The JSON to search */ ++ u32 iRoot, /* Begin the search at this node */ ++ const char *zPath, /* The path to search */ ++ int *pApnd, /* Append nodes to complete path if not NULL */ ++ const char **pzErr /* Make *pzErr point to any syntax error in zPath */ ++){ ++ u32 i, j, nKey; ++ const char *zKey; ++ JsonNode *pRoot = &pParse->aNode[iRoot]; ++ if( zPath[0]==0 ) return pRoot; ++ if( zPath[0]=='.' ){ ++ if( pRoot->eType!=JSON_OBJECT ) return 0; ++ zPath++; ++ if( zPath[0]=='"' ){ ++ zKey = zPath + 1; ++ for(i=1; zPath[i] && zPath[i]!='"'; i++){} ++ nKey = i-1; ++ if( zPath[i] ){ ++ i++; ++ }else{ ++ *pzErr = zPath; ++ return 0; ++ } ++ }else{ ++ zKey = zPath; ++ for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} ++ nKey = i; ++ } ++ if( nKey==0 ){ ++ *pzErr = zPath; ++ return 0; ++ } ++ j = 1; ++ for(;;){ ++ while( j<=pRoot->n ){ ++ if( jsonLabelCompare(pRoot+j, zKey, nKey) ){ ++ return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr); ++ } ++ j++; ++ j += jsonNodeSize(&pRoot[j]); ++ } ++ if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; ++ iRoot += pRoot->u.iAppend; ++ pRoot = &pParse->aNode[iRoot]; ++ j = 1; ++ } ++ if( pApnd ){ ++ u32 iStart, iLabel; ++ JsonNode *pNode; ++ iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0); ++ iLabel = jsonParseAddNode(pParse, JSON_STRING, i, zPath); ++ zPath += i; ++ pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); ++ if( pParse->oom ) return 0; ++ if( pNode ){ ++ pRoot = &pParse->aNode[iRoot]; ++ pRoot->u.iAppend = iStart - iRoot; ++ pRoot->jnFlags |= JNODE_APPEND; ++ pParse->aNode[iLabel].jnFlags |= JNODE_RAW; ++ } ++ return pNode; ++ } ++ }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){ ++ if( pRoot->eType!=JSON_ARRAY ) return 0; ++ i = 0; ++ j = 1; ++ while( safe_isdigit(zPath[j]) ){ ++ i = i*10 + zPath[j] - '0'; ++ j++; ++ } ++ if( zPath[j]!=']' ){ ++ *pzErr = zPath; ++ return 0; ++ } ++ zPath += j + 1; ++ j = 1; ++ for(;;){ ++ while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){ ++ if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--; ++ j += jsonNodeSize(&pRoot[j]); ++ } ++ if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; ++ iRoot += pRoot->u.iAppend; ++ pRoot = &pParse->aNode[iRoot]; ++ j = 1; ++ } ++ if( j<=pRoot->n ){ ++ return jsonLookupStep(pParse, iRoot+j, zPath, pApnd, pzErr); ++ } ++ if( i==0 && pApnd ){ ++ u32 iStart; ++ JsonNode *pNode; ++ iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0); ++ pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); ++ if( pParse->oom ) return 0; ++ if( pNode ){ ++ pRoot = &pParse->aNode[iRoot]; ++ pRoot->u.iAppend = iStart - iRoot; ++ pRoot->jnFlags |= JNODE_APPEND; ++ } ++ return pNode; ++ } ++ }else{ ++ *pzErr = zPath; ++ } ++ return 0; ++} ++ ++/* ++** Append content to pParse that will complete zPath. Return a pointer ++** to the inserted node, or return NULL if the append fails. ++*/ ++static JsonNode *jsonLookupAppend( ++ JsonParse *pParse, /* Append content to the JSON parse */ ++ const char *zPath, /* Description of content to append */ ++ int *pApnd, /* Set this flag to 1 */ ++ const char **pzErr /* Make this point to any syntax error */ ++){ ++ *pApnd = 1; ++ if( zPath[0]==0 ){ ++ jsonParseAddNode(pParse, JSON_NULL, 0, 0); ++ return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1]; ++ } ++ if( zPath[0]=='.' ){ ++ jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); ++ }else if( strncmp(zPath,"[0]",3)==0 ){ ++ jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); ++ }else{ ++ return 0; ++ } ++ if( pParse->oom ) return 0; ++ return jsonLookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr); ++} ++ ++/* ++** Return the text of a syntax error message on a JSON path. Space is ++** obtained from sqlite3_malloc(). ++*/ ++static char *jsonPathSyntaxError(const char *zErr){ ++ return sqlite3_mprintf("JSON path error near '%q'", zErr); ++} ++ ++/* ++** Do a node lookup using zPath. Return a pointer to the node on success. ++** Return NULL if not found or if there is an error. ++** ++** On an error, write an error message into pCtx and increment the ++** pParse->nErr counter. ++** ++** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if ++** nodes are appended. ++*/ ++static JsonNode *jsonLookup( ++ JsonParse *pParse, /* The JSON to search */ ++ const char *zPath, /* The path to search */ ++ int *pApnd, /* Append nodes to complete path if not NULL */ ++ sqlite3_context *pCtx /* Report errors here, if not NULL */ ++){ ++ const char *zErr = 0; ++ JsonNode *pNode = 0; ++ char *zMsg; ++ ++ if( zPath==0 ) return 0; ++ if( zPath[0]!='$' ){ ++ zErr = zPath; ++ goto lookup_err; ++ } ++ zPath++; ++ pNode = jsonLookupStep(pParse, 0, zPath, pApnd, &zErr); ++ if( zErr==0 ) return pNode; ++ ++lookup_err: ++ pParse->nErr++; ++ assert( zErr!=0 && pCtx!=0 ); ++ zMsg = jsonPathSyntaxError(zErr); ++ if( zMsg ){ ++ sqlite3_result_error(pCtx, zMsg, -1); ++ sqlite3_free(zMsg); ++ }else{ ++ sqlite3_result_error_nomem(pCtx); ++ } ++ return 0; ++} ++ ++ ++/* ++** Report the wrong number of arguments for json_insert(), json_replace() ++** or json_set(). ++*/ ++static void jsonWrongNumArgs( ++ sqlite3_context *pCtx, ++ const char *zFuncName ++){ ++ char *zMsg = sqlite3_mprintf("json_%s() needs an odd number of arguments", ++ zFuncName); ++ sqlite3_result_error(pCtx, zMsg, -1); ++ sqlite3_free(zMsg); ++} ++ ++ ++/**************************************************************************** ++** SQL functions used for testing and debugging ++****************************************************************************/ ++ ++#ifdef SQLITE_DEBUG ++/* ++** The json_parse(JSON) function returns a string which describes ++** a parse of the JSON provided. Or it returns NULL if JSON is not ++** well-formed. ++*/ ++static void jsonParseFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonString s; /* Output string - not real JSON */ ++ JsonParse x; /* The parse */ ++ u32 i; ++ ++ assert( argc==1 ); ++ if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; ++ jsonParseFindParents(&x); ++ jsonInit(&s, ctx); ++ for(i=0; ieType==JSON_ARRAY ){ ++ assert( (pNode->jnFlags & JNODE_APPEND)==0 ); ++ for(i=1; i<=pNode->n; n++){ ++ i += jsonNodeSize(&pNode[i]); ++ } ++ } ++ if( x.nErr==0 ) sqlite3_result_int64(ctx, n); ++ jsonParseReset(&x); ++} ++ ++/* ++** json_extract(JSON, PATH, ...) ++** ++** Return the element described by PATH. Return NULL if there is no ++** PATH element. If there are multiple PATHs, then return a JSON array ++** with the result from each path. Throw an error if the JSON or any PATH ++** is malformed. ++*/ ++static void jsonExtractFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonParse x; /* The parse */ ++ JsonNode *pNode; ++ const char *zPath; ++ JsonString jx; ++ int i; ++ ++ if( argc<2 ) return; ++ if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; ++ jsonInit(&jx, ctx); ++ jsonAppendChar(&jx, '['); ++ for(i=1; i2 ){ ++ jsonAppendSeparator(&jx); ++ if( pNode ){ ++ jsonRenderNode(pNode, &jx, 0); ++ }else{ ++ jsonAppendRaw(&jx, "null", 4); ++ } ++ }else if( pNode ){ ++ jsonReturn(pNode, ctx, 0); ++ } ++ } ++ if( argc>2 && i==argc ){ ++ jsonAppendChar(&jx, ']'); ++ jsonResult(&jx); ++ sqlite3_result_subtype(ctx, JSON_SUBTYPE); ++ } ++ jsonReset(&jx); ++ jsonParseReset(&x); ++} ++ ++/* ++** Implementation of the json_object(NAME,VALUE,...) function. Return a JSON ++** object that contains all name/value given in arguments. Or if any name ++** is not a string or if any value is a BLOB, throw an error. ++*/ ++static void jsonObjectFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ int i; ++ JsonString jx; ++ const char *z; ++ u32 n; ++ ++ if( argc&1 ){ ++ sqlite3_result_error(ctx, "json_object() requires an even number " ++ "of arguments", -1); ++ return; ++ } ++ jsonInit(&jx, ctx); ++ jsonAppendChar(&jx, '{'); ++ for(i=0; ijnFlags |= JNODE_REMOVE; ++ } ++ if( (x.aNode[0].jnFlags & JNODE_REMOVE)==0 ){ ++ jsonReturnJson(x.aNode, ctx, 0); ++ } ++remove_done: ++ jsonParseReset(&x); ++} ++ ++/* ++** json_replace(JSON, PATH, VALUE, ...) ++** ++** Replace the value at PATH with VALUE. If PATH does not already exist, ++** this routine is a no-op. If JSON or PATH is malformed, throw an error. ++*/ ++static void jsonReplaceFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonParse x; /* The parse */ ++ JsonNode *pNode; ++ const char *zPath; ++ u32 i; ++ ++ if( argc<1 ) return; ++ if( (argc&1)==0 ) { ++ jsonWrongNumArgs(ctx, "replace"); ++ return; ++ } ++ if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; ++ assert( x.nNode ); ++ for(i=1; i<(u32)argc; i+=2){ ++ zPath = (const char*)sqlite3_value_text(argv[i]); ++ pNode = jsonLookup(&x, zPath, 0, ctx); ++ if( x.nErr ) goto replace_err; ++ if( pNode ){ ++ pNode->jnFlags |= (u8)JNODE_REPLACE; ++ pNode->iVal = (u8)(i+1); ++ } ++ } ++ if( x.aNode[0].jnFlags & JNODE_REPLACE ){ ++ sqlite3_result_value(ctx, argv[x.aNode[0].iVal]); ++ }else{ ++ jsonReturnJson(x.aNode, ctx, argv); ++ } ++replace_err: ++ jsonParseReset(&x); ++} ++ ++/* ++** json_set(JSON, PATH, VALUE, ...) ++** ++** Set the value at PATH to VALUE. Create the PATH if it does not already ++** exist. Overwrite existing values that do exist. ++** If JSON or PATH is malformed, throw an error. ++** ++** json_insert(JSON, PATH, VALUE, ...) ++** ++** Create PATH and initialize it to VALUE. If PATH already exists, this ++** routine is a no-op. If JSON or PATH is malformed, throw an error. ++*/ ++static void jsonSetFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonParse x; /* The parse */ ++ JsonNode *pNode; ++ const char *zPath; ++ u32 i; ++ int bApnd; ++ int bIsSet = *(int*)sqlite3_user_data(ctx); ++ ++ if( argc<1 ) return; ++ if( (argc&1)==0 ) { ++ jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); ++ return; ++ } ++ if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; ++ assert( x.nNode ); ++ for(i=1; i<(u32)argc; i+=2){ ++ zPath = (const char*)sqlite3_value_text(argv[i]); ++ bApnd = 0; ++ pNode = jsonLookup(&x, zPath, &bApnd, ctx); ++ if( x.oom ){ ++ sqlite3_result_error_nomem(ctx); ++ goto jsonSetDone; ++ }else if( x.nErr ){ ++ goto jsonSetDone; ++ }else if( pNode && (bApnd || bIsSet) ){ ++ pNode->jnFlags |= (u8)JNODE_REPLACE; ++ pNode->iVal = (u8)(i+1); ++ } ++ } ++ if( x.aNode[0].jnFlags & JNODE_REPLACE ){ ++ sqlite3_result_value(ctx, argv[x.aNode[0].iVal]); ++ }else{ ++ jsonReturnJson(x.aNode, ctx, argv); ++ } ++jsonSetDone: ++ jsonParseReset(&x); ++} ++ ++/* ++** json_type(JSON) ++** json_type(JSON, PATH) ++** ++** Return the top-level "type" of a JSON string. Throw an error if ++** either the JSON or PATH inputs are not well-formed. ++*/ ++static void jsonTypeFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonParse x; /* The parse */ ++ const char *zPath; ++ JsonNode *pNode; ++ ++ if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; ++ assert( x.nNode ); ++ if( argc==2 ){ ++ zPath = (const char*)sqlite3_value_text(argv[1]); ++ pNode = jsonLookup(&x, zPath, 0, ctx); ++ }else{ ++ pNode = x.aNode; ++ } ++ if( pNode ){ ++ sqlite3_result_text(ctx, jsonType[pNode->eType], -1, SQLITE_STATIC); ++ } ++ jsonParseReset(&x); ++} ++ ++/* ++** json_valid(JSON) ++** ++** Return 1 if JSON is a well-formed JSON string according to RFC-7159. ++** Return 0 otherwise. ++*/ ++static void jsonValidFunc( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonParse x; /* The parse */ ++ int rc = 0; ++ ++ UNUSED_PARAM(argc); ++ if( jsonParse(&x, 0, (const char*)sqlite3_value_text(argv[0]))==0 ){ ++ rc = 1; ++ } ++ jsonParseReset(&x); ++ sqlite3_result_int(ctx, rc); ++} ++ ++ ++/**************************************************************************** ++** Aggregate SQL function implementations ++****************************************************************************/ ++/* ++** json_group_array(VALUE) ++** ++** Return a JSON array composed of all values in the aggregate. ++*/ ++static void jsonArrayStep( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonString *pStr; ++ UNUSED_PARAM(argc); ++ pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); ++ if( pStr ){ ++ if( pStr->zBuf==0 ){ ++ jsonInit(pStr, ctx); ++ jsonAppendChar(pStr, '['); ++ }else{ ++ jsonAppendChar(pStr, ','); ++ pStr->pCtx = ctx; ++ } ++ jsonAppendValue(pStr, argv[0]); ++ } ++} ++static void jsonArrayFinal(sqlite3_context *ctx){ ++ JsonString *pStr; ++ pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); ++ if( pStr ){ ++ pStr->pCtx = ctx; ++ jsonAppendChar(pStr, ']'); ++ if( pStr->bErr ){ ++ if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); ++ assert( pStr->bStatic ); ++ }else{ ++ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, ++ pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); ++ pStr->bStatic = 1; ++ } ++ }else{ ++ sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); ++ } ++ sqlite3_result_subtype(ctx, JSON_SUBTYPE); ++} ++ ++/* ++** json_group_obj(NAME,VALUE) ++** ++** Return a JSON object composed of all names and values in the aggregate. ++*/ ++static void jsonObjectStep( ++ sqlite3_context *ctx, ++ int argc, ++ sqlite3_value **argv ++){ ++ JsonString *pStr; ++ const char *z; ++ u32 n; ++ UNUSED_PARAM(argc); ++ pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); ++ if( pStr ){ ++ if( pStr->zBuf==0 ){ ++ jsonInit(pStr, ctx); ++ jsonAppendChar(pStr, '{'); ++ }else{ ++ jsonAppendChar(pStr, ','); ++ pStr->pCtx = ctx; ++ } ++ z = (const char*)sqlite3_value_text(argv[0]); ++ n = (u32)sqlite3_value_bytes(argv[0]); ++ jsonAppendString(pStr, z, n); ++ jsonAppendChar(pStr, ':'); ++ jsonAppendValue(pStr, argv[1]); ++ } ++} ++static void jsonObjectFinal(sqlite3_context *ctx){ ++ JsonString *pStr; ++ pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); ++ if( pStr ){ ++ jsonAppendChar(pStr, '}'); ++ if( pStr->bErr ){ ++ if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); ++ assert( pStr->bStatic ); ++ }else{ ++ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, ++ pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); ++ pStr->bStatic = 1; ++ } ++ }else{ ++ sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); ++ } ++ sqlite3_result_subtype(ctx, JSON_SUBTYPE); ++} ++ ++ ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++/**************************************************************************** ++** The json_each virtual table ++****************************************************************************/ ++typedef struct JsonEachCursor JsonEachCursor; ++struct JsonEachCursor { ++ sqlite3_vtab_cursor base; /* Base class - must be first */ ++ u32 iRowid; /* The rowid */ ++ u32 iBegin; /* The first node of the scan */ ++ u32 i; /* Index in sParse.aNode[] of current row */ ++ u32 iEnd; /* EOF when i equals or exceeds this value */ ++ u8 eType; /* Type of top-level element */ ++ u8 bRecursive; /* True for json_tree(). False for json_each() */ ++ char *zJson; /* Input JSON */ ++ char *zRoot; /* Path by which to filter zJson */ ++ JsonParse sParse; /* Parse of the input JSON */ ++}; ++ ++/* Constructor for the json_each virtual table */ ++static int jsonEachConnect( ++ sqlite3 *db, ++ void *pAux, ++ int argc, const char *const*argv, ++ sqlite3_vtab **ppVtab, ++ char **pzErr ++){ ++ sqlite3_vtab *pNew; ++ int rc; ++ ++/* Column numbers */ ++#define JEACH_KEY 0 ++#define JEACH_VALUE 1 ++#define JEACH_TYPE 2 ++#define JEACH_ATOM 3 ++#define JEACH_ID 4 ++#define JEACH_PARENT 5 ++#define JEACH_FULLKEY 6 ++#define JEACH_PATH 7 ++#define JEACH_JSON 8 ++#define JEACH_ROOT 9 ++ ++ UNUSED_PARAM(pzErr); ++ UNUSED_PARAM(argv); ++ UNUSED_PARAM(argc); ++ UNUSED_PARAM(pAux); ++ rc = sqlite3_declare_vtab(db, ++ "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path," ++ "json HIDDEN,root HIDDEN)"); ++ if( rc==SQLITE_OK ){ ++ pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); ++ if( pNew==0 ) return SQLITE_NOMEM; ++ memset(pNew, 0, sizeof(*pNew)); ++ } ++ return rc; ++} ++ ++/* destructor for json_each virtual table */ ++static int jsonEachDisconnect(sqlite3_vtab *pVtab){ ++ sqlite3_free(pVtab); ++ return SQLITE_OK; ++} ++ ++/* constructor for a JsonEachCursor object for json_each(). */ ++static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ ++ JsonEachCursor *pCur; ++ ++ UNUSED_PARAM(p); ++ pCur = sqlite3_malloc( sizeof(*pCur) ); ++ if( pCur==0 ) return SQLITE_NOMEM; ++ memset(pCur, 0, sizeof(*pCur)); ++ *ppCursor = &pCur->base; ++ return SQLITE_OK; ++} ++ ++/* constructor for a JsonEachCursor object for json_tree(). */ ++static int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ ++ int rc = jsonEachOpenEach(p, ppCursor); ++ if( rc==SQLITE_OK ){ ++ JsonEachCursor *pCur = (JsonEachCursor*)*ppCursor; ++ pCur->bRecursive = 1; ++ } ++ return rc; ++} ++ ++/* Reset a JsonEachCursor back to its original state. Free any memory ++** held. */ ++static void jsonEachCursorReset(JsonEachCursor *p){ ++ sqlite3_free(p->zJson); ++ sqlite3_free(p->zRoot); ++ jsonParseReset(&p->sParse); ++ p->iRowid = 0; ++ p->i = 0; ++ p->iEnd = 0; ++ p->eType = 0; ++ p->zJson = 0; ++ p->zRoot = 0; ++} ++ ++/* Destructor for a jsonEachCursor object */ ++static int jsonEachClose(sqlite3_vtab_cursor *cur){ ++ JsonEachCursor *p = (JsonEachCursor*)cur; ++ jsonEachCursorReset(p); ++ sqlite3_free(cur); ++ return SQLITE_OK; ++} ++ ++/* Return TRUE if the jsonEachCursor object has been advanced off the end ++** of the JSON object */ ++static int jsonEachEof(sqlite3_vtab_cursor *cur){ ++ JsonEachCursor *p = (JsonEachCursor*)cur; ++ return p->i >= p->iEnd; ++} ++ ++/* Advance the cursor to the next element for json_tree() */ ++static int jsonEachNext(sqlite3_vtab_cursor *cur){ ++ JsonEachCursor *p = (JsonEachCursor*)cur; ++ if( p->bRecursive ){ ++ if( p->sParse.aNode[p->i].jnFlags & JNODE_LABEL ) p->i++; ++ p->i++; ++ p->iRowid++; ++ if( p->iiEnd ){ ++ u32 iUp = p->sParse.aUp[p->i]; ++ JsonNode *pUp = &p->sParse.aNode[iUp]; ++ p->eType = pUp->eType; ++ if( pUp->eType==JSON_ARRAY ){ ++ if( iUp==p->i-1 ){ ++ pUp->u.iKey = 0; ++ }else{ ++ pUp->u.iKey++; ++ } ++ } ++ } ++ }else{ ++ switch( p->eType ){ ++ case JSON_ARRAY: { ++ p->i += jsonNodeSize(&p->sParse.aNode[p->i]); ++ p->iRowid++; ++ break; ++ } ++ case JSON_OBJECT: { ++ p->i += 1 + jsonNodeSize(&p->sParse.aNode[p->i+1]); ++ p->iRowid++; ++ break; ++ } ++ default: { ++ p->i = p->iEnd; ++ break; ++ } ++ } ++ } ++ return SQLITE_OK; ++} ++ ++/* Append the name of the path for element i to pStr ++*/ ++static void jsonEachComputePath( ++ JsonEachCursor *p, /* The cursor */ ++ JsonString *pStr, /* Write the path here */ ++ u32 i /* Path to this element */ ++){ ++ JsonNode *pNode, *pUp; ++ u32 iUp; ++ if( i==0 ){ ++ jsonAppendChar(pStr, '$'); ++ return; ++ } ++ iUp = p->sParse.aUp[i]; ++ jsonEachComputePath(p, pStr, iUp); ++ pNode = &p->sParse.aNode[i]; ++ pUp = &p->sParse.aNode[iUp]; ++ if( pUp->eType==JSON_ARRAY ){ ++ jsonPrintf(30, pStr, "[%d]", pUp->u.iKey); ++ }else{ ++ assert( pUp->eType==JSON_OBJECT ); ++ if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--; ++ assert( pNode->eType==JSON_STRING ); ++ assert( pNode->jnFlags & JNODE_LABEL ); ++ jsonPrintf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); ++ } ++} ++ ++/* Return the value of a column */ ++static int jsonEachColumn( ++ sqlite3_vtab_cursor *cur, /* The cursor */ ++ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ ++ int i /* Which column to return */ ++){ ++ JsonEachCursor *p = (JsonEachCursor*)cur; ++ JsonNode *pThis = &p->sParse.aNode[p->i]; ++ switch( i ){ ++ case JEACH_KEY: { ++ if( p->i==0 ) break; ++ if( p->eType==JSON_OBJECT ){ ++ jsonReturn(pThis, ctx, 0); ++ }else if( p->eType==JSON_ARRAY ){ ++ u32 iKey; ++ if( p->bRecursive ){ ++ if( p->iRowid==0 ) break; ++ iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey; ++ }else{ ++ iKey = p->iRowid; ++ } ++ sqlite3_result_int64(ctx, (sqlite3_int64)iKey); ++ } ++ break; ++ } ++ case JEACH_VALUE: { ++ if( pThis->jnFlags & JNODE_LABEL ) pThis++; ++ jsonReturn(pThis, ctx, 0); ++ break; ++ } ++ case JEACH_TYPE: { ++ if( pThis->jnFlags & JNODE_LABEL ) pThis++; ++ sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC); ++ break; ++ } ++ case JEACH_ATOM: { ++ if( pThis->jnFlags & JNODE_LABEL ) pThis++; ++ if( pThis->eType>=JSON_ARRAY ) break; ++ jsonReturn(pThis, ctx, 0); ++ break; ++ } ++ case JEACH_ID: { ++ sqlite3_result_int64(ctx, ++ (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL)!=0)); ++ break; ++ } ++ case JEACH_PARENT: { ++ if( p->i>p->iBegin && p->bRecursive ){ ++ sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]); ++ } ++ break; ++ } ++ case JEACH_FULLKEY: { ++ JsonString x; ++ jsonInit(&x, ctx); ++ if( p->bRecursive ){ ++ jsonEachComputePath(p, &x, p->i); ++ }else{ ++ if( p->zRoot ){ ++ jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot)); ++ }else{ ++ jsonAppendChar(&x, '$'); ++ } ++ if( p->eType==JSON_ARRAY ){ ++ jsonPrintf(30, &x, "[%d]", p->iRowid); ++ }else{ ++ jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); ++ } ++ } ++ jsonResult(&x); ++ break; ++ } ++ case JEACH_PATH: { ++ if( p->bRecursive ){ ++ JsonString x; ++ jsonInit(&x, ctx); ++ jsonEachComputePath(p, &x, p->sParse.aUp[p->i]); ++ jsonResult(&x); ++ break; ++ } ++ /* For json_each() path and root are the same so fall through ++ ** into the root case */ ++ } ++ default: { ++ const char *zRoot = p->zRoot; ++ if( zRoot==0 ) zRoot = "$"; ++ sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC); ++ break; ++ } ++ case JEACH_JSON: { ++ assert( i==JEACH_JSON ); ++ sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC); ++ break; ++ } ++ } ++ return SQLITE_OK; ++} ++ ++/* Return the current rowid value */ ++static int jsonEachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ ++ JsonEachCursor *p = (JsonEachCursor*)cur; ++ *pRowid = p->iRowid; ++ return SQLITE_OK; ++} ++ ++/* The query strategy is to look for an equality constraint on the json ++** column. Without such a constraint, the table cannot operate. idxNum is ++** 1 if the constraint is found, 3 if the constraint and zRoot are found, ++** and 0 otherwise. ++*/ ++static int jsonEachBestIndex( ++ sqlite3_vtab *tab, ++ sqlite3_index_info *pIdxInfo ++){ ++ int i; ++ int jsonIdx = -1; ++ int rootIdx = -1; ++ const struct sqlite3_index_constraint *pConstraint; ++ ++ UNUSED_PARAM(tab); ++ pConstraint = pIdxInfo->aConstraint; ++ for(i=0; inConstraint; i++, pConstraint++){ ++ if( pConstraint->usable==0 ) continue; ++ if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; ++ switch( pConstraint->iColumn ){ ++ case JEACH_JSON: jsonIdx = i; break; ++ case JEACH_ROOT: rootIdx = i; break; ++ default: /* no-op */ break; ++ } ++ } ++ if( jsonIdx<0 ){ ++ pIdxInfo->idxNum = 0; ++ pIdxInfo->estimatedCost = 1e99; ++ }else{ ++ pIdxInfo->estimatedCost = 1.0; ++ pIdxInfo->aConstraintUsage[jsonIdx].argvIndex = 1; ++ pIdxInfo->aConstraintUsage[jsonIdx].omit = 1; ++ if( rootIdx<0 ){ ++ pIdxInfo->idxNum = 1; ++ }else{ ++ pIdxInfo->aConstraintUsage[rootIdx].argvIndex = 2; ++ pIdxInfo->aConstraintUsage[rootIdx].omit = 1; ++ pIdxInfo->idxNum = 3; ++ } ++ } ++ return SQLITE_OK; ++} ++ ++/* Start a search on a new JSON string */ ++static int jsonEachFilter( ++ sqlite3_vtab_cursor *cur, ++ int idxNum, const char *idxStr, ++ int argc, sqlite3_value **argv ++){ ++ JsonEachCursor *p = (JsonEachCursor*)cur; ++ const char *z; ++ const char *zRoot = 0; ++ size_t n; ++ ++ UNUSED_PARAM(idxStr); ++ UNUSED_PARAM(argc); ++ jsonEachCursorReset(p); ++ if( idxNum==0 ) return SQLITE_OK; ++ z = (const char*)sqlite3_value_text(argv[0]); ++ if( z==0 ) return SQLITE_OK; ++ n = (size_t)sqlite3_value_bytes(argv[0]); ++ p->zJson = sqlite3_malloc( n+1 ); ++ if( p->zJson==0 ) return SQLITE_NOMEM; ++ memcpy(p->zJson, z, n+1); ++ if( jsonParse(&p->sParse, 0, p->zJson) ){ ++ int rc = SQLITE_NOMEM; ++ if( p->sParse.oom==0 ){ ++ sqlite3_free(cur->pVtab->zErrMsg); ++ cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON"); ++ if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR; ++ } ++ jsonEachCursorReset(p); ++ return rc; ++ }else if( p->bRecursive && jsonParseFindParents(&p->sParse) ){ ++ jsonEachCursorReset(p); ++ return SQLITE_NOMEM; ++ }else{ ++ JsonNode *pNode = 0; ++ if( idxNum==3 ){ ++ const char *zErr = 0; ++ zRoot = (const char*)sqlite3_value_text(argv[1]); ++ if( zRoot==0 ) return SQLITE_OK; ++ n = (size_t)sqlite3_value_bytes(argv[1]); ++ p->zRoot = sqlite3_malloc( n+1 ); ++ if( p->zRoot==0 ) return SQLITE_NOMEM; ++ memcpy(p->zRoot, zRoot, n+1); ++ if( zRoot[0]!='$' ){ ++ zErr = zRoot; ++ }else{ ++ pNode = jsonLookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr); ++ } ++ if( zErr ){ ++ sqlite3_free(cur->pVtab->zErrMsg); ++ cur->pVtab->zErrMsg = jsonPathSyntaxError(zErr); ++ jsonEachCursorReset(p); ++ return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; ++ }else if( pNode==0 ){ ++ return SQLITE_OK; ++ } ++ }else{ ++ pNode = p->sParse.aNode; ++ } ++ p->iBegin = p->i = (int)(pNode - p->sParse.aNode); ++ p->eType = pNode->eType; ++ if( p->eType>=JSON_ARRAY ){ ++ pNode->u.iKey = 0; ++ p->iEnd = p->i + pNode->n + 1; ++ if( p->bRecursive ){ ++ p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType; ++ if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){ ++ p->i--; ++ } ++ }else{ ++ p->i++; ++ } ++ }else{ ++ p->iEnd = p->i+1; ++ } ++ } ++ return SQLITE_OK; ++} ++ ++/* The methods of the json_each virtual table */ ++static const sqlite3_module jsonEachModule = { ++ 0, /* iVersion */ ++ 0, /* xCreate */ ++ jsonEachConnect, /* xConnect */ ++ jsonEachBestIndex, /* xBestIndex */ ++ jsonEachDisconnect, /* xDisconnect */ ++ 0, /* xDestroy */ ++ jsonEachOpenEach, /* xOpen - open a cursor */ ++ jsonEachClose, /* xClose - close a cursor */ ++ jsonEachFilter, /* xFilter - configure scan constraints */ ++ jsonEachNext, /* xNext - advance a cursor */ ++ jsonEachEof, /* xEof - check for end of scan */ ++ jsonEachColumn, /* xColumn - read data */ ++ jsonEachRowid, /* xRowid - read data */ ++ 0, /* xUpdate */ ++ 0, /* xBegin */ ++ 0, /* xSync */ ++ 0, /* xCommit */ ++ 0, /* xRollback */ ++ 0, /* xFindMethod */ ++ 0, /* xRename */ ++ 0, /* xSavepoint */ ++ 0, /* xRelease */ ++ 0 /* xRollbackTo */ ++}; ++ ++/* The methods of the json_tree virtual table. */ ++static const sqlite3_module jsonTreeModule = { ++ 0, /* iVersion */ ++ 0, /* xCreate */ ++ jsonEachConnect, /* xConnect */ ++ jsonEachBestIndex, /* xBestIndex */ ++ jsonEachDisconnect, /* xDisconnect */ ++ 0, /* xDestroy */ ++ jsonEachOpenTree, /* xOpen - open a cursor */ ++ jsonEachClose, /* xClose - close a cursor */ ++ jsonEachFilter, /* xFilter - configure scan constraints */ ++ jsonEachNext, /* xNext - advance a cursor */ ++ jsonEachEof, /* xEof - check for end of scan */ ++ jsonEachColumn, /* xColumn - read data */ ++ jsonEachRowid, /* xRowid - read data */ ++ 0, /* xUpdate */ ++ 0, /* xBegin */ ++ 0, /* xSync */ ++ 0, /* xCommit */ ++ 0, /* xRollback */ ++ 0, /* xFindMethod */ ++ 0, /* xRename */ ++ 0, /* xSavepoint */ ++ 0, /* xRelease */ ++ 0 /* xRollbackTo */ ++}; ++#endif /* SQLITE_OMIT_VIRTUALTABLE */ ++ ++/**************************************************************************** ++** The following routines are the only publically visible identifiers in this ++** file. Call the following routines in order to register the various SQL ++** functions and the virtual table implemented by this file. ++****************************************************************************/ ++ ++int sqlite3Json1Init(sqlite3 *db){ ++ int rc = SQLITE_OK; ++ unsigned int i; ++ static const struct { ++ const char *zName; ++ int nArg; ++ int flag; ++ void (*xFunc)(sqlite3_context*,int,sqlite3_value**); ++ } aFunc[] = { ++ { "json", 1, 0, jsonRemoveFunc }, ++ { "json_array", -1, 0, jsonArrayFunc }, ++ { "json_array_length", 1, 0, jsonArrayLengthFunc }, ++ { "json_array_length", 2, 0, jsonArrayLengthFunc }, ++ { "json_extract", -1, 0, jsonExtractFunc }, ++ { "json_insert", -1, 0, jsonSetFunc }, ++ { "json_object", -1, 0, jsonObjectFunc }, ++ { "json_quote", 1, 0, jsonQuoteFunc }, ++ { "json_remove", -1, 0, jsonRemoveFunc }, ++ { "json_replace", -1, 0, jsonReplaceFunc }, ++ { "json_set", -1, 1, jsonSetFunc }, ++ { "json_type", 1, 0, jsonTypeFunc }, ++ { "json_type", 2, 0, jsonTypeFunc }, ++ { "json_valid", 1, 0, jsonValidFunc }, ++ ++#if SQLITE_DEBUG ++ /* DEBUG and TESTING functions */ ++ { "json_parse", 1, 0, jsonParseFunc }, ++ { "json_test1", 1, 0, jsonTest1Func }, ++#endif ++ }; ++ static const struct { ++ const char *zName; ++ int nArg; ++ void (*xStep)(sqlite3_context*,int,sqlite3_value**); ++ void (*xFinal)(sqlite3_context*); ++ } aAgg[] = { ++ { "json_group_array", 1, jsonArrayStep, jsonArrayFinal }, ++ { "json_group_object", 2, jsonObjectStep, jsonObjectFinal }, ++ }; ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ static const struct { ++ const char *zName; ++ const sqlite3_module *pModule; ++ } aMod[] = { ++ { "json_each", &jsonEachModule }, ++ { "json_tree", &jsonTreeModule }, ++ }; ++#endif ++ for(i=0; i ++SQLITE_EXTENSION_INIT1 ++#include ++#include ++ ++ ++/* ++** Forward declaration of objects used by this utility ++*/ ++typedef struct sqlite3_vfs MemVfs; ++typedef struct MemFile MemFile; ++ ++/* Access to a lower-level VFS that (might) implement dynamic loading, ++** access to randomness, etc. ++*/ ++#define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) ++ ++/* An open file */ ++struct MemFile { ++ sqlite3_file base; /* IO methods */ ++ sqlite3_int64 sz; /* Size of the file */ ++ unsigned char *aData; /* content of the file */ ++}; ++ ++/* ++** Methods for MemFile ++*/ ++static int memClose(sqlite3_file*); ++static int memRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); ++static int memWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst); ++static int memTruncate(sqlite3_file*, sqlite3_int64 size); ++static int memSync(sqlite3_file*, int flags); ++static int memFileSize(sqlite3_file*, sqlite3_int64 *pSize); ++static int memLock(sqlite3_file*, int); ++static int memUnlock(sqlite3_file*, int); ++static int memCheckReservedLock(sqlite3_file*, int *pResOut); ++static int memFileControl(sqlite3_file*, int op, void *pArg); ++static int memSectorSize(sqlite3_file*); ++static int memDeviceCharacteristics(sqlite3_file*); ++static int memShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**); ++static int memShmLock(sqlite3_file*, int offset, int n, int flags); ++static void memShmBarrier(sqlite3_file*); ++static int memShmUnmap(sqlite3_file*, int deleteFlag); ++static int memFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); ++static int memUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p); ++ ++/* ++** Methods for MemVfs ++*/ ++static int memOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *); ++static int memDelete(sqlite3_vfs*, const char *zName, int syncDir); ++static int memAccess(sqlite3_vfs*, const char *zName, int flags, int *); ++static int memFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut); ++static void *memDlOpen(sqlite3_vfs*, const char *zFilename); ++static void memDlError(sqlite3_vfs*, int nByte, char *zErrMsg); ++static void (*memDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void); ++static void memDlClose(sqlite3_vfs*, void*); ++static int memRandomness(sqlite3_vfs*, int nByte, char *zOut); ++static int memSleep(sqlite3_vfs*, int microseconds); ++static int memCurrentTime(sqlite3_vfs*, double*); ++static int memGetLastError(sqlite3_vfs*, int, char *); ++static int memCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); ++ ++static sqlite3_vfs mem_vfs = { ++ 2, /* iVersion */ ++ 0, /* szOsFile (set when registered) */ ++ 1024, /* mxPathname */ ++ 0, /* pNext */ ++ "memvfs", /* zName */ ++ 0, /* pAppData (set when registered) */ ++ memOpen, /* xOpen */ ++ memDelete, /* xDelete */ ++ memAccess, /* xAccess */ ++ memFullPathname, /* xFullPathname */ ++ memDlOpen, /* xDlOpen */ ++ memDlError, /* xDlError */ ++ memDlSym, /* xDlSym */ ++ memDlClose, /* xDlClose */ ++ memRandomness, /* xRandomness */ ++ memSleep, /* xSleep */ ++ memCurrentTime, /* xCurrentTime */ ++ memGetLastError, /* xGetLastError */ ++ memCurrentTimeInt64 /* xCurrentTimeInt64 */ ++}; ++ ++static const sqlite3_io_methods mem_io_methods = { ++ 3, /* iVersion */ ++ memClose, /* xClose */ ++ memRead, /* xRead */ ++ memWrite, /* xWrite */ ++ memTruncate, /* xTruncate */ ++ memSync, /* xSync */ ++ memFileSize, /* xFileSize */ ++ memLock, /* xLock */ ++ memUnlock, /* xUnlock */ ++ memCheckReservedLock, /* xCheckReservedLock */ ++ memFileControl, /* xFileControl */ ++ memSectorSize, /* xSectorSize */ ++ memDeviceCharacteristics, /* xDeviceCharacteristics */ ++ memShmMap, /* xShmMap */ ++ memShmLock, /* xShmLock */ ++ memShmBarrier, /* xShmBarrier */ ++ memShmUnmap, /* xShmUnmap */ ++ memFetch, /* xFetch */ ++ memUnfetch /* xUnfetch */ ++}; ++ ++ ++ ++/* ++** Close an mem-file. ++** ++** The pData pointer is owned by the application, so there is nothing ++** to free. ++*/ ++static int memClose(sqlite3_file *pFile){ ++ return SQLITE_OK; ++} ++ ++/* ++** Read data from an mem-file. ++*/ ++static int memRead( ++ sqlite3_file *pFile, ++ void *zBuf, ++ int iAmt, ++ sqlite_int64 iOfst ++){ ++ MemFile *p = (MemFile *)pFile; ++ memcpy(zBuf, p->aData+iOfst, iAmt); ++ return SQLITE_OK; ++} ++ ++/* ++** Write data to an mem-file. ++*/ ++static int memWrite( ++ sqlite3_file *pFile, ++ const void *z, ++ int iAmt, ++ sqlite_int64 iOfst ++){ ++ return SQLITE_READONLY; ++} ++ ++/* ++** Truncate an mem-file. ++*/ ++static int memTruncate(sqlite3_file *pFile, sqlite_int64 size){ ++ return SQLITE_READONLY; ++} ++ ++/* ++** Sync an mem-file. ++*/ ++static int memSync(sqlite3_file *pFile, int flags){ ++ return SQLITE_READONLY; ++} ++ ++/* ++** Return the current file-size of an mem-file. ++*/ ++static int memFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ ++ MemFile *p = (MemFile *)pFile; ++ *pSize = p->sz; ++ return SQLITE_OK; ++} ++ ++/* ++** Lock an mem-file. ++*/ ++static int memLock(sqlite3_file *pFile, int eLock){ ++ return SQLITE_READONLY; ++} ++ ++/* ++** Unlock an mem-file. ++*/ ++static int memUnlock(sqlite3_file *pFile, int eLock){ ++ return SQLITE_OK; ++} ++ ++/* ++** Check if another file-handle holds a RESERVED lock on an mem-file. ++*/ ++static int memCheckReservedLock(sqlite3_file *pFile, int *pResOut){ ++ *pResOut = 0; ++ return SQLITE_OK; ++} ++ ++/* ++** File control method. For custom operations on an mem-file. ++*/ ++static int memFileControl(sqlite3_file *pFile, int op, void *pArg){ ++ MemFile *p = (MemFile *)pFile; ++ int rc = SQLITE_NOTFOUND; ++ if( op==SQLITE_FCNTL_VFSNAME ){ ++ *(char**)pArg = sqlite3_mprintf("mem(%p,%lld)", p->aData, p->sz); ++ rc = SQLITE_OK; ++ } ++ return rc; ++} ++ ++/* ++** Return the sector-size in bytes for an mem-file. ++*/ ++static int memSectorSize(sqlite3_file *pFile){ ++ return 1024; ++} ++ ++/* ++** Return the device characteristic flags supported by an mem-file. ++*/ ++static int memDeviceCharacteristics(sqlite3_file *pFile){ ++ return SQLITE_IOCAP_IMMUTABLE; ++} ++ ++/* Create a shared memory file mapping */ ++static int memShmMap( ++ sqlite3_file *pFile, ++ int iPg, ++ int pgsz, ++ int bExtend, ++ void volatile **pp ++){ ++ return SQLITE_READONLY; ++} ++ ++/* Perform locking on a shared-memory segment */ ++static int memShmLock(sqlite3_file *pFile, int offset, int n, int flags){ ++ return SQLITE_READONLY; ++} ++ ++/* Memory barrier operation on shared memory */ ++static void memShmBarrier(sqlite3_file *pFile){ ++ return; ++} ++ ++/* Unmap a shared memory segment */ ++static int memShmUnmap(sqlite3_file *pFile, int deleteFlag){ ++ return SQLITE_OK; ++} ++ ++/* Fetch a page of a memory-mapped file */ ++static int memFetch( ++ sqlite3_file *pFile, ++ sqlite3_int64 iOfst, ++ int iAmt, ++ void **pp ++){ ++ MemFile *p = (MemFile *)pFile; ++ *pp = (void*)(p->aData + iOfst); ++ return SQLITE_OK; ++} ++ ++/* Release a memory-mapped page */ ++static int memUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ ++ return SQLITE_OK; ++} ++ ++/* ++** Open an mem file handle. ++*/ ++static int memOpen( ++ sqlite3_vfs *pVfs, ++ const char *zName, ++ sqlite3_file *pFile, ++ int flags, ++ int *pOutFlags ++){ ++ MemFile *p = (MemFile*)pFile; ++ memset(p, 0, sizeof(*p)); ++ if( (flags & SQLITE_OPEN_MAIN_DB)==0 ) return SQLITE_CANTOPEN; ++ p->aData = (unsigned char*)(size_t)sqlite3_uri_int64(zName,"ptr",0); ++ if( p->aData==0 ) return SQLITE_CANTOPEN; ++ p->sz = sqlite3_uri_int64(zName,"sz",0); ++ if( p->sz<0 ) return SQLITE_CANTOPEN; ++ pFile->pMethods = &mem_io_methods; ++ return SQLITE_OK; ++} ++ ++/* ++** Delete the file located at zPath. If the dirSync argument is true, ++** ensure the file-system modifications are synced to disk before ++** returning. ++*/ ++static int memDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ ++ return SQLITE_READONLY; ++} ++ ++/* ++** Test for access permissions. Return true if the requested permission ++** is available, or false otherwise. ++*/ ++static int memAccess( ++ sqlite3_vfs *pVfs, ++ const char *zPath, ++ int flags, ++ int *pResOut ++){ ++ /* The spec says there are three possible values for flags. But only ++ ** two of them are actually used */ ++ assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE ); ++ if( flags==SQLITE_ACCESS_READWRITE ){ ++ *pResOut = 0; ++ }else{ ++ *pResOut = 1; ++ } ++ return SQLITE_OK; ++} ++ ++/* ++** Populate buffer zOut with the full canonical pathname corresponding ++** to the pathname in zPath. zOut is guaranteed to point to a buffer ++** of at least (INST_MAX_PATHNAME+1) bytes. ++*/ ++static int memFullPathname( ++ sqlite3_vfs *pVfs, ++ const char *zPath, ++ int nOut, ++ char *zOut ++){ ++ sqlite3_snprintf(nOut, zOut, "%s", zPath); ++ return SQLITE_OK; ++} ++ ++/* ++** Open the dynamic library located at zPath and return a handle. ++*/ ++static void *memDlOpen(sqlite3_vfs *pVfs, const char *zPath){ ++ return ORIGVFS(pVfs)->xDlOpen(ORIGVFS(pVfs), zPath); ++} ++ ++/* ++** Populate the buffer zErrMsg (size nByte bytes) with a human readable ++** utf-8 string describing the most recent error encountered associated ++** with dynamic libraries. ++*/ ++static void memDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){ ++ ORIGVFS(pVfs)->xDlError(ORIGVFS(pVfs), nByte, zErrMsg); ++} ++ ++/* ++** Return a pointer to the symbol zSymbol in the dynamic library pHandle. ++*/ ++static void (*memDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){ ++ return ORIGVFS(pVfs)->xDlSym(ORIGVFS(pVfs), p, zSym); ++} ++ ++/* ++** Close the dynamic library handle pHandle. ++*/ ++static void memDlClose(sqlite3_vfs *pVfs, void *pHandle){ ++ ORIGVFS(pVfs)->xDlClose(ORIGVFS(pVfs), pHandle); ++} ++ ++/* ++** Populate the buffer pointed to by zBufOut with nByte bytes of ++** random data. ++*/ ++static int memRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ ++ return ORIGVFS(pVfs)->xRandomness(ORIGVFS(pVfs), nByte, zBufOut); ++} ++ ++/* ++** Sleep for nMicro microseconds. Return the number of microseconds ++** actually slept. ++*/ ++static int memSleep(sqlite3_vfs *pVfs, int nMicro){ ++ return ORIGVFS(pVfs)->xSleep(ORIGVFS(pVfs), nMicro); ++} ++ ++/* ++** Return the current time as a Julian Day number in *pTimeOut. ++*/ ++static int memCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ ++ return ORIGVFS(pVfs)->xCurrentTime(ORIGVFS(pVfs), pTimeOut); ++} ++ ++static int memGetLastError(sqlite3_vfs *pVfs, int a, char *b){ ++ return ORIGVFS(pVfs)->xGetLastError(ORIGVFS(pVfs), a, b); ++} ++static int memCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){ ++ return ORIGVFS(pVfs)->xCurrentTimeInt64(ORIGVFS(pVfs), p); ++} ++ ++#ifdef MEMVFS_TEST ++/* ++** memload(FILENAME) ++** ++** This an SQL function used to help in testing the memvfs VFS. The ++** function reads the content of a file into memory and then returns ++** a string that gives the locate and size of the in-memory buffer. ++*/ ++#include ++static void memvfsMemloadFunc( ++ sqlite3_context *context, ++ int argc, ++ sqlite3_value **argv ++){ ++ unsigned char *p; ++ sqlite3_int64 sz; ++ FILE *in; ++ const char *zFilename = (const char*)sqlite3_value_text(argv[0]); ++ char zReturn[100]; ++ ++ if( zFilename==0 ) return; ++ in = fopen(zFilename, "rb"); ++ if( in==0 ) return; ++ fseek(in, 0, SEEK_END); ++ sz = ftell(in); ++ rewind(in); ++ p = sqlite3_malloc( sz ); ++ if( p==0 ){ ++ fclose(in); ++ sqlite3_result_error_nomem(context); ++ return; ++ } ++ fread(p, sz, 1, in); ++ fclose(in); ++ sqlite3_snprintf(sizeof(zReturn),zReturn,"ptr=%lld&sz=%lld", ++ (sqlite3_int64)p, sz); ++ sqlite3_result_text(context, zReturn, -1, SQLITE_TRANSIENT); ++} ++/* Called for each new database connection */ ++static int memvfsRegister( ++ sqlite3 *db, ++ const char **pzErrMsg, ++ const struct sqlite3_api_routines *pThunk ++){ ++ return sqlite3_create_function(db, "memload", 1, SQLITE_UTF8, 0, ++ memvfsMemloadFunc, 0, 0); ++} ++#endif /* MEMVFS_TEST */ ++ ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++/* ++** This routine is called when the extension is loaded. ++** Register the new VFS. ++*/ ++int sqlite3_memvfs_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ mem_vfs.pAppData = sqlite3_vfs_find(0); ++ mem_vfs.szOsFile = sizeof(MemFile); ++ rc = sqlite3_vfs_register(&mem_vfs, 1); ++#ifdef MEMVFS_TEST ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_auto_extension((void(*)(void))memvfsRegister); ++ } ++#endif ++ if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY; ++ return rc; ++} ++#if !defined(_WIN32) && !defined(SQLITE_TEST) ++int sqlite3_extension_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ mem_vfs.pAppData = sqlite3_vfs_find(0); ++ mem_vfs.szOsFile = sizeof(MemFile); ++ rc = sqlite3_vfs_register(&mem_vfs, 1); ++#ifdef MEMVFS_TEST ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_auto_extension((void(*)(void))memvfsRegister); ++ } ++#endif ++ if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY; ++ return rc; ++} ++#endif +--- origsrc/sqlite-autoconf-3180000/nextchar.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/nextchar.c 2017-04-19 16:20:01.723911000 +0200 @@ -0,0 +1,333 @@ +/* +** 2013-02-28 @@ -5245,8 +9707,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/percentile.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/percentile.c 2016-01-06 16:30:42.509121700 +0100 +--- origsrc/sqlite-autoconf-3180000/percentile.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/percentile.c 2017-04-19 16:20:01.732911900 +0200 @@ -0,0 +1,233 @@ +/* +** 2013-05-28 @@ -5417,7 +9879,7 @@ +/* +** Compare to doubles for sorting using qsort() +*/ -+static int doubleCmp(const void *pA, const void *pB){ ++static int SQLITE_CDECL doubleCmp(const void *pA, const void *pB){ + double a = *(double*)pA; + double b = *(double*)pB; + if( a==b ) return 0; @@ -5481,8 +9943,8 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/rbu.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/rbu.c 2016-01-06 16:48:54.403574500 +0100 +--- origsrc/sqlite-autoconf-3180000/rbu.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/rbu.c 2017-04-19 16:20:01.740912700 +0200 @@ -0,0 +1,125 @@ +/* +** 2014 August 30 @@ -5609,8 +10071,8 @@ + return (rc==SQLITE_OK || rc==SQLITE_DONE) ? 0 : 1; +} + ---- origsrc/sqlite-autoconf-3100000/regexp.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/regexp.c 2016-01-06 16:30:42.510121800 +0100 +--- origsrc/sqlite-autoconf-3180000/regexp.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/regexp.c 2017-04-19 16:20:01.752913900 +0200 @@ -0,0 +1,773 @@ +/* +** 2012-11-13 @@ -5750,7 +10212,7 @@ +static void re_add_state(ReStateSet *pSet, int newState){ + unsigned i; + for(i=0; inState; i++) if( pSet->aState[i]==newState ) return; -+ pSet->aState[pSet->nState++] = newState; ++ pSet->aState[pSet->nState++] = (ReStateNumber)newState; +} + +/* Extract the next unicode character from *pzIn and return it. Advance @@ -5972,7 +10434,7 @@ + p->aArg[i] = p->aArg[i-1]; + } + p->nState++; -+ p->aOp[iBefore] = op; ++ p->aOp[iBefore] = (char)op; + p->aArg[iBefore] = arg; + return iBefore; +} @@ -6291,12 +10753,12 @@ + for(j=0, i=1; jzInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){ + unsigned x = pRe->aArg[i]; + if( x<=127 ){ -+ pRe->zInit[j++] = x; ++ pRe->zInit[j++] = (unsigned char)x; + }else if( x<=0xfff ){ -+ pRe->zInit[j++] = 0xc0 | (x>>6); ++ pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6)); + pRe->zInit[j++] = 0x80 | (x&0x3f); + }else if( x<=0xffff ){ -+ pRe->zInit[j++] = 0xd0 | (x>>12); ++ pRe->zInit[j++] = (unsigned char)(0xd0 | (x>>12)); + pRe->zInit[j++] = 0x80 | ((x>>6)&0x3f); + pRe->zInit[j++] = 0x80 | (x&0x3f); + }else{ @@ -6385,8 +10847,93 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/rot13.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/rot13.c 2016-01-06 16:30:42.512121900 +0100 +--- origsrc/sqlite-autoconf-3180000/remember.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/remember.c 2017-04-19 16:20:01.761914800 +0200 +@@ -0,0 +1,82 @@ ++/* ++** 2016-08-09 ++** ++** 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 file demonstrates how to create an SQL function that is a pass-through ++** for integer values (it returns a copy of its argument) but also saves the ++** value that is passed through into a C-language variable. The address of ++** the C-language variable is supplied as the second argument. ++** ++** This allows, for example, a counter to incremented and the original ++** value retrieved, atomically, using a single statement: ++** ++** UPDATE counterTab SET cnt=remember(cnt,$PTR)+1 WHERE id=$ID ++** ++** Prepare the above statement once. Then to use it, bind the address ++** of the output variable to $PTR and the id of the counter to $ID and ++** run the prepared statement. ++** ++** One can imagine doing similar things with floating-point values and ++** strings, but this demonstration extension will stick to using just ++** integers. ++*/ ++#include "sqlite3ext.h" ++SQLITE_EXTENSION_INIT1 ++#include ++#include ++ ++/* ++** remember(V,PTR) ++** ++** Return the integer value V. Also save the value of V in a ++** C-language variable whose address is PTR. ++*/ ++static void rememberFunc( ++ sqlite3_context *pCtx, ++ int argc, ++ sqlite3_value **argv ++){ ++ sqlite3_int64 v; ++ sqlite3_int64* ptr; ++ assert( argc==2 ); ++ v = sqlite3_value_int64(argv[0]); ++ ptr = (sqlite3_int64*)(size_t)sqlite3_value_int64(argv[1]); ++ *ptr = v; ++ sqlite3_result_int64(pCtx, v); ++} ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++int sqlite3_remember_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ rc = sqlite3_create_function(db, "remember", 2, SQLITE_UTF8, 0, ++ rememberFunc, 0, 0); ++ return rc; ++} ++#if !defined(_WIN32) && !defined(SQLITE_TEST) ++int sqlite3_extension_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ rc = sqlite3_create_function(db, "remember", 2, SQLITE_UTF8, 0, ++ rememberFunc, 0, 0); ++ return rc; ++} ++#endif +--- origsrc/sqlite-autoconf-3180000/rot13.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/rot13.c 2017-04-19 16:20:01.768915500 +0200 @@ -0,0 +1,131 @@ +/* +** 2013-05-15 @@ -6519,9 +11066,622 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/series.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/series.c 2016-01-06 16:30:42.514122000 +0100 -@@ -0,0 +1,424 @@ +--- origsrc/sqlite-autoconf-3180000/scrub.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/scrub.c 2017-04-19 16:20:01.779916600 +0200 +@@ -0,0 +1,610 @@ ++/* ++** 2016-05-05 ++** ++** 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 file implements a utility function (and a utility program) that ++** makes a copy of an SQLite database while simultaneously zeroing out all ++** deleted content. ++** ++** Normally (when PRAGMA secure_delete=OFF, which is the default) when SQLite ++** deletes content, it does not overwrite the deleted content but rather marks ++** the region of the file that held that content as being reusable. This can ++** cause deleted content to recoverable from the database file. This stale ++** content is removed by the VACUUM command, but VACUUM can be expensive for ++** large databases. When in PRAGMA secure_delete=ON mode, the deleted content ++** is zeroed, but secure_delete=ON has overhead as well. ++** ++** This utility attempts to make a copy of a complete SQLite database where ++** all of the deleted content is zeroed out in the copy, and it attempts to ++** do so while being faster than running VACUUM. ++** ++** Usage: ++** ++** int sqlite3_scrub_backup( ++** const char *zSourceFile, // Source database filename ++** const char *zDestFile, // Destination database filename ++** char **pzErrMsg // Write error message here ++** ); ++** ++** Simply call the API above specifying the filename of the source database ++** and the name of the backup copy. The source database must already exist ++** and can be in active use. (A read lock is held during the backup.) The ++** destination file should not previously exist. If the pzErrMsg parameter ++** is non-NULL and if an error occurs, then an error message might be written ++** into memory obtained from sqlite3_malloc() and *pzErrMsg made to point to ++** that error message. But if the error is an OOM, the error might not be ++** reported. The routine always returns non-zero if there is an error. ++** ++** If compiled with -DSCRUB_STANDALONE then a main() procedure is added and ++** this file becomes a standalone program that can be run as follows: ++** ++** ./sqlite3scrub SOURCE DEST ++*/ ++#include "sqlite3.h" ++#include ++#include ++#include ++#include ++#include ++ ++typedef struct ScrubState ScrubState; ++typedef unsigned char u8; ++typedef unsigned short u16; ++typedef unsigned int u32; ++ ++ ++/* State information for a scrub-and-backup operation */ ++struct ScrubState { ++ const char *zSrcFile; /* Name of the source file */ ++ const char *zDestFile; /* Name of the destination file */ ++ int rcErr; /* Error code */ ++ char *zErr; /* Error message text */ ++ sqlite3 *dbSrc; /* Source database connection */ ++ sqlite3_file *pSrc; /* Source file handle */ ++ sqlite3 *dbDest; /* Destination database connection */ ++ sqlite3_file *pDest; /* Destination file handle */ ++ u32 szPage; /* Page size */ ++ u32 szUsable; /* Usable bytes on each page */ ++ u32 nPage; /* Number of pages */ ++ u32 iLastPage; /* Page number of last page written so far*/ ++ u8 *page1; /* Content of page 1 */ ++}; ++ ++/* Store an error message */ ++static void scrubBackupErr(ScrubState *p, const char *zFormat, ...){ ++ va_list ap; ++ sqlite3_free(p->zErr); ++ va_start(ap, zFormat); ++ p->zErr = sqlite3_vmprintf(zFormat, ap); ++ va_end(ap); ++ if( p->rcErr==0 ) p->rcErr = SQLITE_ERROR; ++} ++ ++/* Allocate memory to hold a single page of content */ ++static u8 *scrubBackupAllocPage(ScrubState *p){ ++ u8 *pPage; ++ if( p->rcErr ) return 0; ++ pPage = sqlite3_malloc( p->szPage ); ++ if( pPage==0 ) p->rcErr = SQLITE_NOMEM; ++ return pPage; ++} ++ ++/* Read a page from the source database into memory. Use the memory ++** provided by pBuf if not NULL or allocate a new page if pBuf==NULL. ++*/ ++static u8 *scrubBackupRead(ScrubState *p, int pgno, u8 *pBuf){ ++ int rc; ++ sqlite3_int64 iOff; ++ u8 *pOut = pBuf; ++ if( p->rcErr ) return 0; ++ if( pOut==0 ){ ++ pOut = scrubBackupAllocPage(p); ++ if( pOut==0 ) return 0; ++ } ++ iOff = (pgno-1)*(sqlite3_int64)p->szPage; ++ rc = p->pSrc->pMethods->xRead(p->pSrc, pOut, p->szPage, iOff); ++ if( rc!=SQLITE_OK ){ ++ if( pBuf==0 ) sqlite3_free(pOut); ++ pOut = 0; ++ scrubBackupErr(p, "read failed for page %d", pgno); ++ p->rcErr = SQLITE_IOERR; ++ } ++ return pOut; ++} ++ ++/* Write a page to the destination database */ ++static void scrubBackupWrite(ScrubState *p, int pgno, const u8 *pData){ ++ int rc; ++ sqlite3_int64 iOff; ++ if( p->rcErr ) return; ++ iOff = (pgno-1)*(sqlite3_int64)p->szPage; ++ rc = p->pDest->pMethods->xWrite(p->pDest, pData, p->szPage, iOff); ++ if( rc!=SQLITE_OK ){ ++ scrubBackupErr(p, "write failed for page %d", pgno); ++ p->rcErr = SQLITE_IOERR; ++ } ++ if( pgno>p->iLastPage ) p->iLastPage = pgno; ++} ++ ++/* Prepare a statement against the "db" database. */ ++static sqlite3_stmt *scrubBackupPrepare( ++ ScrubState *p, /* Backup context */ ++ sqlite3 *db, /* Database to prepare against */ ++ const char *zSql /* SQL statement */ ++){ ++ sqlite3_stmt *pStmt; ++ if( p->rcErr ) return 0; ++ p->rcErr = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); ++ if( p->rcErr ){ ++ scrubBackupErr(p, "SQL error \"%s\" on \"%s\"", ++ sqlite3_errmsg(db), zSql); ++ sqlite3_finalize(pStmt); ++ return 0; ++ } ++ return pStmt; ++} ++ ++ ++/* Open the source database file */ ++static void scrubBackupOpenSrc(ScrubState *p){ ++ sqlite3_stmt *pStmt; ++ int rc; ++ /* Open the source database file */ ++ p->rcErr = sqlite3_open_v2(p->zSrcFile, &p->dbSrc, ++ SQLITE_OPEN_READWRITE | ++ SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0); ++ if( p->rcErr ){ ++ scrubBackupErr(p, "cannot open source database: %s", ++ sqlite3_errmsg(p->dbSrc)); ++ return; ++ } ++ p->rcErr = sqlite3_exec(p->dbSrc, "SELECT 1 FROM sqlite_master; BEGIN;", ++ 0, 0, 0); ++ if( p->rcErr ){ ++ scrubBackupErr(p, ++ "cannot start a read transaction on the source database: %s", ++ sqlite3_errmsg(p->dbSrc)); ++ return; ++ } ++ rc = sqlite3_wal_checkpoint_v2(p->dbSrc, "main", SQLITE_CHECKPOINT_FULL, ++ 0, 0); ++ if( rc ){ ++ scrubBackupErr(p, "cannot checkpoint the source database"); ++ return; ++ } ++ pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_size"); ++ if( pStmt==0 ) return; ++ rc = sqlite3_step(pStmt); ++ if( rc==SQLITE_ROW ){ ++ p->szPage = sqlite3_column_int(pStmt, 0); ++ }else{ ++ scrubBackupErr(p, "unable to determine the page size"); ++ } ++ sqlite3_finalize(pStmt); ++ if( p->rcErr ) return; ++ pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_count"); ++ if( pStmt==0 ) return; ++ rc = sqlite3_step(pStmt); ++ if( rc==SQLITE_ROW ){ ++ p->nPage = sqlite3_column_int(pStmt, 0); ++ }else{ ++ scrubBackupErr(p, "unable to determine the size of the source database"); ++ } ++ sqlite3_finalize(pStmt); ++ sqlite3_file_control(p->dbSrc, "main", SQLITE_FCNTL_FILE_POINTER, &p->pSrc); ++ if( p->pSrc==0 || p->pSrc->pMethods==0 ){ ++ scrubBackupErr(p, "cannot get the source file handle"); ++ p->rcErr = SQLITE_ERROR; ++ } ++} ++ ++/* Create and open the destination file */ ++static void scrubBackupOpenDest(ScrubState *p){ ++ sqlite3_stmt *pStmt; ++ int rc; ++ char *zSql; ++ if( p->rcErr ) return; ++ p->rcErr = sqlite3_open_v2(p->zDestFile, &p->dbDest, ++ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | ++ SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0); ++ if( p->rcErr ){ ++ scrubBackupErr(p, "cannot open destination database: %s", ++ sqlite3_errmsg(p->dbDest)); ++ return; ++ } ++ zSql = sqlite3_mprintf("PRAGMA page_size(%u);", p->szPage); ++ if( zSql==0 ){ ++ p->rcErr = SQLITE_NOMEM; ++ return; ++ } ++ p->rcErr = sqlite3_exec(p->dbDest, zSql, 0, 0, 0); ++ sqlite3_free(zSql); ++ if( p->rcErr ){ ++ scrubBackupErr(p, ++ "cannot set the page size on the destination database: %s", ++ sqlite3_errmsg(p->dbDest)); ++ return; ++ } ++ sqlite3_exec(p->dbDest, "PRAGMA journal_mode=OFF;", 0, 0, 0); ++ p->rcErr = sqlite3_exec(p->dbDest, "BEGIN EXCLUSIVE;", 0, 0, 0); ++ if( p->rcErr ){ ++ scrubBackupErr(p, ++ "cannot start a write transaction on the destination database: %s", ++ sqlite3_errmsg(p->dbDest)); ++ return; ++ } ++ pStmt = scrubBackupPrepare(p, p->dbDest, "PRAGMA page_count;"); ++ if( pStmt==0 ) return; ++ rc = sqlite3_step(pStmt); ++ if( rc!=SQLITE_ROW ){ ++ scrubBackupErr(p, "cannot measure the size of the destination"); ++ }else if( sqlite3_column_int(pStmt, 0)>1 ){ ++ scrubBackupErr(p, "destination database is not empty - holds %d pages", ++ sqlite3_column_int(pStmt, 0)); ++ } ++ sqlite3_finalize(pStmt); ++ sqlite3_file_control(p->dbDest, "main", SQLITE_FCNTL_FILE_POINTER, &p->pDest); ++ if( p->pDest==0 || p->pDest->pMethods==0 ){ ++ scrubBackupErr(p, "cannot get the destination file handle"); ++ p->rcErr = SQLITE_ERROR; ++ } ++} ++ ++/* Read a 32-bit big-endian integer */ ++static u32 scrubBackupInt32(const u8 *a){ ++ u32 v = a[3]; ++ v += ((u32)a[2])<<8; ++ v += ((u32)a[1])<<16; ++ v += ((u32)a[0])<<24; ++ return v; ++} ++ ++/* Read a 16-bit big-endian integer */ ++static u32 scrubBackupInt16(const u8 *a){ ++ return (a[0]<<8) + a[1]; ++} ++ ++/* ++** Read a varint. Put the value in *pVal and return the number of bytes. ++*/ ++static int scrubBackupVarint(const u8 *z, sqlite3_int64 *pVal){ ++ sqlite3_int64 v = 0; ++ int i; ++ for(i=0; i<8; i++){ ++ v = (v<<7) + (z[i]&0x7f); ++ if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; } ++ } ++ v = (v<<8) + (z[i]&0xff); ++ *pVal = v; ++ return 9; ++} ++ ++/* ++** Return the number of bytes in a varint. ++*/ ++static int scrubBackupVarintSize(const u8 *z){ ++ int i; ++ for(i=0; i<8; i++){ ++ if( (z[i]&0x80)==0 ){ return i+1; } ++ } ++ return 9; ++} ++ ++/* ++** Copy the freelist trunk page given, and all its descendents, ++** zeroing out as much as possible in the process. ++*/ ++static void scrubBackupFreelist(ScrubState *p, int pgno, u32 nFree){ ++ u8 *a, *aBuf; ++ u32 n, mx; ++ ++ if( p->rcErr ) return; ++ aBuf = scrubBackupAllocPage(p); ++ if( aBuf==0 ) return; ++ ++ while( pgno && nFree){ ++ a = scrubBackupRead(p, pgno, aBuf); ++ if( a==0 ) break; ++ n = scrubBackupInt32(&a[4]); ++ mx = p->szUsable/4 - 2; ++ if( nszPage); ++ } ++ scrubBackupWrite(p, iLeaf, aZero); ++ nFree--; ++ } ++#endif ++ } ++ sqlite3_free(aBuf); ++} ++ ++/* ++** Copy an overflow chain from source to destination. Zero out any ++** unused tail at the end of the overflow chain. ++*/ ++static void scrubBackupOverflow(ScrubState *p, int pgno, u32 nByte){ ++ u8 *a, *aBuf; ++ ++ aBuf = scrubBackupAllocPage(p); ++ if( aBuf==0 ) return; ++ while( nByte>0 && pgno!=0 ){ ++ a = scrubBackupRead(p, pgno, aBuf); ++ if( a==0 ) break; ++ if( nByte >= (p->szUsable)-4 ){ ++ nByte -= (p->szUsable) - 4; ++ }else{ ++ u32 x = (p->szUsable - 4) - nByte; ++ u32 i = p->szUsable - x; ++ memset(&a[i], 0, x); ++ nByte = 0; ++ } ++ scrubBackupWrite(p, pgno, a); ++ pgno = scrubBackupInt32(a); ++ } ++ sqlite3_free(aBuf); ++} ++ ++ ++/* ++** Copy B-Tree page pgno, and all of its children, from source to destination. ++** Zero out deleted content during the copy. ++*/ ++static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ ++ u8 *a; ++ u32 i, n, pc; ++ u32 nCell; ++ u32 nPrefix; ++ u32 szHdr; ++ u32 iChild; ++ u8 *aTop; ++ u8 *aCell; ++ u32 x, y; ++ int ln = 0; ++ ++ ++ if( p->rcErr ) return; ++ if( iDepth>50 ){ ++ scrubBackupErr(p, "corrupt: b-tree too deep at page %d", pgno); ++ return; ++ } ++ if( pgno==1 ){ ++ a = p->page1; ++ }else{ ++ a = scrubBackupRead(p, pgno, 0); ++ if( a==0 ) return; ++ } ++ nPrefix = pgno==1 ? 100 : 0; ++ aTop = &a[nPrefix]; ++ szHdr = 8 + 4*(aTop[0]==0x02 || aTop[0]==0x05); ++ aCell = aTop + szHdr; ++ nCell = scrubBackupInt16(&aTop[3]); ++ ++ /* Zero out the gap between the cell index and the start of the ++ ** cell content area */ ++ x = scrubBackupInt16(&aTop[5]); /* First byte of cell content area */ ++ if( x>p->szUsable ){ ln=__LINE__; goto btree_corrupt; } ++ y = szHdr + nPrefix + nCell*2; ++ if( y>x ){ ln=__LINE__; goto btree_corrupt; } ++ if( y0 && pc(p->szUsable)-4 ){ ln=__LINE__; goto btree_corrupt; } ++ n = scrubBackupInt16(&a[pc+2]); ++ if( pc+n>(p->szUsable) ){ ln=__LINE__; goto btree_corrupt; } ++ if( n>4 ) memset(&a[pc+4], 0, n-4); ++ x = scrubBackupInt16(&a[pc]); ++ if( x0 ){ ln=__LINE__; goto btree_corrupt; } ++ pc = x; ++ } ++ ++ /* Write this one page */ ++ scrubBackupWrite(p, pgno, a); ++ ++ /* Walk the tree and process child pages */ ++ for(i=0; i p->szUsable-3 ){ ln=__LINE__; goto btree_corrupt; } ++ if( aTop[0]==0x05 || aTop[0]==0x02 ){ ++ if( pc+4 > p->szUsable ){ ln=__LINE__; goto btree_corrupt; } ++ iChild = scrubBackupInt32(&a[pc]); ++ pc += 4; ++ scrubBackupBtree(p, iChild, iDepth+1); ++ if( aTop[0]==0x05 ) continue; ++ } ++ pc += scrubBackupVarint(&a[pc], &P); ++ if( pc >= p->szUsable ){ ln=__LINE__; goto btree_corrupt; } ++ if( aTop[0]==0x0d ){ ++ X = p->szUsable - 35; ++ }else{ ++ X = ((p->szUsable - 12)*64/255) - 23; ++ } ++ if( P<=X ){ ++ /* All content is local. No overflow */ ++ continue; ++ } ++ M = ((p->szUsable - 12)*32/255)-23; ++ K = M + ((P-M)%(p->szUsable-4)); ++ if( aTop[0]==0x0d ){ ++ pc += scrubBackupVarintSize(&a[pc]); ++ if( pc > (p->szUsable-4) ){ ln=__LINE__; goto btree_corrupt; } ++ } ++ nLocal = K<=X ? K : M; ++ if( pc+nLocal > p->szUsable-4 ){ ln=__LINE__; goto btree_corrupt; } ++ iChild = scrubBackupInt32(&a[pc+nLocal]); ++ scrubBackupOverflow(p, iChild, P-nLocal); ++ } ++ ++ /* Walk the right-most tree */ ++ if( aTop[0]==0x05 || aTop[0]==0x02 ){ ++ iChild = scrubBackupInt32(&aTop[8]); ++ scrubBackupBtree(p, iChild, iDepth+1); ++ } ++ ++ /* All done */ ++ if( pgno>1 ) sqlite3_free(a); ++ return; ++ ++btree_corrupt: ++ scrubBackupErr(p, "corruption on page %d of source database (errid=%d)", ++ pgno, ln); ++ if( pgno>1 ) sqlite3_free(a); ++} ++ ++/* ++** Copy all ptrmap pages from source to destination. ++** This routine is only called if the source database is in autovacuum ++** or incremental vacuum mode. ++*/ ++static void scrubBackupPtrmap(ScrubState *p){ ++ u32 pgno = 2; ++ u32 J = p->szUsable/5; ++ u32 iLock = (1073742335/p->szPage)+1; ++ u8 *a, *pBuf; ++ if( p->rcErr ) return; ++ pBuf = scrubBackupAllocPage(p); ++ if( pBuf==0 ) return; ++ while( pgno<=p->nPage ){ ++ a = scrubBackupRead(p, pgno, pBuf); ++ if( a==0 ) break; ++ scrubBackupWrite(p, pgno, a); ++ pgno += J+1; ++ if( pgno==iLock ) pgno++; ++ } ++ sqlite3_free(pBuf); ++} ++ ++int sqlite3_scrub_backup( ++ const char *zSrcFile, /* Source file */ ++ const char *zDestFile, /* Destination file */ ++ char **pzErr /* Write error here if non-NULL */ ++){ ++ ScrubState s; ++ u32 n, i; ++ sqlite3_stmt *pStmt; ++ ++ memset(&s, 0, sizeof(s)); ++ s.zSrcFile = zSrcFile; ++ s.zDestFile = zDestFile; ++ ++ /* Open both source and destination databases */ ++ scrubBackupOpenSrc(&s); ++ scrubBackupOpenDest(&s); ++ ++ /* Read in page 1 */ ++ s.page1 = scrubBackupRead(&s, 1, 0); ++ if( s.page1==0 ) goto scrub_abort; ++ s.szUsable = s.szPage - s.page1[20]; ++ ++ /* Copy the freelist */ ++ n = scrubBackupInt32(&s.page1[36]); ++ i = scrubBackupInt32(&s.page1[32]); ++ if( n ) scrubBackupFreelist(&s, i, n); ++ ++ /* Copy ptrmap pages */ ++ n = scrubBackupInt32(&s.page1[52]); ++ if( n ) scrubBackupPtrmap(&s); ++ ++ /* Copy all of the btrees */ ++ scrubBackupBtree(&s, 1, 0); ++ pStmt = scrubBackupPrepare(&s, s.dbSrc, ++ "SELECT rootpage FROM sqlite_master WHERE coalesce(rootpage,0)>0"); ++ if( pStmt==0 ) goto scrub_abort; ++ while( sqlite3_step(pStmt)==SQLITE_ROW ){ ++ i = (u32)sqlite3_column_int(pStmt, 0); ++ scrubBackupBtree(&s, i, 0); ++ } ++ sqlite3_finalize(pStmt); ++ ++ /* If the last page of the input db file is a free-list leaf, then the ++ ** backup file on disk is still smaller than the size indicated within ++ ** the database header. In this case, write a page of zeroes to the ++ ** last page of the backup database so that SQLite does not mistakenly ++ ** think the db is corrupt. */ ++ if( s.iLastPage=0 ){ + pIdxInfo->aConstraintUsage[startIdx].argvIndex = ++nArg; -+ pIdxInfo->aConstraintUsage[startIdx].omit = 1; ++ pIdxInfo->aConstraintUsage[startIdx].omit= !SQLITE_SERIES_CONSTRAINT_VERIFY; + } + if( stopIdx>=0 ){ + pIdxInfo->aConstraintUsage[stopIdx].argvIndex = ++nArg; -+ pIdxInfo->aConstraintUsage[stopIdx].omit = 1; ++ pIdxInfo->aConstraintUsage[stopIdx].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY; + } + if( stepIdx>=0 ){ + pIdxInfo->aConstraintUsage[stepIdx].argvIndex = ++nArg; -+ pIdxInfo->aConstraintUsage[stepIdx].omit = 1; ++ pIdxInfo->aConstraintUsage[stepIdx].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY; + } + if( (idxNum & 3)==3 ){ + /* Both start= and stop= boundaries are available. This is the + ** the preferred case */ -+ pIdxInfo->estimatedCost = (double)1; ++ pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0)); + pIdxInfo->estimatedRows = 1000; + if( pIdxInfo->nOrderBy==1 ){ + if( pIdxInfo->aOrderBy[0].desc ) idxNum |= 8; @@ -6882,7 +12050,7 @@ +** This following structure defines all the methods for the +** generate_series virtual table. +*/ -+static sqlite3_module seriesModule = { ++static const sqlite3_module seriesModule = { + 0, /* iVersion */ + 0, /* xCreate */ + seriesConnect, /* xConnect */ @@ -6946,9 +12114,447 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/shell.c 2016-01-06 13:03:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/shell.c 2016-01-06 16:18:29.053170500 +0100 -@@ -236,45 +236,14 @@ static HANDLE hProcess; +--- origsrc/sqlite-autoconf-3180000/sha1.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/sha1.c 2017-04-19 16:20:01.800918700 +0200 +@@ -0,0 +1,425 @@ ++/* ++** 2017-01-27 ++** ++** 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 implements a functions that compute SHA1 hashes. ++** Two SQL functions are implemented: ++** ++** sha1(X) ++** sha1_query(Y) ++** ++** The sha1(X) function computes the SHA1 hash of the input X, or NULL if ++** X is NULL. ++** ++** The sha1_query(Y) function evalutes all queries in the SQL statements of Y ++** and returns a hash of their results. ++*/ ++#include "sqlite3ext.h" ++SQLITE_EXTENSION_INIT1 ++#include ++#include ++#include ++ ++/****************************************************************************** ++** The Hash Engine ++*/ ++/* Context for the SHA1 hash */ ++typedef struct SHA1Context SHA1Context; ++struct SHA1Context { ++ unsigned int state[5]; ++ unsigned int count[2]; ++ unsigned char buffer[64]; ++}; ++ ++ ++#if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) ++/* ++ * GCC by itself only generates left rotates. Use right rotates if ++ * possible to be kinder to dinky implementations with iterative rotate ++ * instructions. ++ */ ++#define SHA_ROT(op, x, k) \ ++ ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) ++#define rol(x,k) SHA_ROT("roll", x, k) ++#define ror(x,k) SHA_ROT("rorl", x, k) ++ ++#else ++/* Generic C equivalent */ ++#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) ++#define rol(x,k) SHA_ROT(x,k,32-(k)) ++#define ror(x,k) SHA_ROT(x,32-(k),k) ++#endif ++ ++ ++#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ ++ |(rol(block[i],8)&0x00FF00FF)) ++#define blk0be(i) block[i] ++#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ ++ ^block[(i+2)&15]^block[i&15],1)) ++ ++/* ++ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 ++ * ++ * Rl0() for little-endian and Rb0() for big-endian. Endianness is ++ * determined at run-time. ++ */ ++#define Rl0(v,w,x,y,z,i) \ ++ z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); ++#define Rb0(v,w,x,y,z,i) \ ++ z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); ++#define R1(v,w,x,y,z,i) \ ++ z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); ++#define R2(v,w,x,y,z,i) \ ++ z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); ++#define R3(v,w,x,y,z,i) \ ++ z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); ++#define R4(v,w,x,y,z,i) \ ++ z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); ++ ++/* ++ * Hash a single 512-bit block. This is the core of the algorithm. ++ */ ++void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){ ++ unsigned int qq[5]; /* a, b, c, d, e; */ ++ static int one = 1; ++ unsigned int block[16]; ++ memcpy(block, buffer, 64); ++ memcpy(qq,state,5*sizeof(unsigned int)); ++ ++#define a qq[0] ++#define b qq[1] ++#define c qq[2] ++#define d qq[3] ++#define e qq[4] ++ ++ /* Copy p->state[] to working vars */ ++ /* ++ a = state[0]; ++ b = state[1]; ++ c = state[2]; ++ d = state[3]; ++ e = state[4]; ++ */ ++ ++ /* 4 rounds of 20 operations each. Loop unrolled. */ ++ if( 1 == *(unsigned char*)&one ){ ++ Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); ++ Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); ++ Rl0(c,d,e,a,b, 8); Rl0(b,c,d,e,a, 9); Rl0(a,b,c,d,e,10); Rl0(e,a,b,c,d,11); ++ Rl0(d,e,a,b,c,12); Rl0(c,d,e,a,b,13); Rl0(b,c,d,e,a,14); Rl0(a,b,c,d,e,15); ++ }else{ ++ Rb0(a,b,c,d,e, 0); Rb0(e,a,b,c,d, 1); Rb0(d,e,a,b,c, 2); Rb0(c,d,e,a,b, 3); ++ Rb0(b,c,d,e,a, 4); Rb0(a,b,c,d,e, 5); Rb0(e,a,b,c,d, 6); Rb0(d,e,a,b,c, 7); ++ Rb0(c,d,e,a,b, 8); Rb0(b,c,d,e,a, 9); Rb0(a,b,c,d,e,10); Rb0(e,a,b,c,d,11); ++ Rb0(d,e,a,b,c,12); Rb0(c,d,e,a,b,13); Rb0(b,c,d,e,a,14); Rb0(a,b,c,d,e,15); ++ } ++ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); ++ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); ++ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); ++ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); ++ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); ++ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); ++ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); ++ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); ++ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); ++ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); ++ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); ++ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); ++ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); ++ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); ++ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); ++ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); ++ ++ /* Add the working vars back into context.state[] */ ++ state[0] += a; ++ state[1] += b; ++ state[2] += c; ++ state[3] += d; ++ state[4] += e; ++ ++#undef a ++#undef b ++#undef c ++#undef d ++#undef e ++} ++ ++ ++/* Initialize a SHA1 context */ ++static void hash_init(SHA1Context *p){ ++ /* SHA1 initialization constants */ ++ p->state[0] = 0x67452301; ++ p->state[1] = 0xEFCDAB89; ++ p->state[2] = 0x98BADCFE; ++ p->state[3] = 0x10325476; ++ p->state[4] = 0xC3D2E1F0; ++ p->count[0] = p->count[1] = 0; ++} ++ ++/* Add new content to the SHA1 hash */ ++static void hash_step( ++ SHA1Context *p, /* Add content to this context */ ++ const unsigned char *data, /* Data to be added */ ++ unsigned int len /* Number of bytes in data */ ++){ ++ unsigned int i, j; ++ ++ j = p->count[0]; ++ if( (p->count[0] += len << 3) < j ){ ++ p->count[1] += (len>>29)+1; ++ } ++ j = (j >> 3) & 63; ++ if( (j + len) > 63 ){ ++ (void)memcpy(&p->buffer[j], data, (i = 64-j)); ++ SHA1Transform(p->state, p->buffer); ++ for(; i + 63 < len; i += 64){ ++ SHA1Transform(p->state, &data[i]); ++ } ++ j = 0; ++ }else{ ++ i = 0; ++ } ++ (void)memcpy(&p->buffer[j], &data[i], len - i); ++} ++ ++/* Compute a string using sqlite3_vsnprintf() and hash it */ ++static void hash_step_vformat( ++ SHA1Context *p, /* Add content to this context */ ++ const char *zFormat, ++ ... ++){ ++ va_list ap; ++ int n; ++ char zBuf[50]; ++ va_start(ap, zFormat); ++ sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap); ++ va_end(ap); ++ n = (int)strlen(zBuf); ++ hash_step(p, (unsigned char*)zBuf, n); ++} ++ ++ ++/* Add padding and compute the message digest. Render the ++** message digest as lower-case hexadecimal and put it into ++** zOut[]. zOut[] must be at least 41 bytes long. */ ++static void hash_finish( ++ SHA1Context *p, /* The SHA1 context to finish and render */ ++ char *zOut /* Store hexadecimal hash here */ ++){ ++ unsigned int i; ++ unsigned char finalcount[8]; ++ unsigned char digest[20]; ++ static const char zEncode[] = "0123456789abcdef"; ++ ++ for (i = 0; i < 8; i++){ ++ finalcount[i] = (unsigned char)((p->count[(i >= 4 ? 0 : 1)] ++ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ ++ } ++ hash_step(p, (const unsigned char *)"\200", 1); ++ while ((p->count[0] & 504) != 448){ ++ hash_step(p, (const unsigned char *)"\0", 1); ++ } ++ hash_step(p, finalcount, 8); /* Should cause a SHA1Transform() */ ++ for (i = 0; i < 20; i++){ ++ digest[i] = (unsigned char)((p->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); ++ } ++ for(i=0; i<20; i++){ ++ zOut[i*2] = zEncode[(digest[i]>>4)&0xf]; ++ zOut[i*2+1] = zEncode[digest[i] & 0xf]; ++ } ++ zOut[i*2]= 0; ++} ++/* End of the hashing logic ++*****************************************************************************/ ++ ++/* ++** Implementation of the sha1(X) function. ++** ++** Return a lower-case hexadecimal rendering of the SHA1 hash of the ++** argument X. If X is a BLOB, it is hashed as is. For all other ++** types of input, X is converted into a UTF-8 string and the string ++** is hash without the trailing 0x00 terminator. The hash of a NULL ++** value is NULL. ++*/ ++static void sha1Func( ++ sqlite3_context *context, ++ int argc, ++ sqlite3_value **argv ++){ ++ SHA1Context cx; ++ int eType = sqlite3_value_type(argv[0]); ++ int nByte = sqlite3_value_bytes(argv[0]); ++ char zOut[44]; ++ ++ assert( argc==1 ); ++ if( eType==SQLITE_NULL ) return; ++ hash_init(&cx); ++ if( eType==SQLITE_BLOB ){ ++ hash_step(&cx, sqlite3_value_blob(argv[0]), nByte); ++ }else{ ++ hash_step(&cx, sqlite3_value_text(argv[0]), nByte); ++ } ++ hash_finish(&cx, zOut); ++ sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT); ++} ++ ++/* ++** Implementation of the sha1_query(SQL) function. ++** ++** This function compiles and runs the SQL statement(s) given in the ++** argument. The results are hashed using SHA1 and that hash is returned. ++** ++** The original SQL text is included as part of the hash. ++** ++** The hash is not just a concatenation of the outputs. Each query ++** is delimited and each row and value within the query is delimited, ++** with all values being marked with their datatypes. ++*/ ++static void sha1QueryFunc( ++ sqlite3_context *context, ++ int argc, ++ sqlite3_value **argv ++){ ++ sqlite3 *db = sqlite3_context_db_handle(context); ++ const char *zSql = (const char*)sqlite3_value_text(argv[0]); ++ sqlite3_stmt *pStmt = 0; ++ int nCol; /* Number of columns in the result set */ ++ int i; /* Loop counter */ ++ int rc; ++ int n; ++ const char *z; ++ SHA1Context cx; ++ char zOut[44]; ++ ++ assert( argc==1 ); ++ if( zSql==0 ) return; ++ hash_init(&cx); ++ while( zSql[0] ){ ++ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql); ++ if( rc ){ ++ char *zMsg = sqlite3_mprintf("error SQL statement [%s]: %s", ++ zSql, sqlite3_errmsg(db)); ++ sqlite3_finalize(pStmt); ++ sqlite3_result_error(context, zMsg, -1); ++ sqlite3_free(zMsg); ++ return; ++ } ++ if( !sqlite3_stmt_readonly(pStmt) ){ ++ char *zMsg = sqlite3_mprintf("non-query: [%s]", sqlite3_sql(pStmt)); ++ sqlite3_finalize(pStmt); ++ sqlite3_result_error(context, zMsg, -1); ++ sqlite3_free(zMsg); ++ return; ++ } ++ nCol = sqlite3_column_count(pStmt); ++ z = sqlite3_sql(pStmt); ++ n = (int)strlen(z); ++ hash_step_vformat(&cx,"S%d:",n); ++ hash_step(&cx,(unsigned char*)z,n); ++ ++ /* Compute a hash over the result of the query */ ++ while( SQLITE_ROW==sqlite3_step(pStmt) ){ ++ hash_step(&cx,(const unsigned char*)"R",1); ++ for(i=0; i=1; j--){ ++ x[j] = u & 0xff; ++ u >>= 8; ++ } ++ x[0] = 'I'; ++ hash_step(&cx, x, 9); ++ break; ++ } ++ case SQLITE_FLOAT: { ++ sqlite3_uint64 u; ++ int j; ++ unsigned char x[9]; ++ double r = sqlite3_column_double(pStmt,i); ++ memcpy(&u, &r, 8); ++ for(j=8; j>=1; j--){ ++ x[j] = u & 0xff; ++ u >>= 8; ++ } ++ x[0] = 'F'; ++ hash_step(&cx,x,9); ++ break; ++ } ++ case SQLITE_TEXT: { ++ int n2 = sqlite3_column_bytes(pStmt, i); ++ const unsigned char *z2 = sqlite3_column_text(pStmt, i); ++ hash_step_vformat(&cx,"T%d:",n2); ++ hash_step(&cx, z2, n2); ++ break; ++ } ++ case SQLITE_BLOB: { ++ int n2 = sqlite3_column_bytes(pStmt, i); ++ const unsigned char *z2 = sqlite3_column_blob(pStmt, i); ++ hash_step_vformat(&cx,"B%d:",n2); ++ hash_step(&cx, z2, n2); ++ break; ++ } ++ } ++ } ++ } ++ sqlite3_finalize(pStmt); ++ } ++ hash_finish(&cx, zOut); ++ sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT); ++} ++ ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++int sqlite3_sha_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ (void)pzErrMsg; /* Unused parameter */ ++ rc = sqlite3_create_function(db, "sha1", 1, SQLITE_UTF8, 0, ++ sha1Func, 0, 0); ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_create_function(db, "sha1_query", 1, SQLITE_UTF8, 0, ++ sha1QueryFunc, 0, 0); ++ } ++ return rc; ++} ++#if !defined(_WIN32) && !defined(SQLITE_TEST) ++int sqlite3_extension_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ (void)pzErrMsg; /* Unused parameter */ ++ rc = sqlite3_create_function(db, "sha1", 1, SQLITE_UTF8, 0, ++ sha1Func, 0, 0); ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_create_function(db, "sha1_query", 1, SQLITE_UTF8, 0, ++ sha1QueryFunc, 0, 0); ++ } ++ return rc; ++} ++#endif +--- origsrc/sqlite-autoconf-3180000/shell.c 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/shell.c 2017-04-19 16:20:01.825921200 +0200 +@@ -53,8 +53,8 @@ + #include + #include + ++#include + #if !defined(_WIN32) && !defined(WIN32) +-# include + # if !defined(__RTP__) && !defined(_WRS_KERNEL) + # include + # endif +@@ -244,45 +244,14 @@ static HANDLE hProcess; static FILETIME ftKernelBegin; static FILETIME ftUserBegin; static sqlite3_int64 ftWallBegin; @@ -6977,7 +12583,7 @@ - if( NULL != getProcessTimesAddr ){ - return 1; - } -- FreeLibrary(hinstLib); +- FreeLibrary(hinstLib); - } - } - } @@ -6996,7 +12602,7 @@ &ftKernelBegin,&ftUserBegin); ftWallBegin = timeOfDay(); } -@@ -291,10 +260,10 @@ static double timeDiff(FILETIME *pStart, +@@ -299,10 +268,10 @@ static double timeDiff(FILETIME *pStart, ** Print the timing results. */ static void endTimer(void){ @@ -7009,7 +12615,7 @@ printf("Run Time: real %.3f user %f sys %f\n", (ftWallEnd - ftWallBegin)*0.001, timeDiff(&ftUserBegin, &ftUserEnd), -@@ -304,7 +273,7 @@ static void endTimer(void){ +@@ -312,7 +281,7 @@ static void endTimer(void){ #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() @@ -7017,17 +12623,933 @@ +#define HAS_TIMER 1 #else - #define BEGIN_TIMER -@@ -646,7 +615,7 @@ struct ShellState { - #define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */ - #define MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */ + #define BEGIN_TIMER +@@ -456,6 +425,28 @@ static int isNumber(const char *z, int * + } + + /* ++** A global char* and an SQL function to access its current value ++** from within an SQL statement. This program used to use the ++** sqlite_exec_printf() API to substitue a string into an SQL statement. ++** The correct way to do this with sqlite3 is to use the bind API, but ++** since the shell is built around the callback paradigm it would be a lot ++** of work. Instead just use this hack, which is quite harmless. ++*/ ++static const char *zShellStatic = 0; ++static void shellstaticFunc( ++ sqlite3_context *context, ++ int argc, ++ sqlite3_value **argv ++){ ++ assert( 0==argc ); ++ assert( zShellStatic ); ++ UNUSED_PARAMETER(argc); ++ UNUSED_PARAMETER(argv); ++ sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC); ++} ++ ++ ++/* + ** Compute a string length that is limited to what can be stored in + ** lower 30 bits of a 32-bit signed integer. + */ +@@ -555,779 +546,6 @@ static char *one_input_line(FILE *in, ch + } + return zResult; + } +-/* +-** A variable length string to which one can append text. +-*/ +-typedef struct ShellText ShellText; +-struct ShellText { +- char *z; +- int n; +- int nAlloc; +-}; +- +-/* +-** Initialize and destroy a ShellText object +-*/ +-static void initText(ShellText *p){ +- memset(p, 0, sizeof(*p)); +-} +-static void freeText(ShellText *p){ +- free(p->z); +- initText(p); +-} +- +-/* zIn is either a pointer to a NULL-terminated string in memory obtained +-** from malloc(), or a NULL pointer. The string pointed to by zAppend is +-** added to zIn, and the result returned in memory obtained from malloc(). +-** zIn, if it was not NULL, is freed. +-** +-** If the third argument, quote, is not '\0', then it is used as a +-** quote character for zAppend. +-*/ +-static void appendText(ShellText *p, char const *zAppend, char quote){ +- int len; +- int i; +- int nAppend = strlen30(zAppend); +- +- len = nAppend+p->n+1; +- if( quote ){ +- len += 2; +- for(i=0; in+len>=p->nAlloc ){ +- p->nAlloc = p->nAlloc*2 + len + 20; +- p->z = realloc(p->z, p->nAlloc); +- if( p->z==0 ){ +- memset(p, 0, sizeof(*p)); +- return; +- } +- } +- +- if( quote ){ +- char *zCsr = p->z+p->n; +- *zCsr++ = quote; +- for(i=0; in = (int)(zCsr - p->z); +- *zCsr = '\0'; +- }else{ +- memcpy(p->z+p->n, zAppend, nAppend); +- p->n += nAppend; +- p->z[p->n] = '\0'; +- } +-} +- +-/* +-** Attempt to determine if identifier zName needs to be quoted, either +-** because it contains non-alphanumeric characters, or because it is an +-** SQLite keyword. Be conservative in this estimate: When in doubt assume +-** that quoting is required. +-** +-** Return '"' if quoting is required. Return 0 if no quoting is required. +-*/ +-static char quoteChar(const char *zName){ +- /* All SQLite keywords, in alphabetical order */ +- static const char *azKeywords[] = { +- "ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ANALYZE", "AND", "AS", +- "ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN", "BY", +- "CASCADE", "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "COMMIT", +- "CONFLICT", "CONSTRAINT", "CREATE", "CROSS", "CURRENT_DATE", +- "CURRENT_TIME", "CURRENT_TIMESTAMP", "DATABASE", "DEFAULT", "DEFERRABLE", +- "DEFERRED", "DELETE", "DESC", "DETACH", "DISTINCT", "DROP", "EACH", +- "ELSE", "END", "ESCAPE", "EXCEPT", "EXCLUSIVE", "EXISTS", "EXPLAIN", +- "FAIL", "FOR", "FOREIGN", "FROM", "FULL", "GLOB", "GROUP", "HAVING", "IF", +- "IGNORE", "IMMEDIATE", "IN", "INDEX", "INDEXED", "INITIALLY", "INNER", +- "INSERT", "INSTEAD", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "KEY", +- "LEFT", "LIKE", "LIMIT", "MATCH", "NATURAL", "NO", "NOT", "NOTNULL", +- "NULL", "OF", "OFFSET", "ON", "OR", "ORDER", "OUTER", "PLAN", "PRAGMA", +- "PRIMARY", "QUERY", "RAISE", "RECURSIVE", "REFERENCES", "REGEXP", +- "REINDEX", "RELEASE", "RENAME", "REPLACE", "RESTRICT", "RIGHT", +- "ROLLBACK", "ROW", "SAVEPOINT", "SELECT", "SET", "TABLE", "TEMP", +- "TEMPORARY", "THEN", "TO", "TRANSACTION", "TRIGGER", "UNION", "UNIQUE", +- "UPDATE", "USING", "VACUUM", "VALUES", "VIEW", "VIRTUAL", "WHEN", "WHERE", +- "WITH", "WITHOUT", +- }; +- int i, lwr, upr, mid, c; +- if( !isalpha((unsigned char)zName[0]) && zName[0]!='_' ) return '"'; +- for(i=0; zName[i]; i++){ +- if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ) return '"'; +- } +- lwr = 0; +- upr = sizeof(azKeywords)/sizeof(azKeywords[0]) - 1; +- while( lwr<=upr ){ +- mid = (lwr+upr)/2; +- c = sqlite3_stricmp(azKeywords[mid], zName); +- if( c==0 ) return '"'; +- if( c<0 ){ +- lwr = mid+1; +- }else{ +- upr = mid-1; +- } +- } +- return 0; +-} +- +-/****************************************************************************** +-** SHA3 hash implementation copied from ../ext/misc/shathree.c +-*/ +-typedef sqlite3_uint64 u64; +-/* +-** Macros to determine whether the machine is big or little endian, +-** and whether or not that determination is run-time or compile-time. +-** +-** For best performance, an attempt is made to guess at the byte-order +-** using C-preprocessor macros. If that is unsuccessful, or if +-** -DSHA3_BYTEORDER=0 is set, then byte-order is determined +-** at run-time. +-*/ +-#ifndef SHA3_BYTEORDER +-# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ +- defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ +- defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ +- defined(__arm__) +-# define SHA3_BYTEORDER 1234 +-# elif defined(sparc) || defined(__ppc__) +-# define SHA3_BYTEORDER 4321 +-# else +-# define SHA3_BYTEORDER 0 +-# endif +-#endif +- +- +-/* +-** State structure for a SHA3 hash in progress +-*/ +-typedef struct SHA3Context SHA3Context; +-struct SHA3Context { +- union { +- u64 s[25]; /* Keccak state. 5x5 lines of 64 bits each */ +- unsigned char x[1600]; /* ... or 1600 bytes */ +- } u; +- unsigned nRate; /* Bytes of input accepted per Keccak iteration */ +- unsigned nLoaded; /* Input bytes loaded into u.x[] so far this cycle */ +- unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */ +-}; +- +-/* +-** A single step of the Keccak mixing function for a 1600-bit state +-*/ +-static void KeccakF1600Step(SHA3Context *p){ +- int i; +- u64 B0, B1, B2, B3, B4; +- u64 C0, C1, C2, C3, C4; +- u64 D0, D1, D2, D3, D4; +- static const u64 RC[] = { +- 0x0000000000000001ULL, 0x0000000000008082ULL, +- 0x800000000000808aULL, 0x8000000080008000ULL, +- 0x000000000000808bULL, 0x0000000080000001ULL, +- 0x8000000080008081ULL, 0x8000000000008009ULL, +- 0x000000000000008aULL, 0x0000000000000088ULL, +- 0x0000000080008009ULL, 0x000000008000000aULL, +- 0x000000008000808bULL, 0x800000000000008bULL, +- 0x8000000000008089ULL, 0x8000000000008003ULL, +- 0x8000000000008002ULL, 0x8000000000000080ULL, +- 0x000000000000800aULL, 0x800000008000000aULL, +- 0x8000000080008081ULL, 0x8000000000008080ULL, +- 0x0000000080000001ULL, 0x8000000080008008ULL +- }; +-# define A00 (p->u.s[0]) +-# define A01 (p->u.s[1]) +-# define A02 (p->u.s[2]) +-# define A03 (p->u.s[3]) +-# define A04 (p->u.s[4]) +-# define A10 (p->u.s[5]) +-# define A11 (p->u.s[6]) +-# define A12 (p->u.s[7]) +-# define A13 (p->u.s[8]) +-# define A14 (p->u.s[9]) +-# define A20 (p->u.s[10]) +-# define A21 (p->u.s[11]) +-# define A22 (p->u.s[12]) +-# define A23 (p->u.s[13]) +-# define A24 (p->u.s[14]) +-# define A30 (p->u.s[15]) +-# define A31 (p->u.s[16]) +-# define A32 (p->u.s[17]) +-# define A33 (p->u.s[18]) +-# define A34 (p->u.s[19]) +-# define A40 (p->u.s[20]) +-# define A41 (p->u.s[21]) +-# define A42 (p->u.s[22]) +-# define A43 (p->u.s[23]) +-# define A44 (p->u.s[24]) +-# define ROL64(a,x) ((a<>(64-x))) +- +- for(i=0; i<24; i+=4){ +- C0 = A00^A10^A20^A30^A40; +- C1 = A01^A11^A21^A31^A41; +- C2 = A02^A12^A22^A32^A42; +- C3 = A03^A13^A23^A33^A43; +- C4 = A04^A14^A24^A34^A44; +- D0 = C4^ROL64(C1, 1); +- D1 = C0^ROL64(C2, 1); +- D2 = C1^ROL64(C3, 1); +- D3 = C2^ROL64(C4, 1); +- D4 = C3^ROL64(C0, 1); +- +- B0 = (A00^D0); +- B1 = ROL64((A11^D1), 44); +- B2 = ROL64((A22^D2), 43); +- B3 = ROL64((A33^D3), 21); +- B4 = ROL64((A44^D4), 14); +- A00 = B0 ^((~B1)& B2 ); +- A00 ^= RC[i]; +- A11 = B1 ^((~B2)& B3 ); +- A22 = B2 ^((~B3)& B4 ); +- A33 = B3 ^((~B4)& B0 ); +- A44 = B4 ^((~B0)& B1 ); +- +- B2 = ROL64((A20^D0), 3); +- B3 = ROL64((A31^D1), 45); +- B4 = ROL64((A42^D2), 61); +- B0 = ROL64((A03^D3), 28); +- B1 = ROL64((A14^D4), 20); +- A20 = B0 ^((~B1)& B2 ); +- A31 = B1 ^((~B2)& B3 ); +- A42 = B2 ^((~B3)& B4 ); +- A03 = B3 ^((~B4)& B0 ); +- A14 = B4 ^((~B0)& B1 ); +- +- B4 = ROL64((A40^D0), 18); +- B0 = ROL64((A01^D1), 1); +- B1 = ROL64((A12^D2), 6); +- B2 = ROL64((A23^D3), 25); +- B3 = ROL64((A34^D4), 8); +- A40 = B0 ^((~B1)& B2 ); +- A01 = B1 ^((~B2)& B3 ); +- A12 = B2 ^((~B3)& B4 ); +- A23 = B3 ^((~B4)& B0 ); +- A34 = B4 ^((~B0)& B1 ); +- +- B1 = ROL64((A10^D0), 36); +- B2 = ROL64((A21^D1), 10); +- B3 = ROL64((A32^D2), 15); +- B4 = ROL64((A43^D3), 56); +- B0 = ROL64((A04^D4), 27); +- A10 = B0 ^((~B1)& B2 ); +- A21 = B1 ^((~B2)& B3 ); +- A32 = B2 ^((~B3)& B4 ); +- A43 = B3 ^((~B4)& B0 ); +- A04 = B4 ^((~B0)& B1 ); +- +- B3 = ROL64((A30^D0), 41); +- B4 = ROL64((A41^D1), 2); +- B0 = ROL64((A02^D2), 62); +- B1 = ROL64((A13^D3), 55); +- B2 = ROL64((A24^D4), 39); +- A30 = B0 ^((~B1)& B2 ); +- A41 = B1 ^((~B2)& B3 ); +- A02 = B2 ^((~B3)& B4 ); +- A13 = B3 ^((~B4)& B0 ); +- A24 = B4 ^((~B0)& B1 ); +- +- C0 = A00^A20^A40^A10^A30; +- C1 = A11^A31^A01^A21^A41; +- C2 = A22^A42^A12^A32^A02; +- C3 = A33^A03^A23^A43^A13; +- C4 = A44^A14^A34^A04^A24; +- D0 = C4^ROL64(C1, 1); +- D1 = C0^ROL64(C2, 1); +- D2 = C1^ROL64(C3, 1); +- D3 = C2^ROL64(C4, 1); +- D4 = C3^ROL64(C0, 1); +- +- B0 = (A00^D0); +- B1 = ROL64((A31^D1), 44); +- B2 = ROL64((A12^D2), 43); +- B3 = ROL64((A43^D3), 21); +- B4 = ROL64((A24^D4), 14); +- A00 = B0 ^((~B1)& B2 ); +- A00 ^= RC[i+1]; +- A31 = B1 ^((~B2)& B3 ); +- A12 = B2 ^((~B3)& B4 ); +- A43 = B3 ^((~B4)& B0 ); +- A24 = B4 ^((~B0)& B1 ); +- +- B2 = ROL64((A40^D0), 3); +- B3 = ROL64((A21^D1), 45); +- B4 = ROL64((A02^D2), 61); +- B0 = ROL64((A33^D3), 28); +- B1 = ROL64((A14^D4), 20); +- A40 = B0 ^((~B1)& B2 ); +- A21 = B1 ^((~B2)& B3 ); +- A02 = B2 ^((~B3)& B4 ); +- A33 = B3 ^((~B4)& B0 ); +- A14 = B4 ^((~B0)& B1 ); +- +- B4 = ROL64((A30^D0), 18); +- B0 = ROL64((A11^D1), 1); +- B1 = ROL64((A42^D2), 6); +- B2 = ROL64((A23^D3), 25); +- B3 = ROL64((A04^D4), 8); +- A30 = B0 ^((~B1)& B2 ); +- A11 = B1 ^((~B2)& B3 ); +- A42 = B2 ^((~B3)& B4 ); +- A23 = B3 ^((~B4)& B0 ); +- A04 = B4 ^((~B0)& B1 ); +- +- B1 = ROL64((A20^D0), 36); +- B2 = ROL64((A01^D1), 10); +- B3 = ROL64((A32^D2), 15); +- B4 = ROL64((A13^D3), 56); +- B0 = ROL64((A44^D4), 27); +- A20 = B0 ^((~B1)& B2 ); +- A01 = B1 ^((~B2)& B3 ); +- A32 = B2 ^((~B3)& B4 ); +- A13 = B3 ^((~B4)& B0 ); +- A44 = B4 ^((~B0)& B1 ); +- +- B3 = ROL64((A10^D0), 41); +- B4 = ROL64((A41^D1), 2); +- B0 = ROL64((A22^D2), 62); +- B1 = ROL64((A03^D3), 55); +- B2 = ROL64((A34^D4), 39); +- A10 = B0 ^((~B1)& B2 ); +- A41 = B1 ^((~B2)& B3 ); +- A22 = B2 ^((~B3)& B4 ); +- A03 = B3 ^((~B4)& B0 ); +- A34 = B4 ^((~B0)& B1 ); +- +- C0 = A00^A40^A30^A20^A10; +- C1 = A31^A21^A11^A01^A41; +- C2 = A12^A02^A42^A32^A22; +- C3 = A43^A33^A23^A13^A03; +- C4 = A24^A14^A04^A44^A34; +- D0 = C4^ROL64(C1, 1); +- D1 = C0^ROL64(C2, 1); +- D2 = C1^ROL64(C3, 1); +- D3 = C2^ROL64(C4, 1); +- D4 = C3^ROL64(C0, 1); +- +- B0 = (A00^D0); +- B1 = ROL64((A21^D1), 44); +- B2 = ROL64((A42^D2), 43); +- B3 = ROL64((A13^D3), 21); +- B4 = ROL64((A34^D4), 14); +- A00 = B0 ^((~B1)& B2 ); +- A00 ^= RC[i+2]; +- A21 = B1 ^((~B2)& B3 ); +- A42 = B2 ^((~B3)& B4 ); +- A13 = B3 ^((~B4)& B0 ); +- A34 = B4 ^((~B0)& B1 ); +- +- B2 = ROL64((A30^D0), 3); +- B3 = ROL64((A01^D1), 45); +- B4 = ROL64((A22^D2), 61); +- B0 = ROL64((A43^D3), 28); +- B1 = ROL64((A14^D4), 20); +- A30 = B0 ^((~B1)& B2 ); +- A01 = B1 ^((~B2)& B3 ); +- A22 = B2 ^((~B3)& B4 ); +- A43 = B3 ^((~B4)& B0 ); +- A14 = B4 ^((~B0)& B1 ); +- +- B4 = ROL64((A10^D0), 18); +- B0 = ROL64((A31^D1), 1); +- B1 = ROL64((A02^D2), 6); +- B2 = ROL64((A23^D3), 25); +- B3 = ROL64((A44^D4), 8); +- A10 = B0 ^((~B1)& B2 ); +- A31 = B1 ^((~B2)& B3 ); +- A02 = B2 ^((~B3)& B4 ); +- A23 = B3 ^((~B4)& B0 ); +- A44 = B4 ^((~B0)& B1 ); +- +- B1 = ROL64((A40^D0), 36); +- B2 = ROL64((A11^D1), 10); +- B3 = ROL64((A32^D2), 15); +- B4 = ROL64((A03^D3), 56); +- B0 = ROL64((A24^D4), 27); +- A40 = B0 ^((~B1)& B2 ); +- A11 = B1 ^((~B2)& B3 ); +- A32 = B2 ^((~B3)& B4 ); +- A03 = B3 ^((~B4)& B0 ); +- A24 = B4 ^((~B0)& B1 ); +- +- B3 = ROL64((A20^D0), 41); +- B4 = ROL64((A41^D1), 2); +- B0 = ROL64((A12^D2), 62); +- B1 = ROL64((A33^D3), 55); +- B2 = ROL64((A04^D4), 39); +- A20 = B0 ^((~B1)& B2 ); +- A41 = B1 ^((~B2)& B3 ); +- A12 = B2 ^((~B3)& B4 ); +- A33 = B3 ^((~B4)& B0 ); +- A04 = B4 ^((~B0)& B1 ); +- +- C0 = A00^A30^A10^A40^A20; +- C1 = A21^A01^A31^A11^A41; +- C2 = A42^A22^A02^A32^A12; +- C3 = A13^A43^A23^A03^A33; +- C4 = A34^A14^A44^A24^A04; +- D0 = C4^ROL64(C1, 1); +- D1 = C0^ROL64(C2, 1); +- D2 = C1^ROL64(C3, 1); +- D3 = C2^ROL64(C4, 1); +- D4 = C3^ROL64(C0, 1); +- +- B0 = (A00^D0); +- B1 = ROL64((A01^D1), 44); +- B2 = ROL64((A02^D2), 43); +- B3 = ROL64((A03^D3), 21); +- B4 = ROL64((A04^D4), 14); +- A00 = B0 ^((~B1)& B2 ); +- A00 ^= RC[i+3]; +- A01 = B1 ^((~B2)& B3 ); +- A02 = B2 ^((~B3)& B4 ); +- A03 = B3 ^((~B4)& B0 ); +- A04 = B4 ^((~B0)& B1 ); +- +- B2 = ROL64((A10^D0), 3); +- B3 = ROL64((A11^D1), 45); +- B4 = ROL64((A12^D2), 61); +- B0 = ROL64((A13^D3), 28); +- B1 = ROL64((A14^D4), 20); +- A10 = B0 ^((~B1)& B2 ); +- A11 = B1 ^((~B2)& B3 ); +- A12 = B2 ^((~B3)& B4 ); +- A13 = B3 ^((~B4)& B0 ); +- A14 = B4 ^((~B0)& B1 ); +- +- B4 = ROL64((A20^D0), 18); +- B0 = ROL64((A21^D1), 1); +- B1 = ROL64((A22^D2), 6); +- B2 = ROL64((A23^D3), 25); +- B3 = ROL64((A24^D4), 8); +- A20 = B0 ^((~B1)& B2 ); +- A21 = B1 ^((~B2)& B3 ); +- A22 = B2 ^((~B3)& B4 ); +- A23 = B3 ^((~B4)& B0 ); +- A24 = B4 ^((~B0)& B1 ); +- +- B1 = ROL64((A30^D0), 36); +- B2 = ROL64((A31^D1), 10); +- B3 = ROL64((A32^D2), 15); +- B4 = ROL64((A33^D3), 56); +- B0 = ROL64((A34^D4), 27); +- A30 = B0 ^((~B1)& B2 ); +- A31 = B1 ^((~B2)& B3 ); +- A32 = B2 ^((~B3)& B4 ); +- A33 = B3 ^((~B4)& B0 ); +- A34 = B4 ^((~B0)& B1 ); +- +- B3 = ROL64((A40^D0), 41); +- B4 = ROL64((A41^D1), 2); +- B0 = ROL64((A42^D2), 62); +- B1 = ROL64((A43^D3), 55); +- B2 = ROL64((A44^D4), 39); +- A40 = B0 ^((~B1)& B2 ); +- A41 = B1 ^((~B2)& B3 ); +- A42 = B2 ^((~B3)& B4 ); +- A43 = B3 ^((~B4)& B0 ); +- A44 = B4 ^((~B0)& B1 ); +- } +-} +- +-/* +-** Initialize a new hash. iSize determines the size of the hash +-** in bits and should be one of 224, 256, 384, or 512. Or iSize +-** can be zero to use the default hash size of 256 bits. +-*/ +-static void SHA3Init(SHA3Context *p, int iSize){ +- memset(p, 0, sizeof(*p)); +- if( iSize>=128 && iSize<=512 ){ +- p->nRate = (1600 - ((iSize + 31)&~31)*2)/8; +- }else{ +- p->nRate = (1600 - 2*256)/8; +- } +-#if SHA3_BYTEORDER==1234 +- /* Known to be little-endian at compile-time. No-op */ +-#elif SHA3_BYTEORDER==4321 +- p->ixMask = 7; /* Big-endian */ +-#else +- { +- static unsigned int one = 1; +- if( 1==*(unsigned char*)&one ){ +- /* Little endian. No byte swapping. */ +- p->ixMask = 0; +- }else{ +- /* Big endian. Byte swap. */ +- p->ixMask = 7; +- } +- } +-#endif +-} +- +-/* +-** Make consecutive calls to the SHA3Update function to add new content +-** to the hash +-*/ +-static void SHA3Update( +- SHA3Context *p, +- const unsigned char *aData, +- unsigned int nData +-){ +- unsigned int i = 0; +-#if SHA3_BYTEORDER==1234 +- if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){ +- for(; i+7u.s[p->nLoaded/8] ^= *(u64*)&aData[i]; +- p->nLoaded += 8; +- if( p->nLoaded>=p->nRate ){ +- KeccakF1600Step(p); +- p->nLoaded = 0; +- } +- } +- } +-#endif +- for(; iu.x[p->nLoaded] ^= aData[i]; +-#elif SHA3_BYTEORDER==4321 +- p->u.x[p->nLoaded^0x07] ^= aData[i]; +-#else +- p->u.x[p->nLoaded^p->ixMask] ^= aData[i]; +-#endif +- p->nLoaded++; +- if( p->nLoaded==p->nRate ){ +- KeccakF1600Step(p); +- p->nLoaded = 0; +- } +- } +-} +- +-/* +-** After all content has been added, invoke SHA3Final() to compute +-** the final hash. The function returns a pointer to the binary +-** hash value. +-*/ +-static unsigned char *SHA3Final(SHA3Context *p){ +- unsigned int i; +- if( p->nLoaded==p->nRate-1 ){ +- const unsigned char c1 = 0x86; +- SHA3Update(p, &c1, 1); +- }else{ +- const unsigned char c2 = 0x06; +- const unsigned char c3 = 0x80; +- SHA3Update(p, &c2, 1); +- p->nLoaded = p->nRate - 1; +- SHA3Update(p, &c3, 1); +- } +- for(i=0; inRate; i++){ +- p->u.x[i+p->nRate] = p->u.x[i^p->ixMask]; +- } +- return &p->u.x[p->nRate]; +-} +- +-/* +-** Implementation of the sha3(X,SIZE) function. +-** +-** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default +-** size is 256. If X is a BLOB, it is hashed as is. +-** For all other non-NULL types of input, X is converted into a UTF-8 string +-** and the string is hashed without the trailing 0x00 terminator. The hash +-** of a NULL value is NULL. +-*/ +-static void sha3Func( +- sqlite3_context *context, +- int argc, +- sqlite3_value **argv +-){ +- SHA3Context cx; +- int eType = sqlite3_value_type(argv[0]); +- int nByte = sqlite3_value_bytes(argv[0]); +- int iSize; +- if( argc==1 ){ +- iSize = 256; +- }else{ +- iSize = sqlite3_value_int(argv[1]); +- if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){ +- sqlite3_result_error(context, "SHA3 size should be one of: 224 256 " +- "384 512", -1); +- return; +- } +- } +- if( eType==SQLITE_NULL ) return; +- SHA3Init(&cx, iSize); +- if( eType==SQLITE_BLOB ){ +- SHA3Update(&cx, sqlite3_value_blob(argv[0]), nByte); +- }else{ +- SHA3Update(&cx, sqlite3_value_text(argv[0]), nByte); +- } +- sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT); +-} +- +-/* Compute a string using sqlite3_vsnprintf() with a maximum length +-** of 50 bytes and add it to the hash. +-*/ +-static void hash_step_vformat( +- SHA3Context *p, /* Add content to this context */ +- const char *zFormat, +- ... +-){ +- va_list ap; +- int n; +- char zBuf[50]; +- va_start(ap, zFormat); +- sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap); +- va_end(ap); +- n = (int)strlen(zBuf); +- SHA3Update(p, (unsigned char*)zBuf, n); +-} +- +-/* +-** Implementation of the sha3_query(SQL,SIZE) function. +-** +-** This function compiles and runs the SQL statement(s) given in the +-** argument. The results are hashed using a SIZE-bit SHA3. The default +-** size is 256. +-** +-** The format of the byte stream that is hashed is summarized as follows: +-** +-** S: +-** R +-** N +-** I +-** F +-** B: +-** T: +-** +-** is the original SQL text for each statement run and is +-** the size of that text. The SQL text is UTF-8. A single R character +-** occurs before the start of each row. N means a NULL value. +-** I mean an 8-byte little-endian integer . F is a floating point +-** number with an 8-byte little-endian IEEE floating point value . +-** B means blobs of bytes. T means text rendered as +-** bytes of UTF-8. The and values are expressed as an ASCII +-** text integers. +-** +-** For each SQL statement in the X input, there is one S segment. Each +-** S segment is followed by zero or more R segments, one for each row in the +-** result set. After each R, there are one or more N, I, F, B, or T segments, +-** one for each column in the result set. Segments are concatentated directly +-** with no delimiters of any kind. +-*/ +-static void sha3QueryFunc( +- sqlite3_context *context, +- int argc, +- sqlite3_value **argv +-){ +- sqlite3 *db = sqlite3_context_db_handle(context); +- const char *zSql = (const char*)sqlite3_value_text(argv[0]); +- sqlite3_stmt *pStmt = 0; +- int nCol; /* Number of columns in the result set */ +- int i; /* Loop counter */ +- int rc; +- int n; +- const char *z; +- SHA3Context cx; +- int iSize; +- +- if( argc==1 ){ +- iSize = 256; +- }else{ +- iSize = sqlite3_value_int(argv[1]); +- if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){ +- sqlite3_result_error(context, "SHA3 size should be one of: 224 256 " +- "384 512", -1); +- return; +- } +- } +- if( zSql==0 ) return; +- SHA3Init(&cx, iSize); +- while( zSql[0] ){ +- rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql); +- if( rc ){ +- char *zMsg = sqlite3_mprintf("error SQL statement [%s]: %s", +- zSql, sqlite3_errmsg(db)); +- sqlite3_finalize(pStmt); +- sqlite3_result_error(context, zMsg, -1); +- sqlite3_free(zMsg); +- return; +- } +- if( !sqlite3_stmt_readonly(pStmt) ){ +- char *zMsg = sqlite3_mprintf("non-query: [%s]", sqlite3_sql(pStmt)); +- sqlite3_finalize(pStmt); +- sqlite3_result_error(context, zMsg, -1); +- sqlite3_free(zMsg); +- return; +- } +- nCol = sqlite3_column_count(pStmt); +- z = sqlite3_sql(pStmt); +- if( z==0 ){ +- sqlite3_finalize(pStmt); +- continue; +- } +- n = (int)strlen(z); +- hash_step_vformat(&cx,"S%d:",n); +- SHA3Update(&cx,(unsigned char*)z,n); +- +- /* Compute a hash over the result of the query */ +- while( SQLITE_ROW==sqlite3_step(pStmt) ){ +- SHA3Update(&cx,(const unsigned char*)"R",1); +- for(i=0; i=1; j--){ +- x[j] = u & 0xff; +- u >>= 8; +- } +- x[0] = 'I'; +- SHA3Update(&cx, x, 9); +- break; +- } +- case SQLITE_FLOAT: { +- sqlite3_uint64 u; +- int j; +- unsigned char x[9]; +- double r = sqlite3_column_double(pStmt,i); +- memcpy(&u, &r, 8); +- for(j=8; j>=1; j--){ +- x[j] = u & 0xff; +- u >>= 8; +- } +- x[0] = 'F'; +- SHA3Update(&cx,x,9); +- break; +- } +- case SQLITE_TEXT: { +- int n2 = sqlite3_column_bytes(pStmt, i); +- const unsigned char *z2 = sqlite3_column_text(pStmt, i); +- hash_step_vformat(&cx,"T%d:",n2); +- SHA3Update(&cx, z2, n2); +- break; +- } +- case SQLITE_BLOB: { +- int n2 = sqlite3_column_bytes(pStmt, i); +- const unsigned char *z2 = sqlite3_column_blob(pStmt, i); +- hash_step_vformat(&cx,"B%d:",n2); +- SHA3Update(&cx, z2, n2); +- break; +- } +- } +- } +- } +- sqlite3_finalize(pStmt); +- } +- sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT); +-} +-/* End of SHA3 hashing logic copy/pasted from ../ext/misc/shathree.c +-********************************************************************************/ + + #if defined(SQLITE_ENABLE_SESSION) + /* +@@ -1361,10 +579,13 @@ struct SavedModeInfo { + typedef struct ShellState ShellState; + struct ShellState { + sqlite3 *db; /* The database */ ++ int echoOn; /* True to echo input commands */ + int autoExplain; /* Automatically turn on .explain mode */ + int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ + int statsOn; /* True to display memory stats before each finalize */ + int scanstatsOn; /* True to display scan stats before each finalize */ ++ int countChanges; /* True to display change counts */ ++ int backslashOn; /* Resolve C-style \x escapes in SQL input text */ + int outCount; /* Revert to stdout when reaching zero */ + int cnt; /* Number of records displayed so far */ + FILE *out; /* Write results here */ +@@ -1403,20 +624,9 @@ struct ShellState { + /* + ** These are the allowed shellFlgs values + */ +-#define SHFLG_Scratch 0x00000001 /* The --scratch option is used */ +-#define SHFLG_Pagecache 0x00000002 /* The --pagecache option is used */ +-#define SHFLG_Lookaside 0x00000004 /* Lookaside memory is used */ +-#define SHFLG_Backslash 0x00000008 /* The --backslash option is used */ +-#define SHFLG_PreserveRowid 0x00000010 /* .dump preserves rowid values */ +-#define SHFLG_CountChanges 0x00000020 /* .changes setting */ +-#define SHFLG_Echo 0x00000040 /* .echo or --echo setting */ +- +-/* +-** Macros for testing and setting shellFlgs +-*/ +-#define ShellHasFlag(P,X) (((P)->shellFlgs & (X))!=0) +-#define ShellSetFlag(P,X) ((P)->shellFlgs|=(X)) +-#define ShellClearFlag(P,X) ((P)->shellFlgs&=(~(X))) ++#define SHFLG_Scratch 0x00001 /* The --scratch option is used */ ++#define SHFLG_Pagecache 0x00002 /* The --pagecache option is used */ ++#define SHFLG_Lookaside 0x00004 /* Lookaside memory is used */ + + /* + ** These are the allowed modes. +@@ -1434,7 +644,7 @@ struct ShellState { + #define MODE_Ascii 10 /* Use ASCII unit and record separators (0x1F/0x1E) */ + #define MODE_Pretty 11 /* Pretty-print schemas */ -static const char *modeDescr[] = { +static const char *const modeDescr[] = { "line", "column", "list", -@@ -856,7 +825,7 @@ static void output_csv(ShellState *p, co +@@ -1490,52 +700,32 @@ static void output_hex_blob(FILE *out, c + + /* + ** Output the given string as a quoted string using SQL quoting conventions. +-** +-** The "\n" and "\r" characters are converted to char(10) and char(13) +-** to prevent them from being transformed by end-of-line translators. + */ + static void output_quoted_string(FILE *out, const char *z){ + int i; +- char c; ++ int nSingle = 0; + setBinaryMode(out, 1); +- for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){} +- if( c==0 ){ ++ for(i=0; z[i]; i++){ ++ if( z[i]=='\'' ) nSingle++; ++ } ++ if( nSingle==0 ){ + utf8_printf(out,"'%s'",z); + }else{ +- int inQuote = 0; +- int bStarted = 0; ++ raw_printf(out,"'"); + while( *z ){ +- for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){} +- if( c=='\'' ) i++; +- if( i ){ +- if( !inQuote ){ +- if( bStarted ) raw_printf(out, "||"); +- raw_printf(out, "'"); +- inQuote = 1; +- } +- utf8_printf(out, "%.*s", i, z); +- z += i; +- bStarted = 1; +- } +- if( c=='\'' ){ +- raw_printf(out, "'"); +- continue; +- } +- if( inQuote ){ +- raw_printf(out, "'"); +- inQuote = 0; +- } +- if( c==0 ){ ++ for(i=0; z[i] && z[i]!='\''; i++){} ++ if( i==0 ){ ++ raw_printf(out,"''"); ++ z++; ++ }else if( z[i]=='\'' ){ ++ utf8_printf(out,"%.*s''",i,z); ++ z += i+1; ++ }else{ ++ utf8_printf(out,"%s",z); + break; + } +- for(i=0; (c = z[i])=='\r' || c=='\n'; i++){ +- if( bStarted ) raw_printf(out, "||"); +- raw_printf(out, "char(%d)", c); +- bStarted = 1; +- } +- z += i; + } +- if( inQuote ) raw_printf(out, "'"); ++ raw_printf(out,"'"); + } + setTextMode(out, 1); + } +@@ -1666,7 +856,7 @@ static void output_csv(ShellState *p, co } } @@ -7036,7 +13558,7 @@ /* ** This routine runs when the user presses Ctrl-C */ -@@ -866,6 +835,22 @@ static void interrupt_handler(int NotUse +@@ -1676,6 +866,22 @@ static void interrupt_handler(int NotUse if( seenInterrupt>2 ) exit(1); if( globalDb ) sqlite3_interrupt(globalDb); } @@ -7058,8 +13580,194 @@ +#endif #endif + #ifndef SQLITE_OMIT_AUTHORIZATION +@@ -1692,7 +898,7 @@ static int shellAuth( + const char *zA4 + ){ + ShellState *p = (ShellState*)pClientData; +- static const char *azAction[] = { 0, ++ static const char *const azAction[] = { 0, + "CREATE_INDEX", "CREATE_TABLE", "CREATE_TEMP_INDEX", + "CREATE_TEMP_TABLE", "CREATE_TEMP_TRIGGER", "CREATE_TEMP_VIEW", + "CREATE_TRIGGER", "CREATE_VIEW", "DELETE", +@@ -2027,13 +1233,9 @@ static int shell_callback( + }else if( aiType && aiType[i]==SQLITE_TEXT ){ + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); + output_quoted_string(p->out, azArg[i]); +- }else if( aiType && aiType[i]==SQLITE_INTEGER ){ ++ }else if( aiType && (aiType[i]==SQLITE_INTEGER ++ || aiType[i]==SQLITE_FLOAT) ){ + utf8_printf(p->out,"%s%s",zSep, azArg[i]); +- }else if( aiType && aiType[i]==SQLITE_FLOAT ){ +- char z[50]; +- double r = sqlite3_column_double(p->pStmt, i); +- sqlite3_snprintf(50,z,"%!.20g", r); +- raw_printf(p->out, "%s%s", zSep, z); + }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){ + const void *pBlob = sqlite3_column_blob(p->pStmt, i); + int nBlob = sqlite3_column_bytes(p->pStmt, i); +@@ -2079,78 +1281,13 @@ static int callback(void *pArg, int nArg + } + /* -@@ -1262,7 +1247,7 @@ static char *save_err_msg( +-** This is the callback routine from sqlite3_exec() that appends all +-** output onto the end of a ShellText object. +-*/ +-static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){ +- ShellText *p = (ShellText*)pArg; +- int i; +- UNUSED_PARAMETER(az); +- if( p->n ) appendText(p, "|", 0); +- for(i=0; idb, +- "SAVEPOINT selftest_init;\n" +- "CREATE TABLE IF NOT EXISTS selftest(\n" +- " tno INTEGER PRIMARY KEY,\n" /* Test number */ +- " op TEXT,\n" /* Operator: memo run */ +- " cmd TEXT,\n" /* Command text */ +- " ans TEXT\n" /* Desired answer */ +- ");" +- "CREATE TEMP TABLE [_shell$self](op,cmd,ans);\n" +- "INSERT INTO [_shell$self](rowid,op,cmd)\n" +- " VALUES(coalesce((SELECT (max(tno)+100)/10 FROM selftest),10),\n" +- " 'memo','Tests generated by --init');\n" +- "INSERT INTO [_shell$self]\n" +- " SELECT 'run',\n" +- " 'SELECT hex(sha3_query(''SELECT type,name,tbl_name,sql " +- "FROM sqlite_master ORDER BY 2'',224))',\n" +- " hex(sha3_query('SELECT type,name,tbl_name,sql " +- "FROM sqlite_master ORDER BY 2',224));\n" +- "INSERT INTO [_shell$self]\n" +- " SELECT 'run'," +- " 'SELECT hex(sha3_query(''SELECT * FROM \"' ||" +- " printf('%w',name) || '\" NOT INDEXED'',224))',\n" +- " hex(sha3_query(printf('SELECT * FROM \"%w\" NOT INDEXED',name),224))\n" +- " FROM (\n" +- " SELECT name FROM sqlite_master\n" +- " WHERE type='table'\n" +- " AND name<>'selftest'\n" +- " AND coalesce(rootpage,0)>0\n" +- " )\n" +- " ORDER BY name;\n" +- "INSERT INTO [_shell$self]\n" +- " VALUES('run','PRAGMA integrity_check','ok');\n" +- "INSERT INTO selftest(tno,op,cmd,ans)" +- " SELECT rowid*10,op,cmd,ans FROM [_shell$self];\n" +- "DROP TABLE [_shell$self];" +- ,0,0,&zErrMsg); +- if( zErrMsg ){ +- utf8_printf(stderr, "SELFTEST initialization failure: %s\n", zErrMsg); +- sqlite3_free(zErrMsg); +- } +- sqlite3_exec(p->db, "RELEASE selftest_init",0,0,0); +-} +- +- +-/* + ** Set the destination table field of the ShellState structure to + ** the name of the table given. Escape any quote characters in the + ** table name. + */ + static void set_table_name(ShellState *p, const char *zName){ + int i, n; +- int cQuote; ++ int needQuote; + char *z; + + if( p->zDestTable ){ +@@ -2158,24 +1295,74 @@ static void set_table_name(ShellState *p + p->zDestTable = 0; + } + if( zName==0 ) return; +- cQuote = quoteChar(zName); +- n = strlen30(zName); +- if( cQuote ) n += 2; ++ needQuote = !isalpha((unsigned char)*zName) && *zName!='_'; ++ for(i=n=0; zName[i]; i++, n++){ ++ if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ){ ++ needQuote = 1; ++ if( zName[i]=='\'' ) n++; ++ } ++ } ++ if( needQuote ) n += 2; + z = p->zDestTable = malloc( n+1 ); + if( z==0 ){ + raw_printf(stderr,"Error: out of memory\n"); + exit(1); + } + n = 0; +- if( cQuote ) z[n++] = cQuote; ++ if( needQuote ) z[n++] = '\''; + for(i=0; zName[i]; i++){ + z[n++] = zName[i]; +- if( zName[i]==cQuote ) z[n++] = cQuote; ++ if( zName[i]=='\'' ) z[n++] = '\''; + } +- if( cQuote ) z[n++] = cQuote; ++ if( needQuote ) z[n++] = '\''; + z[n] = 0; + } + ++/* zIn is either a pointer to a NULL-terminated string in memory obtained ++** from malloc(), or a NULL pointer. The string pointed to by zAppend is ++** added to zIn, and the result returned in memory obtained from malloc(). ++** zIn, if it was not NULL, is freed. ++** ++** If the third argument, quote, is not '\0', then it is used as a ++** quote character for zAppend. ++*/ ++static char *appendText(char *zIn, char const *zAppend, char quote){ ++ int len; ++ int i; ++ int nAppend = strlen30(zAppend); ++ int nIn = (zIn?strlen30(zIn):0); ++ ++ len = nAppend+nIn+1; ++ if( quote ){ ++ len += 2; ++ for(i=0; i1 ){ +- sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iCur, iHiwtr); +- }else{ +- sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iHiwtr); +- } +- raw_printf(p->out, "%-36s %s\n", zLabel, zLine); +-} + + /* + ** Display memory stats. +@@ -2322,31 +1484,55 @@ static int display_stats( int iHiwtr; if( pArg && pArg->out ){ -- -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset); +- displayStatLine(pArg, "Memory Used:", +- "%lld (max %lld) bytes", SQLITE_STATUS_MEMORY_USED, bReset); +- displayStatLine(pArg, "Number of Outstanding Allocations:", +- "%lld (max %lld)", SQLITE_STATUS_MALLOC_COUNT, bReset); + char buf[64]; + sqlite3_int64 iHiwtr64 = -1, iCur64 = -1; + + sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &iCur64, &iHiwtr64, bReset); + sqlite3_snprintf(sizeof(buf), buf, "%lld (max %lld)", iCur64, iHiwtr64); - raw_printf(pArg->out, -- "Memory Used: %d (max %d) bytes\n", -- iCur, iHiwtr); -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", -- iCur, iHiwtr); ++ raw_printf(pArg->out, + "Memory Used: %s bytes\n", buf); + iHiwtr64 = iCur64 = -1; + sqlite3_status64(SQLITE_STATUS_MALLOC_COUNT, &iCur64, &iHiwtr64, bReset); + sqlite3_snprintf(sizeof(buf), buf, "%lld (max %lld)", iCur64, iHiwtr64); + raw_printf(pArg->out, "Number of Outstanding Allocations: %s\n", buf); if( pArg->shellFlgs & SHFLG_Pagecache ){ -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset); +- displayStatLine(pArg, "Number of Pcache Pages Used:", +- "%lld (max %lld) pages", SQLITE_STATUS_PAGECACHE_USED, bReset); + iHiwtr64 = iCur64 = -1; + sqlite3_status64(SQLITE_STATUS_PAGECACHE_USED, &iCur64, &iHiwtr64, bReset); + sqlite3_snprintf(sizeof(buf), buf, "%lld (max %lld)", iCur64, iHiwtr64); - raw_printf(pArg->out, -- "Number of Pcache Pages Used: %d (max %d) pages\n", -- iCur, iHiwtr); ++ raw_printf(pArg->out, + "Number of Pcache Pages Used: %s pages\n", buf); } -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, -- "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", -- iCur, iHiwtr); +- displayStatLine(pArg, "Number of Pcache Overflow Bytes:", +- "%lld (max %lld) bytes", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset); + iHiwtr64 = iCur64 = -1; + sqlite3_status64(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur64, &iHiwtr64, bReset); + sqlite3_snprintf(sizeof(buf), buf, "%lld (max %lld)", iCur64, iHiwtr64); + raw_printf(pArg->out, "Number of Pcache Overflow Bytes: %s bytes\n", buf); if( pArg->shellFlgs & SHFLG_Scratch ){ -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, -- "Number of Scratch Allocations Used: %d (max %d)\n", -- iCur, iHiwtr); +- displayStatLine(pArg, "Number of Scratch Allocations Used:", +- "%lld (max %lld)", SQLITE_STATUS_SCRATCH_USED, bReset); - } -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, -- "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", -- iCur, iHiwtr); -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, "Largest Allocation: %d bytes\n", -- iHiwtr); -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, "Largest Pcache Allocation: %d bytes\n", -- iHiwtr); -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, "Largest Scratch Allocation: %d bytes\n", -- iHiwtr); +- displayStatLine(pArg, "Number of Scratch Overflow Bytes:", +- "%lld (max %lld) bytes", SQLITE_STATUS_SCRATCH_OVERFLOW, bReset); +- displayStatLine(pArg, "Largest Allocation:", +- "%lld bytes", SQLITE_STATUS_MALLOC_SIZE, bReset); +- displayStatLine(pArg, "Largest Pcache Allocation:", +- "%lld bytes", SQLITE_STATUS_PAGECACHE_SIZE, bReset); +- displayStatLine(pArg, "Largest Scratch Allocation:", +- "%lld bytes", SQLITE_STATUS_SCRATCH_SIZE, bReset); + iHiwtr64 = iCur64 = -1; + sqlite3_status64(SQLITE_STATUS_SCRATCH_USED, &iCur64, &iHiwtr64, bReset); + sqlite3_snprintf(sizeof(buf), buf, "%lld (max %lld)", iCur64, iHiwtr64); @@ -7158,10 +13876,8 @@ + sqlite3_snprintf(sizeof(buf), buf, "%lld", iCur64); + raw_printf(pArg->out, "Largest Scratch Allocation: %s bytes\n", buf); #ifdef YYTRACKMAXSTACKDEPTH -- iHiwtr = iCur = -1; -- sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset); -- raw_printf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", -- iCur, iHiwtr); +- displayStatLine(pArg, "Deepest Parser Stack:", +- "%lld (max %lld)", SQLITE_STATUS_PARSER_STACK, bReset); + iHiwtr64 = iCur64 = -1; + sqlite3_status64(SQLITE_STATUS_PARSER_STACK, &iCur64, &iHiwtr64, bReset); + sqlite3_snprintf(sizeof(buf), buf, "%lld (max %lld)", iCur64, iHiwtr64); @@ -7169,7 +13885,7 @@ #endif } -@@ -1450,7 +1433,7 @@ static void display_scanstats( +@@ -2469,7 +1655,7 @@ static void display_scanstats( ** is equal, according to strcmp(), to any of the strings in the array. ** Otherwise, return zero. */ @@ -7178,7 +13894,7 @@ int i; for(i=0; azArray[i]; i++){ if( 0==strcmp(zStr, azArray[i]) ) return 1; -@@ -1483,11 +1466,11 @@ static void explain_data_prepare(ShellSt +@@ -2502,11 +1688,11 @@ static void explain_data_prepare(ShellSt int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */ int iOp; /* Index of operation in p->aiIndent[] */ @@ -7193,9 +13909,18 @@ /* Try to figure out if this is really an EXPLAIN statement. If this ** cannot be verified, return early. */ -@@ -1512,8 +1495,8 @@ static void explain_data_prepare(ShellSt - /* Grow the p->aiIndent array as required */ - if( iOp>=nAlloc ){ +@@ -2540,7 +1726,7 @@ static void explain_data_prepare(ShellSt + if( iOp==0 ){ + /* Do further verfication that this is explain output. Abort if + ** it is not */ +- static const char *explainCols[] = { ++ static const char *const explainCols[] = { + "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment" }; + int jj; + for(jj=0; jjaiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int)); - abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int)); @@ -7204,25 +13929,418 @@ } abYield[iOp] = str_in_array(zOp, azYield); p->aiIndent[iOp] = 0; -@@ -1630,7 +1613,7 @@ static int shell_exec( - if( xCallback ){ - /* allocate space for col name ptr, value ptr, and type */ - int nCol = sqlite3_column_count(pStmt); -- void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1); -+ void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1); - if( !pData ){ - rc = SQLITE_NOMEM; - }else{ -@@ -1951,7 +1934,7 @@ static void readfileFunc( +@@ -2634,7 +1820,7 @@ static void exec_prepared_stmt( + if( xCallback ){ + /* allocate space for col name ptr, value ptr, and type */ + int nCol = sqlite3_column_count(pStmt); +- void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1); ++ void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1); + if( !pData ){ + rc = SQLITE_NOMEM; + }else{ +@@ -2733,7 +1919,7 @@ static int shell_exec( + } + + /* echo the sql statement if echo on */ +- if( pArg && ShellHasFlag(pArg, SHFLG_Echo) ){ ++ if( pArg && pArg->echoOn ){ + utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); + } + +@@ -2821,137 +2007,6 @@ static int shell_exec( + return rc; + } + +-/* +-** Release memory previously allocated by tableColumnList(). +-*/ +-static void freeColumnList(char **azCol){ +- int i; +- for(i=1; azCol[i]; i++){ +- sqlite3_free(azCol[i]); +- } +- /* azCol[0] is a static string */ +- sqlite3_free(azCol); +-} +- +-/* +-** Return a list of pointers to strings which are the names of all +-** columns in table zTab. The memory to hold the names is dynamically +-** allocated and must be released by the caller using a subsequent call +-** to freeColumnList(). +-** +-** The azCol[0] entry is usually NULL. However, if zTab contains a rowid +-** value that needs to be preserved, then azCol[0] is filled in with the +-** name of the rowid column. +-** +-** The first regular column in the table is azCol[1]. The list is terminated +-** by an entry with azCol[i]==0. +-*/ +-static char **tableColumnList(ShellState *p, const char *zTab){ +- char **azCol = 0; +- sqlite3_stmt *pStmt; +- char *zSql; +- int nCol = 0; +- int nAlloc = 0; +- int nPK = 0; /* Number of PRIMARY KEY columns seen */ +- int isIPK = 0; /* True if one PRIMARY KEY column of type INTEGER */ +- int preserveRowid = ShellHasFlag(p, SHFLG_PreserveRowid); +- int rc; +- +- zSql = sqlite3_mprintf("PRAGMA table_info=%Q", zTab); +- rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); +- sqlite3_free(zSql); +- if( rc ) return 0; +- while( sqlite3_step(pStmt)==SQLITE_ROW ){ +- if( nCol>=nAlloc-2 ){ +- nAlloc = nAlloc*2 + nCol + 10; +- azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0])); +- if( azCol==0 ){ +- raw_printf(stderr, "Error: out of memory\n"); +- exit(1); +- } +- } +- azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1)); +- if( sqlite3_column_int(pStmt, 5) ){ +- nPK++; +- if( nPK==1 +- && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2), +- "INTEGER")==0 +- ){ +- isIPK = 1; +- }else{ +- isIPK = 0; +- } +- } +- } +- sqlite3_finalize(pStmt); +- azCol[0] = 0; +- azCol[nCol+1] = 0; +- +- /* The decision of whether or not a rowid really needs to be preserved +- ** is tricky. We never need to preserve a rowid for a WITHOUT ROWID table +- ** or a table with an INTEGER PRIMARY KEY. We are unable to preserve +- ** rowids on tables where the rowid is inaccessible because there are other +- ** columns in the table named "rowid", "_rowid_", and "oid". +- */ +- if( preserveRowid && isIPK ){ +- /* If a single PRIMARY KEY column with type INTEGER was seen, then it +- ** might be an alise for the ROWID. But it might also be a WITHOUT ROWID +- ** table or a INTEGER PRIMARY KEY DESC column, neither of which are +- ** ROWID aliases. To distinguish these cases, check to see if +- ** there is a "pk" entry in "PRAGMA index_list". There will be +- ** no "pk" index if the PRIMARY KEY really is an alias for the ROWID. +- */ +- zSql = sqlite3_mprintf("SELECT 1 FROM pragma_index_list(%Q)" +- " WHERE origin='pk'", zTab); +- rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); +- sqlite3_free(zSql); +- if( rc ){ +- freeColumnList(azCol); +- return 0; +- } +- rc = sqlite3_step(pStmt); +- sqlite3_finalize(pStmt); +- preserveRowid = rc==SQLITE_ROW; +- } +- if( preserveRowid ){ +- /* Only preserve the rowid if we can find a name to use for the +- ** rowid */ +- static char *azRowid[] = { "rowid", "_rowid_", "oid" }; +- int i, j; +- for(j=0; j<3; j++){ +- for(i=1; i<=nCol; i++){ +- if( sqlite3_stricmp(azRowid[j],azCol[i])==0 ) break; +- } +- if( i>nCol ){ +- /* At this point, we know that azRowid[j] is not the name of any +- ** ordinary column in the table. Verify that azRowid[j] is a valid +- ** name for the rowid before adding it to azCol[0]. WITHOUT ROWID +- ** tables will fail this last check */ +- rc = sqlite3_table_column_metadata(p->db,0,zTab,azRowid[j],0,0,0,0,0); +- if( rc==SQLITE_OK ) azCol[0] = azRowid[j]; +- break; +- } +- } +- } +- return azCol; +-} +- +-/* +-** Toggle the reverse_unordered_selects setting. +-*/ +-static void toggleSelectOrder(sqlite3 *db){ +- sqlite3_stmt *pStmt = 0; +- int iSetting = 0; +- char zStmt[100]; +- sqlite3_prepare_v2(db, "PRAGMA reverse_unordered_selects", -1, &pStmt, 0); +- if( sqlite3_step(pStmt)==SQLITE_ROW ){ +- iSetting = sqlite3_column_int(pStmt, 0); +- } +- sqlite3_finalize(pStmt); +- sqlite3_snprintf(sizeof(zStmt), zStmt, +- "PRAGMA reverse_unordered_selects(%d)", !iSetting); +- sqlite3_exec(db, zStmt, 0, 0, 0); +-} + + /* + ** This is a different callback routine used for dumping the database. +@@ -2959,21 +2014,22 @@ static void toggleSelectOrder(sqlite3 *d + ** the table type ("index" or "table") and SQL to create the table. + ** This routine should print text sufficient to recreate the table. + */ +-static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){ ++static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ + int rc; + const char *zTable; + const char *zType; + const char *zSql; ++ const char *zPrepStmt = 0; + ShellState *p = (ShellState *)pArg; + +- UNUSED_PARAMETER(azNotUsed); ++ UNUSED_PARAMETER(azCol); + if( nArg!=3 ) return 1; + zTable = azArg[0]; + zType = azArg[1]; + zSql = azArg[2]; + + if( strcmp(zTable, "sqlite_sequence")==0 ){ +- raw_printf(p->out, "DELETE FROM sqlite_sequence;\n"); ++ zPrepStmt = "DELETE FROM sqlite_sequence;\n"; + }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){ + raw_printf(p->out, "ANALYZE sqlite_master;\n"); + }else if( strncmp(zTable, "sqlite_", 7)==0 ){ +@@ -2996,70 +2052,58 @@ static int dump_callback(void *pArg, int + } + + if( strcmp(zType, "table")==0 ){ +- ShellText sSelect; +- ShellText sTable; +- char **azCol; +- int i; +- char *savedDestTable; +- int savedMode; +- +- azCol = tableColumnList(p, zTable); +- if( azCol==0 ){ +- p->nErr++; +- return 0; ++ sqlite3_stmt *pTableInfo = 0; ++ char *zSelect = 0; ++ char *zTableInfo = 0; ++ char *zTmp = 0; ++ int nRow = 0; ++ ++ zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0); ++ zTableInfo = appendText(zTableInfo, zTable, '"'); ++ zTableInfo = appendText(zTableInfo, ");", 0); ++ ++ rc = sqlite3_prepare_v2(p->db, zTableInfo, -1, &pTableInfo, 0); ++ free(zTableInfo); ++ if( rc!=SQLITE_OK || !pTableInfo ){ ++ return 1; + } + ++ zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0); + /* Always quote the table name, even if it appears to be pure ascii, + ** in case it is a keyword. Ex: INSERT INTO "table" ... */ +- initText(&sTable); +- appendText(&sTable, zTable, quoteChar(zTable)); +- /* If preserving the rowid, add a column list after the table name. +- ** In other words: "INSERT INTO tab(rowid,a,b,c,...) VALUES(...)" +- ** instead of the usual "INSERT INTO tab VALUES(...)". +- */ +- if( azCol[0] ){ +- appendText(&sTable, "(", 0); +- appendText(&sTable, azCol[0], 0); +- for(i=1; azCol[i]; i++){ +- appendText(&sTable, ",", 0); +- appendText(&sTable, azCol[i], quoteChar(azCol[i])); +- } +- appendText(&sTable, ")", 0); +- } +- +- /* Build an appropriate SELECT statement */ +- initText(&sSelect); +- appendText(&sSelect, "SELECT ", 0); +- if( azCol[0] ){ +- appendText(&sSelect, azCol[0], 0); +- appendText(&sSelect, ",", 0); +- } +- for(i=1; azCol[i]; i++){ +- appendText(&sSelect, azCol[i], quoteChar(azCol[i])); +- if( azCol[i+1] ){ +- appendText(&sSelect, ",", 0); +- } +- } +- freeColumnList(azCol); +- appendText(&sSelect, " FROM ", 0); +- appendText(&sSelect, zTable, quoteChar(zTable)); +- +- savedDestTable = p->zDestTable; +- savedMode = p->mode; +- p->zDestTable = sTable.z; +- p->mode = p->cMode = MODE_Insert; +- rc = shell_exec(p->db, sSelect.z, shell_callback, p, 0); +- if( (rc&0xff)==SQLITE_CORRUPT ){ +- raw_printf(p->out, "/****** CORRUPTION ERROR *******/\n"); +- toggleSelectOrder(p->db); +- shell_exec(p->db, sSelect.z, shell_callback, p, 0); +- toggleSelectOrder(p->db); +- } +- p->zDestTable = savedDestTable; +- p->mode = savedMode; +- freeText(&sTable); +- freeText(&sSelect); +- if( rc ) p->nErr++; ++ zTmp = appendText(zTmp, zTable, '"'); ++ if( zTmp ){ ++ zSelect = appendText(zSelect, zTmp, '\''); ++ free(zTmp); ++ } ++ zSelect = appendText(zSelect, " || ' VALUES(' || ", 0); ++ rc = sqlite3_step(pTableInfo); ++ while( rc==SQLITE_ROW ){ ++ const char *zText = (const char *)sqlite3_column_text(pTableInfo, 1); ++ zSelect = appendText(zSelect, "quote(", 0); ++ zSelect = appendText(zSelect, zText, '"'); ++ rc = sqlite3_step(pTableInfo); ++ if( rc==SQLITE_ROW ){ ++ zSelect = appendText(zSelect, "), ", 0); ++ }else{ ++ zSelect = appendText(zSelect, ") ", 0); ++ } ++ nRow++; ++ } ++ rc = sqlite3_finalize(pTableInfo); ++ if( rc!=SQLITE_OK || nRow==0 ){ ++ free(zSelect); ++ return 1; ++ } ++ zSelect = appendText(zSelect, "|| ')' FROM ", 0); ++ zSelect = appendText(zSelect, zTable, '"'); ++ ++ rc = run_table_dump_query(p, zSelect, zPrepStmt); ++ if( rc==SQLITE_CORRUPT ){ ++ zSelect = appendText(zSelect, " ORDER BY rowid DESC", 0); ++ run_table_dump_query(p, zSelect, 0); ++ } ++ free(zSelect); + } + return 0; + } +@@ -3151,7 +2195,7 @@ static char zHelp[] = + " html HTML code\n" + " insert SQL insert statements for TABLE\n" + " line One value per line\n" +- " list Values delimited by \"|\"\n" ++ " list Values delimited by .separator strings\n" + " quote Escape answers as for SQL\n" + " tabs Tab-separated values\n" + " tcl TCL list elements\n" +@@ -3169,13 +2213,11 @@ static char zHelp[] = + ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n" + ".schema ?PATTERN? Show the CREATE statements matching PATTERN\n" + " Add --indent for pretty-printing\n" +- ".selftest ?--init? Run tests defined in the SELFTEST table\n" + ".separator COL ?ROW? Change the column separator and optionally the row\n" + " separator for both the output mode and .import\n" + #if defined(SQLITE_ENABLE_SESSION) + ".session CMD ... Create or control sessions\n" + #endif +- ".sha3sum ?OPTIONS...? Compute a SHA3 hash of database content\n" + ".shell CMD ARGS... Run CMD ARGS... in a system shell\n" + ".show Show the current values for various settings\n" + ".stats ?on|off? Show stats or turn stats on or off\n" +@@ -3236,16 +2278,16 @@ static int process_input(ShellState *p, + ** NULL is returned if any error is encountered. The final value of *pnByte + ** is undefined in this case. + */ +-static char *readFile(const char *zName, int *pnByte){ ++static char *readFile(const char *zName, size_t *pnByte){ + FILE *in = fopen(zName, "rb"); +- long nIn; ++ size_t nIn; + size_t nRead; + char *pBuf; + if( in==0 ) return 0; fseek(in, 0, SEEK_END); nIn = ftell(in); rewind(in); -- pBuf = sqlite3_malloc64( nIn ); -+ pBuf = sqlite3_malloc( nIn ); - if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ - sqlite3_result_blob(context, pBuf, nIn, sqlite3_free); - }else{ -@@ -2230,7 +2213,7 @@ struct ImportCtx { +- pBuf = sqlite3_malloc64( nIn+1 ); ++ pBuf = sqlite3_malloc( nIn+1 ); + if( pBuf==0 ) return 0; + nRead = fread(pBuf, nIn, 1, in); + fclose(in); +@@ -3270,7 +2312,7 @@ static void readfileFunc( + ){ + const char *zName; + void *pBuf; +- int nBuf; ++ size_t nBuf; + + UNUSED_PARAMETER(argc); + zName = (const char*)sqlite3_value_text(argv[0]); +@@ -3366,6 +2408,10 @@ static void open_db(ShellState *p, int k + sqlite3_initialize(); + sqlite3_open(p->zDbFilename, &p->db); + globalDb = p->db; ++ if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){ ++ sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0, ++ shellstaticFunc, 0, 0); ++ } + if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){ + utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n", + p->zDbFilename, sqlite3_errmsg(p->db)); +@@ -3375,18 +2421,11 @@ static void open_db(ShellState *p, int k + #ifndef SQLITE_OMIT_LOAD_EXTENSION + sqlite3_enable_load_extension(p->db, 1); + #endif ++ sqlite3_db_config(p->db, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, (char *)0); + sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0, + readfileFunc, 0, 0); + sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0, + writefileFunc, 0, 0); +- sqlite3_create_function(p->db, "sha3", 1, SQLITE_UTF8, 0, +- sha3Func, 0, 0); +- sqlite3_create_function(p->db, "sha3", 2, SQLITE_UTF8, 0, +- sha3Func, 0, 0); +- sqlite3_create_function(p->db, "sha3_query", 1, SQLITE_UTF8, 0, +- sha3QueryFunc, 0, 0); +- sqlite3_create_function(p->db, "sha3_query", 2, SQLITE_UTF8, 0, +- sha3QueryFunc, 0, 0); + } + } + +@@ -3466,7 +2505,7 @@ static int hexDigitValue(char c){ + */ + static sqlite3_int64 integerValue(const char *zArg){ + sqlite3_int64 v = 0; +- static const struct { char *zSuffix; int iMult; } aMult[] = { ++ static const struct { char zSuffix[4]; int iMult; } aMult[] = { + { "KiB", 1024 }, + { "MiB", 1024*1024 }, + { "GiB", 1024*1024*1024 }, +@@ -3531,17 +2570,6 @@ static int booleanValue(const char *zArg + } + + /* +-** Set or clear a shell flag according to a boolean value. +-*/ +-static void setOrClearFlag(ShellState *p, unsigned mFlag, const char *zArg){ +- if( booleanValue(zArg) ){ +- ShellSetFlag(p, mFlag); +- }else{ +- ShellClearFlag(p, mFlag); +- } +-} +- +-/* + ** Close an output file, assuming it is not stderr or stdout + */ + static void output_file_close(FILE *f){ +@@ -3624,7 +2652,7 @@ struct ImportCtx { static void import_append_char(ImportCtx *p, int c){ if( p->n+1>=p->nAlloc ){ p->nAlloc += p->nAlloc + 100; @@ -7231,25 +14349,7 @@ if( p->z==0 ){ raw_printf(stderr, "out of memory\n"); exit(1); -@@ -2244,7 +2227,7 @@ static void import_append_char(ImportCtx - ** - ** + Input comes from p->in. - ** + Store results in p->z of length p->n. Space to hold p->z comes --** from sqlite3_malloc64(). -+** from sqlite3_malloc(). - ** + Use p->cSep as the column separator. The default is ",". - ** + Use p->rSep as the row separator. The default is "\n". - ** + Keep track of the line number in p->nLine. -@@ -2318,7 +2301,7 @@ static char *SQLITE_CDECL csv_read_one_f - ** - ** + Input comes from p->in. - ** + Store results in p->z of length p->n. Space to hold p->z comes --** from sqlite3_malloc64(). -+** from sqlite3_malloc(). - ** + Use p->cSep as the column separator. The default is "\x1F". - ** + Use p->rSep as the row separator. The default is "\x1E". - ** + Keep track of the row number in p->nLine. -@@ -2378,7 +2361,7 @@ static void tryToCloneData( +@@ -3772,7 +2800,7 @@ static void tryToCloneData( goto end_data_xfer; } n = sqlite3_column_count(pQuery); @@ -7258,7 +14358,117 @@ if( zInsert==0 ){ raw_printf(stderr, "out of memory\n"); goto end_data_xfer; -@@ -3172,7 +3155,7 @@ static int do_meta_command(char *zLine, +@@ -4614,7 +3642,7 @@ static int do_meta_command(char *zLine, + + if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){ + if( nArg==2 ){ +- setOrClearFlag(p, SHFLG_CountChanges, azArg[1]); ++ p->countChanges = booleanValue(azArg[1]); + }else{ + raw_printf(stderr, "Usage: .changes on|off\n"); + rc = 1; +@@ -4678,49 +3706,21 @@ static int do_meta_command(char *zLine, + }else + + if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){ +- const char *zLike = 0; +- int i; +- ShellClearFlag(p, SHFLG_PreserveRowid); +- for(i=1; iout, "PRAGMA foreign_keys=OFF;\n"); + raw_printf(p->out, "BEGIN TRANSACTION;\n"); + p->writableSchema = 0; +- /* Set writable_schema=ON since doing so forces SQLite to initialize +- ** as much of the schema as it can even if the sqlite_master table is +- ** corrupt. */ + sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0); + p->nErr = 0; +- if( zLike==0 ){ ++ if( nArg==1 ){ + run_schema_dump_query(p, + "SELECT name, type, sql FROM sqlite_master " + "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'" +@@ -4734,20 +3734,21 @@ static int do_meta_command(char *zLine, + "WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0 + ); + }else{ +- char *zSql; +- zSql = sqlite3_mprintf( +- "SELECT name, type, sql FROM sqlite_master " +- "WHERE tbl_name LIKE %Q AND type=='table'" +- " AND sql NOT NULL", zLike); +- run_schema_dump_query(p,zSql); +- sqlite3_free(zSql); +- zSql = sqlite3_mprintf( +- "SELECT sql FROM sqlite_master " +- "WHERE sql NOT NULL" +- " AND type IN ('index','trigger','view')" +- " AND tbl_name LIKE %Q", zLike); +- run_table_dump_query(p, zSql, 0); +- sqlite3_free(zSql); ++ int i; ++ for(i=1; iwritableSchema ){ + raw_printf(p->out, "PRAGMA writable_schema=OFF;\n"); +@@ -4760,7 +3761,7 @@ static int do_meta_command(char *zLine, + + if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){ + if( nArg==2 ){ +- setOrClearFlag(p, SHFLG_Echo, azArg[1]); ++ p->echoOn = booleanValue(azArg[1]); + }else{ + raw_printf(stderr, "Usage: .echo on|off\n"); + rc = 1; +@@ -5000,7 +4001,7 @@ static int do_meta_command(char *zLine, sqlite3_finalize(pStmt); pStmt = 0; if( nCol==0 ) return 0; /* no columns, no error */ @@ -7267,16 +14477,309 @@ if( zSql==0 ){ raw_printf(stderr, "Error: out of memory\n"); xCloser(sCtx.in); -@@ -3293,7 +3276,7 @@ static int do_meta_command(char *zLine, +@@ -5327,7 +4328,6 @@ static int do_meta_command(char *zLine, + session_close_all(p); + sqlite3_close(p->db); + p->db = 0; +- p->zDbFilename = 0; + sqlite3_free(p->zFreeOnClose); + p->zFreeOnClose = 0; + /* Check for command-line arguments */ +@@ -5557,17 +4557,17 @@ static int do_meta_command(char *zLine, + callback(&data, 1, new_argv, new_colv); + rc = SQLITE_OK; + }else{ +- char *zSql; +- zSql = sqlite3_mprintf( ++ zShellStatic = azArg[1]; ++ rc = sqlite3_exec(p->db, + "SELECT sql FROM " + " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" + " FROM sqlite_master UNION ALL" + " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " +- "WHERE lower(tbl_name) LIKE %Q" ++ "WHERE lower(tbl_name) LIKE shellstatic()" + " AND type!='meta' AND sql NOTNULL " +- "ORDER BY rowid", azArg[1]); +- rc = sqlite3_exec(p->db, zSql, callback, &data, &zErrMsg); +- sqlite3_free(zSql); ++ "ORDER BY rowid", ++ callback, &data, &zErrMsg); ++ zShellStatic = 0; + } + }else if( nArg==1 ){ + rc = sqlite3_exec(p->db, +@@ -5598,7 +4598,7 @@ static int do_meta_command(char *zLine, - #ifdef SQLITE_ENABLE_IOTRACE - if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){ -- SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...); -+ extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...); - if( iotrace && iotrace!=stdout ) fclose(iotrace); - iotrace = 0; - if( nArg<2 ){ -@@ -3865,7 +3848,7 @@ static int do_meta_command(char *zLine, + #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE) + if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){ +- sqlite3SelectTrace = (int)integerValue(azArg[1]); ++ sqlite3SelectTrace = integerValue(azArg[1]); + }else + #endif + +@@ -5821,119 +4821,6 @@ static int do_meta_command(char *zLine, + }else + #endif + +- if( c=='s' && n>=4 && strncmp(azArg[0],"selftest",n)==0 ){ +- int bIsInit = 0; /* True to initialize the SELFTEST table */ +- int bVerbose = 0; /* Verbose output */ +- int bSelftestExists; /* True if SELFTEST already exists */ +- char **azTest = 0; /* Content of the SELFTEST table */ +- int nRow = 0; /* Number of rows in the SELFTEST table */ +- int nCol = 4; /* Number of columns in the SELFTEST table */ +- int i; /* Loop counter */ +- int nTest = 0; /* Number of tests runs */ +- int nErr = 0; /* Number of errors seen */ +- ShellText str; /* Answer for a query */ +- static char *azDefaultTest[] = { +- 0, 0, 0, 0, +- "0", "memo", "Missing SELFTEST table - default checks only", "", +- "1", "run", "PRAGMA integrity_check", "ok" +- }; +- static const int nDefaultRow = 2; +- +- open_db(p,0); +- for(i=1; idb,"main","selftest",0,0,0,0,0,0) +- != SQLITE_OK ){ +- bSelftestExists = 0; +- }else{ +- bSelftestExists = 1; +- } +- if( bIsInit ){ +- createSelftestTable(p); +- bSelftestExists = 1; +- } +- if( bSelftestExists ){ +- rc = sqlite3_get_table(p->db, +- "SELECT tno,op,cmd,ans FROM selftest ORDER BY tno", +- &azTest, &nRow, &nCol, 0); +- if( rc ){ +- raw_printf(stderr, "Error querying the selftest table\n"); +- rc = 1; +- sqlite3_free_table(azTest); +- goto meta_command_exit; +- }else if( nRow==0 ){ +- sqlite3_free_table(azTest); +- azTest = azDefaultTest; +- nRow = nDefaultRow; +- } +- }else{ +- azTest = azDefaultTest; +- nRow = nDefaultRow; +- } +- initText(&str); +- appendText(&str, "x", 0); +- for(i=1; i<=nRow; i++){ +- int tno = atoi(azTest[i*nCol]); +- const char *zOp = azTest[i*nCol+1]; +- const char *zSql = azTest[i*nCol+2]; +- const char *zAns = azTest[i*nCol+3]; +- +- if( bVerbose>0 ){ +- char *zQuote = sqlite3_mprintf("%q", zSql); +- printf("%d: %s %s\n", tno, zOp, zSql); +- sqlite3_free(zQuote); +- } +- if( strcmp(zOp,"memo")==0 ){ +- utf8_printf(p->out, "%s\n", zSql); +- }else +- if( strcmp(zOp,"run")==0 ){ +- char *zErrMsg = 0; +- str.n = 0; +- str.z[0] = 0; +- rc = sqlite3_exec(p->db, zSql, captureOutputCallback, &str, &zErrMsg); +- nTest++; +- if( bVerbose ){ +- utf8_printf(p->out, "Result: %s\n", str.z); +- } +- if( rc || zErrMsg ){ +- nErr++; +- rc = 1; +- utf8_printf(p->out, "%d: error-code-%d: %s\n", tno, rc, zErrMsg); +- sqlite3_free(zErrMsg); +- }else if( strcmp(zAns,str.z)!=0 ){ +- nErr++; +- rc = 1; +- utf8_printf(p->out, "%d: Expected: [%s]\n", tno, zAns); +- utf8_printf(p->out, "%d: Got: [%s]\n", tno, str.z); +- } +- }else +- { +- utf8_printf(stderr, +- "Unknown operation \"%s\" on selftest line %d\n", zOp, tno); +- rc = 1; +- break; +- } +- } +- freeText(&str); +- if( azTest!=azDefaultTest ) sqlite3_free_table(azTest); +- utf8_printf(p->out, "%d errors out of %d tests\n", nErr, nTest); +- }else +- + if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){ + if( nArg<2 || nArg>3 ){ + raw_printf(stderr, "Usage: .separator COL ?ROW?\n"); +@@ -5949,122 +4836,6 @@ static int do_meta_command(char *zLine, + } + }else + +- if( c=='s' && n>=4 && strncmp(azArg[0],"sha3sum",n)==0 ){ +- const char *zLike = 0; /* Which table to checksum. 0 means everything */ +- int i; /* Loop counter */ +- int bSchema = 0; /* Also hash the schema */ +- int bSeparate = 0; /* Hash each table separately */ +- int iSize = 224; /* Hash algorithm to use */ +- int bDebug = 0; /* Only show the query that would have run */ +- sqlite3_stmt *pStmt; /* For querying tables names */ +- char *zSql; /* SQL to be run */ +- char *zSep; /* Separator */ +- ShellText sSql; /* Complete SQL for the query to run the hash */ +- ShellText sQuery; /* Set of queries used to read all content */ +- open_db(p, 0); +- for(i=1; i1" +- " UNION ALL SELECT 'sqlite_master'" +- " ORDER BY 1 collate nocase"; +- }else{ +- zSql = "SELECT lower(name) FROM sqlite_master" +- " WHERE type='table' AND coalesce(rootpage,0)>1" +- " AND name NOT LIKE 'sqlite_%'" +- " ORDER BY 1 collate nocase"; +- } +- sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); +- initText(&sQuery); +- initText(&sSql); +- appendText(&sSql, "WITH [sha3sum$query](a,b) AS(",0); +- zSep = "VALUES("; +- while( SQLITE_ROW==sqlite3_step(pStmt) ){ +- const char *zTab = (const char*)sqlite3_column_text(pStmt,0); +- if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue; +- if( strncmp(zTab, "sqlite_",7)!=0 ){ +- appendText(&sQuery,"SELECT * FROM ", 0); +- appendText(&sQuery,zTab,'"'); +- appendText(&sQuery," NOT INDEXED;", 0); +- }else if( strcmp(zTab, "sqlite_master")==0 ){ +- appendText(&sQuery,"SELECT type,name,tbl_name,sql FROM sqlite_master" +- " ORDER BY name;", 0); +- }else if( strcmp(zTab, "sqlite_sequence")==0 ){ +- appendText(&sQuery,"SELECT name,seq FROM sqlite_sequence" +- " ORDER BY name;", 0); +- }else if( strcmp(zTab, "sqlite_stat1")==0 ){ +- appendText(&sQuery,"SELECT tbl,idx,stat FROM sqlite_stat1" +- " ORDER BY tbl,idx;", 0); +- }else if( strcmp(zTab, "sqlite_stat3")==0 +- || strcmp(zTab, "sqlite_stat4")==0 ){ +- appendText(&sQuery, "SELECT * FROM ", 0); +- appendText(&sQuery, zTab, 0); +- appendText(&sQuery, " ORDER BY tbl, idx, rowid;\n", 0); +- } +- appendText(&sSql, zSep, 0); +- appendText(&sSql, sQuery.z, '\''); +- sQuery.n = 0; +- appendText(&sSql, ",", 0); +- appendText(&sSql, zTab, '\''); +- zSep = "),("; +- } +- sqlite3_finalize(pStmt); +- if( bSeparate ){ +- zSql = sqlite3_mprintf( +- "%s))" +- " SELECT lower(hex(sha3_query(a,%d))) AS hash, b AS label" +- " FROM [sha3sum$query]", +- sSql.z, iSize); +- }else{ +- zSql = sqlite3_mprintf( +- "%s))" +- " SELECT lower(hex(sha3_query(group_concat(a,''),%d))) AS hash" +- " FROM [sha3sum$query]", +- sSql.z, iSize); +- } +- freeText(&sQuery); +- freeText(&sSql); +- if( bDebug ){ +- utf8_printf(p->out, "%s\n", zSql); +- }else{ +- shell_exec(p->db, zSql, shell_callback, p, 0); +- } +- sqlite3_free(zSql); +- }else +- + if( c=='s' + && (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0) + ){ +@@ -6086,15 +4857,14 @@ static int do_meta_command(char *zLine, + }else + + if( c=='s' && strncmp(azArg[0], "show", n)==0 ){ +- static const char *azBool[] = { "off", "on", "full", "unk" }; ++ static const char *const azBool[] = { "off", "on", "full", "unk" }; + int i; + if( nArg!=1 ){ + raw_printf(stderr, "Usage: .show\n"); + rc = 1; + goto meta_command_exit; + } +- utf8_printf(p->out, "%12.12s: %s\n","echo", +- azBool[ShellHasFlag(p, SHFLG_Echo)]); ++ utf8_printf(p->out, "%12.12s: %s\n","echo", azBool[p->echoOn!=0]); + utf8_printf(p->out, "%12.12s: %s\n","eqp", azBool[p->autoEQP&3]); + utf8_printf(p->out, "%12.12s: %s\n","explain", + p->mode==MODE_Explain ? "on" : p->autoExplain ? "auto" : "off"); +@@ -6207,7 +4977,7 @@ static int do_meta_command(char *zLine, if( nRow>=nAlloc ){ char **azNew; int n2 = nAlloc*2 + 10; @@ -7285,31 +14788,64 @@ if( azNew==0 ){ rc = shellNomemError(); break; -@@ -3915,6 +3898,11 @@ static int do_meta_command(char *zLine, - const char *zCtrlName; /* Name of a test-control option */ - int ctrlCode; /* Integer code for that option */ - } aCtrl[] = { -+ { "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT }, -+ { "explain_stmt", SQLITE_TESTCTRL_EXPLAIN_STMT }, -+ { "vdbe_coverage", SQLITE_TESTCTRL_VDBE_COVERAGE }, -+ { "isinit", SQLITE_TESTCTRL_ISINIT }, -+ { "sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP }, - { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE }, - { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE }, - { "prng_reset", SQLITE_TESTCTRL_PRNG_RESET }, -@@ -4037,6 +4025,11 @@ static int do_meta_command(char *zLine, - } - break; +@@ -6406,7 +5176,6 @@ static int do_meta_command(char *zLine, + } + } + }else +-#endif /* !defined(SQLITE_UNTESTABLE) */ -+ case SQLITE_TESTCTRL_LOCALTIME_FAULT: -+ case SQLITE_TESTCTRL_EXPLAIN_STMT: -+ case SQLITE_TESTCTRL_VDBE_COVERAGE: -+ case SQLITE_TESTCTRL_ISINIT: -+ case SQLITE_TESTCTRL_SORTER_MMAP: - case SQLITE_TESTCTRL_BITVEC_TEST: - case SQLITE_TESTCTRL_FAULT_INSTALL: - case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: -@@ -4521,7 +4514,9 @@ static const char zOptions[] = + if( c=='t' && n>4 && strncmp(azArg[0], "timeout", n)==0 ){ + open_db(p, 0); +@@ -6443,6 +5212,7 @@ static int do_meta_command(char *zLine, + } + #endif + }else ++#endif /* !defined(SQLITE_UNTESTABLE) */ + + #if SQLITE_USER_AUTHENTICATION + if( c=='u' && strncmp(azArg[0], "user", n)==0 ){ +@@ -6659,7 +5429,7 @@ static int runOneSqlLine(ShellState *p, + char *zErrMsg = 0; + + open_db(p, 0); +- if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql); ++ if( p->backslashOn ) resolve_backslashes(zSql); + BEGIN_TIMER; + rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg); + END_TIMER; +@@ -6679,7 +5449,7 @@ static int runOneSqlLine(ShellState *p, + utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); + } + return 1; +- }else if( ShellHasFlag(p, SHFLG_CountChanges) ){ ++ }else if( p->countChanges ){ + raw_printf(p->out, "changes: %3d total_changes: %d\n", + sqlite3_changes(p->db), sqlite3_total_changes(p->db)); + } +@@ -6722,11 +5492,11 @@ static int process_input(ShellState *p, + } + lineno++; + if( nSql==0 && _all_whitespace(zLine) ){ +- if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zLine); ++ if( p->echoOn ) printf("%s\n", zLine); + continue; + } + if( zLine && zLine[0]=='.' && nSql==0 ){ +- if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zLine); ++ if( p->echoOn ) printf("%s\n", zLine); + rc = do_meta_command(zLine, p); + if( rc==2 ){ /* exit requested */ + break; +@@ -6769,7 +5539,7 @@ static int process_input(ShellState *p, + p->outCount = 0; + } + }else if( nSql && _all_whitespace(zSql) ){ +- if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zSql); ++ if( p->echoOn ) printf("%s\n", zSql); + nSql = 0; + } + } +@@ -6908,7 +5678,9 @@ static const char zOptions[] = " -interactive force interactive I/O\n" " -line set output mode to 'line'\n" " -list set output mode to 'list'\n" @@ -7319,7 +14855,7 @@ " -mmap N default mmap size set to N\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" -@@ -4529,11 +4524,15 @@ static const char zOptions[] = +@@ -6916,11 +5688,15 @@ static const char zOptions[] = " -newline SEP set output row separator. Default: '\\n'\n" " -nullvalue TEXT set text string for NULL values. Default ''\n" " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n" @@ -7335,15 +14871,16 @@ #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif -@@ -4561,6 +4560,7 @@ static void main_init(ShellState *data) +@@ -6949,6 +5725,8 @@ static void main_init(ShellState *data) memcpy(data->rowSeparator,SEP_Row, 2); data->showHeader = 0; data->shellFlgs = SHFLG_Lookaside; + sqlite3_config(64); /* SQLITE_CONFIG_EXPLAIN_COMMENTS */ ++ sqlite3_config(65); /* SQLITE_CONFIG_ENABLE_UNKOWN_SQL_FUNCTION */ sqlite3_config(SQLITE_CONFIG_URI, 1); sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); sqlite3_config(SQLITE_CONFIG_MULTITHREAD); -@@ -4601,6 +4601,10 @@ static char *cmdline_option_value(int ar +@@ -6989,8 +5767,12 @@ static char *cmdline_option_value(int ar return argv[i]; } @@ -7351,36 +14888,35 @@ +int _CRT_glob = 0x0001; /* See MinGW bug #2062 */ +#endif + - int SQLITE_CDECL main(int argc, char **argv){ - char *zErrMsg = 0; - ShellState data; -@@ -4616,9 +4620,13 @@ int SQLITE_CDECL main(int argc, char **a - if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ - utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", - sqlite3_sourceid(), SQLITE_SOURCE_ID); -+#else -+ if( sqlite3_libversion_number()<3008003 ){ -+ fprintf(stderr, "Unsuitable SQLite version %s, must be at least 3.8.3", -+ sqlite3_libversion()); -+#endif + #ifndef SQLITE_SHELL_IS_UTF8 +-# if (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER) ++# if (defined(_WIN32) || defined(WIN32)) && (defined(_MSC_VER) || defined(__MSVCRT__)) + # define SQLITE_SHELL_IS_UTF8 (0) + # else + # define SQLITE_SHELL_IS_UTF8 (1) +@@ -7028,7 +5810,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t + main_init(&data); + #if !SQLITE_SHELL_IS_UTF8 + sqlite3_initialize(); +- argv = sqlite3_malloc64(sizeof(argv[0])*argc); ++ argv = sqlite3_malloc(sizeof(argv[0])*argc); + if( argv==0 ){ + raw_printf(stderr, "out of memory\n"); exit(1); - } --#endif - setBinaryMode(stdin); - setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */ - Argv0 = argv[0]; -@@ -4631,6 +4639,8 @@ int SQLITE_CDECL main(int argc, char **a +@@ -7047,7 +5829,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t + /* Make sure we have a valid signal handler early, before anything + ** else is done. */ - #ifdef SIGINT - signal(SIGINT, interrupt_handler); -+#elif defined(WIN32) || defined(_WIN32) +-#ifdef SIGINT ++#if defined(WIN32) || defined(_WIN32) + SetConsoleCtrlHandler(CtrlHandler, TRUE); ++#elif defined(SIGINT) + signal(SIGINT, interrupt_handler); #endif - #ifdef SQLITE_SHELL_DBNAME_PROC -@@ -4694,6 +4704,11 @@ int SQLITE_CDECL main(int argc, char **a - if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; - sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); +@@ -7114,6 +5898,11 @@ int SQLITE_CDECL wmain(int argc, wchar_t + #else + (void)cmdline_option_value(argc, argv, ++i); #endif +#ifdef SQLITE_USE_FCNTL_TRACE + }else if( strcmp(z,"-vfslog")==0 ){ @@ -7390,7 +14926,25 @@ }else if( strcmp(z,"-scratch")==0 ){ int n, sz; sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); -@@ -4853,6 +4868,10 @@ int SQLITE_CDECL main(int argc, char **a +@@ -7238,7 +6027,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t + }else if( strcmp(z,"-noheader")==0 ){ + data.showHeader = 0; + }else if( strcmp(z,"-echo")==0 ){ +- ShellSetFlag(&data, SHFLG_Echo); ++ data.echoOn = 1; + }else if( strcmp(z,"-eqp")==0 ){ + data.autoEQP = 1; + }else if( strcmp(z,"-eqpfull")==0 ){ +@@ -7253,7 +6042,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t + ** prior to sending the SQL into SQLite. Useful for injecting + ** crazy bytes in the middle of SQL statements for testing and debugging. + */ +- ShellSetFlag(&data, SHFLG_Backslash); ++ data.backslashOn = 1; + }else if( strcmp(z,"-bail")==0 ){ + bail_on_error = 1; + }else if( strcmp(z,"-version")==0 ){ +@@ -7275,6 +6064,10 @@ int SQLITE_CDECL wmain(int argc, wchar_t i++; }else if( strcmp(z,"-vfs")==0 ){ i++; @@ -7401,8 +14955,8 @@ #ifdef SQLITE_ENABLE_VFSTRACE }else if( strcmp(z,"-vfstrace")==0 ){ i++; ---- origsrc/sqlite-autoconf-3100000/showauth.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/showauth.c 2016-01-06 16:30:42.515122100 +0100 +--- origsrc/sqlite-autoconf-3180000/showauth.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/showauth.c 2017-04-19 16:20:01.835922200 +0200 @@ -0,0 +1,116 @@ +/* +** 2014-09-21 @@ -7520,9 +15074,9 @@ + return rc; +} +#endif ---- origsrc/sqlite-autoconf-3100000/spaceanal.tcl 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/spaceanal.tcl 2016-01-06 17:11:59.871818800 +0100 -@@ -0,0 +1,810 @@ +--- origsrc/sqlite-autoconf-3180000/spaceanal.tcl 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/spaceanal.tcl 2017-04-19 16:20:01.847923400 +0200 +@@ -0,0 +1,815 @@ +#! /bin/sh +# restart with tclsh \ +exec tclsh "$0" ${1+"$@"} @@ -7682,6 +15236,7 @@ + name clob, -- Name of a table or index in the database file + tblname clob, -- Name of associated table + is_index boolean, -- TRUE if it is an index, false for a table ++ is_without_rowid boolean, -- TRUE if WITHOUT ROWID table + nentry int, -- Number of entries in the BTree + leaf_entries int, -- Number of leaf entries + depth int, -- Depth of the b-tree @@ -7714,7 +15269,7 @@ +foreach {name tblname} [concat sqlite_master sqlite_master [db eval $sql]] { + + set is_index [expr {$name!=$tblname}] -+ set idx_btree [expr {$is_index || [is_without_rowid $name]}] ++ set is_without_rowid [is_without_rowid $name] + db eval { + SELECT + sum(ncell) AS nentry, @@ -7765,6 +15320,7 @@ + $name, + $tblname, + $is_index, ++ $is_without_rowid, + $nentry, + $leaf_entries, + $depth, @@ -7860,12 +15416,15 @@ + # following query returns exactly one row (because it is an aggregate). + # + # The results of the query are stored directly by SQLite into local -+ # variables (i.e. $nentry, $nleaf etc.). ++ # variables (i.e. $nentry, $payload etc.). + # + mem eval " + SELECT -+ int(sum(nentry)) AS nentry, -+ int(sum(leaf_entries)) AS nleaf, ++ int(sum( ++ CASE WHEN (is_without_rowid OR is_index) THEN nentry ++ ELSE leaf_entries ++ END ++ )) AS nentry, + int(sum(payload)) AS payload, + int(sum(ovfl_payload)) AS ovfl_payload, + max(mx_payload) AS mx_payload, @@ -7905,8 +15464,8 @@ + set storage [expr {$total_pages*$pageSize}] + set payload_percent [percent $payload $storage {of storage consumed}] + set total_unused [expr {$ovfl_unused+$int_unused+$leaf_unused}] -+ set avg_payload [divide $payload $nleaf] -+ set avg_unused [divide $total_unused $nleaf] ++ set avg_payload [divide $payload $nentry] ++ set avg_unused [divide $total_unused $nentry] + if {$int_pages>0} { + # TODO: Is this formula correct? + set nTab [mem eval " @@ -7920,12 +15479,12 @@ + "] + set avg_fanout [format %.2f $avg_fanout] + } -+ set ovfl_cnt_percent [percent $ovfl_cnt $nleaf {of all entries}] ++ set ovfl_cnt_percent [percent $ovfl_cnt $nentry {of all entries}] + + # Print out the sub-report statistics. + # + statline {Percentage of total database} $total_pages_percent -+ statline {Number of entries} $nleaf ++ statline {Number of entries} $nentry + statline {Bytes of storage consumed} $storage + if {$compressed_size!=$storage} { + set compressed_size [expr {$compressed_size+$compressOverhead*$total_pages}] @@ -8333,9 +15892,9 @@ + puts $errorInfo + exit 1 +} ---- origsrc/sqlite-autoconf-3100000/spellfix.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/spellfix.c 2016-01-06 16:30:42.516122100 +0100 -@@ -0,0 +1,2932 @@ +--- origsrc/sqlite-autoconf-3180000/spellfix.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/spellfix.c 2017-04-19 16:20:01.874926100 +0200 +@@ -0,0 +1,2958 @@ +/* +** 2012 April 10 +** @@ -8703,8 +16262,8 @@ + int *m; /* The cost matrix */ + char *cx; /* Corresponding character values */ + int *toFree = 0; /* Malloced space */ -+ int mStack[60+15]; /* Stack space to use if not too much is needed */ + int nMatch = 0; ++ int mStack[60+15]; /* Stack space to use if not too much is needed */ + + /* Early out if either input is NULL */ + if( zA==0 || zB==0 ) return -1; @@ -8728,7 +16287,7 @@ + + /* Special processing if either string is empty */ + if( nA==0 ){ -+ cBprev = dc; ++ cBprev = (char)dc; + for(xB=res=0; (cB = zB[xB])!=0; xB++){ + res += insertOrDeleteCost(cBprev, cB, zB[xB+1])/FINAL_INS_COST_DIV; + cBprev = cB; @@ -8736,7 +16295,7 @@ + return res; + } + if( nB==0 ){ -+ cAprev = dc; ++ cAprev = (char)dc; + for(xA=res=0; (cA = zA[xA])!=0; xA++){ + res += insertOrDeleteCost(cAprev, cA, zA[xA+1]); + cAprev = cA; @@ -8758,8 +16317,8 @@ + + /* Compute the Wagner edit distance */ + m[0] = 0; -+ cx[0] = dc; -+ cBprev = dc; ++ cx[0] = (char)dc; ++ cBprev = (char)dc; + for(xB=1; xB<=nB; xB++){ + cBnext = zB[xB]; + cB = zB[xB-1]; @@ -8767,7 +16326,7 @@ + m[xB] = m[xB-1] + insertOrDeleteCost(cBprev, cB, cBnext); + cBprev = cB; + } -+ cAprev = dc; ++ cAprev = (char)dc; + for(xA=1; xA<=nA; xA++){ + int lastA = (xA==nA); + cA = zA[xA-1]; @@ -8814,7 +16373,7 @@ + d = m[xB]; + dc = cx[xB]; + m[xB] = totalCost; -+ cx[xB] = ncx; ++ cx[xB] = (char)ncx; + cBprev = cB; + } + cAprev = cA; @@ -9049,9 +16608,9 @@ + if( nExtra<0 ) nExtra = 0; + pCost = sqlite3_malloc( sizeof(*pCost) + nExtra ); + if( pCost==0 ){ rc = SQLITE_NOMEM; break; } -+ pCost->nFrom = nFrom; -+ pCost->nTo = nTo; -+ pCost->iCost = iCost; ++ pCost->nFrom = (u8)nFrom; ++ pCost->nTo = (u8)nTo; ++ pCost->iCost = (u16)iCost; + memcpy(pCost->a, zFrom, nFrom); + memcpy(pCost->a + nFrom, zTo, nTo); + pCost->pNext = pLang->pCost; @@ -9213,6 +16772,17 @@ + } +} + ++/* ++** How much stack space (int bytes) to use for Wagner matrix in ++** editDist3Core(). If more space than this is required, the entire ++** matrix is taken from the heap. To reduce the load on the memory ++** allocator, make this value as large as practical for the ++** architecture in use. ++*/ ++#ifndef SQLITE_SPELLFIX_STACKALLOC_SZ ++# define SQLITE_SPELLFIX_STACKALLOC_SZ (1024) ++#endif ++ +/* Compute the edit distance between two strings. +** +** If an error occurs, return a negative number which is the error code. @@ -9237,15 +16807,24 @@ + EditDist3FromString f = *pFrom; + EditDist3To *a2; + unsigned int *m; ++ unsigned int *pToFree; + int szRow; + EditDist3Cost *p; + int res; ++ sqlite3_uint64 nByte; ++ unsigned int stackSpace[SQLITE_SPELLFIX_STACKALLOC_SZ/sizeof(unsigned int)]; + + /* allocate the Wagner matrix and the aTo[] array for the TO string */ + n = (f.n+1)*(n2+1); + n = (n+1)&~1; -+ m = sqlite3_malloc( n*sizeof(m[0]) + sizeof(a2[0])*n2 ); -+ if( m==0 ) return -1; /* Out of memory */ ++ nByte = n*sizeof(m[0]) + sizeof(a2[0])*n2; ++ if( nByte<=sizeof(stackSpace) ){ ++ m = stackSpace; ++ pToFree = 0; ++ }else{ ++ m = pToFree = sqlite3_malloc( nByte ); ++ if( m==0 ) return -1; /* Out of memory */ ++ } + a2 = (EditDist3To*)&m[n]; + memset(a2, 0, sizeof(a2[0])*n2); + @@ -9367,7 +16946,7 @@ + +editDist3Abort: + for(i2=0; i2=0x80 || midClass[c&0x7f]=0x80 || midClass[c&0x7f]='0' && c<='9' ){ ++ seenDigit = 1; ++ } + }else if( c>=0x0400 && c<=0x04ff ){ + scriptMask |= SCRIPT_CYRILLIC; + }else if( c>=0x0386 && c<=0x03ce ){ @@ -10074,6 +17658,7 @@ + scriptMask |= SCRIPT_ARABIC; + } + } ++ if( scriptMask==0 && seenDigit ) scriptMask = SCRIPT_LATIN; + switch( scriptMask ){ + case 0: res = 999; break; + case SCRIPT_LATIN: res = 215; break; @@ -10093,7 +17678,7 @@ +*/ + +/* Maximum length of a phonehash used for querying the shadow table */ -+#define SPELLFIX_MX_HASH 8 ++#define SPELLFIX_MX_HASH 32 + +/* Maximum number of hash strings to examine per query */ +#define SPELLFIX_MX_RUN 1 @@ -10543,7 +18128,7 @@ +** Compare two spellfix1_row objects for sorting purposes in qsort() such +** that they sort in order of increasing distance. +*/ -+static int spellfix1RowCompare(const void *A, const void *B){ ++static int SQLITE_CDECL spellfix1RowCompare(const void *A, const void *B){ + const struct spellfix1_row *a = (const struct spellfix1_row*)A; + const struct spellfix1_row *b = (const struct spellfix1_row*)B; + return a->iScore - b->iScore; @@ -11268,9 +18853,9 @@ + return SQLITE_OK; +} +#endif ---- origsrc/sqlite-autoconf-3100000/sqldiff.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/sqldiff.c 2016-01-06 16:47:17.166012900 +0100 -@@ -0,0 +1,1881 @@ +--- origsrc/sqlite-autoconf-3180000/sqldiff.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/sqldiff.c 2017-04-19 16:20:01.893928000 +0200 +@@ -0,0 +1,1897 @@ +/* +** 2015-04-06 +** @@ -12267,7 +19852,7 @@ + zDelta += lenOut; + putInt(checksum(zOut, lenOut), &zDelta); + *(zDelta++) = ';'; -+ return zDelta - zOrigDelta; ++ return (int)(zDelta - zOrigDelta); + } + + /* Compute the hash table used to locate matching sections in the @@ -12414,7 +19999,7 @@ + putInt(checksum(zOut, lenOut), &zDelta); + *(zDelta++) = ';'; + sqlite3_free(collide); -+ return zDelta - zOrigDelta; ++ return (int)(zDelta - zOrigDelta); +} + +/* @@ -12517,6 +20102,7 @@ + Str sql = {0, 0, 0}; /* Query to find differences */ + Str insert = {0, 0, 0}; /* First part of output INSERT statement */ + sqlite3_stmt *pStmt = 0; ++ int nRow = 0; /* Total rows in data_xxx table */ + + /* --rbu mode must use real primary keys. */ + g.bSchemaPK = 1; @@ -12562,6 +20148,7 @@ + + /* Output the first part of the INSERT statement */ + fprintf(out, "%s", insert.z); ++ nRow++; + + if( sqlite3_column_type(pStmt, nCol)==SQLITE_INTEGER ){ + for(i=0; i<=nCol; i++){ @@ -12615,6 +20202,12 @@ + } + + sqlite3_finalize(pStmt); ++ if( nRow>0 ){ ++ Str cnt = {0, 0, 0}; ++ strPrintf(&cnt, "INSERT INTO rbu_count VALUES('data_%q', %d);", zTab, nRow); ++ fprintf(out, "%s\n", cnt.z); ++ strFree(&cnt); ++ } + + strFree(&ct); + strFree(&sql); @@ -13030,8 +20623,10 @@ + char *zTab = 0; + FILE *out = stdout; + void (*xDiff)(const char*,FILE*) = diff_one_table; ++#ifndef SQLITE_OMIT_LOAD_EXTENSION + int nExt = 0; + char **azExt = 0; ++#endif + int useTransaction = 0; + int neverUseTransaction = 0; + @@ -13114,8 +20709,8 @@ + cmdlineError("error loading %s: %s", azExt[i], zErrMsg); + } + } -+#endif + free(azExt); ++#endif + zSql = sqlite3_mprintf("ATTACH %Q as aux;", zDb2); + rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg); + if( rc || zErrMsg ){ @@ -13127,7 +20722,13 @@ + } + + if( neverUseTransaction ) useTransaction = 0; -+ if( useTransaction ) printf("BEGIN TRANSACTION;\n"); ++ if( useTransaction ) fprintf(out, "BEGIN TRANSACTION;\n"); ++ if( xDiff==rbudiff_one_table ){ ++ fprintf(out, "CREATE TABLE IF NOT EXISTS rbu_count" ++ "(tbl TEXT PRIMARY KEY COLLATE NOCASE, cnt INTEGER) " ++ "WITHOUT ROWID;\n" ++ ); ++ } + if( zTab ){ + xDiff(zTab, out); + }else{ @@ -13152,19 +20753,233 @@ + sqlite3_close(g.db); + return 0; +} ---- origsrc/sqlite-autoconf-3100000/sqlite3.c 2016-01-06 13:03:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/sqlite3.c 2016-01-06 16:18:35.000510600 +0100 -@@ -359,7 +359,7 @@ extern "C" { +--- origsrc/sqlite-autoconf-3180000/sqlite3.1 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/sqlite3.1 2017-04-19 16:20:01.904929100 +0200 +@@ -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 "Fri Oct 31 10:41:31 EDT 2014" ++.TH SQLITE3 1 "Fry Oct 14 10:20:30 EDT 2016" + .\" Please adjust this date whenever revising the manpage. + .\" + .\" Some roff macros, for reference: +@@ -16,7 +16,7 @@ + .\" .sp insert n+1 empty lines + .\" for manpage-specific macros, see man(7) + .SH NAME +-.B sqlite3 ++.B sqlite3 + \- A command line interface for SQLite version 3 + + .SH SYNOPSIS +@@ -46,10 +46,10 @@ does exist, it will be opened. + For example, to create a new database file named "mydata.db", create + a table named "memos" and insert a couple of records into that table: + .sp +-$ ++$ + .B sqlite3 mydata.db + .br +-SQLite version 3.8.8 ++SQLite version 3.18.0 + .br + Enter ".help" for instructions + .br +@@ -84,7 +84,7 @@ semi-colons. + + For example: + .sp +-$ ++$ + .B sqlite3 -line mydata.db 'select * from memos where priority > 20;' + .br + text = lunch with Christine +@@ -98,7 +98,7 @@ priority = 100 + The interactive interpreter offers a set of meta-commands that can be + used to control the output format, examine the currently attached + database files, or perform administrative operations upon the +-attached databases (such as rebuilding indices). Meta-commands are ++attached databases (such as rebuilding indexes). Meta-commands are + always prefixed with a dot (.). + + A list of available meta-commands can be viewed at any time by issuing +@@ -108,39 +108,50 @@ sqlite> + .B .help + .nf + .tr %. ++%auth ON|OFF Show authorizer callbacks + %backup ?DB? FILE Backup DB (default "main") to FILE + %bail on|off Stop after hitting an error. Default OFF ++%binary on|off Turn binary output on or off. Default OFF ++%changes on|off Show number of rows changed by SQL ++%check GLOB Fail if output since .testcase does not match + %clone NEWDB Clone data into NEWDB from the existing database + %databases List names and files of attached databases ++%dbinfo ?DB? Show status information about the database + %dump ?TABLE? ... Dump the database in an SQL text format + If TABLE specified, only dump tables matching + LIKE pattern TABLE. + %echo on|off Turn command echo on or off +-%eqp on|off Enable or disable automatic EXPLAIN QUERY PLAN ++%eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN + %exit Exit this program +-%explain ?on|off? Turn output mode suitable for EXPLAIN on or off. +- With no args, it turns EXPLAIN on. +-%fullschema Show schema and the content of sqlite_stat tables ++%explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic ++%fullschema ?--indent? Show schema and the content of sqlite_stat tables + %headers on|off Turn display of headers on or off + %help Show this message + %import FILE TABLE Import data from FILE into TABLE +-%indices ?TABLE? Show names of all indices +- If TABLE specified, only show indices for tables ++%imposter INDEX TABLE Create imposter table TABLE on index INDEX ++%indexes ?TABLE? Show names of all indexes ++ If TABLE specified, only show indexes for tables + matching LIKE pattern TABLE. ++%limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT ++%lint OPTIONS Report potential schema issues. Options: ++ fkey-indexes Find missing foreign key indexes + %load FILE ?ENTRY? Load an extension library + %log FILE|off Turn logging on or off. FILE can be stderr/stdout + %mode MODE ?TABLE? Set output mode where MODE is one of: ++ ascii Columns/rows delimited by 0x1F and 0x1E + csv Comma-separated values + column Left-aligned columns. (See .width) + html HTML
code + insert SQL insert statements for TABLE + line One value per line +- list Values delimited by .separator string ++ list Values delimited by .separator strings ++ quote Escape answers as for SQL + tabs Tab-separated values + tcl TCL list elements + %nullvalue STRING Use STRING in place of NULL values + %once FILENAME Output for the next SQL command only to FILENAME +-%open ?FILENAME? Close existing database and reopen FILENAME ++%open ?--new? ?FILE? Close existing database and reopen FILE ++ The --new starts with an empty file + %output ?FILENAME? Send output to FILENAME or stdout + %print STRING... Print literal STRING + %prompt MAIN CONTINUE Replace the standard prompts +@@ -148,21 +159,25 @@ sqlite> + %read FILENAME Execute SQL in FILENAME + %restore ?DB? FILE Restore content of DB (default "main") from FILE + %save FILE Write in-memory database into FILE +-%schema ?TABLE? Show the CREATE statements +- If TABLE specified, only show tables matching +- LIKE pattern TABLE. +-%separator STRING ?NL? Change separator used by output mode and .import +- NL is the end-of-line mark for CSV ++%scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off ++%schema ?PATTERN? Show the CREATE statements matching PATTERN ++ Add --indent for pretty-printing ++%separator COL ?ROW? Change the column separator and optionally the row ++ separator for both the output mode and .import ++%session CMD ... Create or control sessions + %shell CMD ARGS... Run CMD ARGS... in a system shell + %show Show the current values for various settings +-%stats on|off Turn stats on or off ++%stats ?on|off? Show stats or turn stats on or off + %system CMD ARGS... Run CMD ARGS... in a system shell + %tables ?TABLE? List names of tables + If TABLE specified, only list tables matching + LIKE pattern TABLE. ++%testcase NAME Begin redirecting output to 'testcase-out.txt' + %timeout MS Try opening locked tables for MS milliseconds + %timer on|off Turn SQL timer on or off + %trace FILE|off Output each SQL statement as it is run ++%vfsinfo ?AUX? Information about the top-level VFS ++%vfslist List all available VFSes + %vfsname ?AUX? Print the name of the VFS stack + %width NUM1 NUM2 ... Set column widths for "column" mode + Negative values right-justify +@@ -173,6 +188,9 @@ sqlite> + .B sqlite3 + has the following options: + .TP ++.B \-ascii ++Set output mode to ascii. ++.TP + .B \-bail + Stop after hitting an error. + .TP +@@ -226,12 +244,32 @@ Set default mmap size to + .I N + \. + .TP ++.BI \-newline\ separator ++Set output row separator. Default is the newline character. ++.TP + .BI \-nullvalue\ string + Set string used to represent NULL values. Default is '' + (empty string). + .TP ++.BI \-pagecache\ SIZE N ++Use ++.I SIZE ++entries of ++.I N ++bytes each for page cache memory. ++.TP ++.B \-scanstats ++Print scan stats before each finalize. ++.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 '|'. ++Set output column separator. Default is '|'. + .TP + .B \-stats + Print memory stats before each finalize. +@@ -243,6 +281,9 @@ Show SQLite version. + Use + .I name + as the default VFS. ++.TP ++.B \-vfslog ++Enable the vfslog extension. + + + .SH INIT FILE +@@ -265,7 +306,7 @@ continue prompt = " ...> " + .sp + .fi + +-o If the file ++o If the file + .B ~/.sqliterc + exists, it is processed first. + can be found in the user's home directory, it is +--- origsrc/sqlite-autoconf-3180000/sqlite3.c 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/sqlite3.c 2017-04-19 16:20:02.033942000 +0200 +@@ -79,7 +79,7 @@ + ** Make sure that rand_s() is available on Windows systems with MSVC 2005 + ** or higher. + */ +-#if defined(_MSC_VER) && _MSC_VER>=1400 ++#if defined(__MSVCRT__) || defined(_MSC_VER) && _MSC_VER>=1400 + # define _CRT_RAND_S + #endif + +@@ -432,7 +432,7 @@ extern "C" { ** ** See also: [sqlite_version()] and [sqlite_source_id()]. */ -SQLITE_API const char sqlite3_version[] = SQLITE_VERSION; +const char sqlite3_version[] = SQLITE_VERSION; - SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void); - SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void); - SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void); -@@ -1636,81 +1636,6 @@ SQLITE_API int SQLITE_CDECL sqlite3_conf - SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...); + SQLITE_API const char *sqlite3_libversion(void); + SQLITE_API const char *sqlite3_sourceid(void); + SQLITE_API int sqlite3_libversion_number(void); +@@ -1742,81 +1742,6 @@ SQLITE_API int sqlite3_config(int, ...); + SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); /* -** CAPI3REF: Memory Allocation Routines @@ -13245,7 +21060,7 @@ ** CAPI3REF: Configuration Options ** KEYWORDS: {configuration option} ** -@@ -1766,24 +1691,6 @@ struct sqlite3_mem_methods { +@@ -1872,24 +1797,6 @@ struct sqlite3_mem_methods { ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_SERIALIZED configuration option. ** @@ -13270,65 +21085,96 @@ ** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
**
^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, ** interpreted as a boolean, which enables or disables the collection of -@@ -3783,7 +3690,7 @@ typedef struct sqlite3_context sqlite3_c +@@ -2428,7 +2335,9 @@ SQLITE_API void sqlite3_set_last_insert_ + ** while [sqlite3_changes()] is running then the value returned + ** is unpredictable and not meaningful. + */ +-SQLITE_API int sqlite3_changes(sqlite3*); ++SQLITE_API sqlite3_uint64 sqlite3_changes(sqlite3*); ++#define sqlite3_changes(db) ((int)(sqlite3_changes)(db)) ++#define sqlite3_changes64(db) ((sqlite3_changes)(db)) + + /* + ** CAPI3REF: Total Number Of Rows Modified +@@ -2452,7 +2361,9 @@ SQLITE_API int sqlite3_changes(sqlite3*) + ** while [sqlite3_total_changes()] is running then the value + ** returned is unpredictable and not meaningful. + */ +-SQLITE_API int sqlite3_total_changes(sqlite3*); ++SQLITE_API sqlite3_uint64 sqlite3_total_changes(sqlite3*); ++#define sqlite3_total_changes(db) ((int)(sqlite3_total_changes)(db)) ++#define sqlite3_total_changes64(db) ((sqlite3_total_changes)(db)) + + /* + ** CAPI3REF: Interrupt A Long-Running Query +@@ -3982,7 +3893,7 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3 + ** The [sqlite3_value_blob | sqlite3_value_type()] family of + ** interfaces require protected sqlite3_value objects. + */ +-typedef struct Mem sqlite3_value; ++typedef struct sqlite3_value sqlite3_value; + + /* + ** CAPI3REF: SQL Function Context Object +@@ -4105,7 +4016,7 @@ typedef struct sqlite3_context sqlite3_c ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ --SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); -+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, unsigned int n, void(*)(void*)); - SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, +-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); ++SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, unsigned int n, void(*)(void*)); + SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, void(*)(void*)); - SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double); -@@ -4292,8 +4199,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_da + SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); +@@ -4619,8 +4530,8 @@ SQLITE_API int sqlite3_data_count(sqlite ** [SQLITE_NOMEM].)^ */ - SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol); --SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol); --SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol); - SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol); - SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol); - SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol); -@@ -4465,6 +4372,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr + SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); +-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); +-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); ++SQLITE_API unsigned int sqlite3_column_bytes(sqlite3_stmt*, int iCol); ++SQLITE_API unsigned int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); + SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); + SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); + SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); +@@ -4792,6 +4703,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 SQLITE_STDCALL sqlite3_create_function16( + SQLITE_API int sqlite3_create_function16( sqlite3 *db, const void *zFunctionName, -@@ -4520,7 +4429,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr +@@ -4847,7 +4760,7 @@ SQLITE_API int sqlite3_create_function_v ** the use of these functions. To encourage programmers to avoid ** these functions, we will not explain what they do. */ -#ifndef SQLITE_OMIT_DEPRECATED +#if 0 - SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*); - SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*); - SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); -@@ -4577,8 +4486,8 @@ SQLITE_API SQLITE_DEPRECATED int SQLITE_ + SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); + SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); + SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); +@@ -4904,8 +4817,8 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3 ** the SQL function that supplied the [sqlite3_value*] parameters. */ - SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*); --SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*); --SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*); - SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*); - SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*); - SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*); -@@ -4882,7 +4791,7 @@ typedef void (*sqlite3_destructor_type)( + SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); +-SQLITE_API int sqlite3_value_bytes(sqlite3_value*); +-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); ++SQLITE_API unsigned int sqlite3_value_bytes(sqlite3_value*); ++SQLITE_API unsigned int sqlite3_value_bytes16(sqlite3_value*); + SQLITE_API double sqlite3_value_double(sqlite3_value*); + SQLITE_API int sqlite3_value_int(sqlite3_value*); + SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); +@@ -5210,7 +5123,7 @@ typedef void (*sqlite3_destructor_type)( ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ --SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); -+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, unsigned int, void(*)(void*)); - SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*, +-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); ++SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, unsigned int, void(*)(void*)); + SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*, sqlite3_uint64,void(*)(void*)); - SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double); -@@ -4906,6 +4815,19 @@ SQLITE_API int SQLITE_STDCALL sqlite3_re + SQLITE_API void sqlite3_result_double(sqlite3_context*, double); +@@ -5234,6 +5147,19 @@ SQLITE_API int sqlite3_result_zeroblob64 /* @@ -13348,16 +21194,16 @@ ** CAPI3REF: Setting The Subtype Of An SQL Function ** METHOD: sqlite3_context ** -@@ -5006,6 +4928,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr +@@ -5334,6 +5260,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 SQLITE_STDCALL sqlite3_create_collation_v2( + SQLITE_API int sqlite3_create_collation_v2( sqlite3*, const char *zName, -@@ -5190,7 +5114,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_sl +@@ -5518,7 +5446,7 @@ SQLITE_API int sqlite3_sleep(int); ** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf); ** */ @@ -13366,7 +21212,7 @@ /* ** CAPI3REF: Name Of The Folder Holding Database Files -@@ -5227,7 +5151,7 @@ SQLITE_API char *sqlite3_temp_directory; +@@ -5555,7 +5483,7 @@ SQLITE_API char *sqlite3_temp_directory; ** made NULL or made to point to memory obtained from [sqlite3_malloc] ** or else the use of the [data_store_directory pragma] should be avoided. */ @@ -13375,15 +21221,24 @@ /* ** CAPI3REF: Test For Auto-Commit Mode -@@ -5543,6 +5467,7 @@ SQLITE_API sqlite3_int64 SQLITE_STDCALL +@@ -5873,6 +5801,7 @@ SQLITE_API sqlite3_int64 sqlite3_soft_he */ - SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N); + SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); +#define sqlite3_soft_heap_limit(N) sqlite3_soft_heap_limit64(N) /* ** CAPI3REF: Extract Metadata About A Column Of A Table -@@ -5995,6 +5920,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr +@@ -6273,7 +6202,7 @@ struct sqlite3_index_info { + unsigned char omit; /* Do not code a test for this constraint */ + } *aConstraintUsage; + int idxNum; /* Number used to identify the index */ +- char *idxStr; /* String, possibly obtained from sqlite3_malloc */ ++ const char *idxStr; /* String, possibly obtained from sqlite3_malloc */ + int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ + int orderByConsumed; /* True if output is already ordered */ + double estimatedCost; /* Estimated cost of using this index */ +@@ -6347,6 +6276,8 @@ SQLITE_API int sqlite3_create_module_v2( void *pClientData, /* Client data for xCreate/xConnect */ void(*xDestroy)(void*) /* Module destructor function */ ); @@ -13392,16 +21247,16 @@ /* ** CAPI3REF: Virtual Table Instance Object -@@ -7757,6 +7684,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wa +@@ -8133,6 +8064,8 @@ SQLITE_API int sqlite3_wal_autocheckpoin ** complication) of [sqlite3_wal_checkpoint_v2()]. */ - SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); + SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); +/* A macro is more efficient than a wrapped call */ +#define sqlite3_wal_checkpoint(a,b) sqlite3_wal_checkpoint_v2(a,b,SQLITE_CHECKPOINT_PASSIVE,0,0); /* ** CAPI3REF: Checkpoint a database -@@ -8803,7 +8732,7 @@ struct fts5_api { +@@ -10733,7 +10666,7 @@ struct fts5_api { fts5_api *pApi, const char *zName, void *pContext, @@ -13410,7 +21265,7 @@ void (*xDestroy)(void*) ); -@@ -8873,7 +8802,7 @@ struct fts5_api { +@@ -10803,7 +10736,7 @@ struct fts5_api { ** to count the size: 2^31-1 or 2147483647. */ #ifndef SQLITE_MAX_LENGTH @@ -13419,7 +21274,16 @@ #endif /* -@@ -9023,7 +8952,7 @@ struct fts5_api { +@@ -10907,7 +10840,7 @@ struct fts5_api { + ** and we have to allow 2 extra counts for the "main" and "temp" databases. + */ + #ifndef SQLITE_MAX_ATTACHED +-# define SQLITE_MAX_ATTACHED 10 ++# define SQLITE_MAX_ATTACHED 62 + #endif + + +@@ -10954,7 +10887,7 @@ struct fts5_api { ** SQLite will choose on its own. */ #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE @@ -13428,7 +21292,7 @@ #endif #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE # undef SQLITE_MAX_DEFAULT_PAGE_SIZE -@@ -9061,6 +8990,13 @@ struct fts5_api { +@@ -10992,6 +10925,13 @@ struct fts5_api { # define SQLITE_MAX_TRIGGER_DEPTH 1000 #endif @@ -13442,16 +21306,16 @@ /************** End of sqliteLimit.h *****************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ -@@ -9404,6 +9340,8 @@ SQLITE_PRIVATE void sqlite3Coverage(in - #ifndef _SQLITE_HASH_H_ - #define _SQLITE_HASH_H_ +@@ -11343,6 +11283,8 @@ SQLITE_PRIVATE void sqlite3Coverage(in + #ifndef SQLITE_HASH_H + #define SQLITE_HASH_H +#include + /* Forward declarations of structures. */ typedef struct Hash Hash; typedef struct HashElem HashElem; -@@ -9430,11 +9368,11 @@ typedef struct HashElem HashElem; +@@ -11369,11 +11311,11 @@ typedef struct HashElem HashElem; ** the hash table. */ struct Hash { @@ -13466,7 +21330,7 @@ HashElem *chain; /* Pointer to first entry with this hash */ } *ht; }; -@@ -9662,7 +9600,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Has +@@ -11604,7 +11546,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Has #include #include #include @@ -13474,21 +21338,8 @@ +/* #include */ /* - ** If compiling for a processor that lacks floating point support, -@@ -9764,8 +9702,12 @@ SQLITE_PRIVATE void sqlite3HashClear(Has - /* - ** Macros to compute minimum and maximum of two numbers. - */ -+#ifndef MIN - #define MIN(A,B) ((A)<(B)?(A):(B)) -+#endif -+#ifndef MAX - #define MAX(A,B) ((A)>(B)?(A):(B)) -+#endif - - /* - ** Swap two objects of type TYPE. -@@ -9986,6 +9928,7 @@ typedef INT16_TYPE LogEst; + ** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY. +@@ -11967,6 +11909,7 @@ typedef INT16_TYPE LogEst; #ifndef SQLITE_MAX_MMAP_SIZE # if defined(__linux__) \ || defined(_WIN32) \ @@ -13496,7 +21347,34 @@ || (defined(__APPLE__) && defined(__MACH__)) \ || defined(__sun) \ || defined(__FreeBSD__) \ -@@ -10585,7 +10528,7 @@ struct VdbeOp { +@@ -12299,7 +12242,7 @@ SQLITE_PRIVATE int sqlite3BtreeIncrVacuu + #define BTREE_BLOBKEY 2 /* Table has keys only - no data */ + + SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*); +-SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*); ++SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, u64*); + SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*); + SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int); + +@@ -12460,7 +12403,7 @@ struct BtreePayload { + const void *pKey; /* Key content for indexes. NULL for tables */ + sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */ + const void *pData; /* Data for tables. NULL for indexes */ +- struct Mem *aMem; /* First of nMem value in the unpacked pKey */ ++ sqlite3_value *aMem; /* First of nMem value in the unpacked pKey */ + u16 nMem; /* Number of aMem[] value. Might be zero */ + int nData; /* Size of pData. 0 if none. */ + int nZero; /* Extra zero data appended after pData,nData */ +@@ -12590,7 +12533,7 @@ typedef struct Vdbe Vdbe; + ** The names of the following types declared in vdbeInt.h are required + ** for the VdbeOp definition. + */ +-typedef struct Mem Mem; ++typedef struct sqlite3_value Mem; + typedef struct SubProgram SubProgram; + + /* +@@ -12625,7 +12568,7 @@ struct VdbeOp { #endif int (*xAdvance)(BtCursor *, int *); } p4; @@ -13505,7 +21383,7 @@ char *zComment; /* Comment to improve readability */ #endif #ifdef VDBE_PROFILE -@@ -10944,11 +10887,11 @@ SQLITE_PRIVATE char *sqlite3VdbeExpand +@@ -13004,11 +12947,11 @@ SQLITE_PRIVATE char *sqlite3VdbeExpand SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*); @@ -13513,14 +21391,14 @@ -SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int); +SQLITE_PRIVATE int sqlite3VdbeRecordCompare(size_t,const void*,UnpackedRecord*); +SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(size_t, const void *, UnpackedRecord *, int); - SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **); + SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*); -typedef int (*RecordCompare)(int,const void*,UnpackedRecord*); +typedef int (*RecordCompare)(size_t,const void*,UnpackedRecord*); SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); #ifndef SQLITE_OMIT_TRIGGER -@@ -10962,7 +10905,7 @@ SQLITE_PRIVATE void sqlite3VdbeLinkSubPr +@@ -13022,7 +12965,7 @@ SQLITE_PRIVATE void sqlite3VdbeLinkSubPr ** comments in VDBE programs that show key decision points in the code ** generator. */ @@ -13529,7 +21407,7 @@ SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe*, const char*, ...); # define VdbeComment(X) sqlite3VdbeComment X SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); -@@ -10973,9 +10916,13 @@ SQLITE_PRIVATE void sqlite3VdbeNoopCom +@@ -13033,9 +12976,13 @@ SQLITE_PRIVATE void sqlite3VdbeNoopCom # define VdbeModuleComment(X) # endif #else @@ -13546,7 +21424,7 @@ #endif /* -@@ -11319,7 +11266,7 @@ SQLITE_PRIVATE void sqlite3PcacheShutdow +@@ -13396,7 +13343,7 @@ SQLITE_PRIVATE void sqlite3PcacheShutdow /* Page cache buffer management: ** These routines implement SQLITE_CONFIG_PAGECACHE. */ @@ -13555,7 +21433,7 @@ /* Create a new pager cache. ** Under memory stress, invoke xStress to try to make pages clean. -@@ -11415,7 +11362,7 @@ SQLITE_PRIVATE void sqlite3PcacheShrink( +@@ -13498,7 +13445,7 @@ SQLITE_PRIVATE void sqlite3PcacheShrink( #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT /* Try to return memory used by the pcache module to the main memory heap */ @@ -13564,7 +21442,7 @@ #endif #ifdef SQLITE_TEST -@@ -11502,10 +11449,13 @@ SQLITE_PRIVATE int sqlite3HeaderSizePcac +@@ -13587,10 +13534,13 @@ SQLITE_PRIVATE int sqlite3PCachePercentD #if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER) # define SQLITE_OS_OTHER 0 # ifndef SQLITE_OS_WIN @@ -13579,7 +21457,7 @@ # else # define SQLITE_OS_WIN 0 # define SQLITE_OS_UNIX 1 -@@ -11753,7 +11703,7 @@ SQLITE_PRIVATE int sqlite3OsCloseFree(sq +@@ -13839,7 +13789,7 @@ SQLITE_PRIVATE void sqlite3OsCloseFree(s # define SQLITE_MUTEX_OMIT #endif #if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) @@ -13588,25 +21466,66 @@ # define SQLITE_MUTEX_PTHREADS # elif SQLITE_OS_WIN # define SQLITE_MUTEX_W32 -@@ -12038,7 +11988,7 @@ struct sqlite3 { +@@ -13909,7 +13859,7 @@ SQLITE_PRIVATE void sqlite3OsCloseFree(s + ** databases may be attached. + */ + struct Db { +- char *zDbSName; /* Name of this database. (schema name, not filename) */ ++ const char *zDbSName; /* Name of this database. (schema name, not filename) */ + Btree *pBt; /* The B*Tree structure for this database file */ + u8 safety_level; /* How aggressive at syncing data to disk */ + u8 bSyncSet; /* True if "PRAGMA synchronous=N" has been run */ +@@ -14104,8 +14054,8 @@ struct sqlite3 { + u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */ + int nextPagesize; /* Pagesize after VACUUM if >0 */ + u32 magic; /* Magic number for detect library misuse */ +- int nChange; /* Value returned by sqlite3_changes() */ +- int nTotalChange; /* Value returned by sqlite3_total_changes() */ ++ u64 nChange; /* Value returned by sqlite3_changes() */ ++ u64 nTotalChange; /* Value returned by sqlite3_total_changes() */ + int aLimit[SQLITE_N_LIMIT]; /* Limits */ + int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */ + struct sqlite3InitInfo { /* Information used during initialization */ +@@ -14178,7 +14128,7 @@ struct sqlite3 { int nStatement; /* Number of nested statement-transactions */ i64 nDeferredCons; /* Net deferred constraints this transaction. */ i64 nDeferredImmCons; /* Net deferred immediate constraints */ - int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ + size_t *pnBytesFreed; /* If not NULL, increment this in DbFree() */ #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY - /* The following variables are all protected by the STATIC_MASTER - ** mutex, not by sqlite3.mutex. They are used by code in notify.c. -@@ -13529,7 +13479,7 @@ struct Parse { - int nSet; /* Number of sets used so far */ - int nOnce; /* Number of OP_Once instructions so far */ + /* The following variables are all protected by the STATIC_MASTER + ** mutex, not by sqlite3.mutex. They are used by code in notify.c. +@@ -15657,7 +15607,7 @@ struct TriggerPrg { + /* + ** The yDbMask datatype for the bitmask of all attached databases. + */ +-#if SQLITE_MAX_ATTACHED>30 ++#if SQLITE_MAX_ATTACHED>62 + typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8]; + # define DbMaskTest(M,I) (((M)[(I)/8]&(1<<((I)&7)))!=0) + # define DbMaskZero(M) memset((M),0,sizeof(M)) +@@ -15665,7 +15615,11 @@ struct TriggerPrg { + # define DbMaskAllZero(M) sqlite3DbMaskAllZero(M) + # define DbMaskNonZero(M) (sqlite3DbMaskAllZero(M)==0) + #else ++#if SQLITE_MAX_ATTACHED>30 ++ typedef u64 yDbMask; ++#else + typedef unsigned int yDbMask; ++#endif + # define DbMaskTest(M,I) (((M)&(((yDbMask)1)<<(I)))!=0) + # define DbMaskZero(M) (M)=0 + # define DbMaskSet(M,I) (M)|=(((yDbMask)1)<<(I)) +@@ -15710,7 +15664,7 @@ struct Parse { + int nTab; /* Number of previously allocated VDBE cursors */ + int nMem; /* Number of memory cells used so far */ int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ - int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ + size_t szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ - int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ int ckBase; /* Base register of data during check constraints */ int iSelfTab; /* Table of an index whose exprs are being coded */ -@@ -13761,9 +13711,9 @@ struct StrAccum { + int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ +@@ -15966,9 +15920,9 @@ struct StrAccum { sqlite3 *db; /* Optional database for lookaside. Can be NULL */ char *zBase; /* A base allocation. Not from malloc. */ char *zText; /* The string collected so far */ @@ -13617,9 +21536,9 @@ + size_t nAlloc; /* Amount of space allocated in zText */ + size_t mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ - u8 bMalloced; /* zText points to allocated space */ + u8 printfFlags; /* SQLITE_PRINTF flags below */ }; -@@ -13782,6 +13732,32 @@ typedef struct { +@@ -15993,6 +15947,32 @@ typedef struct { } InitData; /* @@ -13627,12 +21546,12 @@ +*/ + +#ifndef SQLITE_OMIT_DEPRECATED -+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*); -+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*); -+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); -+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void); -+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void); -+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), ++SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); ++SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); ++SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); ++SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); ++SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); ++SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), + void*,sqlite3_int64); +#endif + @@ -13652,15 +21571,7 @@ ** Structure containing global configuration data for the SQLite library. ** ** This structure also contains some state information. -@@ -13793,7 +13769,6 @@ struct Sqlite3Config { - int bOpenUri; /* True to interpret filenames as URIs */ - int bUseCis; /* Use covering indices for full-scans */ - int mxStrlen; /* Maximum string length */ -- int neverCorrupt; /* Database is always well-formed */ - int szLookaside; /* Default lookaside buffer size */ - int nLookaside; /* Default lookaside buffer count */ - sqlite3_mem_methods m; /* Low-level memory allocation interface */ -@@ -13805,7 +13780,7 @@ struct Sqlite3Config { +@@ -16017,7 +15997,7 @@ struct Sqlite3Config { sqlite3_int64 szMmap; /* mmap() space per open file */ sqlite3_int64 mxMmap; /* Maximum value for szMmap */ void *pScratch; /* Scratch memory */ @@ -13669,31 +21580,33 @@ int nScratch; /* Number of scratch buffers */ void *pPage; /* Page cache memory */ int szPage; /* Size of each page in pPage[] */ -@@ -13824,6 +13799,7 @@ struct Sqlite3Config { +@@ -16036,6 +16016,8 @@ 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() */ + int bVdbeComments; /* True to enable VDBE comments */ ++ int bEnableUnknownSqlFunction; /* True to enable VDBE comments */ #ifdef SQLITE_ENABLE_SQLLOG void(*xSqllog)(void*,sqlite3*,const char*, int); void *pSqllogArg; -@@ -13837,8 +13813,9 @@ struct Sqlite3Config { +@@ -16049,8 +16031,8 @@ struct Sqlite3Config { #endif - #ifndef SQLITE_OMIT_BUILTIN_TEST + #ifndef SQLITE_UNTESTABLE int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ -#endif int bLocaltimeFault; /* True to fail localtime() calls */ +#endif -+ int neverCorrupt; /* Database is always well-formed */ + int iOnceResetThreshold; /* When to reset OP_Once counters */ }; - /* -@@ -13994,26 +13971,26 @@ SQLITE_PRIVATE int sqlite3IsIdChar(u8); +@@ -16227,28 +16209,28 @@ SQLITE_PRIVATE int sqlite3IsIdChar(u8); ** Internal function prototypes */ - #define sqlite3StrICmp sqlite3_stricmp + SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*); -SQLITE_PRIVATE int sqlite3Strlen30(const char*); +-SQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*); +SQLITE_PRIVATE size_t sqlite3Strlen30(const char*); ++SQLITE_PRIVATE const char *sqlite3ColumnType(Column*,const char*); #define sqlite3StrNICmp sqlite3_strnicmp SQLITE_PRIVATE int sqlite3MallocInit(void); @@ -13706,6 +21619,7 @@ +SQLITE_PRIVATE void *sqlite3MallocZero(size_t); +SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, size_t); +SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, size_t); + SQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3*, u64); SQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*); -SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64); -SQLITE_PRIVATE void *sqlite3Realloc(void*, u64); @@ -13727,8 +21641,18 @@ +SQLITE_PRIVATE void *sqlite3PageMalloc(size_t); SQLITE_PRIVATE void sqlite3PageFree(void*); SQLITE_PRIVATE void sqlite3MemSetDefault(void); - #ifndef SQLITE_OMIT_BUILTIN_TEST -@@ -14060,10 +14037,10 @@ SQLITE_PRIVATE void sqlite3MemoryBarri + #ifndef SQLITE_UNTESTABLE +@@ -16265,6 +16247,9 @@ SQLITE_PRIVATE int sqlite3HeapNearlyFull + ** that deal with sqlite3StackAlloc() failures to be unreachable. + */ + #ifdef SQLITE_USE_ALLOCA ++#if !defined(alloca) && defined(_WIN32) ++# define alloca _alloca ++#endif + # define sqlite3StackAllocRaw(D,N) alloca(N) + # define sqlite3StackAllocZero(D,N) memset(alloca(N), 0, N) + # define sqlite3StackFree(D,P) +@@ -16299,10 +16284,10 @@ SQLITE_PRIVATE void sqlite3MemoryBarri # define sqlite3MemoryBarrier() #endif @@ -13743,8 +21667,8 @@ /* Access to mutexes used by sqlite3_status() */ SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void); -@@ -14102,7 +14079,7 @@ SQLITE_PRIVATE void *sqlite3TestTextTo - SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8); +@@ -16340,7 +16325,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExp + SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*); SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*); SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8); -SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8); @@ -13752,25 +21676,43 @@ #endif -@@ -14342,7 +14319,7 @@ SQLITE_PRIVATE void sqlite3SelectSetName - # define sqlite3SelectSetName(A,B) +@@ -16440,7 +16425,7 @@ SQLITE_PRIVATE int sqlite3ViewGetColum + # define sqlite3ViewGetColumnNames(A,B) 0 #endif - SQLITE_PRIVATE void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*); --SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,u8); -+SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,size_t,int,u8,u8); - SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3*); - SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void); - SQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void); -@@ -14490,7 +14467,7 @@ SQLITE_PRIVATE void sqlite3FileSuffix3(c + +-#if SQLITE_MAX_ATTACHED>30 ++#if SQLITE_MAX_ATTACHED>62 + SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask); + #endif + SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int); +@@ -16480,7 +16465,7 @@ SQLITE_PRIVATE Table *sqlite3SrcListLook + SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); + SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); + #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) +-SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*); ++SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,const char*); + #endif + SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*); + SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); +@@ -16742,7 +16727,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAddColla + SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*); + SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *); + SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *); +-SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int); ++SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, u64); + SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64); + SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64); + SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64); +@@ -16755,7 +16740,7 @@ SQLITE_PRIVATE void sqlite3FileSuffix3(c SQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z,u8); SQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value*, u8); -SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8); +SQLITE_PRIVATE size_t sqlite3ValueBytes(sqlite3_value*, u8); - SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, + SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, void(*)(void*)); SQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value*); -@@ -14560,10 +14537,10 @@ SQLITE_PRIVATE int sqlite3CreateFunc(sql +@@ -16826,10 +16811,10 @@ SQLITE_PRIVATE void sqlite3OomClear(sqli SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); @@ -13784,24 +21726,16 @@ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*); SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*); SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int); -@@ -14583,7 +14560,7 @@ SQLITE_PRIVATE int sqlite3Stat4Column(sq - /* +@@ -16858,7 +16843,7 @@ SQLITE_PRIVATE char sqlite3IndexColumnAf ** The interface to the LEMON-generated parser */ --SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64)); -+SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); - SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); + #ifndef SQLITE_AMALGAMATION +-SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64)); ++SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); + SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); + #endif SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); - #ifdef YYTRACKMAXSTACKDEPTH -@@ -15016,7 +14993,6 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 - SQLITE_USE_URI, /* bOpenUri */ - SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */ - 0x7ffffffe, /* mxStrlen */ -- 0, /* neverCorrupt */ - 128, /* szLookaside */ - 500, /* nLookaside */ - {0,0,0,0,0,0,0,0}, /* m */ -@@ -15046,6 +15022,11 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 +@@ -17354,6 +17339,16 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 0, /* pInitMutex */ 0, /* xLog */ 0, /* pLogArg */ @@ -13809,22 +21743,36 @@ + 1, /* bVdbeComments */ +#else + 0, /* bVdbeComments */ ++#endif ++#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION ++ 1, /* bEnableUnknownSqlFunction */ ++#else ++ 0, /* bEnableUnknownSqlFunction */ +#endif #ifdef SQLITE_ENABLE_SQLLOG 0, /* xSqllog */ 0, /* pSqllogArg */ -@@ -15056,8 +15037,9 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 +@@ -17364,8 +17359,8 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3 #endif - #ifndef SQLITE_OMIT_BUILTIN_TEST + #ifndef SQLITE_UNTESTABLE 0, /* xTestCallback */ -+ 0, /* bLocaltimeFault */ - #endif -- 0 /* bLocaltimeFault */ -+ 0 /* neverCorrupt */ +-#endif + 0, /* bLocaltimeFault */ ++#endif + 0x7ffffffe /* iOnceResetThreshold */ }; - /* -@@ -15256,7 +15238,7 @@ static const char * const azCompileOpt[] +@@ -17554,9 +17549,6 @@ static const char * const azCompileOpt[] + #if SQLITE_ENABLE_JSON1 + "ENABLE_JSON1", + #endif +-#if SQLITE_ENABLE_LOAD_EXTENSION +- "ENABLE_LOAD_EXTENSION", +-#endif + #if SQLITE_ENABLE_LOCKING_STYLE + "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), + #endif +@@ -17583,7 +17575,7 @@ static const char * const azCompileOpt[] #if SQLITE_ENABLE_UNLOCK_NOTIFY "ENABLE_UNLOCK_NOTIFY", #endif @@ -13832,8 +21780,24 @@ +#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) "ENABLE_UPDATE_DELETE_LIMIT", #endif - #if SQLITE_HAS_CODEC -@@ -15764,7 +15746,7 @@ struct Mem { + #if defined(SQLITE_ENABLE_URI_00_ERROR) +@@ -18083,8 +18075,8 @@ struct VdbeFrame { + int nMem; /* Number of entries in aMem */ + int nChildMem; /* Number of memory cells for child frame */ + int nChildCsr; /* Number of cursors for child frame */ +- int nChange; /* Statement changes (Vdbe.nChange) */ +- int nDbChange; /* Value of db->nChange */ ++ u64 nChange; /* Statement changes (Vdbe.nChange) */ ++ u64 nDbChange; /* Value of db->nChange */ + }; + + #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))]) +@@ -18094,11 +18086,11 @@ struct VdbeFrame { + ** structures. Each Mem struct may cache multiple representations (string, + ** integer etc.) of the same value. + */ +-struct Mem { ++struct sqlite3_value { union MemValue { double r; /* Real value used when MEM_Real is set in flags */ i64 i; /* Integer value used when MEM_Int is set in flags */ @@ -13842,7 +21806,7 @@ FuncDef *pDef; /* Used only when flags==MEM_Agg */ RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ -@@ -15772,11 +15754,11 @@ struct Mem { +@@ -18106,11 +18098,11 @@ struct Mem { u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ u8 eSubtype; /* Subtype for this value */ @@ -13856,7 +21820,16 @@ u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */ sqlite3 *db; /* The associated database connection */ void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */ -@@ -16007,7 +15989,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorRest +@@ -18262,7 +18254,7 @@ struct Vdbe { + u32 cacheCtr; /* VdbeCursor row cache generation counter */ + int pc; /* The program counter */ + int rc; /* Value to return */ +- int nChange; /* Number of db changes made since last reset */ ++ u64 nChange; /* Number of db changes made since last reset */ + int iStatement; /* Statement number (or 0 if has not opened stmt) */ + i64 iCurrentTime; /* Value of julianday('now') for this statement */ + i64 nFkConstraint; /* Number of imm. FK constraints this VM */ +@@ -18358,7 +18350,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorRest #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*); #endif @@ -13865,7 +21838,7 @@ SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8); SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*); SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32); -@@ -16026,7 +16008,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemCopy(Me +@@ -18377,7 +18369,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemCopy(Me SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int); SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*); SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*); @@ -13874,7 +21847,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64); #ifdef SQLITE_OMIT_FLOATING_POINT # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64 -@@ -16035,7 +16017,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetD +@@ -18386,7 +18378,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetD #endif SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); @@ -13883,8 +21856,8 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); -@@ -16052,8 +16034,8 @@ SQLITE_PRIVATE void sqlite3VdbeMemReleas - (((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame))!=0) +@@ -18401,8 +18393,8 @@ SQLITE_PRIVATE int sqlite3VdbeMemFromBtr + SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); SQLITE_PRIVATE const char *sqlite3OpcodeName(int); -SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); @@ -13894,7 +21867,7 @@ SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int); SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *); -@@ -16110,15 +16092,10 @@ SQLITE_PRIVATE int sqlite3VdbeMemExpan +@@ -18466,15 +18458,10 @@ SQLITE_PRIVATE int sqlite3VdbeMemExpan /* ** Variables in which to record status information. */ @@ -13912,7 +21885,7 @@ } sqlite3Stat = { {0,}, {0,} }; /* -@@ -16157,7 +16134,7 @@ static const char statMutex[] = { +@@ -18513,7 +18500,7 @@ static const char statMutex[] = { ** Return the current value of a status parameter. The caller must ** be holding the appropriate mutex. */ @@ -13921,7 +21894,7 @@ wsdStatInit; assert( op>=0 && op=0 && op=0 && op=0 && op=0 && op=0 && op=0 && oppnBytesFreed = &nByte; -@@ -16349,10 +16322,10 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db +@@ -18710,10 +18693,10 @@ SQLITE_API int sqlite3_db_status( + pSchema->idxHash.count + pSchema->fkeyHash.count ); @@ -13978,7 +21951,7 @@ for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){ sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p)); -@@ -16366,7 +16339,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db +@@ -18727,7 +18710,7 @@ SQLITE_API int sqlite3_db_status( sqlite3BtreeLeaveAll(db); *pHighwater = 0; @@ -13987,7 +21960,7 @@ break; } -@@ -16377,7 +16350,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db +@@ -18738,7 +18721,7 @@ SQLITE_API int sqlite3_db_status( */ case SQLITE_DBSTATUS_STMT_USED: { struct Vdbe *pVdbe; /* Used to iterate through VMs */ @@ -13996,7 +21969,7 @@ db->pnBytesFreed = &nByte; for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){ -@@ -16387,7 +16360,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db +@@ -18748,7 +18731,7 @@ SQLITE_API int sqlite3_db_status( db->pnBytesFreed = 0; *pHighwater = 0; /* IMP: R-64479-57858 */ @@ -14005,16 +21978,27 @@ break; } -@@ -16619,7 +16592,7 @@ static int parseHhMmSs(const char *zDate +@@ -18910,8 +18893,8 @@ struct DateTime { + */ + static int getDigits(const char *zDate, const char *zFormat, ...){ + /* The aMx[] array translates the 3rd character of each format +- ** spec into a max size: a b c d e f */ +- static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 }; ++ ** spec into a max size: a b c d e f g */ ++ static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999, 60 }; + va_list ap; + int cnt = 0; + char nextC; +@@ -19007,7 +18990,7 @@ static int parseHhMmSs(const char *zDate zDate += 5; if( *zDate==':' ){ zDate++; -- if( getDigits(zDate, 2, 0, 59, 0, &s)!=1 ){ -+ if( getDigits(zDate, 2, 0, 60, 0, &s)!=1 ){ +- if( getDigits(zDate, "20e", &s)!=1 ){ ++ if( getDigits(zDate, "20g", &s)!=1 ){ return 1; } zDate += 2; -@@ -16904,7 +16877,7 @@ static int osLocaltime(time_t *t, struct +@@ -19339,7 +19322,7 @@ static int osLocaltime(time_t *t, struct #endif /* SQLITE_OMIT_LOCALTIME */ @@ -14023,12 +22007,12 @@ /* ** Compute the difference (in milliseconds) between localtime and UTC ** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs, -@@ -16918,6 +16891,16 @@ static sqlite3_int64 localtimeOffset( +@@ -19353,6 +19336,16 @@ static sqlite3_int64 localtimeOffset( sqlite3_context *pCtx, /* Write error here if one occurs */ int *pRc /* OUT: Error code. SQLITE_OK or ERROR */ ){ +#ifdef SQLITE_OMIT_LOCALTIME -+#ifndef SQLITE_OMIT_BUILTIN_TEST ++#ifndef SQLITE_UNTESTABLE + if( sqlite3GlobalConfig.bLocaltimeFault ) { + sqlite3_result_error(pCtx, "local time unavailable", -1); + *pRc = SQLITE_ERROR; @@ -14040,7 +22024,7 @@ DateTime x, y; time_t t; struct tm sLocal; -@@ -16965,6 +16948,7 @@ static sqlite3_int64 localtimeOffset( +@@ -19402,6 +19395,7 @@ static sqlite3_int64 localtimeOffset( computeJD(&y); *pRc = SQLITE_OK; return y.iJD - x.iJD; @@ -14048,34 +22032,57 @@ } #endif /* SQLITE_OMIT_LOCALTIME */ -@@ -17003,7 +16987,7 @@ static int parseModifier(sqlite3_context - } - z[n] = 0; - switch( z[0] ){ +@@ -19416,16 +19410,16 @@ static sqlite3_int64 localtimeOffset( + static const struct { + u8 eType; /* Transformation type code */ + u8 nName; /* Length of th name */ +- char *zName; /* Name of the transformation */ ++ const char *zName; /* Name of the transformation */ + double rLimit; /* Maximum NNN value for this transform */ + double rXform; /* Constant used for this transform */ + } aXformType[] = { +- { 0, 6, "second", 464269060800.0, 86400000.0/(24.0*60.0*60.0) }, +- { 0, 6, "minute", 7737817680.0, 86400000.0/(24.0*60.0) }, +- { 0, 4, "hour", 128963628.0, 86400000.0/24.0 }, ++ { 0, 6, "second", 464269060800.0, 1000.0 }, ++ { 0, 6, "minute", 7737817680.0, 60000.0 }, ++ { 0, 4, "hour", 128963628.0, 3600000.0 }, + { 0, 3, "day", 5373485.0, 86400000.0 }, +- { 1, 5, "month", 176546.0, 30.0*86400000.0 }, +- { 2, 4, "year", 14713.0, 365.0*86400000.0 }, ++ { 1, 5, "month", 176546.0, 2592000000.0 }, ++ { 2, 4, "year", 14713.0, 31536000000.0 }, + }; + + /* +@@ -19461,7 +19455,7 @@ static int parseModifier( + int rc = 1; + double r; + switch(sqlite3UpperToLower[(u8)z[0]] ){ -#ifndef SQLITE_OMIT_LOCALTIME +#if 1 case 'l': { /* localtime ** -@@ -17030,7 +17014,7 @@ static int parseModifier(sqlite3_context - clearYMD_HMS_TZ(p); - rc = 0; +@@ -19493,7 +19487,7 @@ static int parseModifier( + rc = 0; + } } -#ifndef SQLITE_OMIT_LOCALTIME +#if 1 - else if( strcmp(z, "utc")==0 ){ + else if( sqlite3_stricmp(z, "utc")==0 ){ if( p->tzSet==0 ){ sqlite3_int64 c1; -@@ -17882,7 +17866,7 @@ SQLITE_PRIVATE int sqlite3OsCloseFree(sq +@@ -20365,7 +20359,7 @@ SQLITE_PRIVATE void sqlite3OsCloseFree(s ** error in sqlite3_os_init() by the upper layers can be tested. */ SQLITE_PRIVATE int sqlite3OsInit(void){ - void *p = sqlite3_malloc(10); + void *p = sqlite3Malloc(10); - if( p==0 ) return SQLITE_NOMEM; + if( p==0 ) return SQLITE_NOMEM_BKPT; sqlite3_free(p); return sqlite3_os_init(); -@@ -18104,11 +18088,11 @@ SQLITE_PRIVATE void sqlite3EndBenignMall +@@ -20587,11 +20581,11 @@ SQLITE_PRIVATE void sqlite3EndBenignMall /* ** No-op versions of all memory allocation routines */ @@ -14091,7 +22098,7 @@ static int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; } static void sqlite3MemShutdown(void *NotUsed){ return; } -@@ -18226,7 +18210,7 @@ static malloc_zone_t* _sqliteZone_; +@@ -20711,7 +20705,7 @@ static malloc_zone_t* _sqliteZone_; ** -DSQLITE_WITHOUT_MSIZE. Using the _msize() function also requires ** the malloc.h header file. */ @@ -14100,14 +22107,26 @@ # define SQLITE_USE_MALLOC_H # define SQLITE_USE_MSIZE #endif -@@ -18261,12 +18245,12 @@ static malloc_zone_t* _sqliteZone_; +@@ -20725,6 +20719,9 @@ static malloc_zone_t* _sqliteZone_; + */ + #if defined(SQLITE_USE_MALLOC_H) + # include ++#if !defined(alloca) && defined(_WIN32) ++# define alloca _alloca ++#endif + # if defined(SQLITE_USE_MALLOC_USABLE_SIZE) + # if !defined(SQLITE_MALLOCSIZE) + # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x) +@@ -20746,14 +20743,14 @@ static malloc_zone_t* _sqliteZone_; ** cases of nByte<=0 will be intercepted and dealt with by higher level ** routines. */ -static void *sqlite3MemMalloc(int nByte){ +static void *sqlite3MemMalloc(size_t nByte){ #ifdef SQLITE_MALLOCSIZE - void *p = SQLITE_MALLOC( nByte ); + void *p; + testcase( ROUND8(nByte)==nByte ); + p = SQLITE_MALLOC( nByte ); if( p==0 ){ testcase( sqlite3GlobalConfig.xLog!=0 ); - sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); @@ -14115,7 +22134,7 @@ } return p; #else -@@ -18279,7 +18263,7 @@ static void *sqlite3MemMalloc(int nByte) +@@ -20766,7 +20763,7 @@ static void *sqlite3MemMalloc(int nByte) p++; }else{ testcase( sqlite3GlobalConfig.xLog!=0 ); @@ -14124,7 +22143,7 @@ } return (void *)p; #endif -@@ -18308,16 +18292,16 @@ static void sqlite3MemFree(void *pPrior) +@@ -20795,16 +20792,16 @@ static void sqlite3MemFree(void *pPrior) ** Report the allocated size of a prior return from xMalloc() ** or xRealloc(). */ @@ -14144,7 +22163,7 @@ #endif } -@@ -18331,14 +18315,14 @@ static int sqlite3MemSize(void *pPrior){ +@@ -20818,14 +20815,14 @@ static int sqlite3MemSize(void *pPrior){ ** cases where nByte<=0 will have been intercepted by higher-level ** routines and redirected to xFree. */ @@ -14162,7 +22181,7 @@ } return p; #else -@@ -18353,8 +18337,8 @@ static void *sqlite3MemRealloc(void *pPr +@@ -20840,8 +20837,8 @@ static void *sqlite3MemRealloc(void *pPr }else{ testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, @@ -14173,7 +22192,7 @@ } return (void*)p; #endif -@@ -18363,7 +18347,7 @@ static void *sqlite3MemRealloc(void *pPr +@@ -20850,7 +20847,7 @@ static void *sqlite3MemRealloc(void *pPr /* ** Round up a request size to the next valid allocation size. */ @@ -14182,7 +22201,7 @@ return ROUND8(n); } -@@ -18490,20 +18474,20 @@ SQLITE_PRIVATE void sqlite3MemSetDefault +@@ -20968,20 +20965,20 @@ SQLITE_PRIVATE void sqlite3MemSetDefault ** MemBlockHdr. */ struct MemBlockHdr { @@ -14207,7 +22226,7 @@ /* ** Number of malloc size increments to track. -@@ -18588,13 +18572,16 @@ static void adjustStats(int iSize, int i +@@ -21066,13 +21063,16 @@ static void adjustStats(int iSize, int i */ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){ struct MemBlockHdr *p; @@ -14226,7 +22245,7 @@ nReserve = ROUND8(p->iSize); pInt = (int*)pAllocation; pU8 = (u8*)pAllocation; -@@ -18604,19 +18591,20 @@ static struct MemBlockHdr *sqlite3Memsys +@@ -21082,19 +21082,20 @@ static struct MemBlockHdr *sqlite3Memsys ** they haven't been overwritten. */ while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 ); @@ -14249,7 +22268,7 @@ } /* -@@ -18644,7 +18632,7 @@ static void sqlite3MemShutdown(void *Not +@@ -21122,7 +21123,7 @@ static void sqlite3MemShutdown(void *Not /* ** Round up a request size to the next valid allocation size. */ @@ -14258,7 +22277,7 @@ return ROUND8(n); } -@@ -18653,7 +18641,7 @@ static int sqlite3MemRoundup(int n){ +@@ -21131,7 +21132,7 @@ static int sqlite3MemRoundup(int n){ ** the content of a new memory allocation to unpredictable values and ** to clear the content of a freed allocation to unpredictable values. */ @@ -14267,7 +22286,7 @@ unsigned int x, y, r; x = SQLITE_PTR_TO_INT(pBuf); y = nByte | 1; -@@ -18676,14 +18664,14 @@ static void randomFill(char *pBuf, int n +@@ -21154,14 +21155,14 @@ static void randomFill(char *pBuf, int n /* ** Allocate nByte bytes of memory. */ @@ -14285,7 +22304,7 @@ sqlite3_mutex_enter(mem.mutex); assert( mem.disallow==0 ); nReserve = ROUND8(nByte); -@@ -18777,7 +18765,7 @@ static void sqlite3MemFree(void *pPrior) +@@ -21255,7 +21256,7 @@ static void sqlite3MemFree(void *pPrior) ** much more likely to break and we are much more liking to find ** the error. */ @@ -14294,7 +22313,7 @@ struct MemBlockHdr *pOldHdr; void *pNew; assert( mem.disallow==0 ); -@@ -18924,8 +18912,8 @@ SQLITE_PRIVATE void sqlite3MemdebugDump( +@@ -21402,8 +21403,8 @@ SQLITE_PRIVATE void sqlite3MemdebugDump( for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){ char *z = (char*)pHdr; z -= pHdr->nBacktraceSlots*sizeof(void*) + pHdr->nTitle; @@ -14305,7 +22324,7 @@ if( pHdr->nBacktrace ){ fflush(out); pBt = (void**)pHdr; -@@ -19200,12 +19188,14 @@ static void memsys3Leave(void){ +@@ -21678,12 +21679,14 @@ static void memsys3Leave(void){ /* ** Called when we are unable to satisfy an allocation of nBytes. */ @@ -14322,7 +22341,7 @@ sqlite3_mutex_enter(mem3.mutex); mem3.alarmBusy = 0; } -@@ -19319,9 +19309,9 @@ static void memsys3Merge(u32 *pRoot){ +@@ -21797,9 +21800,9 @@ static void memsys3Merge(u32 *pRoot){ ** This function assumes that the necessary mutexes, if any, are ** already held by the caller. Hence "Unsafe". */ @@ -14334,7 +22353,7 @@ u32 toFree; assert( sqlite3_mutex_held(mem3.mutex) ); -@@ -19345,7 +19335,7 @@ static void *memsys3MallocUnsafe(int nBy +@@ -21823,7 +21826,7 @@ static void *memsys3MallocUnsafe(int nBy return memsys3Checkout(i, nBlock); } }else{ @@ -14343,7 +22362,7 @@ for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){ if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){ memsys3UnlinkFromList(i, &mem3.aiHash[hash]); -@@ -19442,7 +19432,7 @@ static void memsys3FreeUnsafe(void *pOld +@@ -21920,7 +21923,7 @@ static void memsys3FreeUnsafe(void *pOld ** size returned omits the 8-byte header overhead. This only ** works for chunks that are currently checked out. */ @@ -14352,7 +22371,7 @@ Mem3Block *pBlock; assert( p!=0 ); pBlock = (Mem3Block*)p; -@@ -19453,7 +19443,7 @@ static int memsys3Size(void *p){ +@@ -21931,7 +21934,7 @@ static int memsys3Size(void *p){ /* ** Round up a request size to the next valid allocation size. */ @@ -14361,7 +22380,7 @@ if( n<=12 ){ return 12; }else{ -@@ -19464,7 +19454,7 @@ static int memsys3Roundup(int n){ +@@ -21942,7 +21945,7 @@ static int memsys3Roundup(int n){ /* ** Allocate nBytes of memory. */ @@ -14370,7 +22389,7 @@ sqlite3_int64 *p; assert( nBytes>0 ); /* malloc.c filters out 0 byte requests */ memsys3Enter(); -@@ -19486,11 +19476,11 @@ static void memsys3Free(void *pPrior){ +@@ -21964,11 +21967,11 @@ static void memsys3Free(void *pPrior){ /* ** Change the size of an existing memory allocation */ @@ -14385,7 +22404,7 @@ } if( nBytes<=0 ){ sqlite3_free(pPrior); -@@ -19554,8 +19544,8 @@ static void memsys3Shutdown(void *NotUse +@@ -22032,8 +22035,8 @@ static void memsys3Shutdown(void *NotUse ** Open the file indicated and write a log of all unfreed memory ** allocations into that log. */ @@ -14395,7 +22414,7 @@ FILE *out; u32 i, j; u32 size; -@@ -19622,10 +19612,8 @@ SQLITE_PRIVATE void sqlite3Memsys3Dump(c +@@ -22100,10 +22103,8 @@ SQLITE_PRIVATE void sqlite3Memsys3Dump(c }else{ fclose(out); } @@ -14407,7 +22426,7 @@ /* ** This routine is the only routine in this file with external -@@ -19751,8 +19739,8 @@ static SQLITE_WSD struct Mem5Global { +@@ -22229,8 +22230,8 @@ static SQLITE_WSD struct Mem5Global { /* ** Memory available for allocation */ @@ -14418,16 +22437,16 @@ u8 *zPool; /* Memory available to be allocated */ /* -@@ -19770,7 +19758,7 @@ static SQLITE_WSD struct Mem5Global { +@@ -22249,7 +22250,7 @@ static SQLITE_WSD struct Mem5Global { u32 currentCount; /* Current number of distinct checkouts */ u32 maxOut; /* Maximum instantaneous currentOut */ u32 maxCount; /* Maximum instantaneous currentCount */ - u32 maxRequest; /* Largest allocation (exclusive of internal frag) */ + size_t maxRequest; /* Largest allocation (exclusive of internal frag) */ + #endif /* - ** Lists of free blocks. aiFreelist[0] is a list of free blocks of -@@ -19802,10 +19790,10 @@ static SQLITE_WSD struct Mem5Global { +@@ -22282,10 +22283,10 @@ static SQLITE_WSD struct Mem5Global { ** Unlink the chunk at mem5.aPool[i] from list it is currently ** on. It should be found on mem5.aiFreelist[iLogsize]. */ @@ -14441,7 +22460,7 @@ assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); next = MEM5LINK(i)->next; -@@ -19854,8 +19842,9 @@ static void memsys5Leave(void){ +@@ -22334,8 +22335,9 @@ static void memsys5Leave(void){ ** Return the size of an outstanding allocation, in bytes. ** This only works for chunks that are currently checked out. */ @@ -14453,7 +22472,7 @@ assert( p!=0 ); i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom); assert( i>=0 && i0 ); ++#if 0 + /* No more than 1GiB per allocation */ + if( nByte > 0x40000000 ) return 0; ++#endif + + #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) /* Keep track of the maximum allocation request. Even unfulfilled ** requests are counted */ - if( (u32)nByte>mem5.maxRequest ){ -- /* Abort if the requested allocation size is larger than the largest -- ** power of two that we can represent using 32-bit signed integers. */ -- if( nByte > 0x40000000 ) return 0; + if( nByte>mem5.maxRequest ){ mem5.maxRequest = nByte; } - -@@ -19907,10 +19893,10 @@ static void *memsys5MallocUnsafe(int nBy + #endif +@@ -22390,10 +22394,10 @@ static void *memsys5MallocUnsafe(int nBy i = mem5.aiFreelist[iBin]; memsys5Unlink(i, iBin); while( iBin>iLogsize ){ @@ -14491,7 +22513,7 @@ mem5.aCtrl[i+newSize] = CTRL_FREE | iBin; memsys5Link(i+newSize, iBin); } -@@ -19939,21 +19925,21 @@ static void *memsys5MallocUnsafe(int nBy +@@ -22424,21 +22428,21 @@ static void *memsys5MallocUnsafe(int nBy ** Free an outstanding memory allocation. */ static void memsys5FreeUnsafe(void *pOld){ @@ -14518,7 +22540,7 @@ assert( iBlock+size-1<(u32)mem5.nBlock ); mem5.aCtrl[iBlock] |= CTRL_FREE; -@@ -19967,14 +19953,14 @@ static void memsys5FreeUnsafe(void *pOld +@@ -22455,7 +22459,7 @@ static void memsys5FreeUnsafe(void *pOld mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize; while( ALWAYS(iLogsize>iLogsize) & 1 ){ iBuddy = iBlock - size; - }else{ - iBuddy = iBlock + size; - } - assert( iBuddy>=0 ); -- if( (iBuddy+(1<mem5.nBlock ) break; -+ if( (iBuddy+((size_t)1<mem5.nBlock ) break; - if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break; - memsys5Unlink(iBuddy, iLogsize); - iLogsize++; -@@ -20001,7 +19987,7 @@ static void memsys5FreeUnsafe(void *pOld + assert( iBuddy>=0 ); +@@ -22489,7 +22493,7 @@ static void memsys5FreeUnsafe(void *pOld /* ** Allocate nBytes of memory. */ @@ -14544,7 +22558,7 @@ sqlite3_int64 *p = 0; if( nBytes>0 ){ memsys5Enter(); -@@ -20036,8 +20022,8 @@ static void memsys5Free(void *pPrior){ +@@ -22524,8 +22528,8 @@ static void memsys5Free(void *pPrior){ ** (an allocation larger than 0x40000000) was requested and this ** routine should return 0 without freeing pPrior. */ @@ -14555,7 +22569,7 @@ void *p; assert( pPrior!=0 ); assert( (nBytes&(nBytes-1))==0 ); /* EV: R-46199-30249 */ -@@ -20066,9 +20052,8 @@ static void *memsys5Realloc(void *pPrior +@@ -22554,9 +22558,8 @@ static void *memsys5Realloc(void *pPrior ** 32-bit signed integer. Hence the largest allocation is 0x40000000 ** or 1073741824 bytes. */ @@ -14567,7 +22581,7 @@ for(iFullSz=mem5.szAtom; iFullSz 3 ** memsys5Log(9) -> 4 */ @@ -14579,7 +22593,7 @@ return iLog; } -@@ -20097,10 +20082,10 @@ static int memsys5Log(int iValue){ +@@ -22585,10 +22588,10 @@ static int memsys5Log(int iValue){ */ static int memsys5Init(void *NotUsed){ int ii; /* Loop counter */ @@ -14592,7 +22606,7 @@ UNUSED_PARAMETER(NotUsed); -@@ -20118,8 +20103,8 @@ static int memsys5Init(void *NotUsed){ +@@ -22606,8 +22609,8 @@ static int memsys5Init(void *NotUsed){ /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */ nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq); @@ -14603,7 +22617,7 @@ mem5.szAtom = mem5.szAtom << 1; } -@@ -20133,7 +20118,7 @@ static int memsys5Init(void *NotUsed){ +@@ -22621,7 +22624,7 @@ static int memsys5Init(void *NotUsed){ iOffset = 0; for(ii=LOGMAX; ii>=0; ii--){ @@ -14612,7 +22626,7 @@ if( (iOffset+nAlloc)<=mem5.nBlock ){ mem5.aCtrl[iOffset] = ii | CTRL_FREE; memsys5Link(iOffset, ii); -@@ -20185,14 +20170,14 @@ SQLITE_PRIVATE void sqlite3Memsys5Dump(c +@@ -22673,14 +22676,14 @@ SQLITE_PRIVATE void sqlite3Memsys5Dump(c for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){} fprintf(out, "freelist items of size %d: %d\n", mem5.szAtom << i, n); } @@ -14631,7 +22645,7 @@ memsys5Leave(); if( out==stdout ){ fflush(stdout); -@@ -21251,9 +21236,15 @@ SQLITE_API int sqlite3_open_file_count = +@@ -23739,9 +23742,16 @@ SQLITE_API extern int sqlite3_open_file_ */ #include "windows.h" @@ -14639,6 +22653,7 @@ #ifdef __CYGWIN__ # include -# include /* amalgamator: dontcache */ ++# include /* amalgamator: dontcache */ +# include /* amalgamator: dontcache */ +#elif defined(_WIN32) +enum { @@ -14648,7 +22663,7 @@ #endif /* -@@ -21310,7 +21301,7 @@ SQLITE_API int sqlite3_open_file_count = +@@ -23798,7 +23808,7 @@ SQLITE_API extern int sqlite3_open_file_ ** functions are not available (e.g. those not using MSVC, Cygwin, etc). */ #if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \ @@ -14657,7 +22672,7 @@ # define SQLITE_OS_WIN_THREADS 1 #else # define SQLITE_OS_WIN_THREADS 0 -@@ -21333,8 +21324,10 @@ SQLITE_API int sqlite3_open_file_count = +@@ -23821,8 +23831,10 @@ SQLITE_API extern int sqlite3_open_file_ */ struct sqlite3_mutex { CRITICAL_SECTION mutex; /* Mutex controlling the lock */ @@ -14669,7 +22684,7 @@ volatile int nRef; /* Number of enterances */ volatile DWORD owner; /* Thread holding this mutex */ volatile int trace; /* True to trace changes */ -@@ -21351,6 +21344,8 @@ struct sqlite3_mutex { +@@ -23839,6 +23851,8 @@ struct sqlite3_mutex { #ifdef SQLITE_DEBUG #define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, \ 0L, (DWORD)0, 0 } @@ -14678,7 +22693,7 @@ #else #define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0 } #endif -@@ -21411,7 +21406,6 @@ static sqlite3_mutex winMutex_staticMute +@@ -23898,7 +23912,6 @@ static sqlite3_mutex winMutex_staticMute }; static int winMutex_isInit = 0; @@ -14686,18 +22701,18 @@ /* As the winMutexInit() and winMutexEnd() functions are called as part ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the -@@ -21419,7 +21413,9 @@ static int winMutex_isNt = -1; /* <0 mea +@@ -23906,7 +23919,9 @@ static int winMutex_isNt = -1; /* <0 mea */ static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0; --SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */ +-SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */ +#if defined(__CYGWIN__) && defined(SQLITE_AMALGAMATION) +static +#endif - SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ + SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ static int winMutexInit(void){ -@@ -21515,9 +21511,9 @@ static sqlite3_mutex *winMutexAlloc(int +@@ -24002,9 +24017,9 @@ static sqlite3_mutex *winMutexAlloc(int case SQLITE_MUTEX_RECURSIVE: { p = sqlite3MallocZero( sizeof(*p) ); if( p ){ @@ -14709,7 +22724,7 @@ p->trace = 1; #endif #endif -@@ -21537,9 +21533,9 @@ static sqlite3_mutex *winMutexAlloc(int +@@ -24024,9 +24039,9 @@ static sqlite3_mutex *winMutexAlloc(int } #endif p = &winMutex_staticMutexes[iType-2]; @@ -14721,7 +22736,7 @@ p->trace = 1; #endif #endif -@@ -21558,14 +21554,19 @@ static sqlite3_mutex *winMutexAlloc(int +@@ -24045,14 +24060,19 @@ static sqlite3_mutex *winMutexAlloc(int static void winMutexFree(sqlite3_mutex *p){ assert( p ); assert( p->nRef==0 && p->owner==0 ); @@ -14744,7 +22759,7 @@ } /* -@@ -21613,30 +21614,15 @@ static int winMutexTry(sqlite3_mutex *p) +@@ -24100,30 +24120,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. @@ -14775,8 +22790,8 @@ -#endif #ifdef SQLITE_DEBUG if( p->trace ){ - OSTRACE(("TRY-MUTEX tid=%lu, mutex=%p (%d), owner=%lu, nRef=%d, rc=%s\n", -@@ -21745,7 +21731,7 @@ typedef struct ScratchFreeslot { + OSTRACE(("TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\n", +@@ -24232,7 +24237,7 @@ typedef struct ScratchFreeslot { */ static SQLITE_WSD struct Mem0Global { sqlite3_mutex *mutex; /* Mutex to serialize access */ @@ -14785,10 +22800,10 @@ /* ** Pointers to the end of sqlite3GlobalConfig.pScratch memory -@@ -21796,9 +21782,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_me +@@ -24283,9 +24288,8 @@ SQLITE_API int sqlite3_memory_alarm( ** negative value indicates no limit. */ - SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){ + SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ - sqlite3_int64 priorLimit; - sqlite3_int64 excess; - sqlite3_int64 nUsed; @@ -14797,7 +22812,7 @@ #ifndef SQLITE_OMIT_AUTOINIT int rc = sqlite3_initialize(); if( rc ) return -1; -@@ -21811,16 +21796,20 @@ SQLITE_API sqlite3_int64 SQLITE_STDCALL +@@ -24298,16 +24302,20 @@ SQLITE_API sqlite3_int64 sqlite3_soft_he } mem0.alarmThreshold = n; nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); @@ -14813,7 +22828,7 @@ } +#ifndef SQLITE_OMIT_DEPRECATED +#undef sqlite3_soft_heap_limit - SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){ + SQLITE_API void sqlite3_soft_heap_limit(int n){ if( n<0 ) n = 0; sqlite3_soft_heap_limit64(n); } @@ -14821,7 +22836,7 @@ /* ** Initialize the memory allocation subsystem. -@@ -21906,10 +21895,12 @@ SQLITE_API sqlite3_int64 SQLITE_STDCALL +@@ -24393,10 +24401,12 @@ SQLITE_API sqlite3_int64 sqlite3_memory_ /* ** Trigger the alarm */ @@ -14836,27 +22851,30 @@ sqlite3_mutex_enter(mem0.mutex); } -@@ -21917,15 +21908,15 @@ static void sqlite3MallocAlarm(int nByte +@@ -24404,9 +24414,9 @@ static void sqlite3MallocAlarm(int nByte ** Do a memory allocation with statistics and alarms. Assume the ** lock is already held. */ --static int mallocWithAlarm(int n, void **pp){ -- int nFull; -+static size_t mallocWithAlarm(size_t n, void **pp){ -+ size_t nFull; +-static void mallocWithAlarm(int n, void **pp){ ++static void mallocWithAlarm(size_t n, void **pp){ void *p; +- int nFull; ++ size_t nFull; assert( sqlite3_mutex_held(mem0.mutex) ); - nFull = sqlite3GlobalConfig.m.xRoundup(n); + assert( n>0 ); + +@@ -24426,8 +24436,8 @@ static void mallocWithAlarm(int n, void + sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n); if( mem0.alarmThreshold>0 ){ - sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); - if( nUsed >= mem0.alarmThreshold - nFull ){ + size_t nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); -+ if( nUsed + nFull >= mem0.alarmThreshold ){ ++ if( (nUsed + nFull >= mem0.alarmThreshold) || (nUsed + nFull < nUsed) ){ mem0.nearlyFull = 1; sqlite3MallocAlarm(nFull); }else{ -@@ -21952,9 +21943,9 @@ static int mallocWithAlarm(int n, void * +@@ -24453,9 +24463,9 @@ static void mallocWithAlarm(int n, void ** Allocate memory. This routine is like sqlite3_malloc() except that it ** assumes the memory subsystem has already been initialized. */ @@ -14868,7 +22886,7 @@ /* A memory allocation of a number of bytes which is near the maximum ** signed integer value might cause an integer overflow inside of the ** xMalloc(). Hence we limit the maximum size to 0x7fffff00, giving -@@ -21963,10 +21954,10 @@ SQLITE_PRIVATE void *sqlite3Malloc(u64 n +@@ -24464,10 +24474,10 @@ SQLITE_PRIVATE void *sqlite3Malloc(u64 n p = 0; }else if( sqlite3GlobalConfig.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); @@ -14881,13 +22899,13 @@ } assert( EIGHT_BYTE_ALIGNMENT(p) ); /* IMP: R-11148-40995 */ return p; -@@ -21977,18 +21968,26 @@ SQLITE_PRIVATE void *sqlite3Malloc(u64 n +@@ -24478,18 +24488,26 @@ SQLITE_PRIVATE void *sqlite3Malloc(u64 n ** First make sure the memory subsystem is initialized, then do the ** allocation. */ +#undef sqlite3_malloc +#if !defined(SQLITE_OMIT_DEPRECATED) || SQLITE_PTRSIZE<8 - SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){ + SQLITE_API void *sqlite3_malloc(int n){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif @@ -14896,7 +22914,7 @@ } +#endif +#define sqlite3_malloc(x) sqlite3Malloc(x) - SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){ + SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif @@ -14909,7 +22927,7 @@ /* ** Each thread may only have a single outstanding allocation from -@@ -22009,7 +22008,7 @@ static int scratchAllocOut = 0; +@@ -24510,7 +24528,7 @@ static int scratchAllocOut = 0; ** structures that would not normally fit on the stack of an ** embedded processor. */ @@ -14918,7 +22936,7 @@ void *p; assert( n>0 ); -@@ -22075,7 +22074,7 @@ SQLITE_PRIVATE void sqlite3ScratchFree(v +@@ -24576,7 +24594,7 @@ SQLITE_PRIVATE void sqlite3ScratchFree(v assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_SCRATCH) ); sqlite3MemdebugSetType(p, MEMTYPE_HEAP); if( sqlite3GlobalConfig.bMemstat ){ @@ -14927,7 +22945,7 @@ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusDown(SQLITE_STATUS_SCRATCH_OVERFLOW, iSize); sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, iSize); -@@ -22104,11 +22103,11 @@ static int isLookaside(sqlite3 *db, void +@@ -24605,11 +24623,11 @@ static int isLookaside(sqlite3 *db, void ** Return the size of a memory allocation previously obtained from ** sqlite3Malloc() or sqlite3_malloc(). */ @@ -14940,8 +22958,8 @@ +SQLITE_PRIVATE size_t sqlite3DbMallocSize(sqlite3 *db, void *p){ assert( p!=0 ); if( db==0 || !isLookaside(db,p) ){ - #if SQLITE_DEBUG -@@ -22192,8 +22191,8 @@ SQLITE_PRIVATE void sqlite3DbFree(sqlite + #ifdef SQLITE_DEBUG +@@ -24693,8 +24711,8 @@ SQLITE_PRIVATE void sqlite3DbFree(sqlite /* ** Change the size of an existing memory allocation */ @@ -14952,7 +22970,7 @@ void *pNew; assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) ); assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) ); -@@ -22204,33 +22203,29 @@ SQLITE_PRIVATE void *sqlite3Realloc(void +@@ -24705,33 +24723,29 @@ SQLITE_PRIVATE void *sqlite3Realloc(void sqlite3_free(pOld); /* IMP: R-26507-47431 */ return 0; } @@ -14972,11 +22990,11 @@ sqlite3_mutex_enter(mem0.mutex); - sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes); - nDiff = nNew - nOld; -- if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= +- if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= - mem0.alarmThreshold-nDiff ){ - sqlite3MallocAlarm(nDiff); + sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, nBytes); -+ if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nNew >= ++ if( nNew > nOld && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nNew >= + mem0.alarmThreshold+nOld ){ + sqlite3MallocAlarm(nNew - nOld); } @@ -14994,13 +23012,13 @@ } sqlite3_mutex_leave(mem0.mutex); }else{ -@@ -22244,28 +22239,35 @@ SQLITE_PRIVATE void *sqlite3Realloc(void +@@ -24745,28 +24759,35 @@ SQLITE_PRIVATE void *sqlite3Realloc(void ** The public interface to sqlite3Realloc. Make sure that the memory ** subsystem is initialized prior to invoking sqliteRealloc. */ +#undef sqlite3_realloc +#if !defined(SQLITE_OMIT_DEPRECATED) || SQLITE_PTRSIZE<8 - SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){ + SQLITE_API void *sqlite3_realloc(void *pOld, int n){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif @@ -15010,7 +23028,7 @@ } +#endif +#define sqlite3_realloc(x,y) sqlite3Realloc(x,y) - SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){ + SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif @@ -15034,38 +23052,63 @@ } return p; } -@@ -22274,10 +22276,10 @@ SQLITE_PRIVATE void *sqlite3MallocZero(u +@@ -24775,11 +24796,11 @@ SQLITE_PRIVATE void *sqlite3MallocZero(u ** Allocate and zero memory. If the allocation fails, make ** the mallocFailed flag in the connection pointer. */ -SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, u64 n){ +SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, size_t n){ - void *p = sqlite3DbMallocRaw(db, n); - if( p ){ -- memset(p, 0, (size_t)n); -+ memset(p, 0, n); - } + void *p; + testcase( db==0 ); + p = sqlite3DbMallocRaw(db, n); +- if( p ) memset(p, 0, (size_t)n); ++ if( p ) memset(p, 0, n); return p; } -@@ -22300,7 +22302,7 @@ SQLITE_PRIVATE void *sqlite3DbMallocZero - ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed - ** that all prior mallocs (ex: "a") worked too. + +@@ -24787,7 +24808,7 @@ SQLITE_PRIVATE void *sqlite3DbMallocZero + /* Finish the work of sqlite3DbMallocRawNN for the unusual and + ** slower case when the allocation cannot be fulfilled using lookaside. + */ +-static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){ ++static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, size_t n){ + void *p; + assert( db!=0 ); + p = sqlite3Malloc(n); +@@ -24819,7 +24840,7 @@ static SQLITE_NOINLINE void *dbMallocRaw + ** The sqlite3MallocRawNN() variant guarantees that the "db" parameter is + ** not a NULL pointer. */ -SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){ +SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, size_t n){ void *p; - assert( db==0 || sqlite3_mutex_held(db->mutex) ); - assert( db==0 || db->pnBytesFreed==0 ); -@@ -22344,7 +22346,7 @@ SQLITE_PRIVATE void *sqlite3DbMallocRaw( + if( db ) return sqlite3DbMallocRawNN(db, n); + p = sqlite3Malloc(n); +@@ -24862,20 +24883,20 @@ SQLITE_PRIVATE void *sqlite3DbMallocRawN + } + + /* Forward declaration */ +-static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n); ++static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, size_t n); + + /* ** Resize the block of memory pointed to by p to n bytes. If the ** resize fails, set the mallocFailed flag in the connection object. */ -SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){ +SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, size_t n){ + assert( db!=0 ); + if( p==0 ) return sqlite3DbMallocRawNN(db, n); + assert( sqlite3_mutex_held(db->mutex) ); + if( isLookaside(db,p) && n<=db->lookaside.sz ) return p; + return dbReallocFinish(db, p, n); + } +-static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){ ++static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, size_t n){ void *pNew = 0; assert( db!=0 ); - assert( sqlite3_mutex_held(db->mutex) ); -@@ -22380,7 +22382,7 @@ SQLITE_PRIVATE void *sqlite3DbRealloc(sq + assert( p!=0 ); +@@ -24905,7 +24926,7 @@ static SQLITE_NOINLINE void *dbReallocFi ** Attempt to reallocate p. If the reallocation fails, then free p ** and set the mallocFailed flag in the database connection. */ @@ -15074,32 +23117,78 @@ void *pNew; pNew = sqlite3DbRealloc(db, p, n); if( !pNew ){ -@@ -22404,13 +22406,13 @@ SQLITE_PRIVATE char *sqlite3DbStrDup(sql - } - n = sqlite3Strlen30(z) + 1; - assert( (n&0x7fffffff)==n ); -- zNew = sqlite3DbMallocRaw(db, (int)n); -+ zNew = sqlite3DbMallocRaw(db, n); - if( zNew ){ - memcpy(zNew, z, n); +@@ -24934,7 +24955,7 @@ SQLITE_PRIVATE char *sqlite3DbStrDup(sql } return zNew; } -SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){ +SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, size_t n){ char *zNew; + assert( db!=0 ); if( z==0 ){ - return 0; -@@ -22418,7 +22420,7 @@ SQLITE_PRIVATE char *sqlite3DbStrNDup(sq +@@ -24943,7 +24964,7 @@ SQLITE_PRIVATE char *sqlite3DbStrNDup(sq assert( (n&0x7fffffff)==n ); - zNew = sqlite3DbMallocRaw(db, n+1); + zNew = sqlite3DbMallocRawNN(db, n+1); if( zNew ){ - memcpy(zNew, z, (size_t)n); + memcpy(zNew, z, n); zNew[n] = 0; } return zNew; -@@ -23223,7 +23225,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf( +@@ -25340,6 +25361,16 @@ SQLITE_PRIVATE void sqlite3VXPrintf( + flag_long = 2; + c = *++fmt; + } ++ }else if( c=='L' && strchr("efgEG", fmt[1]) ){ ++ flag_long = 2; ++ c = *++fmt; ++ }else if( c=='j' && strchr("diouxX", fmt[1]) ){ ++ flag_long = 2; ++ c = *++fmt; ++ }else if( c=='t' && strchr("diouxX", fmt[1]) ){ ++ flag_long = sizeof(size_t)==sizeof(i64) ? 2 : ++ sizeof(size_t)==sizeof(long int) ? 1 : 0; ++ c = *++fmt; + }else{ + flag_long = 0; + } +@@ -25486,6 +25517,8 @@ SQLITE_PRIVATE void sqlite3VXPrintf( + case etGENERIC: + if( bArgList ){ + realvalue = getDoubleArg(pArgList); ++ }else if( flag_long==2 ){ ++ realvalue = va_arg(ap,long double); + }else{ + realvalue = va_arg(ap,double); + } +@@ -25506,7 +25539,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf( + /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ + exp = 0; + if( sqlite3IsNaN((double)realvalue) ){ +- bufpt = "NaN"; ++ bufpt = (char *)"NaN"; + length = 3; + break; + } +@@ -25676,7 +25709,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf( + bufpt = va_arg(ap,char*); + } + if( bufpt==0 ){ +- bufpt = ""; ++ bufpt = (char *)""; + }else if( xtype==etDYNSTRING ){ + zExtra = bufpt; + } +@@ -25693,7 +25726,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf( + int needQuote; + char ch; + char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote character */ +- char *escarg; ++ const char *escarg; + + if( bArgList ){ + escarg = getTextArg(pArgList); +@@ -25794,7 +25827,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf( ** Return the number of bytes of text that StrAccum is able to accept ** after the attempted enlargement. The value returned might be zero. */ @@ -15108,16 +23197,16 @@ char *zNew; assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */ if( p->accError ){ -@@ -23237,7 +23239,7 @@ static int sqlite3StrAccumEnlarge(StrAcc +@@ -25808,7 +25841,7 @@ static int sqlite3StrAccumEnlarge(StrAcc return N; }else{ - char *zOld = p->bMalloced ? p->zText : 0; + char *zOld = isMalloced(p) ? p->zText : 0; - i64 szNew = p->nChar; + size_t szNew = p->nChar; - assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); + assert( (p->zText==0 || p->zText==p->zBase)==!isMalloced(p) ); szNew += N + 1; if( szNew+p->nChar<=p->mxAlloc ){ -@@ -23250,12 +23252,12 @@ static int sqlite3StrAccumEnlarge(StrAcc +@@ -25821,12 +25854,12 @@ static int sqlite3StrAccumEnlarge(StrAcc setStrAccumError(p, STRACCUM_TOOBIG); return 0; }else{ @@ -15132,7 +23221,7 @@ } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); -@@ -23275,7 +23277,7 @@ static int sqlite3StrAccumEnlarge(StrAcc +@@ -25846,7 +25879,7 @@ static int sqlite3StrAccumEnlarge(StrAcc /* ** Append N copies of character c to the given string buffer. */ @@ -15141,7 +23230,7 @@ testcase( p->nChar + (i64)N > 0x7fffffff ); if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){ return; -@@ -23292,7 +23294,7 @@ SQLITE_PRIVATE void sqlite3AppendChar(St +@@ -25863,7 +25896,7 @@ SQLITE_PRIVATE void sqlite3AppendChar(St ** work (enlarging the buffer) using tail recursion, so that the ** sqlite3StrAccumAppend() routine can use fast calling semantics. */ @@ -15150,7 +23239,7 @@ N = sqlite3StrAccumEnlarge(p, N); if( N>0 ){ memcpy(&p->zText[p->nChar], z, N); -@@ -23305,10 +23307,9 @@ static void SQLITE_NOINLINE enlargeAndAp +@@ -25876,10 +25909,9 @@ static void SQLITE_NOINLINE enlargeAndAp ** Append N bytes of text from z to the StrAccum object. Increase the ** size of the memory allocation for StrAccum if necessary. */ @@ -15162,7 +23251,7 @@ assert( p->accError==0 || p->nAlloc==0 ); if( p->nChar+N >= p->nAlloc ){ enlargeAndAppend(p,z,N); -@@ -23323,7 +23324,7 @@ SQLITE_PRIVATE void sqlite3StrAccumAppen +@@ -25894,7 +25926,7 @@ SQLITE_PRIVATE void sqlite3StrAccumAppen ** Append the complete text of zero-terminated string z[] to the p string. */ SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){ @@ -15171,7 +23260,7 @@ } -@@ -23375,7 +23376,7 @@ SQLITE_PRIVATE void sqlite3StrAccumReset +@@ -25951,7 +25983,7 @@ SQLITE_PRIVATE void sqlite3StrAccumReset ** mx: Maximum number of bytes to accumulate. If mx==0 then no memory ** allocations will ever occur. */ @@ -15180,7 +23269,7 @@ p->zText = p->zBase = zBase; p->db = db; p->nChar = 0; -@@ -23591,14 +23592,14 @@ SQLITE_PRIVATE void sqlite3XPrintf(StrAc +@@ -26169,14 +26201,14 @@ SQLITE_PRIVATE void sqlite3XPrintf(StrAc */ static TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){ if( p==0 ){ @@ -15197,7 +23286,7 @@ return p; } -@@ -23622,7 +23623,7 @@ static void sqlite3TreeViewLine(TreeView +@@ -26200,7 +26232,7 @@ static void sqlite3TreeViewLine(TreeView char zBuf[500]; sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); if( p ){ @@ -15206,7 +23295,7 @@ sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4); } sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4); -@@ -23647,7 +23648,7 @@ static void sqlite3TreeViewItem(TreeView +@@ -26226,7 +26258,7 @@ static void sqlite3TreeViewItem(TreeView /* ** Generate a human-readable description of a WITH clause. */ @@ -15215,8 +23304,8 @@ int i; if( pWith==0 ) return; if( pWith->nCte==0 ) return; -@@ -23692,7 +23693,7 @@ SQLITE_PRIVATE void sqlite3TreeViewSelec - int cnt = 0; +@@ -26275,7 +26307,7 @@ SQLITE_PRIVATE void sqlite3TreeViewSelec + } pView = sqlite3TreeViewPush(pView, moreToFollow); if( p->pWith ){ - sqlite3TreeViewWith(pView, p->pWith, 1); @@ -15224,7 +23313,7 @@ cnt = 1; sqlite3TreeViewPush(pView, 1); } -@@ -24224,7 +24225,8 @@ SQLITE_PRIVATE void sqlite3PrngRestoreSt +@@ -26837,7 +26869,8 @@ SQLITE_PRIVATE void sqlite3PrngRestoreSt #if SQLITE_MAX_WORKER_THREADS>0 /********************************* Unix Pthreads ****************************/ @@ -15234,7 +23323,7 @@ #define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */ /* #include */ -@@ -24291,7 +24293,8 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQL +@@ -26904,7 +26937,8 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQL return rc; } @@ -15244,15 +23333,15 @@ /******************************** End Unix Pthreads *************************/ -@@ -24374,7 +24377,6 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HA +@@ -26987,7 +27021,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; -@@ -24386,8 +24388,7 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQL + if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT; +@@ -26999,8 +27032,7 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQL assert( p->id!=0 && p->id!=GetCurrentThreadId() ); rc = sqlite3Win32Wait((HANDLE)p->tid); assert( rc!=WAIT_IO_COMPLETION ); @@ -15262,7 +23351,7 @@ } if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult; sqlite3_free(p); -@@ -24668,7 +24669,7 @@ SQLITE_PRIVATE u32 sqlite3Utf8Read( +@@ -27281,7 +27313,7 @@ SQLITE_PRIVATE u32 sqlite3Utf8Read( ** encoding, or if *pMem does not contain a string value. */ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){ @@ -15271,7 +23360,7 @@ unsigned char *zOut; /* Output buffer */ unsigned char *zIn; /* Input iterator */ unsigned char *zTerm; /* End of input */ -@@ -24679,7 +24680,6 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlit +@@ -27292,7 +27324,6 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlit assert( pMem->flags&MEM_Str ); assert( pMem->enc!=desiredEnc ); assert( pMem->enc!=0 ); @@ -15279,7 +23368,7 @@ #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { -@@ -24814,7 +24814,6 @@ SQLITE_PRIVATE int sqlite3VdbeMemHandleB +@@ -27427,7 +27458,6 @@ SQLITE_PRIVATE int sqlite3VdbeMemHandleB int rc = SQLITE_OK; u8 bom = 0; @@ -15287,7 +23376,7 @@ if( pMem->n>1 ){ u8 b1 = *(u8 *)pMem->z; u8 b2 = *(((u8 *)pMem->z) + 1); -@@ -25105,9 +25104,14 @@ SQLITE_PRIVATE int sqlite3IsNaN(double x +@@ -27718,9 +27748,14 @@ SQLITE_PRIVATE int sqlite3IsNaN(double x ** than the actual length of the string. For very long strings (greater ** than 1GiB) the value returned might be less than the true string length. */ @@ -15304,7 +23393,16 @@ } /* -@@ -26501,7 +26505,7 @@ static void insertElement( +@@ -27730,7 +27765,7 @@ SQLITE_PRIVATE int sqlite3Strlen30(const + ** The column type is an extra string stored after the zero-terminator on + ** the column name if and only if the COLFLAG_HASTYPE flag is set. + */ +-SQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){ ++SQLITE_PRIVATE const char *sqlite3ColumnType(Column *pCol, const char *zDflt){ + if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt; + return pCol->zName + strlen(pCol->zName) + 1; + } +@@ -29286,7 +29321,7 @@ static void insertElement( ** if the new size is the same as the prior size. ** Return TRUE if the resize occurs and false if not. */ @@ -15313,7 +23411,7 @@ struct _ht *new_ht; /* The new hash table */ HashElem *elem, *next_elem; /* For looping over existing elements */ -@@ -26595,7 +26599,6 @@ static void removeElementGivenHash( +@@ -29380,7 +29415,6 @@ static void removeElementGivenHash( pEntry->chain = elem->next; } pEntry->count--; @@ -15321,7 +23419,7 @@ } sqlite3_free( elem ); pH->count--; -@@ -26938,7 +26941,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode +@@ -29738,7 +29772,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode # include #endif @@ -15330,16 +23428,16 @@ # include # include # include -@@ -27000,7 +27003,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode +@@ -29800,7 +29834,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode /* ** Maximum supported path-length. */ -#define MAX_PATHNAME 512 +#define MAX_PATHNAME SQLITE_MAX_PATH_LENGTH - /* Always cast the getpid() return type for compatibility with - ** kernel modules in VxWorks. */ -@@ -27346,7 +27349,7 @@ SQLITE_API int sqlite3_open_file_count = + /* + ** Maximum supported symbolic links +@@ -30151,7 +30185,7 @@ SQLITE_API extern int sqlite3_open_file_ ** HAVE_MREMAP defaults to true on Linux and false everywhere else. */ #if !defined(HAVE_MREMAP) @@ -15348,7 +23446,7 @@ # define HAVE_MREMAP 1 # else # define HAVE_MREMAP 0 -@@ -27383,6 +27386,7 @@ static int unixGetpagesize(void); +@@ -30188,6 +30222,7 @@ static int unixGetpagesize(void); ** testing and sandboxing. The following array holds the names and pointers ** to all overrideable system calls. */ @@ -15356,7 +23454,7 @@ static struct unix_syscall { const char *zName; /* Name of the system call */ sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ -@@ -27918,7 +27922,7 @@ static struct vxworksFileId *vxworksFind +@@ -30747,7 +30782,7 @@ static struct vxworksFileId *vxworksFind assert( zAbsoluteName[0]=='/' ); n = (int)strlen(zAbsoluteName); @@ -15365,16 +23463,25 @@ if( pNew==0 ) return 0; pNew->zCanonicalName = (char*)&pNew[1]; memcpy(pNew->zCanonicalName, zAbsoluteName, n+1); -@@ -28322,7 +28326,7 @@ static int findInodeInfo( +@@ -30967,7 +31002,7 @@ static int unixLogErrorAtLine( + const char *zPath, /* File path associated with error */ + int iLine /* Source line number where error occurred */ + ){ +- char *zErr; /* Message from strerror() or equivalent */ ++ const char *zErr; /* Message from strerror() or equivalent */ + int iErrno = errno; /* Saved syscall error number */ + + /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use +@@ -31158,7 +31193,7 @@ static int findInodeInfo( pInode = pInode->pNext; } if( pInode==0 ){ - pInode = sqlite3_malloc64( sizeof(*pInode) ); + pInode = sqlite3Malloc( sizeof(*pInode) ); if( pInode==0 ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; } -@@ -29232,7 +29236,7 @@ static int dotlockClose(sqlite3_file *id +@@ -32074,7 +32109,7 @@ static int dotlockClose(sqlite3_file *id ** ** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off */ @@ -15383,7 +23490,7 @@ /* ** Retry flock() calls that fail with EINTR -@@ -30364,9 +30368,13 @@ static int unixWrite( +@@ -33206,9 +33241,13 @@ static int unixWrite( ** Count the number of fullsyncs and normal syncs. This is used to test ** that syncs and fullsyncs are occurring at the right times. */ @@ -15397,7 +23504,7 @@ /* ** We do not trust systems to provide a working fdatasync(). Some do. -@@ -30805,7 +30813,7 @@ static int unixFileControl(sqlite3_file +@@ -33647,7 +33686,7 @@ static int unixFileControl(sqlite3_file return SQLITE_OK; } case SQLITE_FCNTL_TEMPFILENAME: { @@ -15406,25 +23513,25 @@ if( zTFile ){ unixGetTempname(pFile->pVfs->mxPathname, zTFile); *(char**)pArg = zTFile; -@@ -31243,7 +31251,7 @@ static int unixOpenSharedMemory(unixFile +@@ -34085,7 +34124,7 @@ static int unixOpenSharedMemory(unixFile int nShmFilename; /* Size of the SHM filename in bytes */ /* Allocate space for the new unixShm object. */ - p = sqlite3_malloc64( sizeof(*p) ); + p = sqlite3Malloc( sizeof(*p) ); - if( p==0 ) return SQLITE_NOMEM; + if( p==0 ) return SQLITE_NOMEM_BKPT; memset(p, 0, sizeof(*p)); assert( pDbFd->pShm==0 ); -@@ -31274,7 +31282,7 @@ static int unixOpenSharedMemory(unixFile +@@ -34116,7 +34155,7 @@ static int unixOpenSharedMemory(unixFile #else nShmFilename = 6 + (int)strlen(zBasePath); #endif - pShmNode = sqlite3_malloc64( sizeof(*pShmNode) + nShmFilename ); + pShmNode = sqlite3Malloc( sizeof(*pShmNode) + nShmFilename ); if( pShmNode==0 ){ - rc = SQLITE_NOMEM; + rc = SQLITE_NOMEM_BKPT; goto shm_open_err; -@@ -31463,7 +31471,7 @@ static int unixShmMap( +@@ -34307,7 +34346,7 @@ static int unixShmMap( } /* Map the requested memory region into this processes address space. */ @@ -15433,16 +23540,16 @@ pShmNode->apRegion, nReqRegion*sizeof(char *) ); if( !apNew ){ -@@ -31485,7 +31493,7 @@ static int unixShmMap( +@@ -34329,7 +34368,7 @@ static int unixShmMap( goto shmpage_out; } }else{ - pMem = sqlite3_malloc64(szRegion); + pMem = sqlite3Malloc(szRegion); if( pMem==0 ){ - rc = SQLITE_NOMEM; + rc = SQLITE_NOMEM_BKPT; goto shmpage_out; -@@ -32021,7 +32029,7 @@ IOMETHODS( +@@ -34865,7 +34904,7 @@ IOMETHODS( 0 /* xShmMap method */ ) @@ -15451,7 +23558,7 @@ IOMETHODS( flockIoFinder, /* Finder function name */ flockIoMethods, /* sqlite3_io_methods object name */ -@@ -32060,6 +32068,19 @@ IOMETHODS( +@@ -34904,6 +34943,19 @@ IOMETHODS( ) #endif @@ -15471,25 +23578,25 @@ /* ** The proxy locking method is a "super-method" in the sense that it ** opens secondary file descriptors for the conch and lock files and -@@ -32319,7 +32340,7 @@ static int fillInUnixFile( +@@ -35163,7 +35215,7 @@ static int fillInUnixFile( ** the afpLockingContext. */ afpLockingContext *pCtx; - pNew->lockingContext = pCtx = sqlite3_malloc64( sizeof(*pCtx) ); + pNew->lockingContext = pCtx = sqlite3Malloc( sizeof(*pCtx) ); if( pCtx==0 ){ - rc = SQLITE_NOMEM; + rc = SQLITE_NOMEM_BKPT; }else{ -@@ -32349,7 +32370,7 @@ static int fillInUnixFile( +@@ -35193,7 +35245,7 @@ static int fillInUnixFile( int nFilename; assert( zFilename!=0 ); nFilename = (int)strlen(zFilename) + 6; - zLockFile = (char *)sqlite3_malloc64(nFilename); + zLockFile = (char *)sqlite3Malloc(nFilename); if( zLockFile==0 ){ - rc = SQLITE_NOMEM; + rc = SQLITE_NOMEM_BKPT; }else{ -@@ -32381,6 +32402,15 @@ static int fillInUnixFile( +@@ -35225,6 +35277,15 @@ static int fillInUnixFile( unixLeaveMutex(); } #endif @@ -15505,7 +23612,7 @@ storeLastErrno(pNew, 0); #if OS_VXWORKS -@@ -32409,6 +32439,8 @@ static const char *unixTempFileDir(void) +@@ -35253,6 +35314,8 @@ static const char *unixTempFileDir(void) static const char *azDirs[] = { 0, 0, @@ -15514,25 +23621,34 @@ "/var/tmp", "/usr/tmp", "/tmp", -@@ -32420,6 +32452,8 @@ static const char *unixTempFileDir(void) +@@ -35264,6 +35327,8 @@ static const char *unixTempFileDir(void) if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR"); if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); + if( !azDirs[3] ) azDirs[2] = getenv("TMP"); + if( !azDirs[4] ) azDirs[3] = getenv("TEMP"); - for(i=0; ifd; }else{ - pUnused = sqlite3_malloc64(sizeof(*pUnused)); + pUnused = sqlite3Malloc(sizeof(*pUnused)); if( !pUnused ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; } -@@ -33048,7 +33082,7 @@ static int unixFullPathname( +@@ -35903,7 +35968,7 @@ static int unixFullPathname( + + if( bLink ){ + if( zDel==0 ){ +- zDel = sqlite3_malloc(nOut); ++ zDel = sqlite3Malloc(nOut); + if( zDel==0 ) rc = SQLITE_NOMEM_BKPT; + }else if( ++nLink>SQLITE_MAX_SYMLINKS ){ + rc = SQLITE_CANTOPEN_BKPT; +@@ -35954,7 +36019,7 @@ static int unixFullPathname( #include static void *unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename){ UNUSED_PARAMETER(NotUsed); @@ -15541,7 +23657,7 @@ } /* -@@ -33179,7 +33213,11 @@ static int unixSleep(sqlite3_vfs *NotUse +@@ -36085,7 +36150,11 @@ static int unixSleep(sqlite3_vfs *NotUse ** sqlite3OsCurrentTime() during testing. */ #ifdef SQLITE_TEST @@ -15553,25 +23669,25 @@ #endif /* -@@ -33540,7 +33578,7 @@ static int proxyCreateUnixFile( +@@ -36441,7 +36510,7 @@ static int proxyCreateUnixFile( if( pUnused ){ fd = pUnused->fd; }else{ - pUnused = sqlite3_malloc64(sizeof(*pUnused)); + pUnused = sqlite3Malloc(sizeof(*pUnused)); if( !pUnused ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; } -@@ -33573,7 +33611,7 @@ static int proxyCreateUnixFile( +@@ -36474,7 +36543,7 @@ static int proxyCreateUnixFile( } } - pNew = (unixFile *)sqlite3_malloc64(sizeof(*pNew)); + pNew = (unixFile *)sqlite3Malloc(sizeof(*pNew)); if( pNew==NULL ){ - rc = SQLITE_NOMEM; + rc = SQLITE_NOMEM_BKPT; goto end_create_proxy; -@@ -34035,7 +34073,7 @@ static int proxyReleaseConch(unixFile *p +@@ -36936,7 +37005,7 @@ static int proxyReleaseConch(unixFile *p /* ** Given the name of a database file, compute the name of its conch file. @@ -15580,25 +23696,25 @@ ** Make *pConchPath point to the new name. Return SQLITE_OK on success ** or SQLITE_NOMEM if unable to obtain memory. ** -@@ -34051,7 +34089,7 @@ static int proxyCreateConchPathname(char +@@ -36952,7 +37021,7 @@ static int proxyCreateConchPathname(char /* Allocate space for the conch filename and initialize the name to ** the name of the original database file. */ - *pConchPath = conchPath = (char *)sqlite3_malloc64(len + 8); + *pConchPath = conchPath = (char *)sqlite3Malloc(len + 8); if( conchPath==0 ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; } -@@ -34167,7 +34205,7 @@ static int proxyTransformUnixFile(unixFi +@@ -37068,7 +37137,7 @@ static int proxyTransformUnixFile(unixFi OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h, (lockPath ? lockPath : ":auto:"), osGetpid(0))); - pCtx = sqlite3_malloc64( sizeof(*pCtx) ); + pCtx = sqlite3Malloc( sizeof(*pCtx) ); if( pCtx==0 ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; } -@@ -34452,7 +34490,15 @@ static int proxyClose(sqlite3_file *id) +@@ -37353,7 +37422,15 @@ static int proxyClose(sqlite3_file *id) ** necessarily been initialized when this routine is called, and so they ** should not be used. */ @@ -15606,15 +23722,15 @@ +#if defined(SQLITE_AMALGAMATION) +static +#endif -+SQLITE_API int SQLITE_STDCALL sqlite3_os_unix_init(void){ ++SQLITE_API int sqlite3_os_unix_init(void){ +#else - SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){ + SQLITE_API int sqlite3_os_init(void){ +#endif + /* ** 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 -@@ -34508,21 +34554,29 @@ SQLITE_API int SQLITE_STDCALL sqlite3_os +@@ -37409,21 +37486,32 @@ SQLITE_API int sqlite3_os_init(void){ static sqlite3_vfs aVfs[] = { #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) UNIXVFS("unix", autolockIoFinder ), @@ -15627,6 +23743,9 @@ #else UNIXVFS("unix", posixIoFinder ), #endif ++#if !SQLITE_OS_WIN ++ UNIXVFS("none", nolockIoFinder ), ++#endif UNIXVFS("unix-none", nolockIoFinder ), UNIXVFS("unix-dotfile", dotlockIoFinder ), +#if defined(__CYGWIN__) @@ -15646,7 +23765,7 @@ UNIXVFS("unix-flock", flockIoFinder ), #endif #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) -@@ -34544,6 +34598,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_os +@@ -37445,6 +37533,8 @@ SQLITE_API int sqlite3_os_init(void){ return SQLITE_OK; } @@ -15655,15 +23774,29 @@ /* ** Shutdown the operating system interface. ** -@@ -34554,6 +34610,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_os - SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){ +@@ -37455,6 +37545,7 @@ SQLITE_API int sqlite3_os_init(void){ + SQLITE_API int sqlite3_os_end(void){ return SQLITE_OK; } +#endif /* !SQLITE_OS_WIN */ #endif /* SQLITE_OS_UNIX */ -@@ -34802,7 +34859,7 @@ SQLITE_API int sqlite3_open_file_count = +@@ -37685,6 +37776,13 @@ SQLITE_API extern int sqlite3_open_file_ + */ + /* #include "os_win.h" */ + ++struct cygwinstat { ++ i64 st_dev; ++ i64 st_ino; ++ i64 st_mode; ++ char dummy[40 + 8*SQLITE_PTRSIZE]; ++}; ++ + /* + ** Compiling and using WAL mode requires several APIs that are only + ** available in Windows platforms based on the NT kernel. +@@ -37703,7 +37801,7 @@ SQLITE_API extern int sqlite3_open_file_ ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions ** based on the sub-platform)? */ @@ -15672,7 +23805,7 @@ # define SQLITE_WIN32_HAS_ANSI #endif -@@ -34883,7 +34940,11 @@ SQLITE_API int sqlite3_open_file_count = +@@ -37801,7 +37899,11 @@ SQLITE_API extern int sqlite3_open_file_ ** 4-bytes-per-character for UTF8. */ #ifndef SQLITE_WIN32_MAX_PATH_BYTES @@ -15684,7 +23817,7 @@ #endif /* -@@ -35153,11 +35214,11 @@ static struct winMemData win_mem_data = +@@ -38132,11 +38234,11 @@ static struct winMemData win_mem_data = #define winMemGetHeap() win_mem_data.hHeap #define winMemGetOwned() win_mem_data.bOwned @@ -15700,7 +23833,7 @@ static int winMemInit(void *pAppData); static void winMemShutdown(void *pAppData); -@@ -35178,8 +35239,6 @@ SQLITE_PRIVATE const sqlite3_mem_methods +@@ -38157,8 +38259,6 @@ SQLITE_PRIVATE const sqlite3_mem_methods */ #ifdef SQLITE_TEST SQLITE_API LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0; @@ -15709,7 +23842,7 @@ #endif #ifndef SYSCALL -@@ -35273,7 +35332,7 @@ static struct win_syscall { +@@ -38253,7 +38353,7 @@ static struct win_syscall { #define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \ DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent) @@ -15718,25 +23851,7 @@ { "CreateMutexW", (SYSCALL)CreateMutexW, 0 }, #else { "CreateMutexW", (SYSCALL)0, 0 }, -@@ -35304,7 +35363,7 @@ static struct win_syscall { - { "FileTimeToLocalFileTime", (SYSCALL)0, 0 }, - #endif - --#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(CONST FILETIME*, \ -+#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(const FILETIME*, \ - LPFILETIME))aSyscall[11].pCurrent) - - #if SQLITE_OS_WINCE -@@ -35313,7 +35372,7 @@ static struct win_syscall { - { "FileTimeToSystemTime", (SYSCALL)0, 0 }, - #endif - --#define osFileTimeToSystemTime ((BOOL(WINAPI*)(CONST FILETIME*, \ -+#define osFileTimeToSystemTime ((BOOL(WINAPI*)(const FILETIME*, \ - LPSYSTEMTIME))aSyscall[12].pCurrent) - - { "FlushFileBuffers", (SYSCALL)FlushFileBuffers, 0 }, -@@ -35423,7 +35482,7 @@ static struct win_syscall { +@@ -38403,7 +38503,7 @@ static struct win_syscall { #define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent) @@ -15745,7 +23860,7 @@ #if SQLITE_OS_WINCE /* The GetProcAddressA() routine is only available on Windows CE. */ { "GetProcAddressA", (SYSCALL)GetProcAddressA, 0 }, -@@ -35582,7 +35641,7 @@ static struct win_syscall { +@@ -38561,7 +38661,7 @@ static struct win_syscall { #define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent) @@ -15754,7 +23869,7 @@ { "LockFile", (SYSCALL)LockFile, 0 }, #else { "LockFile", (SYSCALL)0, 0 }, -@@ -35650,12 +35709,16 @@ static struct win_syscall { +@@ -38629,12 +38729,16 @@ static struct win_syscall { #define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent) @@ -15764,8 +23879,7 @@ + { "SystemTimeToFileTime", (SYSCALL)0, 0 }, +#endif --#define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \ -+#define osSystemTimeToFileTime ((BOOL(WINAPI*)(const SYSTEMTIME*, \ + #define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \ LPFILETIME))aSyscall[56].pCurrent) -#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT @@ -15773,7 +23887,7 @@ { "UnlockFile", (SYSCALL)UnlockFile, 0 }, #else { "UnlockFile", (SYSCALL)0, 0 }, -@@ -35702,7 +35765,7 @@ static struct win_syscall { +@@ -38681,7 +38785,7 @@ static struct win_syscall { #define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \ DWORD,DWORD))aSyscall[62].pCurrent) @@ -15782,7 +23896,7 @@ { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, #else { "WaitForSingleObject", (SYSCALL)0, 0 }, -@@ -35816,6 +35879,7 @@ static struct win_syscall { +@@ -38795,6 +38899,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. */ @@ -15790,11 +23904,11 @@ #if defined(InterlockedCompareExchange) { "InterlockedCompareExchange", (SYSCALL)0, 0 }, -@@ -35826,6 +35890,15 @@ static struct win_syscall { +@@ -38805,6 +38910,15 @@ static struct win_syscall { #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \ SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent) #endif /* defined(InterlockedCompareExchange) */ -+#endif /* 0*/ ++#endif /* 0 */ + +#if defined(SQLITE_WIN32_HAS_WIDE) && defined(_WIN32) + { "GetModuleHandleW", (SYSCALL)GetModuleHandleW, 0 }, @@ -15806,7 +23920,7 @@ #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID { "UuidCreate", (SYSCALL)UuidCreate, 0 }, -@@ -35853,6 +35926,60 @@ static struct win_syscall { +@@ -38832,6 +38946,68 @@ static struct win_syscall { #define osFlushViewOfFile \ ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent) @@ -15843,12 +23957,20 @@ +#define readlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[83].pCurrent) + +#if defined(__CYGWIN__) ++ { "lstat", (SYSCALL)lstat, 0 }, ++#else ++ { "lstat", (SYSCALL)0, 0 }, ++#endif ++ ++#define lstat ((int(*)(const char*,struct cygwinstat*))aSyscall[84].pCurrent) ++ ++#if defined(__CYGWIN__) + { "__errno", (SYSCALL)__errno, 0 }, +#else + { "__errno", (SYSCALL)0, 0 }, +#endif + -+#define osErrno (*((int*(*)(void))aSyscall[84].pCurrent)()) ++#define osErrno (*((int*(*)(void))aSyscall[85].pCurrent)()) + +#if defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE) + { "cygwin_conv_path", (SYSCALL)cygwin_conv_path, 0 }, @@ -15857,17 +23979,26 @@ +#endif + +#define cygwin_conv_path ((size_t(*)(unsigned int, \ -+ const void *, void *, size_t))aSyscall[85].pCurrent) ++ const void *, void *, size_t))aSyscall[86].pCurrent) + + { "cygwin_conv_to_full_win32_path", (SYSCALL)0, 0 }, + +#define cygwin_conv_to_full_win32_path ((void(*)(const char *, \ -+ char *))aSyscall[86].pCurrent) ++ char *))aSyscall[87].pCurrent) + }; /* End of the overrideable system calls */ /* -@@ -36026,6 +36153,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wi +@@ -38945,7 +39121,7 @@ SQLITE_API int sqlite3_win32_compact_hea + (void*)hHeap); + rc = SQLITE_NOMEM_BKPT; + }else{ +- sqlite3_log(SQLITE_ERROR, "failed to HeapCompact (%lu), heap=%p", ++ sqlite3_log(SQLITE_ERROR, "failed to HeapCompact (%u), heap=%p", + osGetLastError(), (void*)hHeap); + rc = SQLITE_ERROR; + } +@@ -39005,6 +39181,7 @@ SQLITE_API int sqlite3_win32_reset_heap( } #endif /* SQLITE_WIN32_MALLOC */ @@ -15875,7 +24006,7 @@ /* ** This function outputs the specified (ANSI) string to the Win32 debugger ** (if available). -@@ -36062,6 +36190,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_w +@@ -39047,6 +39224,7 @@ SQLITE_API void sqlite3_win32_write_debu } #endif } @@ -15883,17 +24014,17 @@ /* ** The following routine suspends the current thread for at least ms -@@ -36071,6 +36200,9 @@ SQLITE_API void SQLITE_STDCALL sqlite3_w +@@ -39056,6 +39234,9 @@ SQLITE_API void sqlite3_win32_write_debu static HANDLE sleepObj = NULL; #endif +#if defined(__CYGWIN__) && defined(SQLITE_AMALGAMATION) +static +#endif - SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){ + SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){ #if SQLITE_OS_WINRT if ( sleepObj==NULL ){ -@@ -36084,8 +36216,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_w +@@ -39069,8 +39250,7 @@ SQLITE_API void sqlite3_win32_sleep(DWOR #endif } @@ -15903,7 +24034,7 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){ DWORD rc; while( (rc = osWaitForSingleObjectEx(hObject, INFINITE, -@@ -36116,6 +36247,7 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HA +@@ -39101,6 +39281,7 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HA # define osIsNT() ((sqlite3_os_type==2) || sqlite3_win32_is_nt()) #endif @@ -15911,7 +24042,7 @@ /* ** This function determines if the machine is running a version of Windows ** based on the NT kernel. -@@ -36154,12 +36286,13 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wi +@@ -39139,12 +39320,13 @@ SQLITE_API int sqlite3_win32_is_nt(void) return 1; #endif } @@ -15926,7 +24057,7 @@ HANDLE hHeap; void *p; -@@ -36170,11 +36303,10 @@ static void *winMemMalloc(int nBytes){ +@@ -39155,11 +39337,10 @@ static void *winMemMalloc(int nBytes){ #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); #endif @@ -15935,12 +24066,21 @@ if( !p ){ - sqlite3_log(SQLITE_NOMEM, "failed to HeapAlloc %u bytes (%lu), heap=%p", - nBytes, osGetLastError(), (void*)hHeap); -+ sqlite3_log(SQLITE_NOMEM, "failed to HeapAlloc %llu bytes (%lu), heap=%p", ++ sqlite3_log(SQLITE_NOMEM, "failed to HeapAlloc %llu bytes (%u), heap=%p", + (u64)nBytes, osGetLastError(), (void*)hHeap); } return p; } -@@ -36202,7 +36334,7 @@ static void winMemFree(void *pPrior){ +@@ -39179,7 +39360,7 @@ static void winMemFree(void *pPrior){ + #endif + if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */ + if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){ +- sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%lu), heap=%p", ++ sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%u), heap=%p", + pPrior, osGetLastError(), (void*)hHeap); + } + } +@@ -39187,7 +39368,7 @@ static void winMemFree(void *pPrior){ /* ** Change the size of an existing memory allocation */ @@ -15949,7 +24089,7 @@ HANDLE hHeap; void *p; -@@ -36213,15 +36345,14 @@ static void *winMemRealloc(void *pPrior, +@@ -39198,15 +39379,14 @@ static void *winMemRealloc(void *pPrior, #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); #endif @@ -15962,12 +24102,12 @@ if( !p ){ - sqlite3_log(SQLITE_NOMEM, "failed to %s %u bytes (%lu), heap=%p", - pPrior ? "HeapReAlloc" : "HeapAlloc", nBytes, osGetLastError(), -+ sqlite3_log(SQLITE_NOMEM, "failed to %s %llu bytes (%lu), heap=%p", ++ sqlite3_log(SQLITE_NOMEM, "failed to %s %llu bytes (%u), heap=%p", + pPrior ? "HeapReAlloc" : "HeapAlloc", (u64)nBytes, osGetLastError(), (void*)hHeap); } return p; -@@ -36230,7 +36361,7 @@ static void *winMemRealloc(void *pPrior, +@@ -39215,7 +39395,7 @@ static void *winMemRealloc(void *pPrior, /* ** Return the size of an outstanding allocation, in bytes. */ @@ -15976,7 +24116,12 @@ HANDLE hHeap; SIZE_T n; -@@ -36248,13 +36379,13 @@ static int winMemSize(void *p){ +@@ -39229,17 +39409,17 @@ static int winMemSize(void *p){ + if( !p ) return 0; + n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p); + if( n==(SIZE_T)-1 ){ +- sqlite3_log(SQLITE_NOMEM, "failed to HeapSize block %p (%lu), heap=%p", ++ sqlite3_log(SQLITE_NOMEM, "failed to HeapSize block %p (%u), heap=%p", p, osGetLastError(), (void*)hHeap); return 0; } @@ -15992,108 +24137,151 @@ return n; } -@@ -36281,7 +36412,7 @@ static int winMemInit(void *pAppData){ +@@ -39266,7 +39446,7 @@ static int winMemInit(void *pAppData){ dwInitialSize, dwMaximumSize); if( !pWinMemData->hHeap ){ sqlite3_log(SQLITE_NOMEM, - "failed to HeapCreate (%lu), flags=%u, initSize=%lu, maxSize=%lu", -+ "failed to HeapCreate (%lu), flags=%lu, initSize=%lu, maxSize=%u", ++ "failed to HeapCreate (%u), flags=%u, initSize=%u, maxSize=%u", osGetLastError(), SQLITE_WIN32_HEAP_FLAGS, dwInitialSize, dwMaximumSize); - return SQLITE_NOMEM; -@@ -36360,12 +36491,13 @@ SQLITE_PRIVATE void sqlite3MemSetDefault + return SQLITE_NOMEM_BKPT; +@@ -39278,7 +39458,7 @@ static int winMemInit(void *pAppData){ + pWinMemData->hHeap = osGetProcessHeap(); + if( !pWinMemData->hHeap ){ + sqlite3_log(SQLITE_NOMEM, +- "failed to GetProcessHeap (%lu)", osGetLastError()); ++ "failed to GetProcessHeap (%u)", osGetLastError()); + return SQLITE_NOMEM_BKPT; + } + pWinMemData->bOwned = FALSE; +@@ -39309,7 +39489,7 @@ static void winMemShutdown(void *pAppDat + #endif + if( pWinMemData->bOwned ){ + if( !osHeapDestroy(pWinMemData->hHeap) ){ +- sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%lu), heap=%p", ++ sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%u), heap=%p", + osGetLastError(), (void*)pWinMemData->hHeap); + } + pWinMemData->bOwned = FALSE; +@@ -39345,12 +39525,13 @@ SQLITE_PRIVATE void sqlite3MemSetDefault } #endif /* SQLITE_WIN32_MALLOC */ +#ifdef _WIN32 /* - ** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). + ** Convert a UTF-8 string to Microsoft Unicode. ** - ** Space to hold the returned string is obtained from malloc. + ** Space to hold the returned string is obtained from sqlite3_malloc(). */ --static LPWSTR winUtf8ToUnicode(const char *zFilename){ -+static LPWSTR winUtf8ToUnicode(const char *zFilename, WCHAR *buf){ +-static LPWSTR winUtf8ToUnicode(const char *zText){ ++static LPWSTR winUtf8ToUnicode(const char *zText, WCHAR *buf){ int nChar; - LPWSTR zWideFilename; + LPWSTR zWideText; -@@ -36373,9 +36505,13 @@ static LPWSTR winUtf8ToUnicode(const cha +@@ -39358,9 +39539,13 @@ static LPWSTR winUtf8ToUnicode(const cha if( nChar==0 ){ return 0; } -- zWideFilename = sqlite3MallocZero( nChar*sizeof(zWideFilename[0]) ); -- if( zWideFilename==0 ){ +- zWideText = sqlite3MallocZero( nChar*sizeof(WCHAR) ); +- if( zWideText==0 ){ - return 0; + if( buf && ((size_t)nChar<=MAX_PATH) ){ -+ zWideFilename = buf; ++ zWideText = buf; + }else{ -+ zWideFilename = sqlite3Malloc( nChar*sizeof(WCHAR) ); -+ if( zWideFilename==0 ){ ++ zWideText = sqlite3Malloc( nChar*sizeof(WCHAR) ); ++ if( zWideText==0 ){ + return 0; + } } - nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, + nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, zWideText, nChar); -@@ -36385,6 +36521,7 @@ static LPWSTR winUtf8ToUnicode(const cha +@@ -39370,6 +39555,7 @@ static LPWSTR winUtf8ToUnicode(const cha } - return zWideFilename; + return zWideText; } +#endif /* _WIN32 */ /* - ** Convert Microsoft Unicode to UTF-8. Space to hold the returned string is -@@ -36424,7 +36561,7 @@ static LPWSTR winMbcsToUnicode(const cha - int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP; + ** Convert a Microsoft Unicode string to UTF-8. +@@ -39409,7 +39595,7 @@ static LPWSTR winMbcsToUnicode(const cha + int codepage = useAnsi ? CP_ACP : CP_OEMCP; - nByte = osMultiByteToWideChar(codepage, 0, zFilename, -1, NULL, + nByte = osMultiByteToWideChar(codepage, 0, zText, -1, NULL, - 0)*sizeof(WCHAR); + 0); if( nByte==0 ){ return 0; } -@@ -36441,6 +36578,7 @@ static LPWSTR winMbcsToUnicode(const cha - return zMbcsFilename; +@@ -39426,6 +39612,7 @@ static LPWSTR winMbcsToUnicode(const cha + return zMbcsText; } +#ifdef _WIN32 /* - ** Convert Microsoft Unicode to multi-byte character string, based on the - ** user's ANSI codepage. -@@ -36469,6 +36607,7 @@ static char *winUnicodeToMbcs(LPCWSTR zW + ** Convert a Microsoft Unicode string to a multi-byte character string, + ** using the ANSI or OEM code page. +@@ -39453,6 +39640,7 @@ static char *winUnicodeToMbcs(LPCWSTR zW } - return zFilename; + return zText; } +#endif /* _WIN32 */ /* - ** Convert multibyte character string to UTF-8. Space to hold the -@@ -36487,6 +36626,7 @@ SQLITE_API char *SQLITE_STDCALL sqlite3_ - return zFilenameUtf8; + ** Convert a multi-byte character string to UTF-8. +@@ -39472,6 +39660,7 @@ static char *winMbcsToUtf8(const char *z + return zTextUtf8; } +#ifdef _WIN32 /* - ** Convert UTF-8 to multibyte character string. Space to hold the - ** returned string is obtained from sqlite3_malloc(). -@@ -36494,13 +36634,16 @@ SQLITE_API char *SQLITE_STDCALL sqlite3_ - SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){ - char *zFilenameMbcs; + ** Convert a UTF-8 string to a multi-byte character string. + ** +@@ -39480,13 +39669,16 @@ static char *winMbcsToUtf8(const char *z + static char *winUtf8ToMbcs(const char *zText, int useAnsi){ + char *zTextMbcs; LPWSTR zTmpWide; + WCHAR buf[MAX_PATH]; -- zTmpWide = winUtf8ToUnicode(zFilename); -+ zTmpWide = winUtf8ToUnicode(zFilename, buf); +- zTmpWide = winUtf8ToUnicode(zText); ++ zTmpWide = winUtf8ToUnicode(zText, buf); if( zTmpWide==0 ){ return 0; } - zFilenameMbcs = winUnicodeToMbcs(zTmpWide); + zTextMbcs = winUnicodeToMbcs(zTmpWide, useAnsi); - sqlite3_free(zTmpWide); -+ if( zTmpWide!=buf ){ ++ if (zTmpWide != buf){ + sqlite3_free(zTmpWide); + } - return zFilenameMbcs; + return zTextMbcs; } -@@ -36526,7 +36669,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wi +@@ -39503,7 +39695,7 @@ SQLITE_API LPWSTR sqlite3_win32_utf8_to_ + #ifndef SQLITE_OMIT_AUTOINIT + if( sqlite3_initialize() ) return 0; + #endif +- return winUtf8ToUnicode(zText); ++ return winUtf8ToUnicode(zText, 0); + } + + /* +@@ -39521,6 +39713,7 @@ SQLITE_API char *sqlite3_win32_unicode_t + #endif + return winUnicodeToUtf8(zWideText); + } ++#endif /* _WIN32 */ + + /* + ** This is a public wrapper for the winMbcsToUtf8() function. +@@ -39538,6 +39731,7 @@ SQLITE_API char *sqlite3_win32_mbcs_to_u + return winMbcsToUtf8(zText, osAreFileApisANSI()); + } + ++#ifdef _WIN32 + /* + ** This is a public wrapper for the winMbcsToUtf8() function. + */ +@@ -39608,7 +39802,7 @@ SQLITE_API int sqlite3_win32_set_directo || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ); assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) ); @@ -16102,7 +24290,7 @@ char *zValueUtf8 = 0; if( zValue && zValue[0] ){ zValueUtf8 = winUnicodeToUtf8(zValue); -@@ -36540,6 +36683,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wi +@@ -39622,6 +39816,7 @@ SQLITE_API int sqlite3_win32_set_directo } return SQLITE_ERROR; } @@ -16110,7 +24298,7 @@ /* ** The return value of winGetLastErrorMsg -@@ -36611,7 +36755,7 @@ static int winGetLastErrorMsg(DWORD last +@@ -39693,7 +39888,7 @@ static int winGetLastErrorMsg(DWORD last } #endif if( 0 == dwLen ){ @@ -16119,7 +24307,7 @@ }else{ /* copy a maximum of nBuf chars to output buffer */ sqlite3_snprintf(nBuf, zBuf, "%s", zOut); -@@ -36654,7 +36798,7 @@ static int winLogErrorAtLine( +@@ -39736,7 +39931,7 @@ static int winLogErrorAtLine( for(i=0; zMsg[i] && zMsg[i]!='\r' && zMsg[i]!='\n'; i++){} zMsg[i] = 0; sqlite3_log(errcode, @@ -16128,7 +24316,7 @@ iLine, lastErrno, zFunc, zPath, zMsg ); -@@ -36804,8 +36948,9 @@ static int winceCreateLock(const char *z +@@ -39891,8 +40086,9 @@ static int winceCreateLock(const char *z DWORD lastErrno; BOOL bLogged = FALSE; BOOL bInit = TRUE; @@ -16138,8 +24326,8 @@ + zName = winUtf8ToUnicode(zFilename, buf); if( zName==0 ){ /* out of memory */ - return SQLITE_IOERR_NOMEM; -@@ -36825,7 +36970,9 @@ static int winceCreateLock(const char *z + return SQLITE_IOERR_NOMEM_BKPT; +@@ -39912,7 +40108,9 @@ static int winceCreateLock(const char *z pFile->hMutex = osCreateMutexW(NULL, FALSE, zName); if (!pFile->hMutex){ pFile->lastErrno = osGetLastError(); @@ -16150,7 +24338,7 @@ return winLogError(SQLITE_IOERR, pFile->lastErrno, "winceCreateLock1", zFilename); } -@@ -36849,7 +36996,9 @@ static int winceCreateLock(const char *z +@@ -39936,7 +40134,9 @@ static int winceCreateLock(const char *z bInit = FALSE; } @@ -16161,7 +24349,7 @@ /* If we succeeded in making the shared memory handle, map it. */ if( pFile->hShared ){ -@@ -37083,9 +37232,11 @@ static BOOL winLockFile( +@@ -40170,9 +40370,11 @@ static BOOL winLockFile( ovlp.Offset = offsetLow; ovlp.OffsetHigh = offsetHigh; return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp); @@ -16173,7 +24361,7 @@ } #endif } -@@ -37114,9 +37265,11 @@ static BOOL winUnlockFile( +@@ -40201,9 +40403,11 @@ static BOOL winUnlockFile( ovlp.Offset = offsetLow; ovlp.OffsetHigh = offsetHigh; return osUnlockFileEx(*phFile, 0, numBytesLow, numBytesHigh, &ovlp); @@ -16185,7 +24373,7 @@ } #endif } -@@ -37220,7 +37373,7 @@ static int winClose(sqlite3_file *id){ +@@ -40307,7 +40511,7 @@ static int winClose(sqlite3_file *id){ assert( pFile->pShm==0 ); #endif assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE ); @@ -16194,7 +24382,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); #if SQLITE_MAX_MMAP_SIZE>0 -@@ -37250,7 +37403,7 @@ static int winClose(sqlite3_file *id){ +@@ -40342,7 +40546,7 @@ static int winClose(sqlite3_file *id){ pFile->h = NULL; } OpenCounter(-1); @@ -16203,7 +24391,7 @@ osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed")); return rc ? SQLITE_OK : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(), -@@ -37279,7 +37432,7 @@ static int winRead( +@@ -40371,7 +40575,7 @@ static int winRead( assert( amt>0 ); assert( offset>=0 ); SimulateIOError(return SQLITE_IOERR_READ); @@ -16212,7 +24400,7 @@ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile, pFile->h, pBuf, amt, offset, pFile->locktype)); -@@ -37289,7 +37442,7 @@ static int winRead( +@@ -40381,7 +40585,7 @@ static int winRead( if( offsetmmapSize ){ if( offset+amt <= pFile->mmapSize ){ memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt); @@ -16221,7 +24409,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); return SQLITE_OK; }else{ -@@ -37304,7 +37457,7 @@ static int winRead( +@@ -40396,7 +40600,7 @@ static int winRead( #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED) if( winSeekFile(pFile, offset) ){ @@ -16230,7 +24418,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); return SQLITE_FULL; } -@@ -37319,7 +37472,7 @@ static int winRead( +@@ -40411,7 +40615,7 @@ static int winRead( DWORD lastErrno; if( winRetryIoerr(&nRetry, &lastErrno) ) continue; pFile->lastErrno = lastErrno; @@ -16239,7 +24427,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); return winLogError(SQLITE_IOERR_READ, pFile->lastErrno, "winRead", pFile->zPath); -@@ -37328,12 +37481,12 @@ static int winRead( +@@ -40420,12 +40624,12 @@ static int winRead( if( nRead<(DWORD)amt ){ /* Unread parts of the buffer must be zero-filled */ memset(&((char*)pBuf)[nRead], 0, amt-nRead); @@ -16254,7 +24442,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); return SQLITE_OK; } -@@ -37357,7 +37510,7 @@ static int winWrite( +@@ -40449,7 +40653,7 @@ static int winWrite( SimulateIOError(return SQLITE_IOERR_WRITE); SimulateDiskfullError(return SQLITE_FULL); @@ -16263,7 +24451,7 @@ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile, pFile->h, pBuf, amt, offset, pFile->locktype)); -@@ -37367,7 +37520,7 @@ static int winWrite( +@@ -40459,7 +40663,7 @@ static int winWrite( if( offsetmmapSize ){ if( offset+amt <= pFile->mmapSize ){ memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt); @@ -16272,7 +24460,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); return SQLITE_OK; }else{ -@@ -37431,19 +37584,19 @@ static int winWrite( +@@ -40523,19 +40727,19 @@ static int winWrite( if( rc ){ if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ) || ( pFile->lastErrno==ERROR_DISK_FULL )){ @@ -16295,7 +24483,7 @@ osGetCurrentProcessId(), pFile, pFile->h)); return SQLITE_OK; } -@@ -37458,7 +37611,7 @@ static int winTruncate(sqlite3_file *id, +@@ -40550,7 +40754,7 @@ static int winTruncate(sqlite3_file *id, assert( pFile ); SimulateIOError(return SQLITE_IOERR_TRUNCATE); @@ -16304,7 +24492,7 @@ osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype)); /* If the user has configured a chunk-size for this file, truncate the -@@ -37491,7 +37644,7 @@ static int winTruncate(sqlite3_file *id, +@@ -40583,7 +40787,7 @@ static int winTruncate(sqlite3_file *id, } #endif @@ -16313,7 +24501,7 @@ osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc))); return rc; } -@@ -37537,7 +37690,7 @@ static int winSync(sqlite3_file *id, int +@@ -40629,7 +40833,7 @@ static int winSync(sqlite3_file *id, int */ SimulateDiskfullError( return SQLITE_FULL ); @@ -16322,7 +24510,7 @@ osGetCurrentProcessId(), pFile, pFile->h, flags, pFile->locktype)); -@@ -37554,19 +37707,19 @@ static int winSync(sqlite3_file *id, int +@@ -40646,19 +40850,19 @@ static int winSync(sqlite3_file *id, int ** no-op */ #ifdef SQLITE_NO_SYNC @@ -16345,7 +24533,7 @@ "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile, pFile->pMapRegion)); return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, -@@ -37577,12 +37730,12 @@ static int winSync(sqlite3_file *id, int +@@ -40669,12 +40873,12 @@ static int winSync(sqlite3_file *id, int rc = osFlushFileBuffers(pFile->h); SimulateIOError( rc=FALSE ); if( rc ){ @@ -16360,16 +24548,16 @@ osGetCurrentProcessId(), pFile, pFile->h)); return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno, "winSync2", pFile->zPath); -@@ -38278,7 +38431,7 @@ static int winShmSystemLock( +@@ -41413,7 +41617,7 @@ static int winShmSystemLock( rc = SQLITE_BUSY; } - OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n", + OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%u, rc=%s\n", - pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" : + pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" : "winLockFile", pFile->lastErrno, sqlite3ErrName(rc))); -@@ -38299,7 +38452,7 @@ static void winShmPurge(sqlite3_vfs *pVf +@@ -41434,7 +41638,7 @@ static void winShmPurge(sqlite3_vfs *pVf winShmNode **pp; winShmNode *p; assert( winShmMutexHeld() ); @@ -16378,7 +24566,7 @@ osGetCurrentProcessId(), deleteFlag)); pp = &winShmNodeList; while( (p = *pp)!=0 ){ -@@ -38308,11 +38461,11 @@ static void winShmPurge(sqlite3_vfs *pVf +@@ -41443,11 +41647,11 @@ static void winShmPurge(sqlite3_vfs *pVf if( p->mutex ){ sqlite3_mutex_free(p->mutex); } for(i=0; inRegion; i++){ BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap); @@ -16392,7 +24580,7 @@ osGetCurrentProcessId(), i, bRc ? "ok" : "failed")); UNUSED_VARIABLE_VALUE(bRc); } -@@ -38593,7 +38746,7 @@ static int winShmLock( +@@ -41730,7 +41934,7 @@ static int winShmLock( } } sqlite3_mutex_leave(pShmNode->mutex); @@ -16401,7 +24589,16 @@ osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask, sqlite3ErrName(rc))); return rc; -@@ -38716,7 +38869,7 @@ static int winShmMap( +@@ -41827,7 +42031,7 @@ static int winShmMap( + } + + /* Map the requested memory region into this processes address space. */ +- apNew = (struct ShmRegion *)sqlite3_realloc64( ++ apNew = (struct ShmRegion *)sqlite3Realloc( + pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0]) + ); + if( !apNew ){ +@@ -41853,7 +42057,7 @@ static int winShmMap( NULL, PAGE_READWRITE, 0, nByte, NULL ); #endif @@ -16410,7 +24607,7 @@ osGetCurrentProcessId(), pShmNode->nRegion, nByte, hMap ? "ok" : "failed")); if( hMap ){ -@@ -38731,7 +38884,7 @@ static int winShmMap( +@@ -41868,7 +42072,7 @@ static int winShmMap( 0, iOffset - iOffsetShift, szRegion + iOffsetShift ); #endif @@ -16419,7 +24616,7 @@ osGetCurrentProcessId(), pShmNode->nRegion, iOffset, szRegion, pMap ? "ok" : "failed")); } -@@ -38775,14 +38928,14 @@ shmpage_out: +@@ -41912,14 +42116,14 @@ shmpage_out: #if SQLITE_MAX_MMAP_SIZE>0 static int winUnmapfile(winFile *pFile){ assert( pFile!=0 ); @@ -16436,7 +24633,7 @@ "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile, pFile->pMapRegion)); return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, -@@ -38795,14 +38948,14 @@ static int winUnmapfile(winFile *pFile){ +@@ -41932,14 +42136,14 @@ static int winUnmapfile(winFile *pFile){ if( pFile->hMap!=NULL ){ if( !osCloseHandle(pFile->hMap) ){ pFile->lastErrno = osGetLastError(); @@ -16453,7 +24650,7 @@ osGetCurrentProcessId(), pFile)); return SQLITE_OK; } -@@ -38828,7 +38981,7 @@ static int winMapfile(winFile *pFd, sqli +@@ -41965,7 +42169,7 @@ static int winMapfile(winFile *pFd, sqli int rc; assert( nMap>=0 || pFd->nFetchOut==0 ); @@ -16462,7 +24659,7 @@ osGetCurrentProcessId(), pFd, nByte)); if( pFd->nFetchOut>0 ) return SQLITE_OK; -@@ -38836,7 +38989,7 @@ static int winMapfile(winFile *pFd, sqli +@@ -41973,7 +42177,7 @@ static int winMapfile(winFile *pFd, sqli if( nMap<0 ){ rc = winFileSize((sqlite3_file*)pFd, &nMap); if( rc ){ @@ -16471,7 +24668,7 @@ osGetCurrentProcessId(), pFd)); return SQLITE_IOERR_FSTAT; } -@@ -38877,7 +39030,7 @@ static int winMapfile(winFile *pFd, sqli +@@ -42014,7 +42218,7 @@ static int winMapfile(winFile *pFd, sqli rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno, "winMapfile1", pFd->zPath); /* Log the error, but continue normal operation using xRead/xWrite */ @@ -16480,7 +24677,7 @@ osGetCurrentProcessId(), pFd, sqlite3ErrName(rc))); return SQLITE_OK; } -@@ -38895,7 +39048,7 @@ static int winMapfile(winFile *pFd, sqli +@@ -42032,7 +42236,7 @@ static int winMapfile(winFile *pFd, sqli rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno, "winMapfile2", pFd->zPath); /* Log the error, but continue normal operation using xRead/xWrite */ @@ -16489,7 +24686,7 @@ osGetCurrentProcessId(), pFd, sqlite3ErrName(rc))); return SQLITE_OK; } -@@ -38904,7 +39057,7 @@ static int winMapfile(winFile *pFd, sqli +@@ -42041,7 +42245,7 @@ static int winMapfile(winFile *pFd, sqli pFd->mmapSizeActual = nMap; } @@ -16498,7 +24695,7 @@ osGetCurrentProcessId(), pFd)); return SQLITE_OK; } -@@ -38928,7 +39081,7 @@ static int winFetch(sqlite3_file *fd, i6 +@@ -42065,7 +42269,7 @@ static int winFetch(sqlite3_file *fd, i6 #endif *pp = 0; @@ -16507,7 +24704,7 @@ osGetCurrentProcessId(), fd, iOff, nAmt, pp)); #if SQLITE_MAX_MMAP_SIZE>0 -@@ -38936,7 +39089,7 @@ static int winFetch(sqlite3_file *fd, i6 +@@ -42073,7 +42277,7 @@ static int winFetch(sqlite3_file *fd, i6 if( pFd->pMapRegion==0 ){ int rc = winMapfile(pFd, -1); if( rc!=SQLITE_OK ){ @@ -16516,7 +24713,7 @@ osGetCurrentProcessId(), pFd, sqlite3ErrName(rc))); return rc; } -@@ -38948,7 +39101,7 @@ static int winFetch(sqlite3_file *fd, i6 +@@ -42085,7 +42289,7 @@ static int winFetch(sqlite3_file *fd, i6 } #endif @@ -16525,7 +24722,7 @@ osGetCurrentProcessId(), fd, pp, *pp)); return SQLITE_OK; } -@@ -38975,7 +39128,7 @@ static int winUnfetch(sqlite3_file *fd, +@@ -42112,7 +42316,7 @@ static int winUnfetch(sqlite3_file *fd, /* If p!=0, it must match the iOff value. */ assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] ); @@ -16534,7 +24731,7 @@ osGetCurrentProcessId(), pFd, iOff, p)); if( p ){ -@@ -38991,7 +39144,8 @@ static int winUnfetch(sqlite3_file *fd, +@@ -42128,7 +42332,8 @@ static int winUnfetch(sqlite3_file *fd, assert( pFd->nFetchOut>=0 ); #endif @@ -16544,7 +24741,7 @@ osGetCurrentProcessId(), fd)); return SQLITE_OK; } -@@ -39035,7 +39189,7 @@ static const sqlite3_io_methods winIoMet +@@ -42210,7 +42415,7 @@ static winVfsAppData winNolockAppData = ** sqlite3_vfs object. */ @@ -16553,7 +24750,7 @@ /* ** Convert a filename from whatever the underlying operating system ** supports for filenames into UTF-8. Space to hold the result is -@@ -39060,12 +39214,106 @@ static char *winConvertToUtf8Filename(co +@@ -42235,12 +42440,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 @@ -16627,7 +24824,7 @@ + !(winIsDriveLetterAndColon(zFilename) && winIsDirSep(zFilename[2]))){ + char buf1[MAX_PATH]; + cygwin_conv_to_full_win32_path(zFilename, buf1); -+ return winMbcsToUnicode(buf1); ++ return winMbcsToUnicode(buf1, osAreFileApisANSI()); +#endif + } + nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); @@ -16663,7 +24860,7 @@ } #ifdef SQLITE_WIN32_HAS_ANSI else{ -@@ -39088,7 +39336,14 @@ static int winMakeEndInDirSep(int nBuf, +@@ -42263,7 +42562,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); @@ -16820,17 +25017,18 @@ sqlite3_free(zTmpname); if( isReadWrite && !isExclusive ){ return winOpen(pVfs, zName, id, -@@ -39601,17 +39870,21 @@ static int winOpen( - && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK - ){ - osCloseHandle(h); -- sqlite3_free(zConverted); -+ if( zConverted!=buf ){ -+ sqlite3_free(zConverted); -+ } - sqlite3_free(zTmpname); - OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc))); - return rc; +@@ -42781,18 +43101,22 @@ static int winOpen( + && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK + ){ + osCloseHandle(h); +- sqlite3_free(zConverted); ++ if( zConverted!=buf ){ ++ sqlite3_free(zConverted); ++ } + sqlite3_free(zTmpname); + OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc))); + return rc; + } } - if( isTemp ){ + if( isDelete ){ @@ -16845,7 +25043,7 @@ } sqlite3_free(zTmpname); -@@ -39660,13 +39933,14 @@ static int winDelete( +@@ -42841,13 +43165,14 @@ static int winDelete( DWORD attr; DWORD lastErrno = 0; void *zConverted; @@ -16860,8 +25058,8 @@ + zConverted = winConvertFromUtf8Filename(zFilename, buf); if( zConverted==0 ){ OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename)); - return SQLITE_IOERR_NOMEM; -@@ -39750,7 +40024,9 @@ static int winDelete( + return SQLITE_IOERR_NOMEM_BKPT; +@@ -42931,7 +43256,9 @@ static int winDelete( }else{ winLogIoerr(cnt, __LINE__); } @@ -16872,7 +25070,7 @@ OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc))); return rc; } -@@ -39768,13 +40044,14 @@ static int winAccess( +@@ -42949,13 +43276,14 @@ static int winAccess( int rc = 0; DWORD lastErrno = 0; void *zConverted; @@ -16887,8 +25085,8 @@ + zConverted = winConvertFromUtf8Filename(zFilename, buf); if( zConverted==0 ){ OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename)); - return SQLITE_IOERR_NOMEM; -@@ -39800,7 +40077,9 @@ static int winAccess( + return SQLITE_IOERR_NOMEM_BKPT; +@@ -42981,7 +43309,9 @@ static int winAccess( }else{ winLogIoerr(cnt, __LINE__); if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){ @@ -16899,7 +25097,7 @@ return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename); }else{ -@@ -39813,7 +40092,9 @@ static int winAccess( +@@ -42994,7 +43324,9 @@ static int winAccess( attr = osGetFileAttributesA((char*)zConverted); } #endif @@ -16910,7 +25108,7 @@ switch( flags ){ case SQLITE_ACCESS_READ: case SQLITE_ACCESS_EXISTS: -@@ -39842,6 +40123,7 @@ static BOOL winIsDriveLetterAndColon( +@@ -43023,6 +43355,7 @@ static BOOL winIsDriveLetterAndColon( return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' ); } @@ -16918,7 +25116,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 -@@ -39878,6 +40160,42 @@ static BOOL winIsVerbatimPathname( +@@ -43059,6 +43392,71 @@ static BOOL winIsVerbatimPathname( */ return FALSE; } @@ -16958,83 +25156,137 @@ + } + while(jnOut ){ ++ /* SQLite assumes that xFullPathname() nul-terminates the output buffer ++ ** even if it returns an error. */ ++ zOut[iOff] = '\0'; ++ return SQLITE_CANTOPEN_BKPT; ++ } ++ sqlite3_snprintf(nOut-iOff, &zOut[iOff], "%s", zPath); ++ return SQLITE_OK; ++} ++#endif /* ** Turn a relative pathname into a full pathname. Write the full -@@ -39891,7 +40209,71 @@ static int winFullPathname( +@@ -43071,8 +43469,9 @@ static int winFullPathname( + int nFull, /* Size of output buffer in bytes */ char *zFull /* Output buffer */ ){ +-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) +- DWORD nByte; ++#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT ++ WCHAR buf[MAX_PATH]; ++ int nByte; + void *zConverted; + char *zOut; + #endif +@@ -43084,7 +43483,84 @@ static int winFullPathname( + zRelative++; + } -#if defined(__CYGWIN__) -+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT -+ int nByte; -+ void *zConverted; -+ char *zOut; -+ WCHAR buf[MAX_PATH]; -+#endif -+ + SimulateIOError( return SQLITE_ERROR ); + -+ if( getcwd && readlink){ ++ if( getcwd ){ + zFull[nFull-1] = '\0'; + if( !winIsDriveLetterAndColon(zRelative) || !winIsDirSep(zRelative[2]) ){ ++ int rc = SQLITE_OK; ++ int nByte; ++ int nLink = 1; /* Number of symbolic links followed so far */ ++ const char *zIn = zRelative; /* Input path for each iteration of loop */ ++ char *zDel = 0; ++ struct cygwinstat buf; + -+ /* Attempt to resolve the path as if it were a symbolic link. If it is -+ ** a symbolic link, the resolved path is stored in buffer zFull[]. Or, if -+ ** the identified file is not a symbolic link or does not exist, then -+ ** zRelative is copied directly into zFull. Either way, nByte is left set to -+ ** the size of the string copied into zFull[] in bytes. */ -+ nByte = readlink(zRelative, zFull, nFull-1); -+ if( nByte<0 ){ -+ int myErrno = osErrno; -+ if( myErrno!=EINVAL && myErrno!=ENOENT ){ -+ return winLogError(SQLITE_CANTOPEN_BKPT, (DWORD)myErrno, "readlink", zRelative); -+ } -+ zFull[nFull-1] = '\0'; -+ sqlite3_snprintf(nFull-1, zFull, "%s", zRelative); -+ nByte = sqlite3Strlen30(zFull); -+ }else{ -+ zFull[nByte] = '\0'; -+ } ++ assert( pVfs->mxPathname==MAX_PATHNAME ); ++#ifdef __CYGWIN__ /* Make sure that "struct cygwinstat" corresponds with real struct */ ++ assert( sizeof(buf)==sizeof(struct stat)); ++#endif ++ UNUSED_PARAMETER(pVfs); + -+ /* If buffer zFull[] now contains an absolute path there is nothing more -+ ** to do. If it contains a relative path, do the following: -+ ** -+ ** * move the relative path string so that it is at the end of th -+ ** zFull[] buffer. -+ ** * Call getcwd() to read the path of the current working directory -+ ** into the start of the zFull[] buffer. -+ ** * Append a '/' character to the cwd string and move the -+ ** relative path back within the buffer so that it immediately -+ ** follows the '/'. -+ ** -+ ** This code is written so that if the combination of the CWD and relative -+ ** path are larger than the allocated size of zFull[] the CWD is silently -+ ** truncated to make it fit. This is Ok, as SQLite refuses to open any -+ ** file for which this function returns a full path larger than (nFull-8) -+ ** bytes in size. */ -+ if( !winIsDirSep(zFull[0]) ){ -+ int nCwd; -+ int nRem = nFull-nByte-1; -+ memmove(&zFull[nRem], zFull, nByte+1); -+ zFull[nRem-1] = '\0'; -+ if( getcwd(zFull, nRem-1)==0 ){ -+ return winLogError(SQLITE_CANTOPEN_BKPT, (DWORD)osErrno, "getcwd", zRelative); ++ do { ++ /* Call lstat() on path zIn. Set bLink to true if the path is a symbolic ++ ** link, or false otherwise. */ ++ int bLink = 0; ++ if( lstat && readlink ) { ++ if( lstat(zIn, &buf)!=0 ){ ++ int myErrno = osErrno; ++ if( myErrno!=ENOENT ){ ++ rc = winLogError(SQLITE_CANTOPEN_BKPT, (DWORD)myErrno, "lstat", zIn); ++ } ++ }else{ ++ bLink = ((buf.st_mode & 0170000) == 0120000); ++ } ++ ++ if( bLink ){ ++ if( zDel==0 ){ ++ zDel = sqlite3Malloc(nFull); ++ if( zDel==0 ) rc = SQLITE_NOMEM; ++ }else if( ++nLink>SQLITE_MAX_SYMLINKS ){ ++ rc = SQLITE_CANTOPEN_BKPT; ++ } ++ ++ if( rc==SQLITE_OK ){ ++ nByte = readlink(zIn, zDel, nFull-1); ++ if( nByte<0 ){ ++ rc = winLogError(SQLITE_CANTOPEN_BKPT, (DWORD)osErrno, "readlink", zIn); ++ }else{ ++ if( zDel[0]!='/' ){ ++ int n; ++ for(n = sqlite3Strlen30(zIn); n>0 && zIn[n-1]!='/'; n--); ++ if( nByte+n+1>nFull ){ ++ rc = SQLITE_CANTOPEN_BKPT; ++ }else{ ++ memmove(&zDel[n], zDel, nByte+1); ++ memcpy(zDel, zIn, n); ++ nByte += n; ++ } ++ } ++ zDel[nByte] = '\0'; ++ } ++ } ++ ++ zIn = zDel; ++ } + } -+ nCwd = sqlite3Strlen30(zFull); -+ assert( nCwd<=nRem-1 ); -+ zFull[nCwd] = '/'; -+ memmove(&zFull[nCwd+1], &zFull[nRem], nByte+1); -+ } ++ ++ assert( rc!=SQLITE_OK || zIn!=zFull || zIn[0]=='/' ); ++ if( rc==SQLITE_OK && zIn!=zFull ){ ++ rc = mkFullPathname(zIn, zFull, nFull); ++ } ++ if( bLink==0 ) break; ++ zIn = zFull; ++ }while( rc==SQLITE_OK ); ++ ++ sqlite3_free(zDel); + winSimplifyName(zFull); -+ return SQLITE_OK; ++ return rc; + } + } +#if 0 SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); assert( nFull>=pVfs->mxPathname ); -@@ -39949,7 +40331,6 @@ static int winFullPathname( +@@ -43142,7 +43618,6 @@ static int winFullPathname( #endif #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) @@ -17042,35 +25294,23 @@ /* 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) ){ -@@ -39967,10 +40348,12 @@ static int winFullPathname( +@@ -43160,13 +43635,8 @@ static int winFullPathname( return SQLITE_OK; #endif -#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) -+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT -+#if 0 - DWORD nByte; - void *zConverted; - char *zOut; -+#endif - - /* If this path name begins with "/X:", where "X" is any alphabetic - ** character, discard the initial "/" from the pathname. -@@ -39979,12 +40362,7 @@ static int winFullPathname( - zRelative++; - } - - /* It's odd to simulate an io-error here, but really this is just - ** using the io-error infrastructure to test that SQLite handles this - ** function failing. This function could fail if, for example, the - ** current working directory has been unlinked. - */ - SimulateIOError( return SQLITE_ERROR ); ++#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT +#if defined(_WIN32) if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data -@@ -39996,7 +40374,8 @@ static int winFullPathname( +@@ -43178,7 +43648,8 @@ static int winFullPathname( sqlite3_data_directory, winGetDirSep(), zRelative); return SQLITE_OK; } @@ -17078,9 +25318,9 @@ +#endif + zConverted = winConvertFromUtf8Filename(zRelative, buf); if( zConverted==0 ){ - return SQLITE_IOERR_NOMEM; + return SQLITE_IOERR_NOMEM_BKPT; } -@@ -40004,24 +40383,32 @@ static int winFullPathname( +@@ -43186,24 +43657,32 @@ static int winFullPathname( LPWSTR zTemp; nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); if( nByte==0 ){ @@ -17099,7 +25339,7 @@ + if( zConverted != buf ){ + sqlite3_free(zConverted); + } - return SQLITE_IOERR_NOMEM; + return SQLITE_IOERR_NOMEM_BKPT; } nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0); if( nByte==0 ){ @@ -17118,7 +25358,7 @@ zOut = winUnicodeToUtf8(zTemp); sqlite3_free(zTemp); } -@@ -40053,7 +40440,22 @@ static int winFullPathname( +@@ -43235,7 +43714,22 @@ static int winFullPathname( } #endif if( zOut ){ @@ -17142,7 +25382,7 @@ sqlite3_free(zOut); return SQLITE_OK; }else{ -@@ -40069,7 +40471,7 @@ static int winFullPathname( +@@ -43251,7 +43745,7 @@ static int winFullPathname( */ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ HANDLE h; @@ -17151,7 +25391,7 @@ int nFull = pVfs->mxPathname+1; char *zFull = sqlite3MallocZero( nFull ); void *zConverted = 0; -@@ -40085,7 +40487,8 @@ static void *winDlOpen(sqlite3_vfs *pVfs +@@ -43267,7 +43761,8 @@ static void *winDlOpen(sqlite3_vfs *pVfs zConverted = winConvertFromUtf8Filename(zFull); sqlite3_free(zFull); #else @@ -17161,7 +25401,7 @@ UNUSED_PARAMETER(pVfs); #endif if( zConverted==0 ){ -@@ -40105,7 +40508,9 @@ static void *winDlOpen(sqlite3_vfs *pVfs +@@ -43287,7 +43782,9 @@ static void *winDlOpen(sqlite3_vfs *pVfs } #endif OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)h)); @@ -17172,91 +25412,99 @@ return (void*)h; } static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ -@@ -40143,45 +40548,62 @@ static int winRandomness(sqlite3_vfs *pV - n = nBuf; +@@ -43348,7 +43845,7 @@ static int winRandomness(sqlite3_vfs *pV + EntropyGatherer e; + UNUSED_PARAMETER(pVfs); memset(zBuf, 0, nBuf); - #else -- if( sizeof(SYSTEMTIME)<=nBuf-n ){ -+ if( (int)sizeof(SYSTEMTIME)<=nBuf-n ){ - SYSTEMTIME x; - osGetSystemTime(&x); - memcpy(&zBuf[n], &x, sizeof(x)); - n += sizeof(x); - } -- if( sizeof(DWORD)<=nBuf-n ){ -+ if( (int)sizeof(DWORD)<=nBuf-n ){ - DWORD pid = osGetCurrentProcessId(); - memcpy(&zBuf[n], &pid, sizeof(pid)); - n += sizeof(pid); - } - #if SQLITE_OS_WINRT -- if( sizeof(ULONGLONG)<=nBuf-n ){ -+ if( (int)sizeof(ULONGLONG)<=nBuf-n ){ - ULONGLONG cnt = osGetTickCount64(); - memcpy(&zBuf[n], &cnt, sizeof(cnt)); - n += sizeof(cnt); - } - #else -- if( sizeof(DWORD)<=nBuf-n ){ -+ if( (int)sizeof(DWORD)<=nBuf-n ){ - DWORD cnt = osGetTickCount(); - memcpy(&zBuf[n], &cnt, sizeof(cnt)); - n += sizeof(cnt); - } - #endif -- if( sizeof(LARGE_INTEGER)<=nBuf-n ){ -+ if( (int)sizeof(LARGE_INTEGER)<=nBuf-n ){ - LARGE_INTEGER i; +-#if defined(_MSC_VER) && _MSC_VER>=1400 && !SQLITE_OS_WINCE ++#ifdef HAVE_RAND_S + rand_s((unsigned int*)zBuf); /* rand_s() is not available with MinGW */ + #endif /* defined(_MSC_VER) && _MSC_VER>=1400 */ + e.a = (unsigned char*)zBuf; +@@ -43380,15 +43877,31 @@ static int winRandomness(sqlite3_vfs *pV osQueryPerformanceCounter(&i); - memcpy(&zBuf[n], &i, sizeof(i)); - n += sizeof(i); + xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER)); } -#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID -- if( sizeof(UUID)<=nBuf-n ){ +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT -+ if( (int)sizeof(UUID)<=nBuf-n ){ + { UUID id; +- memset(&id, 0, sizeof(UUID)); +- osUuidCreate(&id); +- xorMemory(&e, (unsigned char*)&id, sizeof(UUID)); +- memset(&id, 0, sizeof(UUID)); +- osUuidCreateSequential(&id); +- xorMemory(&e, (unsigned char*)&id, sizeof(UUID)); +#if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_WIN32_USE_UUID) + static HMODULE module = 0; -+ if( module == (HMODULE)-1 ){ -+ return n; -+ }else if( !module ){ ++ if( !module && module != (HMODULE)-1 ){ + module = osLoadLibraryW(L"RPCRT4.DLL"); -+ if( !module){ ++ if( !module ){ + module = (HMODULE)-1; -+ return n; ++ }else{ ++ aSyscall[77].pCurrent = (SYSCALL) osGetProcAddressA(module, "UuidCreate"); ++ aSyscall[78].pCurrent = (SYSCALL) osGetProcAddressA(module, "UuidCreateSequential"); + } -+ aSyscall[77].pCurrent = (SYSCALL) osGetProcAddressA(module, "UuidCreate"); -+ aSyscall[78].pCurrent = (SYSCALL) osGetProcAddressA(module, "UuidCreateSequential"); + } +#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */ -+ if( !osUuidCreate ){ -+ return n; ++ if( osUuidCreate ){ ++ memset(&id, 0, sizeof(UUID)); ++ osUuidCreate(&id); ++ xorMemory(&e, (unsigned char*)&id, sizeof(UUID)); ++ } ++ if( osUuidCreateSequential ){ ++ memset(&id, 0, sizeof(UUID)); ++ osUuidCreateSequential(&id); ++ xorMemory(&e, (unsigned char*)&id, sizeof(UUID)); + } - memset(&id, 0, sizeof(UUID)); - osUuidCreate(&id); - memcpy(&zBuf[n], &id, sizeof(UUID)); - n += sizeof(UUID); } -- if( sizeof(UUID)<=nBuf-n ){ -+ if( osUuidCreateSequential && (int)sizeof(UUID)<=nBuf-n ){ - UUID id; - memset(&id, 0, sizeof(UUID)); - osUuidCreateSequential(&id); -@@ -40310,6 +40732,10 @@ static int winGetLastError(sqlite3_vfs * - return winGetLastErrorMsg(osGetLastError(), nBuf, zBuf); + #endif /* !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID */ + return e.nXor>nBuf ? nBuf : e.nXor; +@@ -43514,6 +44027,10 @@ static int winGetLastError(sqlite3_vfs * + return e; } +#if SQLITE_OS_UNIX && !defined(SQLITE_AMALGAMATION) -+SQLITE_API int SQLITE_STDCALL sqlite3_os_unix_init(void); ++SQLITE_API int sqlite3_os_unix_init(void); +#endif + /* ** Initialize and deinitialize the operating system interface. */ -@@ -40363,11 +40789,15 @@ SQLITE_API int SQLITE_STDCALL sqlite3_os - winGetSystemCall, /* xGetSystemCall */ - winNextSystemCall, /* xNextSystemCall */ +@@ -43592,6 +44109,30 @@ SQLITE_API int sqlite3_os_init(void){ + winGetSystemCall, /* xGetSystemCall */ + winNextSystemCall, /* xNextSystemCall */ + }; ++ static sqlite3_vfs winNolockVfs1 = { ++ 3, /* iVersion */ ++ sizeof(winFile), /* szOsFile */ ++ SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ ++ 0, /* pNext */ ++ "none", /* zName */ ++ &winNolockAppData, /* pAppData */ ++ winOpen, /* xOpen */ ++ winDelete, /* xDelete */ ++ winAccess, /* xAccess */ ++ winFullPathname, /* xFullPathname */ ++ winDlOpen, /* xDlOpen */ ++ winDlError, /* xDlError */ ++ winDlSym, /* xDlSym */ ++ winDlClose, /* xDlClose */ ++ winRandomness, /* xRandomness */ ++ winSleep, /* xSleep */ ++ winCurrentTime, /* xCurrentTime */ ++ winGetLastError, /* xGetLastError */ ++ winCurrentTimeInt64, /* xCurrentTimeInt64 */ ++ winSetSystemCall, /* xSetSystemCall */ ++ winGetSystemCall, /* xGetSystemCall */ ++ winNextSystemCall, /* xNextSystemCall */ ++ }; + #if defined(SQLITE_WIN32_HAS_WIDE) + static sqlite3_vfs winLongPathNolockVfs = { + 3, /* iVersion */ +@@ -43617,11 +44158,15 @@ SQLITE_API int sqlite3_os_init(void){ + winGetSystemCall, /* xGetSystemCall */ + winNextSystemCall, /* xNextSystemCall */ }; +#ifdef _WIN32 + int i; @@ -17267,11 +25515,11 @@ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==80 ); -+ assert( ArraySize(aSyscall)==87 ); ++ assert( ArraySize(aSyscall)==88 ); /* get memory map allocation granularity */ memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); -@@ -40379,8 +40809,46 @@ SQLITE_API int SQLITE_STDCALL sqlite3_os +@@ -43633,13 +44178,52 @@ SQLITE_API int sqlite3_os_init(void){ assert( winSysInfo.dwAllocationGranularity>0 ); assert( winSysInfo.dwPageSize>0 ); @@ -17318,10 +25566,16 @@ #if defined(SQLITE_WIN32_HAS_WIDE) sqlite3_vfs_register(&winLongPathVfs, 0); #endif -@@ -40389,6 +40857,19 @@ SQLITE_API int SQLITE_STDCALL sqlite3_os + + sqlite3_vfs_register(&winNolockVfs, 0); ++ sqlite3_vfs_register(&winNolockVfs1, 0); + + #if defined(SQLITE_WIN32_HAS_WIDE) + sqlite3_vfs_register(&winLongPathNolockVfs, 0); +@@ -43649,6 +44233,19 @@ SQLITE_API int sqlite3_os_init(void){ } - SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){ + SQLITE_API int sqlite3_os_end(void){ +#ifdef _WIN32 + int i; +#endif @@ -17338,7 +25592,7 @@ #if SQLITE_OS_WINRT if( sleepObj!=NULL ){ osCloseHandle(sleepObj); -@@ -40749,7 +41230,7 @@ SQLITE_PRIVATE int sqlite3BitvecBuiltinT +@@ -44009,7 +44606,7 @@ SQLITE_PRIVATE int sqlite3BitvecBuiltinT ** bits to act as the reference */ pBitvec = sqlite3BitvecCreate( sz ); pV = sqlite3MallocZero( (sz+7)/8 + 1 ); @@ -17347,7 +25601,7 @@ if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end; /* NULL pBitvec tests */ -@@ -41663,8 +42144,8 @@ struct PCache1 { +@@ -45111,8 +45708,8 @@ struct PCache1 { ** The PGroup mutex must be held when accessing nMax. */ PGroup *pGroup; /* PGroup this cache belongs to */ @@ -17358,7 +25612,7 @@ int szAlloc; /* Total size of one pcache line */ int bPurgeable; /* True if cache is purgeable */ unsigned int nMin; /* Minimum number of pages reserved */ -@@ -41705,7 +42186,7 @@ static SQLITE_WSD struct PCacheGlobal { +@@ -45153,7 +45750,7 @@ static SQLITE_WSD struct PCacheGlobal { int isInit; /* True if initialized */ int separateCache; /* Use a new PGroup for each PCache */ int nInitPage; /* Initial bulk allocation size */ @@ -17367,7 +25621,7 @@ int nSlot; /* The number of pcache slots */ int nReserve; /* Try to keep nFreeSlot above this */ void *pStart, *pEnd; /* Bounds of global page cache memory */ -@@ -41753,7 +42234,7 @@ static SQLITE_WSD struct PCacheGlobal { +@@ -45201,7 +45798,7 @@ static SQLITE_WSD struct PCacheGlobal { ** This routine is called from sqlite3_initialize() and so it is guaranteed ** to be serialized already. There is no need for further mutexing. */ @@ -17376,7 +25630,7 @@ if( pcache1.isInit ){ PgFreeslot *p; if( pBuf==0 ) sz = n = 0; -@@ -41821,7 +42302,7 @@ static int pcache1InitBulk(PCache1 *pCac +@@ -45269,7 +45866,7 @@ static int pcache1InitBulk(PCache1 *pCac ** Multiple threads can run this routine at the same time. Global variables ** in pcache1 need to be protected via mutex. */ @@ -17385,7 +25639,7 @@ void *p = 0; assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); if( nByte<=pcache1.szSlot ){ -@@ -41844,7 +42325,7 @@ static void *pcache1Alloc(int nByte){ +@@ -45292,7 +45889,7 @@ static void *pcache1Alloc(int nByte){ p = sqlite3Malloc(nByte); #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS if( p ){ @@ -17394,7 +25648,7 @@ sqlite3_mutex_enter(pcache1.mutex); sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte); sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); -@@ -41890,11 +42371,11 @@ static void pcache1Free(void *p){ +@@ -45340,11 +45937,11 @@ static void pcache1Free(void *p){ /* ** Return the size of a pcache allocation */ @@ -17408,7 +25662,7 @@ assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) ); sqlite3MemdebugSetType(p, MEMTYPE_HEAP); iSize = sqlite3MallocSize(p); -@@ -41981,7 +42462,7 @@ static void pcache1FreePage(PgHdr1 *p){ +@@ -45431,7 +46028,7 @@ static void pcache1FreePage(PgHdr1 *p){ ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer ** exists, this function falls back to sqlite3Malloc(). */ @@ -17417,7 +25671,7 @@ return pcache1Alloc(sz); } -@@ -42697,14 +43178,14 @@ SQLITE_PRIVATE sqlite3_mutex *sqlite3Pca +@@ -46167,14 +46764,14 @@ SQLITE_PRIVATE sqlite3_mutex *sqlite3Pca ** been released, the function returns. The return value is the total number ** of bytes of memory released. */ @@ -17435,7 +25689,7 @@ && (p=pcache1.grp.lru.pLruPrev)!=0 && p->isAnchor==0 ){ -@@ -51299,9 +51780,9 @@ static int walIndexPage(Wal *pWal, int i +@@ -54941,9 +55538,9 @@ static int walIndexPage(Wal *pWal, int i /* Enlarge the pWal->apWiData[] array if required */ if( pWal->nWiData<=iPage ){ @@ -17446,26 +25700,26 @@ + apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte); if( !apNew ){ *ppPage = 0; - return SQLITE_NOMEM; -@@ -51925,7 +52406,7 @@ static int walIndexRecover(Wal *pWal){ + return SQLITE_NOMEM_BKPT; +@@ -55571,7 +56168,7 @@ static int walIndexRecover(Wal *pWal){ /* Malloc a buffer to read frames into. */ szFrame = szPage + WAL_FRAME_HDRSIZE; - aFrame = (u8 *)sqlite3_malloc64(szFrame); + aFrame = (u8 *)sqlite3Malloc(szFrame); if( !aFrame ){ - rc = SQLITE_NOMEM; + rc = SQLITE_NOMEM_BKPT; goto recovery_error; -@@ -52327,7 +52808,7 @@ static int walIteratorInit(Wal *pWal, Wa +@@ -55973,7 +56570,7 @@ static int walIteratorInit(Wal *pWal, Wa nByte = sizeof(WalIterator) + (nSegment-1)*sizeof(struct WalSegment) + iLast*sizeof(ht_slot); - p = (WalIterator *)sqlite3_malloc64(nByte); + p = (WalIterator *)sqlite3Malloc(nByte); if( !p ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; } -@@ -52337,7 +52818,7 @@ static int walIteratorInit(Wal *pWal, Wa +@@ -55983,7 +56580,7 @@ static int walIteratorInit(Wal *pWal, Wa /* Allocate temporary space used by the merge-sort routine. This block ** of memory will be freed before this function returns. */ @@ -17474,7 +25728,54 @@ sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast) ); if( !aTmp ){ -@@ -65682,7 +66163,7 @@ SQLITE_PRIVATE int sqlite3VdbeChangeEnco +@@ -57397,7 +57994,7 @@ static int walRewriteChecksums(Wal *pWal + u32 iRead; /* Next frame to read from wal file */ + i64 iCksumOff; + +- aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE); ++ aBuf = sqlite3Malloc(szPage + WAL_FRAME_HDRSIZE); + if( aBuf==0 ) return SQLITE_NOMEM_BKPT; + + /* Find the checksum values to use as input for the recalculating the +@@ -57883,7 +58480,7 @@ SQLITE_PRIVATE int sqlite3WalSnapshotGet + *ppSnapshot = 0; + return SQLITE_ERROR; + } +- pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr)); ++ pRet = (WalIndexHdr*)sqlite3Malloc(sizeof(WalIndexHdr)); + if( pRet==0 ){ + rc = SQLITE_NOMEM_BKPT; + }else{ +@@ -67550,7 +68147,7 @@ static int clearDatabasePage( + BtShared *pBt, /* The BTree that contains the table */ + Pgno pgno, /* Page number to clear */ + int freePageFlag, /* Deallocate page if true */ +- int *pnChange /* Add number of Cells freed to this counter */ ++ u64 *pnChange /* Add number of Cells freed to this counter */ + ){ + MemPage *pPage; + int rc; +@@ -67613,7 +68210,7 @@ cleardatabasepage_out: + ** integer value pointed to by pnChange is incremented by the number of + ** entries in the table. + */ +-SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ ++SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, u64 *pnChange){ + int rc; + BtShared *pBt = p->pBt; + sqlite3BtreeEnter(p); +@@ -69658,6 +70255,10 @@ SQLITE_PRIVATE int sqlite3VdbeCheckMemIn + /* Cannot be both MEM_Int and MEM_Real at the same time */ + assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); + ++ /* Cannot be both MEM_Null and some other type */ ++ assert( (p->flags & MEM_Null)==0 || ++ (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob))==0 ); ++ + /* The szMalloc field holds the correct memory allocation size */ + assert( p->szMalloc==0 + || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); +@@ -69731,7 +70332,7 @@ SQLITE_PRIVATE int sqlite3VdbeChangeEnco ** blob if bPreserve is true. If bPreserve is false, any prior content ** in pMem->z is discarded. */ @@ -17482,8 +25783,8 @@ +SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, size_t n, int bPreserve){ assert( sqlite3VdbeCheckMemInvariants(pMem) ); assert( (pMem->flags&MEM_RowSet)==0 ); - -@@ -65738,7 +66219,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlit + testcase( pMem->db==0 ); +@@ -69788,7 +70389,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlit ** Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM) ** if unable to complete the resizing. */ @@ -17492,7 +25793,7 @@ assert( szNew>0 ); assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 ); if( pMem->szMallocu.nZero = n; pMem->enc = SQLITE_UTF8; pMem->z = 0; -@@ -66423,7 +66904,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemMove(M +@@ -70469,7 +71070,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemMove(M SQLITE_PRIVATE int sqlite3VdbeMemSetStr( Mem *pMem, /* Memory cell to set to string value */ const char *z, /* String pointer */ @@ -17515,16 +25816,7 @@ u8 enc, /* Encoding of z. 0 for BLOBs */ void (*xDel)(void*) /* Destructor function */ ){ -@@ -66754,7 +67235,7 @@ static int valueFromFunction( - FuncDef *pFunc = 0; /* Function definition */ - sqlite3_value *pVal = 0; /* New value */ - int rc = SQLITE_OK; /* Return code */ -- int nName; /* Size of function name in bytes */ -+ size_t nName; /* Size of function name in bytes */ - ExprList *pList = 0; /* Function arguments */ - int i; /* Iterator variable */ - -@@ -67266,10 +67747,10 @@ SQLITE_PRIVATE void sqlite3ValueFree(sql +@@ -71305,10 +71906,10 @@ SQLITE_PRIVATE void sqlite3ValueFree(sql ** sqlite3_value object assuming that it uses the encoding "enc". ** The valueBytes() routine is a helper function. */ @@ -17537,16 +25829,16 @@ Mem *p = (Mem*)pVal; assert( (p->flags & MEM_Null)==0 || (p->flags & (MEM_Str|MEM_Blob))==0 ); if( (p->flags & MEM_Str)!=0 && pVal->enc==enc ){ -@@ -67411,7 +67892,7 @@ static int growOpArray(Vdbe *v, int nOp) - UNUSED_PARAMETER(nOp); - #endif +@@ -71452,7 +72053,7 @@ static int growOpArray(Vdbe *v, int nOp) + return SQLITE_NOMEM; + } - assert( nOp<=(1024/sizeof(Op)) ); + assert( (unsigned)nOp<=(1024/sizeof(Op)) ); assert( nNew>=(p->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); if( pNew ){ -@@ -67474,7 +67955,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdb +@@ -71515,7 +72116,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdb pOp->p3 = p3; pOp->p4.p = 0; pOp->p4type = P4_NOTUSED; @@ -17555,7 +25847,7 @@ pOp->zComment = 0; #endif #ifdef SQLITE_DEBUG -@@ -67944,7 +68425,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOpList( +@@ -72058,7 +72659,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpL pOut->p4type = P4_NOTUSED; pOut->p4.p = 0; pOut->p5 = 0; @@ -17564,17 +25856,17 @@ pOut->zComment = 0; #endif #ifdef SQLITE_VDBE_COVERAGE -@@ -68096,7 +68577,7 @@ static void vdbeFreeOpArray(sqlite3 *db, +@@ -72210,7 +72811,7 @@ static void vdbeFreeOpArray(sqlite3 *db, Op *pOp; for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ - freeP4(db, pOp->p4type, pOp->p4.p); + if( pOp->p4type ) freeP4(db, pOp->p4type, pOp->p4.p); -#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS +#if 1 sqlite3DbFree(db, pOp->zComment); #endif } -@@ -68227,7 +68708,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyI - P4_KEYINFO); +@@ -72363,7 +72964,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyI + if( pKeyInfo ) sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO); } -#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS @@ -17582,7 +25874,7 @@ /* ** Change the comment on the most recently coded instruction. Or ** insert a No-op and add the comment to that new instruction. This -@@ -68300,7 +68781,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp( +@@ -72436,7 +73037,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp( } } @@ -17591,7 +25883,25 @@ /* ** Return an integer value for one of the parameters to the opcode pOp ** determined by character c. -@@ -68681,8 +69162,12 @@ SQLITE_PRIVATE void sqlite3VdbePrintOp(F +@@ -72614,8 +73215,8 @@ static void displayP4Expr(StrAccum *p, E + ** Compute a string that describes the P4 parameter for an opcode. + ** Use zTemp for any required temporary buffer space. + */ +-static char *displayP4(Op *pOp, char *zTemp, int nTemp){ +- char *zP4 = zTemp; ++static const char *displayP4(Op *pOp, char *zTemp, int nTemp){ ++ const char *zP4 = zTemp; + StrAccum x; + assert( nTemp>=20 ); + sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0); +@@ -72815,14 +73416,18 @@ SQLITE_PRIVATE void sqlite3VdbeLeave(Vdb + ** Print a single opcode. This routine is used for debugging only. + */ + SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){ +- char *zP4; ++ const char *zP4; + char zPtr[50]; + char zCom[100]; static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n"; if( pOut==0 ) pOut = stdout; zP4 = displayP4(pOp, zPtr, sizeof(zPtr)); @@ -17606,7 +25916,16 @@ #else zCom[0] = 0; #endif -@@ -68927,15 +69412,19 @@ SQLITE_PRIVATE int sqlite3VdbeList( +@@ -72996,7 +73601,7 @@ SQLITE_PRIVATE int sqlite3VdbeList( + rc = SQLITE_ERROR; + sqlite3VdbeError(p, sqlite3ErrStr(p->rc)); + }else{ +- char *zP4; ++ const char *zP4; + Op *pOp; + if( inOp ){ + /* The output line number is small enough that we are still in the +@@ -73082,15 +73687,19 @@ SQLITE_PRIVATE int sqlite3VdbeList( sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */ pMem->enc = SQLITE_UTF8; pMem++; @@ -17634,7 +25953,7 @@ #else pMem->flags = MEM_Null; /* Comment */ #endif -@@ -70390,7 +70879,6 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialType +@@ -74543,7 +75152,6 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialType return 7; } assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) ); @@ -17642,7 +25961,7 @@ n = (u32)pMem->n; if( flags & MEM_Zero ){ n += pMem->u.nZero; -@@ -70422,7 +70910,7 @@ static const u8 sqlite3SmallTypeSizes[] +@@ -74575,7 +75183,7 @@ static const u8 sqlite3SmallTypeSizes[] /* ** Return the length of the data corresponding to the supplied serial-type. */ @@ -17651,7 +25970,7 @@ if( serial_type>=128 ){ return (serial_type-12)/2; }else{ -@@ -70528,7 +71016,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialPut( +@@ -74681,7 +75289,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialPut( /* String or blob */ if( serial_type>=12 ){ assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0) @@ -17660,7 +25979,7 @@ len = pMem->n; if( len>0 ) memcpy(buf, pMem->z, len); return len; -@@ -70880,7 +71368,7 @@ debugCompareEnd: +@@ -75017,7 +75625,7 @@ debugCompareEnd: ** incorrectly. */ static void vdbeAssertFieldCountWithinLimits( @@ -17669,7 +25988,7 @@ const KeyInfo *pKeyInfo /* Compare size with this KeyInfo */ ){ int nField = 0; -@@ -70891,8 +71379,7 @@ static void vdbeAssertFieldCountWithinLi +@@ -75028,8 +75636,7 @@ static void vdbeAssertFieldCountWithinLi if( CORRUPT_DB ) return; idx = getVarint32(aKey, szHdr); @@ -17679,7 +25998,7 @@ while( idxpKeyInfo->db). */ SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip( @@ -17688,7 +26007,7 @@ UnpackedRecord *pPKey2, /* Right key */ int bSkip /* If true, skip the first field */ ){ -@@ -71260,7 +71747,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordComp +@@ -75432,7 +76039,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordComp if( serial_type<12 || (serial_type & 0x01) ){ rc = -1; }else{ @@ -17697,7 +26016,7 @@ testcase( (d1+nStr)==(unsigned)nKey1 ); testcase( (d1+nStr+1)==(unsigned)nKey1 ); if( (d1+nStr) > (unsigned)nKey1 ){ -@@ -71311,7 +71798,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordComp +@@ -75489,7 +76096,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordComp return pPKey2->default_rc; } SQLITE_PRIVATE int sqlite3VdbeRecordCompare( @@ -17706,7 +26025,7 @@ UnpackedRecord *pPKey2 /* Right key */ ){ return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0); -@@ -71328,7 +71815,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordComp +@@ -75506,7 +76113,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordComp ** on schemas where the maximum valid header size is 63 bytes or less. */ static int vdbeRecordCompareInt( @@ -17715,7 +26034,7 @@ UnpackedRecord *pPKey2 /* Right key */ ){ const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F]; -@@ -71421,7 +71908,7 @@ static int vdbeRecordCompareInt( +@@ -75600,7 +76207,7 @@ static int vdbeRecordCompareInt( ** at the start of (pKey1/nKey1) fits in a single byte. */ static int vdbeRecordCompareString( @@ -17724,7 +26043,7 @@ UnpackedRecord *pPKey2 /* Right key */ ){ const u8 *aKey1 = (const u8*)pKey1; -@@ -71436,8 +71923,8 @@ static int vdbeRecordCompareString( +@@ -75615,8 +76222,8 @@ static int vdbeRecordCompareString( }else if( !(serial_type & 0x01) ){ res = pPKey2->r2; /* (pKey1/nKey1) is a blob */ }else{ @@ -17735,7 +26054,7 @@ int szHdr = aKey1[0]; nStr = (serial_type-12) / 2; -@@ -71556,7 +72043,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxRowid(s +@@ -75734,7 +76341,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxRowid(s (void)getVarint32((u8*)m.z, szHdr); testcase( szHdr==3 ); testcase( szHdr==m.n ); @@ -17744,10 +26063,10 @@ goto idx_rowid_corruption; } -@@ -71621,12 +72108,13 @@ SQLITE_PRIVATE int sqlite3VdbeIdxKeyComp +@@ -75798,12 +76405,13 @@ SQLITE_PRIVATE int sqlite3VdbeIdxKeyComp + pCur = pC->uc.pCursor; assert( sqlite3BtreeCursorIsValid(pCur) ); - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); - assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ + nCellKey = sqlite3BtreePayloadSize(pCur); - /* nCellKey will always be between 0 and 0xffffffff because of the way + /* nCellKey will always be between 0 and 0x7fffffff because of the way ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ @@ -17758,22 +26077,40 @@ } + assert( nCellKey>=0 && nCellKey<=0x7fffffff ); sqlite3VdbeMemInit(&m, db, 0); - rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m); + rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m); if( rc ){ -@@ -71908,10 +72396,10 @@ SQLITE_API const void *SQLITE_STDCALL sq +@@ -75818,7 +76426,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxKeyComp + ** This routine sets the value to be returned by subsequent calls to + ** sqlite3_changes() on the database handle 'db'. + */ +-SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){ ++SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, u64 nChange){ + assert( sqlite3_mutex_held(db->mutex) ); + db->nChange = nChange; + db->nTotalChange += nChange; +@@ -76184,10 +76792,10 @@ SQLITE_API const void *sqlite3_value_blo return sqlite3_value_text(pVal); } } --SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){ -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){ +-SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){ ++SQLITE_API unsigned int sqlite3_value_bytes(sqlite3_value *pVal){ return sqlite3ValueBytes(pVal, SQLITE_UTF8); } --SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){ -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){ +-SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){ ++SQLITE_API unsigned int sqlite3_value_bytes16(sqlite3_value *pVal){ return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE); } - SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){ -@@ -72026,7 +72514,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_v + SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){ +@@ -76264,7 +76872,7 @@ SQLITE_API int sqlite3_value_type(sqlite + SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){ + sqlite3_value *pNew; + if( pOrig==0 ) return 0; +- pNew = sqlite3_malloc( sizeof(*pNew) ); ++ pNew = sqlite3Malloc( sizeof(*pNew) ); + if( pNew==0 ) return 0; + memset(pNew, 0, sizeof(*pNew)); + memcpy(pNew, pOrig, MEMCELLSIZE); +@@ -76303,7 +76911,7 @@ SQLITE_API void sqlite3_value_free(sqlit static void setResultStrOrError( sqlite3_context *pCtx, /* Function context */ const char *z, /* String pointer */ @@ -17782,12 +26119,12 @@ u8 enc, /* Encoding of z. 0 for BLOBs */ void (*xDel)(void*) /* Destructor function */ ){ -@@ -72050,15 +72538,15 @@ static int invokeValueDestructor( +@@ -76327,15 +76935,15 @@ static int invokeValueDestructor( if( pCtx ) sqlite3_result_error_toobig(pCtx); return SQLITE_TOOBIG; } +#undef sqlite3_result_blob - SQLITE_API void SQLITE_STDCALL sqlite3_result_blob( + SQLITE_API void sqlite3_result_blob( sqlite3_context *pCtx, const void *z, - int n, @@ -17799,9 +26136,9 @@ - setResultStrOrError(pCtx, z, n, 0, xDel); + setResultStrOrError(pCtx, z, (size_t)n, 0, xDel); } - SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64( + SQLITE_API void sqlite3_result_blob64( sqlite3_context *pCtx, -@@ -72068,11 +72556,12 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r +@@ -76345,11 +76953,12 @@ SQLITE_API void sqlite3_result_blob64( ){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); assert( xDel!=SQLITE_DYNAMIC ); @@ -17816,26 +26153,26 @@ } + setResultStrOrError(pCtx, z, (size_t)n, 0, xDel); } - SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){ + SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); -@@ -72108,6 +72597,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r - assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); - pCtx->pOut->eSubtype = eSubtype & 0xff; +@@ -76387,6 +76996,7 @@ SQLITE_API void sqlite3_result_subtype(s + pOut->eSubtype = eSubtype & 0xff; + pOut->flags |= MEM_Subtype; } +#undef sqlite3_result_text - SQLITE_API void SQLITE_STDCALL sqlite3_result_text( + SQLITE_API void sqlite3_result_text( sqlite3_context *pCtx, const char *z, -@@ -72115,7 +72605,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r +@@ -76394,7 +77004,7 @@ SQLITE_API void sqlite3_result_text( void (*xDel)(void *) ){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); - setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); + setResultStrOrError(pCtx, z, (size_t)n, SQLITE_UTF8, xDel); } - SQLITE_API void SQLITE_STDCALL sqlite3_result_text64( + SQLITE_API void sqlite3_result_text64( sqlite3_context *pCtx, -@@ -72126,14 +72616,20 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r +@@ -76405,14 +77015,20 @@ SQLITE_API void sqlite3_result_text64( ){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); assert( xDel!=SQLITE_DYNAMIC ); @@ -17857,28 +26194,28 @@ +#undef sqlite3_result_text16 +#undef sqlite3_result_text16be +#undef sqlite3_result_text16le - SQLITE_API void SQLITE_STDCALL sqlite3_result_text16( + SQLITE_API void sqlite3_result_text16( sqlite3_context *pCtx, const void *z, -@@ -72141,7 +72637,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r +@@ -76420,7 +77036,7 @@ SQLITE_API void sqlite3_result_text16( void (*xDel)(void *) ){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); - setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel); + setResultStrOrError(pCtx, z, (size_t)n, SQLITE_UTF16NATIVE, xDel); } - SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be( + SQLITE_API void sqlite3_result_text16be( sqlite3_context *pCtx, -@@ -72150,7 +72646,7 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r +@@ -76429,7 +77045,7 @@ SQLITE_API void sqlite3_result_text16be( void (*xDel)(void *) ){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); - setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel); + setResultStrOrError(pCtx, z, (size_t)n, SQLITE_UTF16BE, xDel); } - SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le( + SQLITE_API void sqlite3_result_text16le( sqlite3_context *pCtx, -@@ -72159,16 +72655,17 @@ SQLITE_API void SQLITE_STDCALL sqlite3_r +@@ -76438,16 +77054,17 @@ SQLITE_API void sqlite3_result_text16le( void (*xDel)(void *) ){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); @@ -17886,19 +26223,19 @@ + setResultStrOrError(pCtx, z, (size_t)n, SQLITE_UTF16LE, xDel); } #endif /* SQLITE_OMIT_UTF16 */ - SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ + SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemCopy(pCtx->pOut, pValue); } +#undef sqlite3_result_zeroblob - SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ + SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); - sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n); + sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (size_t)n); } - SQLITE_API int SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ + SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ Mem *pOut = pCtx->pOut; -@@ -72176,7 +72673,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_re +@@ -76455,7 +77072,7 @@ SQLITE_API int sqlite3_result_zeroblob64 if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ return SQLITE_TOOBIG; } @@ -17906,26 +26243,26 @@ + sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (size_t)n); return SQLITE_OK; } - SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ -@@ -72736,13 +73233,13 @@ SQLITE_API const void *SQLITE_STDCALL sq + SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ +@@ -77017,13 +77634,13 @@ SQLITE_API const void *sqlite3_column_bl columnMallocFailure(pStmt); return val; } --SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){ +-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){ - int val = sqlite3_value_bytes( columnMem(pStmt,i) ); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){ ++SQLITE_API unsigned int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){ + unsigned int val = sqlite3ValueBytes( columnMem(pStmt,i), SQLITE_UTF8 ); columnMallocFailure(pStmt); return val; } --SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){ +-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){ - int val = sqlite3_value_bytes16( columnMem(pStmt,i) ); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){ ++SQLITE_API unsigned int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){ + unsigned int val = sqlite3ValueBytes( columnMem(pStmt,i), SQLITE_UTF16NATIVE ); columnMallocFailure(pStmt); return val; } -@@ -72997,7 +73494,7 @@ static int bindText( +@@ -77277,7 +77894,7 @@ static int bindText( sqlite3_stmt *pStmt, /* The statement to bind against */ int i, /* Index of the parameter to bind */ const void *zData, /* Pointer to the data to be bound */ @@ -17934,12 +26271,12 @@ void (*xDel)(void*), /* Destructor for the data */ u8 encoding /* Encoding for the data */ ){ -@@ -73027,11 +73524,12 @@ static int bindText( +@@ -77307,11 +77924,12 @@ static int bindText( /* ** Bind a blob value to an SQL statement variable. */ +#undef sqlite3_bind_blob - SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob( + SQLITE_API int sqlite3_bind_blob( sqlite3_stmt *pStmt, int i, const void *zData, @@ -17947,8 +26284,8 @@ + unsigned int nData, void (*xDel)(void*) ){ - return bindText(pStmt, i, zData, nData, xDel, 0); -@@ -73044,11 +73542,11 @@ SQLITE_API int SQLITE_STDCALL sqlite3_bi + #ifdef SQLITE_ENABLE_API_ARMOR +@@ -77327,11 +77945,11 @@ SQLITE_API int sqlite3_bind_blob64( void (*xDel)(void*) ){ assert( xDel!=SQLITE_DYNAMIC ); @@ -17961,17 +26298,17 @@ } + return bindText(pStmt, i, zData, (size_t)nData, xDel, 0); } - SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ + SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ int rc; -@@ -73082,6 +73580,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_bi +@@ -77365,6 +77983,7 @@ SQLITE_API int sqlite3_bind_null(sqlite3 } return rc; } +#undef sqlite3_bind_text - SQLITE_API int SQLITE_STDCALL sqlite3_bind_text( + SQLITE_API int sqlite3_bind_text( sqlite3_stmt *pStmt, int i, -@@ -73101,13 +73600,16 @@ SQLITE_API int SQLITE_STDCALL sqlite3_bi +@@ -77384,13 +78003,16 @@ SQLITE_API int sqlite3_bind_text64( ){ assert( xDel!=SQLITE_DYNAMIC ); if( nData>0x7fffffff ){ @@ -17989,15 +26326,15 @@ } #ifndef SQLITE_OMIT_UTF16 +#undef sqlite3_bind_text16 - SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16( + SQLITE_API int sqlite3_bind_text16( sqlite3_stmt *pStmt, int i, -@@ -73149,12 +73651,13 @@ SQLITE_API int SQLITE_STDCALL sqlite3_bi +@@ -77432,12 +78054,13 @@ SQLITE_API int sqlite3_bind_value(sqlite } return rc; } +#undef sqlite3_bind_zeroblob - SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ + SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ int rc; Vdbe *p = (Vdbe *)pStmt; rc = vdbeUnbind(p, i); @@ -18007,7 +26344,7 @@ sqlite3_mutex_leave(p->db->mutex); } return rc; -@@ -73166,7 +73669,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_bi +@@ -77449,7 +78072,7 @@ SQLITE_API int sqlite3_bind_zeroblob64(s if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ rc = SQLITE_TOOBIG; }else{ @@ -18016,10 +26353,10 @@ rc = sqlite3_bind_zeroblob(pStmt, i, n); } rc = sqlite3ApiExit(p->db, rc); -@@ -73991,13 +74494,13 @@ SQLITE_PRIVATE void sqlite3VdbeMemPretty - - sqlite3_snprintf(100, zCsr, "%c", c); - zCsr += sqlite3Strlen30(zCsr); +@@ -78499,20 +79122,20 @@ SQLITE_PRIVATE void sqlite3VdbeMemPretty + c = 's'; + } + *(zCsr++) = c; - sqlite3_snprintf(100, zCsr, "%d[", pMem->n); + sqlite3_snprintf(100, zCsr, "%lld[", (u64)pMem->n); zCsr += sqlite3Strlen30(zCsr); @@ -18033,16 +26370,15 @@ char z = pMem->z[i]; if( z<32 || z>126 ) *zCsr++ = '.'; else *zCsr++ = z; -@@ -74006,7 +74509,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemPretty - sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem->enc]); - zCsr += sqlite3Strlen30(zCsr); + } + *(zCsr++) = ']'; if( f & MEM_Zero ){ - sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero); + sqlite3_snprintf(100, zCsr,"+%lldz",(u64)pMem->u.nZero); zCsr += sqlite3Strlen30(zCsr); } *zCsr = '\0'; -@@ -74026,10 +74529,10 @@ SQLITE_PRIVATE void sqlite3VdbeMemPretty +@@ -78532,10 +79155,10 @@ SQLITE_PRIVATE void sqlite3VdbeMemPretty zBuf[1] = 's'; } k = 2; @@ -18055,7 +26391,7 @@ u8 c = pMem->z[j]; if( c>=0x20 && c<0x7f ){ zBuf[k++] = c; -@@ -74055,9 +74558,15 @@ static void memTracePrint(Mem *p){ +@@ -78561,9 +79184,15 @@ static void memTracePrint(Mem *p){ }else if( p->flags & MEM_Null ){ printf(" NULL"); }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){ @@ -18071,7 +26407,97 @@ #ifndef SQLITE_OMIT_FLOATING_POINT }else if( p->flags & MEM_Real ){ printf(" r:%g", p->u.r); -@@ -81564,7 +82073,7 @@ static int vdbeSorterMapFile(SortSubtask +@@ -78581,6 +79210,7 @@ static void registerTrace(int iReg, Mem + printf("REG[%d] = ", iReg); + memTracePrint(p); + printf("\n"); ++ sqlite3VdbeCheckMemInvariants(p); + } + #endif + +@@ -79335,7 +79965,7 @@ case OP_Null: { /* out2 */ + case OP_SoftNull: { + assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); + pOut = &aMem[pOp->p1]; +- pOut->flags = (pOut->flags|MEM_Null)&~MEM_Undefined; ++ pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null; + break; + } + +@@ -79678,7 +80308,6 @@ case OP_Remainder: { /* same a + type2 = numericType(pIn2); + pOut = &aMem[pOp->p3]; + flags = pIn1->flags | pIn2->flags; +- if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; + if( (type1 & type2 & MEM_Int)!=0 ){ + iA = pIn1->u.i; + iB = pIn2->u.i; +@@ -79702,6 +80331,8 @@ case OP_Remainder: { /* same a + } + pOut->u.i = iB; + MemSetTypeFlag(pOut, MEM_Int); ++ }else if( (flags & MEM_Null)!=0 ){ ++ goto arithmetic_result_is_null; + }else{ + bIntint = 0; + fp_math: +@@ -80643,7 +81274,7 @@ case OP_Column: { + VdbeCursor *pC; /* The VDBE cursor */ + BtCursor *pCrsr; /* The BTree cursor */ + u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */ +- int len; /* The length of the serialized data for the column */ ++ size_t len; /* The length of the serialized data for the column */ + int i; /* Loop counter */ + Mem *pDest; /* Where to write the extracted value */ + Mem sMem; /* For storing the record being decoded */ +@@ -81735,7 +82366,6 @@ open_cursor_set_hints: + case OP_OpenAutoindex: + case OP_OpenEphemeral: { + VdbeCursor *pCx; +- KeyInfo *pKeyInfo; + + static const int vfsFlags = + SQLITE_OPEN_READWRITE | +@@ -81760,16 +82390,16 @@ case OP_OpenEphemeral: { + ** opening it. If a transient table is required, just use the + ** automatically created table with root-page 1 (an BLOB_INTKEY table). + */ +- if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){ ++ if( (pCx->pKeyInfo = pOp->p4.pKeyInfo)!=0 ){ + int pgno; + assert( pOp->p4type==P4_KEYINFO ); + rc = sqlite3BtreeCreateTable(pCx->pBtx, &pgno, BTREE_BLOBKEY | pOp->p5); + if( rc==SQLITE_OK ){ + assert( pgno==MASTER_ROOT+1 ); +- assert( pKeyInfo->db==db ); +- assert( pKeyInfo->enc==ENC(db) ); ++ assert( pCx->pKeyInfo->db==db ); ++ assert( pCx->pKeyInfo->enc==ENC(db) ); + rc = sqlite3BtreeCursor(pCx->pBtx, pgno, BTREE_WRCSR, +- pKeyInfo, pCx->uc.pCursor); ++ pCx->pKeyInfo, pCx->uc.pCursor); + } + pCx->isTable = 0; + }else{ +@@ -83629,7 +84259,7 @@ case OP_Destroy: { /* out2 */ + ** See also: Destroy + */ + case OP_Clear: { +- int nChange; ++ u64 nChange; + + nChange = 0; + assert( p->readOnly==0 ); +@@ -85522,7 +86152,7 @@ SQLITE_API int sqlite3_blob_open( + goto blob_open_out; + } + pBlob->pTab = pTab; +- pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName; ++ pBlob->zDb = (char *) db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName; + + /* Now search pTab for the exact column. */ + for(iCol=0; iColnCol; iCol++) { +@@ -86463,7 +87093,7 @@ static int vdbeSorterMapFile(SortSubtask int rc = SQLITE_OK; if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){ sqlite3_file *pFd = pFile->pFd; @@ -18080,7 +26506,7 @@ rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp); testcase( rc!=SQLITE_OK ); } -@@ -81756,10 +82265,10 @@ static int vdbeSorterCompareText( +@@ -86655,10 +87285,10 @@ static int vdbeSorterCompareText( const void *pKey1, int nKey1, /* Left side of comparison */ const void *pKey2, int nKey2 /* Right side of comparison */ ){ @@ -18095,7 +26521,7 @@ int n1; int n2; -@@ -82358,7 +82867,7 @@ static int vdbeSorterSort(SortSubtask *p +@@ -87267,7 +87897,7 @@ static int vdbeSorterSort(SortSubtask *p if( (u8*)p==pList->aMemory ){ pNext = 0; }else{ @@ -18104,34 +26530,47 @@ pNext = (SorterRecord*)&pList->aMemory[p->u.iNext]; } }else{ -@@ -84082,7 +84591,7 @@ static int memjrnlWrite( +@@ -88832,7 +89462,7 @@ static int memjrnlWrite( - if( iChunkOffset==0 ){ - /* New chunk is required to extend the file. */ -- FileChunk *pNew = sqlite3_malloc(sizeof(FileChunk)); -+ FileChunk *pNew = sqlite3Malloc(sizeof(FileChunk)); - if( !pNew ){ - return SQLITE_IOERR_NOMEM; + if( iChunkOffset==0 ){ + /* New chunk is required to extend the file. */ +- FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize)); ++ FileChunk *pNew = sqlite3Malloc(fileChunkSize(p->nChunkSize)); + if( !pNew ){ + return SQLITE_IOERR_NOMEM_BKPT; + } +@@ -89913,8 +90543,8 @@ static int resolveExprStep(Walker *pWalk + pNC->nErr++; + is_agg = 0; + }else if( no_such_func && pParse->db->init.busy==0 +-#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION +- && pParse->explain==0 ++#if 1 ++ && (pParse->explain==0 || !sqlite3GlobalConfig.bEnableUnknownSqlFunction) + #endif + ){ + sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); +@@ -94375,8 +95005,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget + assert( !ExprHasProperty(pExpr, EP_IntValue) ); + zId = pExpr->u.zToken; + pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0); +-#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION +- if( pDef==0 && pParse->explain ){ ++#if 1 ++ if( pDef==0 && pParse->explain && sqlite3GlobalConfig.bEnableUnknownSqlFunction){ + pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0); } -@@ -86612,7 +87121,7 @@ SQLITE_PRIVATE void sqlite3ExprDelete(sq - ** passed as the first argument. This is always one of EXPR_FULLSIZE, - ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. - */ --static int exprStructSize(Expr *p){ -+static size_t exprStructSize(Expr *p){ - if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE; - if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE; - return EXPR_FULLSIZE; -@@ -86756,7 +87265,7 @@ static Expr *exprDup(sqlite3 *db, Expr * - assert( ExprHasProperty(p, EP_Reduced)==0 ); - memcpy(zAlloc, p, nNewSize); - }else{ -- u32 nSize = (u32)exprStructSize(p); -+ size_t nSize = exprStructSize(p); - memcpy(zAlloc, p, nSize); - if( nSizedb; /* Database connection */ +@@ -96960,7 +97590,7 @@ struct Stat4Sample { i64 iRowid; /* Rowid in main table of the key */ u8 *aRowid; /* Key for WITHOUT ROWID tables */ } u; @@ -18140,7 +26579,7 @@ u8 isPSample; /* True if a periodic sample */ int iCol; /* If !isPSample, the reason for inclusion */ u32 iHash; /* Tiebreaker hash */ -@@ -91267,7 +91776,7 @@ static void sampleClear(sqlite3 *db, Sta +@@ -96998,7 +97628,7 @@ static void sampleClear(sqlite3 *db, Sta /* Initialize the BLOB value of a ROWID */ #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 @@ -18148,8 +26587,18 @@ +static void sampleSetRowid(sqlite3 *db, Stat4Sample *p, size_t n, const u8 *pData){ assert( db!=0 ); if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid); - p->u.aRowid = sqlite3DbMallocRaw(db, n); -@@ -92644,14 +93153,14 @@ static int loadStatTbl( + p->u.aRowid = sqlite3DbMallocRawNN(db, n); +@@ -98055,7 +98685,8 @@ SQLITE_PRIVATE void sqlite3Analyze(Parse + sqlite3 *db = pParse->db; + int iDb; + int i; +- char *z, *zDb; ++ char *z; ++ const char *zDb; + Table *pTab; + Index *pIdx; + Token *pTableName; +@@ -98385,14 +99016,14 @@ static int loadStatTbl( char *zIndex; /* Index name */ Index *pIdx; /* Pointer to the index object */ @@ -18166,34 +26615,93 @@ pIdx = findIndexOrPrimaryKey(db, zIndex, zDb); assert( pIdx==0 || bStat3 || pIdx->nSample==0 ); /* Index.nSample is non-zero at this point if data has already been -@@ -94417,7 +94926,7 @@ SQLITE_PRIVATE int sqlite3FindDbName(sql - int i = -1; /* Database number */ - if( zName ){ - Db *pDb; -- int n = sqlite3Strlen30(zName); -+ size_t n = sqlite3Strlen30(zName); - for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){ - if( (!OMIT_TEMPDB || i!=1 ) && n==sqlite3Strlen30(pDb->zName) && - 0==sqlite3StrICmp(pDb->zName, zName) ){ -@@ -98417,7 +98926,7 @@ static FuncDef *functionSearch( - FuncDefHash *pHash, /* Hash table to search */ - int h, /* Hash of the name */ - const char *zFunc, /* Name of function */ -- int nFunc /* Number of bytes in zFunc */ -+ size_t nFunc /* Number of bytes in zFunc */ +@@ -98698,7 +99329,7 @@ static void attachFunc( + goto attach_error; + } + for(i=0; inDb; i++){ +- char *z = db->aDb[i].zDbSName; ++ const char *z = db->aDb[i].zDbSName; + assert( z && zName ); + if( sqlite3StrICmp(z, zName)==0 ){ + zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName); +@@ -99295,7 +99926,7 @@ SQLITE_PRIVATE int sqlite3AuthReadCol( + int iDb /* Index of containing database. */ ){ - FuncDef *p; - for(p=pHash->a[h]; p; p=p->pHash){ -@@ -98475,7 +98984,7 @@ SQLITE_PRIVATE void sqlite3FuncDefInsert - SQLITE_PRIVATE FuncDef *sqlite3FindFunction( - sqlite3 *db, /* An open database */ - const char *zName, /* Name of the function. Not null-terminated */ -- int nName, /* Number of characters in the name */ -+ size_t nName, /* Number of characters in the name */ - int nArg, /* Number of arguments. -1 means any number */ - u8 enc, /* Preferred text encoding */ - u8 createFlag /* Create new entry if true and does not otherwise exist */ -@@ -99772,7 +100281,7 @@ static void substrFunc( + sqlite3 *db = pParse->db; /* Database handle */ +- char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */ ++ const char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */ + int rc; /* Auth callback return code */ + + if( db->init.busy ) return SQLITE_OK; +@@ -99560,9 +100191,9 @@ static void codeTableLocks(Parse *pParse + /* + ** Return TRUE if the given yDbMask object is empty - if it contains no + ** 1 bits. This routine is used by the DbMaskAllZero() and DbMaskNotZero() +-** macros when SQLITE_MAX_ATTACHED is greater than 30. ++** macros when SQLITE_MAX_ATTACHED is greater than 62. + */ +-#if SQLITE_MAX_ATTACHED>30 ++#if SQLITE_MAX_ATTACHED>62 + SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask m){ + int i; + for(i=0; inDb; i++){ + struct Db *pDb = &db->aDb[i]; + if( pDb->pBt==0 ){ +- sqlite3DbFree(db, pDb->zDbSName); ++ sqlite3DbFree(db, (char *)pDb->zDbSName); + pDb->zDbSName = 0; + continue; + } +@@ -100340,7 +100971,7 @@ SQLITE_PRIVATE void sqlite3StartTable( + SQLITE_CREATE_VIEW, + SQLITE_CREATE_TEMP_VIEW + }; +- char *zDb = db->aDb[iDb].zDbSName; ++ const char *zDb = db->aDb[iDb].zDbSName; + if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ + goto begin_table_error; + } +@@ -100359,7 +100990,7 @@ SQLITE_PRIVATE void sqlite3StartTable( + ** collisions. + */ + if( !IN_DECLARE_VTAB ){ +- char *zDb = db->aDb[iDb].zDbSName; ++ const char *zDb = db->aDb[iDb].zDbSName; + if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ + goto begin_table_error; + } +@@ -100987,7 +101618,7 @@ static void identPut(char *z, int *pIdx, + static char *createTableStmt(sqlite3 *db, Table *p){ + int i, k, n; + char *zStmt; +- char *zSep, *zSep2, *zEnd; ++ const char *zSep, *zSep2, *zEnd; + Column *pCol; + n = 0; + for(pCol = p->aCol, i=0; inCol; i++, pCol++){ +@@ -101356,8 +101987,8 @@ SQLITE_PRIVATE void sqlite3EndTable( + if( !db->init.busy ){ + int n; + Vdbe *v; +- char *zType; /* "view" or "table" */ +- char *zType2; /* "VIEW" or "TABLE" */ ++ const char *zType; /* "view" or "table" */ ++ const char *zType2; /* "VIEW" or "TABLE" */ + char *zStmt; /* Text of the CREATE TABLE or CREATE VIEW statement */ + + v = sqlite3GetVdbe(pParse); +@@ -104518,7 +105149,7 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( + ExprList *pOrderBy, /* The ORDER BY clause. May be null */ + Expr *pLimit, /* The LIMIT clause. May be null */ + Expr *pOffset, /* The OFFSET clause. May be null */ +- char *zStmtType /* Either DELETE or UPDATE. For err msgs. */ ++ const char *zStmtType /* Either DELETE or UPDATE. For err msgs. */ + ){ + Expr *pWhereRowid = NULL; /* WHERE rowid .. */ + Expr *pInClause = NULL; /* WHERE rowid IN ( select ) */ +@@ -105557,7 +106188,7 @@ static void substrFunc( ){ const unsigned char *z; const unsigned char *z2; @@ -18202,7 +26710,7 @@ int p0type; i64 p1, p2; int negP2 = 0; -@@ -99848,7 +100357,7 @@ static void substrFunc( +@@ -105633,7 +106264,7 @@ static void substrFunc( sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT, SQLITE_UTF8); }else{ @@ -18211,7 +26719,25 @@ p2 = len-p1; if( p2<0 ) p2 = 0; } -@@ -100579,7 +101088,7 @@ static void charFunc( +@@ -105836,7 +106467,7 @@ static void changes( + ){ + sqlite3 *db = sqlite3_context_db_handle(context); + UNUSED_PARAMETER2(NotUsed, NotUsed2); +- sqlite3_result_int(context, sqlite3_changes(db)); ++ sqlite3_result_int64(context, sqlite3_changes(db)); + } + + /* +@@ -105852,7 +106483,7 @@ static void total_changes( + UNUSED_PARAMETER2(NotUsed, NotUsed2); + /* IMP: R-52756-41993 This function is a wrapper around the + ** sqlite3_total_changes() C/C++ interface. */ +- sqlite3_result_int(context, sqlite3_total_changes(db)); ++ sqlite3_result_int64(context, sqlite3_total_changes(db)); + } + + /* +@@ -106374,7 +107005,7 @@ static void charFunc( ){ unsigned char *z, *zOut; int i; @@ -18220,7 +26746,7 @@ if( z==0 ){ sqlite3_result_error_nomem(context); return; -@@ -100673,10 +101182,10 @@ static void replaceFunc( +@@ -106468,10 +107099,10 @@ static void replaceFunc( const unsigned char *zPattern; /* The pattern string B */ const unsigned char *zRep; /* The replacement string C */ unsigned char *zOut; /* The output */ @@ -18234,7 +26760,7 @@ int loopLimit; /* Last zStr[] that might match zPattern[] */ int i, j; /* Loop counters */ -@@ -100725,7 +101234,7 @@ static void replaceFunc( +@@ -106520,7 +107151,7 @@ static void replaceFunc( return; } zOld = zOut; @@ -18243,7 +26769,7 @@ if( zOut==0 ){ sqlite3_result_error_nomem(context); sqlite3_free(zOld); -@@ -100736,7 +101245,7 @@ static void replaceFunc( +@@ -106531,7 +107162,7 @@ static void replaceFunc( i += nPattern-1; } } @@ -18252,7 +26778,25 @@ memcpy(&zOut[j], &zStr[i], nStr-i); j += nStr - i; assert( j<=nOut ); -@@ -105026,7 +105535,7 @@ typedef struct sqlite3_api_routines sqli +@@ -106624,7 +107255,7 @@ static void trimFunc( + } + + +-#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION ++#if 1 /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/ + /* + ** The "unknown" function is automatically substituted in place of + ** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN +@@ -107124,7 +107755,7 @@ SQLITE_PRIVATE void sqlite3RegisterBuilt + LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE), + LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE), + #endif +-#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION ++#if 1 /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/ + FUNCTION(unknown, -1, 0, 0, unknownFunc ), + #endif + FUNCTION(coalesce, 1, 0, 0, 0 ), +@@ -111031,7 +111662,7 @@ exec_out: struct sqlite3_api_routines { void * (*aggregate_context)(sqlite3_context*,int nBytes); int (*aggregate_count)(sqlite3_context*); @@ -18261,7 +26805,7 @@ int (*bind_double)(sqlite3_stmt*,int,double); int (*bind_int)(sqlite3_stmt*,int,int); int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); -@@ -105034,7 +105543,7 @@ struct sqlite3_api_routines { +@@ -111039,20 +111670,20 @@ struct sqlite3_api_routines { int (*bind_parameter_count)(sqlite3_stmt*); int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); const char * (*bind_parameter_name)(sqlite3_stmt*,int); @@ -18270,7 +26814,12 @@ int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); -@@ -105046,8 +105555,8 @@ struct sqlite3_api_routines { + int (*busy_timeout)(sqlite3*,int ms); +- int (*changes)(sqlite3*); ++ sqlite_uint64 (*changes)(sqlite3*); + int (*close)(sqlite3*); + int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, + int eTextRep,const char*)); int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, int eTextRep,const void*)); const void * (*column_blob)(sqlite3_stmt*,int iCol); @@ -18281,7 +26830,7 @@ int (*column_count)(sqlite3_stmt*pStmt); const char * (*column_database_name)(sqlite3_stmt*,int); const void * (*column_database_name16)(sqlite3_stmt*,int); -@@ -105112,7 +105621,7 @@ struct sqlite3_api_routines { +@@ -111117,7 +111748,7 @@ struct sqlite3_api_routines { void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); void *(*realloc)(void*,int); int (*reset)(sqlite3_stmt*pStmt); @@ -18290,7 +26839,15 @@ void (*result_double)(sqlite3_context*,double); void (*result_error)(sqlite3_context*,const char*,int); void (*result_error16)(sqlite3_context*,const void*,int); -@@ -105140,8 +105649,8 @@ struct sqlite3_api_routines { +@@ -111138,15 +111769,15 @@ struct sqlite3_api_routines { + int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, + char const**,char const**,int*,int*,int*); + void (*thread_cleanup)(void); +- int (*total_changes)(sqlite3*); ++ sqlite_uint64 (*total_changes)(sqlite3*); + void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); + int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); + void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, sqlite_int64),void*); void * (*user_data)(sqlite3_context*); const void * (*value_blob)(sqlite3_value*); @@ -18301,7 +26858,7 @@ double (*value_double)(sqlite3_value*); int (*value_int)(sqlite3_value*); sqlite_int64 (*value_int64)(sqlite3_value*); -@@ -105286,10 +105795,9 @@ struct sqlite3_api_routines { +@@ -111308,10 +111939,9 @@ typedef int (*sqlite3_loadext_entry)( */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) #define sqlite3_aggregate_context sqlite3_api->aggregate_context @@ -18314,7 +26871,7 @@ #define sqlite3_bind_double sqlite3_api->bind_double #define sqlite3_bind_int sqlite3_api->bind_int #define sqlite3_bind_int64 sqlite3_api->bind_int64 -@@ -105297,8 +105805,12 @@ struct sqlite3_api_routines { +@@ -111319,12 +111949,19 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name @@ -18327,7 +26884,15 @@ #define sqlite3_bind_value sqlite3_api->bind_value #define sqlite3_busy_handler sqlite3_api->busy_handler #define sqlite3_busy_timeout sqlite3_api->busy_timeout -@@ -105330,11 +105842,14 @@ struct sqlite3_api_routines { +-#define sqlite3_changes sqlite3_api->changes ++#undef sqlite3_changes ++#define sqlite3_changes (int)sqlite3_api->changes ++#undef sqlite3_changes64 ++#define sqlite3_changes64 sqlite3_api->changes + #define sqlite3_close sqlite3_api->close + #define sqlite3_collation_needed sqlite3_api->collation_needed + #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 +@@ -111352,11 +111989,14 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_commit_hook sqlite3_api->commit_hook #define sqlite3_complete sqlite3_api->complete #define sqlite3_complete16 sqlite3_api->complete16 @@ -18345,7 +26910,7 @@ #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 #define sqlite3_data_count sqlite3_api->data_count #define sqlite3_db_handle sqlite3_api->db_handle -@@ -105344,23 +105859,19 @@ struct sqlite3_api_routines { +@@ -111366,23 +112006,19 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_errmsg sqlite3_api->errmsg #define sqlite3_errmsg16 sqlite3_api->errmsg16 #define sqlite3_exec sqlite3_api->exec @@ -18371,7 +26936,7 @@ #define sqlite3_mprintf sqlite3_api->mprintf #define sqlite3_open sqlite3_api->open #define sqlite3_open16 sqlite3_api->open16 -@@ -105370,19 +105881,31 @@ struct sqlite3_api_routines { +@@ -111392,19 +112028,31 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 #define sqlite3_profile sqlite3_api->profile #define sqlite3_progress_handler sqlite3_api->progress_handler @@ -18403,12 +26968,16 @@ #define sqlite3_result_value sqlite3_api->result_value #define sqlite3_rollback_hook sqlite3_api->rollback_hook #define sqlite3_set_authorizer sqlite3_api->set_authorizer -@@ -105390,12 +105913,8 @@ struct sqlite3_api_routines { +@@ -111412,12 +112060,11 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_snprintf sqlite3_api->snprintf #define sqlite3_step sqlite3_api->step #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata -#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup - #define sqlite3_total_changes sqlite3_api->total_changes +-#define sqlite3_total_changes sqlite3_api->total_changes ++#undef sqlite3_total_changes ++#define sqlite3_total_changes (int)sqlite3_api->total_changes ++#undef sqlite3_total_changes64 ++#define sqlite3_total_changes64 sqlite3_api->total_changes #define sqlite3_trace sqlite3_api->trace -#ifndef SQLITE_OMIT_DEPRECATED -#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings @@ -18416,7 +26985,7 @@ #define sqlite3_update_hook sqlite3_api->update_hook #define sqlite3_user_data sqlite3_api->user_data #define sqlite3_value_blob sqlite3_api->value_blob -@@ -105436,12 +105955,13 @@ struct sqlite3_api_routines { +@@ -111458,12 +112105,13 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig #define sqlite3_sleep sqlite3_api->sleep @@ -18431,7 +27000,7 @@ #define sqlite3_result_error_code sqlite3_api->result_error_code #define sqlite3_test_control sqlite3_api->test_control #define sqlite3_randomness sqlite3_api->randomness -@@ -105470,7 +105990,8 @@ struct sqlite3_api_routines { +@@ -111492,7 +112140,8 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_strnicmp sqlite3_api->strnicmp #define sqlite3_unlock_notify sqlite3_api->unlock_notify #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint @@ -18441,16 +27010,16 @@ #define sqlite3_wal_hook sqlite3_api->wal_hook #define sqlite3_blob_reopen sqlite3_api->blob_reopen #define sqlite3_vtab_config sqlite3_api->vtab_config -@@ -105538,7 +106059,7 @@ struct sqlite3_api_routines { +@@ -111566,7 +112215,7 @@ typedef int (*sqlite3_loadext_entry)( + /************** Continuing where we left off in loadext.c ********************/ /* #include "sqliteInt.h" */ - /* #include */ -#ifndef SQLITE_OMIT_LOAD_EXTENSION +#if !defined(SQLITE_OMIT_LOAD_EXTENSION) || !defined(SQLITE_OMIT_AUTOINIT) - /* ** Some API routines are omitted when various features are -@@ -105629,6 +106150,11 @@ struct sqlite3_api_routines { + ** excluded from a build of SQLite. Substitute a NULL pointer +@@ -111656,6 +112305,11 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_blob_reopen 0 #endif @@ -18459,10 +27028,10 @@ +# define sqlite3_soft_heap_limit 0 +#endif + - /* - ** The following structure contains pointers to all SQLite API routines. - ** A pointer to this structure is passed into extensions when they are -@@ -105644,7 +106170,8 @@ struct sqlite3_api_routines { + #if defined(SQLITE_OMIT_TRACE) + # define sqlite3_trace_v2 0 + #endif +@@ -111675,7 +112329,8 @@ typedef int (*sqlite3_loadext_entry)( ** also check to make sure that the pointer to the function is ** not NULL before calling it. */ @@ -18472,7 +27041,7 @@ sqlite3_aggregate_context, #ifndef SQLITE_OMIT_DEPRECATED sqlite3_aggregate_count, -@@ -105721,7 +106248,11 @@ static const sqlite3_api_routines sqlite +@@ -111752,7 +112407,11 @@ static const sqlite3_api_routines sqlite sqlite3_last_insert_rowid, sqlite3_libversion, sqlite3_libversion_number, @@ -18484,7 +27053,7 @@ sqlite3_mprintf, sqlite3_open, sqlite3_open16, -@@ -105729,7 +106260,11 @@ static const sqlite3_api_routines sqlite +@@ -111760,7 +112419,11 @@ static const sqlite3_api_routines sqlite sqlite3_prepare16, sqlite3_profile, sqlite3_progress_handler, @@ -18496,19 +27065,20 @@ sqlite3_reset, sqlite3_result_blob, sqlite3_result_double, -@@ -105933,6 +106468,7 @@ static const sqlite3_api_routines sqlite - sqlite3_status64, - sqlite3_strlike, - sqlite3_db_cacheflush +@@ -111971,6 +112634,7 @@ static const sqlite3_api_routines sqlite + sqlite3_expanded_sql, + /* Version 3.18.0 and later */ + sqlite3_set_last_insert_rowid +},{0,0,0,0,0,0,0,0,0,0} }; /* -@@ -105961,18 +106497,17 @@ static int sqlite3LoadExtension( +@@ -111999,19 +112663,18 @@ static int sqlite3LoadExtension( char *zAltEntry = 0; void **aHandle; u64 nMsg = 300 + sqlite3Strlen30(zFile); - int ii; + int rc; /* Shared library endings to try if zFile cannot be loaded as written */ - static const char *azEndings[] = { @@ -18526,7 +27096,7 @@ if( pzErrMsg ) *pzErrMsg = 0; -@@ -105993,14 +106528,24 @@ static int sqlite3LoadExtension( +@@ -112033,17 +112696,27 @@ static int sqlite3LoadExtension( zEntry = zProc ? zProc : "sqlite3_extension_init"; handle = sqlite3OsDlOpen(pVfs, zFile); @@ -18535,7 +27105,7 @@ - char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]); + if( handle==0 ){ + char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEnding); - if( zAltFile==0 ) return SQLITE_NOMEM; + if( zAltFile==0 ) return SQLITE_NOMEM_BKPT; handle = sqlite3OsDlOpen(pVfs, zAltFile); sqlite3_free(zAltFile); - } @@ -18554,54 +27124,69 @@ + } if( handle==0 ){ if( pzErrMsg ){ - *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); -@@ -106193,7 +106738,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_au +- *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); ++ *pzErrMsg = zErrmsg = sqlite3Malloc(nMsg); + if( zErrmsg ){ + sqlite3_snprintf(nMsg, zErrmsg, + "unable to open shared library [%s]", zFile); +@@ -112068,7 +112741,7 @@ static int sqlite3LoadExtension( + if( xInit==0 && zProc==0 ){ + int iFile, iEntry, c; + int ncFile = sqlite3Strlen30(zFile); +- zAltEntry = sqlite3_malloc64(ncFile+30); ++ zAltEntry = sqlite3Malloc(ncFile+30); + if( zAltEntry==0 ){ + sqlite3OsDlClose(pVfs, handle); + return SQLITE_NOMEM_BKPT; +@@ -112089,7 +112762,7 @@ static int sqlite3LoadExtension( + if( xInit==0 ){ + if( pzErrMsg ){ + nMsg += sqlite3Strlen30(zEntry); +- *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); ++ *pzErrMsg = zErrmsg = sqlite3Malloc(nMsg); + if( zErrmsg ){ + sqlite3_snprintf(nMsg, zErrmsg, + "no entry point [%s] in shared library [%s]", zEntry, zFile); +@@ -112224,9 +112897,9 @@ SQLITE_API int sqlite3_auto_extension( if( wsdAutoext.aExt[i]==xInit ) break; } if( i==wsdAutoext.nExt ){ - u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); + size_t nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]); void (**aNew)(void); - aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte); +- aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte); ++ aNew = sqlite3Realloc(wsdAutoext.aExt, nByte); if( aNew==0 ){ -@@ -106463,7 +107008,7 @@ static const struct sPragmaNames { - /* ePragFlag: */ 0, - /* iArg: */ SQLITE_CountRows }, + rc = SQLITE_NOMEM_BKPT; + }else{ +@@ -112585,7 +113258,7 @@ static const PragmaName aPragmaName[] = + /* ColNames: */ 0, 0, + /* iArg: */ SQLITE_CountRows }, #endif -#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN +#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && defined(_WIN32) - { /* zName: */ "data_store_directory", - /* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY, - /* ePragFlag: */ 0, -@@ -106796,7 +107341,7 @@ static const struct sPragmaNames { - /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, + {/* zName: */ "data_store_directory", + /* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY, + /* ePragFlg: */ PragFlg_NoColumns1, +@@ -112985,7 +113658,7 @@ static const PragmaName aPragmaName[] = + /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, #endif }; --/* Number of pragmas: 60 on by default, 73 total. */ -+/* Number of pragmas: 59 on by default, 73 total. */ +-/* Number of pragmas: 60 on by default, 74 total. */ ++/* Number of pragmas: 59 on by default, 74 total. */ /************** End of pragma.h **********************************************/ /************** Continuing where we left off in pragma.c *********************/ -@@ -106936,7 +107481,7 @@ static int changeTempStorage(Parse *pPar - static void setAllColumnNames( - Vdbe *v, /* The query under construction */ - int N, /* Number of columns */ -- const char **azCol /* Names of columns */ -+ const char *const *azCol /* Names of columns */ - ){ - int i; - sqlite3VdbeSetNumCols(v, N); -@@ -106945,7 +107490,8 @@ static void setAllColumnNames( - } - } - static void setOneColumnName(Vdbe *v, const char *z){ -- setAllColumnNames(v, 1, &z); -+ sqlite3VdbeSetNumCols(v, 1); -+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, z, SQLITE_STATIC); - } - - /* -@@ -107662,7 +108208,7 @@ SQLITE_PRIVATE void sqlite3Pragma( +@@ -113217,7 +113890,7 @@ static const char *actionName(u8 action) + ** journal-mode name. + */ + SQLITE_PRIVATE const char *sqlite3JournalModename(int eMode){ +- static char * const azModeName[] = { ++ static const char * const azModeName[] = { + "delete", "persist", "off", "truncate", "memory" + #ifndef SQLITE_OMIT_WAL + , "wal" +@@ -113883,7 +114556,7 @@ SQLITE_PRIVATE void sqlite3Pragma( break; } @@ -18610,16 +27195,16 @@ /* ** PRAGMA data_store_directory ** PRAGMA data_store_directory = ""|"directory_name" -@@ -107715,7 +108261,7 @@ SQLITE_PRIVATE void sqlite3Pragma( +@@ -113936,7 +114609,7 @@ SQLITE_PRIVATE void sqlite3Pragma( Pager *pPager = sqlite3BtreePager(pDb->pBt); char *proxy_file_path = NULL; sqlite3_file *pFile = sqlite3PagerFile(pPager); - sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, + sqlite3OsFileControlHint(pFile, SQLITE_FCNTL_GET_LOCKPROXYFILE, &proxy_file_path); - returnSingleText(v, "lock_proxy_file", proxy_file_path); + returnSingleText(v, proxy_file_path); }else{ -@@ -107723,10 +108269,10 @@ SQLITE_PRIVATE void sqlite3Pragma( +@@ -113944,10 +114617,10 @@ SQLITE_PRIVATE void sqlite3Pragma( sqlite3_file *pFile = sqlite3PagerFile(pPager); int res; if( zRight[0] ){ @@ -18632,106 +27217,76 @@ NULL); } if( res!=SQLITE_OK ){ -@@ -107818,7 +108364,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - Table *pTab; - pTab = sqlite3FindTable(db, zRight, zDb); - if( pTab ){ -- static const char *azCol[] = { -+ static const char *const azCol[] = { - "cid", "name", "type", "notnull", "dflt_value", "pk" - }; - int i, k; -@@ -107855,7 +108401,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - break; - - case PragTyp_STATS: { -- static const char *azCol[] = { "table", "index", "width", "height" }; -+ static const char *const azCol[] = { "table", "index", "width", "height" }; - Index *pIdx; - HashElem *i; - v = sqlite3GetVdbe(pParse); -@@ -107886,7 +108432,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - Table *pTab; - pIdx = sqlite3FindIndex(db, zRight, zDb); - if( pIdx ){ -- static const char *azCol[] = { -+ static const char *const azCol[] = { - "seqno", "cid", "name", "desc", "coll", "key" - }; - int i; -@@ -107926,7 +108472,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - int i; - pTab = sqlite3FindTable(db, zRight, zDb); - if( pTab ){ -- static const char *azCol[] = { -+ static const char *const azCol[] = { - "seq", "name", "unique", "origin", "partial" - }; - v = sqlite3GetVdbe(pParse); -@@ -107948,7 +108494,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - break; - - case PragTyp_DATABASE_LIST: { -- static const char *azCol[] = { "seq", "name", "file" }; -+ static const char *const azCol[] = { "seq", "name", "file" }; - int i; - pParse->nMem = 3; - setAllColumnNames(v, 3, azCol); assert( 3==ArraySize(azCol) ); -@@ -107965,7 +108511,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - break; - - case PragTyp_COLLATION_LIST: { -- static const char *azCol[] = { "seq", "name" }; -+ static const char *const azCol[] = { "seq", "name" }; - int i = 0; - HashElem *p; - pParse->nMem = 2; -@@ -107988,7 +108534,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - v = sqlite3GetVdbe(pParse); - pFK = pTab->pFKey; - if( pFK ){ -- static const char *azCol[] = { -+ static const char *const azCol[] = { - "id", "seq", "table", "from", "to", "on_update", "on_delete", - "match" - }; -@@ -108036,7 +108582,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - int addrTop; /* Top of a loop checking foreign keys */ - int addrOk; /* Jump here if the key is OK */ - int *aiCols; /* child to parent column mapping */ -- static const char *azCol[] = { "table", "rowid", "parent", "fkid" }; -+ static const char *const azCol[] = { "table", "rowid", "parent", "fkid" }; - - regResult = pParse->nMem+1; - pParse->nMem += 4; -@@ -108545,7 +109091,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - ** Checkpoint the database. +@@ -114293,8 +114966,8 @@ SQLITE_PRIVATE void sqlite3Pragma( + int iKey = pFK->aCol[0].iFrom; + assert( iKey>=0 && iKeynCol ); + if( iKey!=pTab->iPKey ){ +- sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); +- sqlite3ColumnDefault(v, pTab, iKey, regRow); ++ sqlite3ExprCodeGetColumnOfTable( ++ v, pTab, 0, pFK->aCol[0].iFrom, regRow); + sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v); + }else{ + sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); +@@ -114315,7 +114988,11 @@ SQLITE_PRIVATE void sqlite3Pragma( + VdbeCoverage(v); + } + } +- sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); ++ if( HasRowid(pTab) ){ ++ sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); ++ }else{ ++ sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1); ++ } + sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1); + sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); + sqlite3VdbeResolveLabel(v, addrOk); +@@ -114600,7 +115277,7 @@ SQLITE_PRIVATE void sqlite3Pragma( + if( aOp ){ + aOp[0].p2 = 1-mxErr; + aOp[2].p4type = P4_STATIC; +- aOp[2].p4.z = "ok"; ++ aOp[2].p4.z = (char *)"ok"; + } + } + } +@@ -114632,7 +115309,7 @@ SQLITE_PRIVATE void sqlite3Pragma( */ - case PragTyp_WAL_CHECKPOINT: { -- static const char *azCol[] = { "busy", "log", "checkpointed" }; -+ static const char *const azCol[] = { "busy", "log", "checkpointed" }; - int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED); - int eMode = SQLITE_CHECKPOINT_PASSIVE; - if( zRight ){ -@@ -108661,7 +109207,7 @@ SQLITE_PRIVATE void sqlite3Pragma( - static const char *const azLockName[] = { - "unlocked", "shared", "reserved", "pending", "exclusive" - }; -- static const char *azCol[] = { "database", "status" }; -+ static const char *const azCol[] = { "database", "status" }; - int i; - setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) ); - pParse->nMem = 2; -@@ -110833,7 +111379,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 - -@@ -115330,7 +115876,7 @@ static int sqlite3_get_table_cb(void *pA + case PragTyp_ENCODING: { + static const struct EncName { +- char *zName; ++ const char *zName; + u8 enc; + } encnames[] = { + { "UTF8", SQLITE_UTF8 }, +@@ -117372,7 +118049,7 @@ static KeyInfo *keyInfoFromExprList( + ** Name of the connection operator, used for error messages. + */ + static const char *selectOpName(int id){ +- char *z; ++ const char *z; + switch( id ){ + case TK_ALL: z = "UNION ALL"; break; + case TK_INTERSECT: z = "INTERSECT"; break; +@@ -117839,7 +118516,7 @@ static void generateColumnNames( + sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); + }else if( p->op==TK_COLUMN || p->op==TK_AGG_COLUMN ){ + Table *pTab; +- char *zCol; ++ const char *zCol; + int iCol = p->iColumn; + for(j=0; ALWAYS(jnSrc); j++){ + if( pTabList->a[j].iCursor==p->iTable ) break; +@@ -117932,7 +118609,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExp + int iCol = pColExpr->iColumn; + pTab = pColExpr->pTab; + if( iCol<0 ) iCol = pTab->iPKey; +- zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid"; ++ zName = iCol>=0 ? pTab->aCol[iCol].zName : (char *)"rowid"; + }else if( pColExpr->op==TK_ID ){ + assert( !ExprHasProperty(pColExpr, EP_IntValue) ); + zName = pColExpr->u.zToken; +@@ -122037,7 +122714,7 @@ static int sqlite3_get_table_cb(void *pA if( p->nData + need > p->nAlloc ){ char **azNew; p->nAlloc = p->nAlloc*2 + need; @@ -18740,7 +27295,7 @@ if( azNew==0 ) goto malloc_failed; p->azResult = azNew; } -@@ -115362,7 +115908,7 @@ static int sqlite3_get_table_cb(void *pA +@@ -122069,7 +122746,7 @@ static int sqlite3_get_table_cb(void *pA z = 0; }else{ int n = sqlite3Strlen30(argv[i])+1; @@ -18749,7 +27304,7 @@ if( z==0 ) goto malloc_failed; memcpy(z, argv[i], n); } -@@ -115411,7 +115957,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_ge +@@ -122118,7 +122795,7 @@ SQLITE_API int sqlite3_get_table( res.nData = 1; res.nAlloc = 20; res.rc = SQLITE_OK; @@ -18757,8 +27312,8 @@ + res.azResult = sqlite3Malloc(sizeof(char*)*res.nAlloc ); if( res.azResult==0 ){ db->errCode = SQLITE_NOMEM; - return SQLITE_NOMEM; -@@ -115439,7 +115985,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_ge + return SQLITE_NOMEM_BKPT; +@@ -122146,7 +122823,7 @@ SQLITE_API int sqlite3_get_table( } if( res.nAlloc>res.nData ){ char **azNew; @@ -18767,7 +27322,7 @@ if( azNew==0 ){ sqlite3_free_table(&res.azResult[1]); db->errCode = SQLITE_NOMEM; -@@ -116222,7 +116768,7 @@ static int codeTriggerProgram( +@@ -122929,7 +123606,7 @@ static int codeTriggerProgram( return 0; } @@ -18776,24 +27331,71 @@ /* ** This function is used to add VdbeComment() annotations to a VDBE ** program. It is not used in production code, only for debugging. -@@ -117807,7 +118353,7 @@ static int createModule( - void (*xDestroy)(void *) /* Module destructor function */ - ){ - int rc = SQLITE_OK; -- int nName; -+ size_t nName; - - sqlite3_mutex_enter(db->mutex); - nName = sqlite3Strlen30(zName); -@@ -117844,6 +118390,7 @@ static int createModule( +@@ -124285,8 +124962,8 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char + Btree *pMain; /* The database being vacuumed */ + Btree *pTemp; /* The temporary database we vacuum into */ + int saved_flags; /* Saved value of the db->flags */ +- int saved_nChange; /* Saved value of db->nChange */ +- int saved_nTotalChange; /* Saved value of db->nTotalChange */ ++ u64 saved_nChange; /* Saved value of db->nChange */ ++ u64 saved_nTotalChange; /* Saved value of db->nTotalChange */ + u8 saved_mTrace; /* Saved trace settings */ + Db *pDb = 0; /* Database to detach at end of vacuum */ + int isMemDb; /* True if vacuuming a :memory: database */ +@@ -124618,6 +125295,7 @@ static int createModule( /* ** External API function used to create a new virtual-table module. */ +#undef sqlite3_create_module - SQLITE_API int SQLITE_STDCALL sqlite3_create_module( + SQLITE_API int sqlite3_create_module( sqlite3 *db, /* Database in which module is registered */ const char *zName, /* Name assigned to this module */ -@@ -124216,7 +124763,7 @@ static void whereLoopPrint(WhereLoop *p, +@@ -125057,7 +125735,7 @@ static int vtabCallConstructor( + pVTable->pMod = pMod; + + iDb = sqlite3SchemaToIndex(db, pTab->pSchema); +- pTab->azModuleArg[1] = db->aDb[iDb].zDbSName; ++ pTab->azModuleArg[1] = (char *)db->aDb[iDb].zDbSName; + + /* Invoke the virtual table constructor */ + assert( &db->pVtabCtx ); +@@ -125103,7 +125781,7 @@ static int vtabCallConstructor( + pTab->pVTable = pVTable; + + for(iCol=0; iColnCol; iCol++){ +- char *zType = sqlite3ColumnType(&pTab->aCol[iCol], ""); ++ char *zType = (char *) sqlite3ColumnType(&pTab->aCol[iCol], 0); + int nType; + int i = 0; + nType = sqlite3Strlen30(zType); +@@ -125633,7 +126311,7 @@ SQLITE_PRIVATE void sqlite3VtabMakeWrita + if( pTab==pToplevel->apVtabLock[i] ) return; + } + n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]); +- apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n); ++ apVtabLock = sqlite3Realloc(pToplevel->apVtabLock, n); + if( apVtabLock ){ + pToplevel->apVtabLock = apVtabLock; + pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab; +@@ -125920,7 +126598,7 @@ struct WhereLoop { + u8 needFree; /* True if sqlite3_free(idxStr) is needed */ + i8 isOrdered; /* True if satisfies ORDER BY */ + u16 omitMask; /* Terms that may be omitted */ +- char *idxStr; /* Index identifier string */ ++ const char *idxStr; /* Index identifier string */ + } vtab; + } u; + u32 wsFlags; /* WHERE_* flags describing the plan */ +@@ -130562,7 +131240,7 @@ static void constructAutomaticIndex( + pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed); + if( pIdx==0 ) goto end_auto_index_create; + pLoop->u.btree.pIndex = pIdx; +- pIdx->zName = "auto-index"; ++ pIdx->zName = (char *)"auto-index"; + pIdx->pTable = pTable; + n = 0; + idxCols = 0; +@@ -131564,7 +132242,7 @@ static void whereLoopPrint(WhereLoop *p, const char *zName; if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){ if( strncmp(zName, "sqlite_autoindex_", 17)==0 ){ @@ -18802,7 +27404,34 @@ while( zName[i]!='_' ) i--; zName += i; } -@@ -127236,7 +127783,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(Wher +@@ -131615,7 +132293,7 @@ static void whereLoopInit(WhereLoop *p){ + static void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){ + if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) ){ + if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){ +- sqlite3_free(p->u.vtab.idxStr); ++ sqlite3_free((char *)p->u.vtab.idxStr); + p->u.vtab.needFree = 0; + p->u.vtab.idxStr = 0; + }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){ +@@ -132939,7 +133617,7 @@ static int whereLoopAddVirtualOne( + } + rc = whereLoopInsert(pBuilder, pNew); + if( pNew->u.vtab.needFree ){ +- sqlite3_free(pNew->u.vtab.idxStr); ++ sqlite3_free((char *)pNew->u.vtab.idxStr); + pNew->u.vtab.needFree = 0; + } + WHERETRACE(0xffff, (" bIn=%d prereqIn=%04llx prereqOut=%04llx\n", +@@ -133086,7 +133764,7 @@ static int whereLoopAddVirtual( + } + } + +- if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); ++ if( p->needToFreeIdxStr ) sqlite3_free((char *)p->idxStr); + sqlite3DbFree(pParse->db, p); + return rc; + } +@@ -134885,7 +135563,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(Wher ** Alternative datatype for the argument to the malloc() routine passed ** into sqlite3ParserAlloc(). The default is size_t. */ @@ -18811,661 +27440,699 @@ /* ** An instance of this structure holds information about the -@@ -127485,16 +128032,16 @@ typedef union { +@@ -135143,16 +135821,16 @@ typedef union { #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse #define sqlite3ParserARG_STORE yypParser->pParse = pParse #define YYFALLBACK 1 --#define YYNSTATE 436 -+#define YYNSTATE 440 - #define YYNRULE 328 --#define YY_MAX_SHIFT 435 --#define YY_MIN_SHIFTREDUCE 649 --#define YY_MAX_SHIFTREDUCE 976 --#define YY_MIN_REDUCE 977 --#define YY_MAX_REDUCE 1304 --#define YY_ERROR_ACTION 1305 --#define YY_ACCEPT_ACTION 1306 --#define YY_NO_ACTION 1307 -+#define YY_MAX_SHIFT 439 -+#define YY_MIN_SHIFTREDUCE 653 -+#define YY_MAX_SHIFTREDUCE 980 -+#define YY_MIN_REDUCE 981 -+#define YY_MAX_REDUCE 1308 -+#define YY_ERROR_ACTION 1309 -+#define YY_ACCEPT_ACTION 1310 -+#define YY_NO_ACTION 1311 +-#define YYNSTATE 456 ++#define YYNSTATE 460 + #define YYNRULE 332 +-#define YY_MAX_SHIFT 455 +-#define YY_MIN_SHIFTREDUCE 668 +-#define YY_MAX_SHIFTREDUCE 999 +-#define YY_MIN_REDUCE 1000 +-#define YY_MAX_REDUCE 1331 +-#define YY_ERROR_ACTION 1332 +-#define YY_ACCEPT_ACTION 1333 +-#define YY_NO_ACTION 1334 ++#define YY_MAX_SHIFT 459 ++#define YY_MIN_SHIFTREDUCE 672 ++#define YY_MAX_SHIFTREDUCE 1003 ++#define YY_MIN_REDUCE 1004 ++#define YY_MAX_REDUCE 1335 ++#define YY_ERROR_ACTION 1336 ++#define YY_ACCEPT_ACTION 1337 ++#define YY_NO_ACTION 1338 /************* End control #defines *******************************************/ - /* The yyzerominor constant is used to initialize instances of -@@ -127566,159 +128113,159 @@ static const YYMINORTYPE yyzerominor = { + /* Define the yytestcase() macro to be a no-op if is not already defined +@@ -135224,165 +135902,165 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ --#define YY_ACTTAB_COUNT (1501) -+#define YY_ACTTAB_COUNT (1507) +-#define YY_ACTTAB_COUNT (1567) ++#define YY_ACTTAB_COUNT (1570) static const YYACTIONTYPE yy_action[] = { -- /* 0 */ 311, 1306, 145, 651, 2, 192, 652, 338, 780, 92, -+ /* 0 */ 315, 1310, 145, 655, 2, 192, 656, 342, 784, 92, - /* 10 */ 92, 92, 92, 85, 90, 90, 90, 90, 89, 89, -- /* 20 */ 88, 88, 88, 87, 335, 88, 88, 88, 87, 335, -- /* 30 */ 327, 856, 856, 92, 92, 92, 92, 697, 90, 90, -- /* 40 */ 90, 90, 89, 89, 88, 88, 88, 87, 335, 76, -- /* 50 */ 807, 74, 93, 94, 84, 868, 871, 860, 860, 91, -- /* 60 */ 91, 92, 92, 92, 92, 335, 90, 90, 90, 90, -- /* 70 */ 89, 89, 88, 88, 88, 87, 335, 311, 780, 90, -- /* 80 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 335, -- /* 90 */ 356, 808, 776, 701, 689, 689, 86, 83, 166, 257, -- /* 100 */ 809, 715, 430, 86, 83, 166, 324, 697, 856, 856, -- /* 110 */ 201, 158, 276, 387, 271, 386, 188, 689, 689, 828, -- /* 120 */ 86, 83, 166, 269, 833, 49, 123, 87, 335, 93, -- /* 130 */ 94, 84, 868, 871, 860, 860, 91, 91, 92, 92, -+ /* 20 */ 88, 88, 88, 87, 339, 88, 88, 88, 87, 339, -+ /* 30 */ 331, 860, 860, 92, 92, 92, 92, 701, 90, 90, -+ /* 40 */ 90, 90, 89, 89, 88, 88, 88, 87, 339, 76, -+ /* 50 */ 811, 74, 93, 94, 84, 872, 875, 864, 864, 91, -+ /* 60 */ 91, 92, 92, 92, 92, 339, 90, 90, 90, 90, -+ /* 70 */ 89, 89, 88, 88, 88, 87, 339, 315, 784, 90, -+ /* 80 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 339, -+ /* 90 */ 360, 812, 780, 705, 693, 693, 86, 83, 166, 261, -+ /* 100 */ 813, 719, 434, 86, 83, 166, 328, 701, 860, 860, -+ /* 110 */ 201, 158, 280, 391, 275, 390, 188, 693, 693, 832, -+ /* 120 */ 86, 83, 166, 273, 837, 49, 123, 87, 339, 93, -+ /* 130 */ 94, 84, 872, 875, 864, 864, 91, 91, 92, 92, - /* 140 */ 92, 92, 239, 90, 90, 90, 90, 89, 89, 88, -- /* 150 */ 88, 88, 87, 335, 311, 763, 333, 332, 216, 408, -- /* 160 */ 394, 69, 231, 393, 690, 691, 396, 910, 251, 354, -- /* 170 */ 250, 288, 315, 430, 908, 430, 909, 89, 89, 88, -- /* 180 */ 88, 88, 87, 335, 391, 856, 856, 690, 691, 183, -- /* 190 */ 95, 123, 384, 381, 380, 833, 31, 833, 49, 912, -- /* 200 */ 912, 751, 752, 379, 123, 311, 93, 94, 84, 868, -- /* 210 */ 871, 860, 860, 91, 91, 92, 92, 92, 92, 114, -+ /* 150 */ 88, 88, 87, 339, 315, 767, 337, 336, 216, 412, -+ /* 160 */ 398, 69, 231, 397, 694, 695, 400, 914, 255, 358, -+ /* 170 */ 254, 292, 319, 434, 912, 434, 913, 89, 89, 88, -+ /* 180 */ 88, 88, 87, 339, 395, 860, 860, 694, 695, 183, -+ /* 190 */ 95, 123, 388, 385, 384, 837, 31, 837, 49, 916, -+ /* 200 */ 916, 755, 756, 383, 123, 315, 93, 94, 84, 872, -+ /* 210 */ 875, 864, 864, 91, 91, 92, 92, 92, 92, 114, - /* 220 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87, -- /* 230 */ 335, 430, 408, 399, 435, 657, 856, 856, 346, 57, -- /* 240 */ 232, 828, 109, 704, 366, 689, 689, 363, 825, 760, -- /* 250 */ 97, 749, 752, 833, 49, 708, 708, 93, 94, 84, -- /* 260 */ 868, 871, 860, 860, 91, 91, 92, 92, 92, 92, -- /* 270 */ 423, 90, 90, 90, 90, 89, 89, 88, 88, 88, -- /* 280 */ 87, 335, 311, 114, 22, 361, 688, 58, 408, 390, -- /* 290 */ 251, 349, 240, 213, 762, 689, 689, 847, 685, 115, -- /* 300 */ 361, 231, 393, 689, 689, 396, 183, 689, 689, 384, -- /* 310 */ 381, 380, 361, 856, 856, 690, 691, 160, 159, 223, -- /* 320 */ 379, 738, 25, 806, 707, 841, 143, 689, 689, 835, -- /* 330 */ 392, 339, 766, 766, 93, 94, 84, 868, 871, 860, -- /* 340 */ 860, 91, 91, 92, 92, 92, 92, 914, 90, 90, -- /* 350 */ 90, 90, 89, 89, 88, 88, 88, 87, 335, 311, -- /* 360 */ 840, 840, 840, 266, 257, 690, 691, 778, 706, 86, -- /* 370 */ 83, 166, 219, 690, 691, 737, 1, 690, 691, 689, -- /* 380 */ 689, 689, 689, 430, 86, 83, 166, 249, 688, 937, -- /* 390 */ 856, 856, 427, 699, 700, 828, 298, 690, 691, 221, -- /* 400 */ 686, 115, 123, 944, 795, 833, 48, 342, 305, 970, -- /* 410 */ 847, 93, 94, 84, 868, 871, 860, 860, 91, 91, -+ /* 230 */ 339, 434, 412, 403, 439, 661, 860, 860, 350, 57, -+ /* 240 */ 232, 832, 109, 708, 370, 693, 693, 367, 829, 764, -+ /* 250 */ 97, 753, 756, 837, 49, 712, 712, 93, 94, 84, -+ /* 260 */ 872, 875, 864, 864, 91, 91, 92, 92, 92, 92, -+ /* 270 */ 427, 90, 90, 90, 90, 89, 89, 88, 88, 88, -+ /* 280 */ 87, 339, 315, 114, 22, 365, 692, 58, 412, 394, -+ /* 290 */ 255, 353, 242, 213, 766, 693, 693, 851, 689, 115, -+ /* 300 */ 365, 231, 397, 693, 693, 400, 183, 693, 693, 388, -+ /* 310 */ 385, 384, 365, 860, 860, 694, 695, 160, 159, 223, -+ /* 320 */ 383, 742, 25, 810, 711, 845, 143, 693, 693, 839, -+ /* 330 */ 396, 343, 770, 770, 93, 94, 84, 872, 875, 864, -+ /* 340 */ 864, 91, 91, 92, 92, 92, 92, 918, 90, 90, -+ /* 350 */ 90, 90, 89, 89, 88, 88, 88, 87, 339, 315, -+ /* 360 */ 844, 844, 844, 270, 261, 694, 695, 782, 710, 86, -+ /* 370 */ 83, 166, 219, 694, 695, 741, 1, 694, 695, 693, -+ /* 380 */ 693, 693, 693, 434, 86, 83, 166, 253, 692, 941, -+ /* 390 */ 860, 860, 431, 703, 704, 832, 302, 694, 695, 221, -+ /* 400 */ 690, 115, 123, 948, 799, 837, 48, 346, 309, 974, -+ /* 410 */ 851, 93, 94, 84, 872, 875, 864, 864, 91, 91, - /* 420 */ 92, 92, 92, 92, 114, 90, 90, 90, 90, 89, -- /* 430 */ 89, 88, 88, 88, 87, 335, 311, 940, 841, 679, -- /* 440 */ 713, 429, 835, 430, 251, 354, 250, 355, 288, 690, -- /* 450 */ 691, 690, 691, 285, 941, 340, 971, 287, 210, 23, -- /* 460 */ 174, 793, 832, 430, 353, 833, 10, 856, 856, 24, -- /* 470 */ 942, 151, 753, 840, 840, 840, 794, 968, 1290, 321, -- /* 480 */ 398, 1290, 356, 352, 754, 833, 49, 935, 93, 94, -- /* 490 */ 84, 868, 871, 860, 860, 91, 91, 92, 92, 92, -- /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88, -- /* 510 */ 88, 87, 335, 311, 376, 114, 907, 705, 430, 907, -- /* 520 */ 328, 890, 114, 833, 10, 966, 430, 857, 857, 320, -- /* 530 */ 189, 163, 832, 165, 430, 906, 344, 323, 906, 904, -- /* 540 */ 833, 10, 965, 306, 856, 856, 187, 419, 833, 10, -- /* 550 */ 220, 869, 872, 832, 222, 403, 833, 49, 1219, 793, -- /* 560 */ 68, 937, 406, 245, 66, 93, 94, 84, 868, 871, -- /* 570 */ 860, 860, 91, 91, 92, 92, 92, 92, 861, 90, -- /* 580 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 335, -- /* 590 */ 311, 404, 213, 762, 834, 345, 114, 940, 902, 368, -- /* 600 */ 727, 5, 316, 192, 396, 772, 780, 269, 230, 242, -- /* 610 */ 771, 244, 397, 164, 941, 385, 123, 347, 55, 355, -- /* 620 */ 329, 856, 856, 728, 333, 332, 688, 968, 1291, 724, -- /* 630 */ 942, 1291, 413, 214, 833, 9, 362, 286, 955, 115, -- /* 640 */ 718, 311, 93, 94, 84, 868, 871, 860, 860, 91, -- /* 650 */ 91, 92, 92, 92, 92, 430, 90, 90, 90, 90, -- /* 660 */ 89, 89, 88, 88, 88, 87, 335, 912, 912, 1300, -- /* 670 */ 1300, 758, 856, 856, 325, 966, 780, 833, 35, 747, -- /* 680 */ 720, 334, 699, 700, 977, 652, 338, 243, 745, 920, -- /* 690 */ 920, 369, 187, 93, 94, 84, 868, 871, 860, 860, -+ /* 430 */ 89, 88, 88, 88, 87, 339, 315, 944, 845, 683, -+ /* 440 */ 717, 433, 839, 434, 255, 358, 254, 359, 292, 694, -+ /* 450 */ 695, 694, 695, 289, 945, 344, 975, 291, 210, 23, -+ /* 460 */ 174, 797, 836, 434, 357, 837, 10, 860, 860, 24, -+ /* 470 */ 946, 151, 757, 844, 844, 844, 798, 972, 1294, 325, -+ /* 480 */ 402, 1294, 360, 356, 758, 837, 49, 939, 93, 94, -+ /* 490 */ 84, 872, 875, 864, 864, 91, 91, 92, 92, 92, -+ /* 500 */ 92, 434, 90, 90, 90, 90, 89, 89, 88, 88, -+ /* 510 */ 88, 87, 339, 315, 380, 114, 911, 709, 434, 911, -+ /* 520 */ 332, 894, 114, 837, 10, 970, 434, 861, 861, 324, -+ /* 530 */ 189, 163, 836, 165, 434, 910, 348, 327, 910, 908, -+ /* 540 */ 837, 10, 969, 310, 860, 860, 187, 423, 837, 10, -+ /* 550 */ 220, 873, 876, 836, 222, 407, 837, 49, 1223, 797, -+ /* 560 */ 68, 941, 410, 249, 66, 93, 94, 84, 872, 875, -+ /* 570 */ 864, 864, 91, 91, 92, 92, 92, 92, 865, 90, -+ /* 580 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 339, -+ /* 590 */ 315, 408, 213, 766, 838, 349, 114, 944, 906, 372, -+ /* 600 */ 731, 5, 320, 192, 400, 776, 784, 273, 230, 246, -+ /* 610 */ 775, 248, 401, 164, 945, 389, 123, 351, 55, 359, -+ /* 620 */ 333, 860, 860, 732, 337, 336, 692, 972, 1295, 728, -+ /* 630 */ 946, 1295, 417, 214, 837, 9, 366, 290, 959, 115, -+ /* 640 */ 722, 315, 93, 94, 84, 872, 875, 864, 864, 91, -+ /* 650 */ 91, 92, 92, 92, 92, 434, 90, 90, 90, 90, -+ /* 660 */ 89, 89, 88, 88, 88, 87, 339, 916, 916, 1304, -+ /* 670 */ 1304, 762, 860, 860, 329, 970, 784, 837, 35, 751, -+ /* 680 */ 724, 338, 703, 704, 981, 656, 342, 247, 749, 924, -+ /* 690 */ 924, 373, 187, 93, 94, 84, 872, 875, 864, 864, - /* 700 */ 91, 91, 92, 92, 92, 92, 114, 90, 90, 90, -- /* 710 */ 90, 89, 89, 88, 88, 88, 87, 335, 311, 430, -- /* 720 */ 954, 430, 112, 310, 430, 693, 317, 698, 400, 430, -- /* 730 */ 793, 359, 430, 1017, 430, 192, 430, 401, 780, 430, -- /* 740 */ 360, 833, 36, 833, 12, 430, 833, 27, 316, 856, -- /* 750 */ 856, 833, 37, 20, 833, 38, 833, 39, 833, 28, -- /* 760 */ 72, 833, 29, 663, 664, 665, 264, 833, 40, 234, -- /* 770 */ 93, 94, 84, 868, 871, 860, 860, 91, 91, 92, -- /* 780 */ 92, 92, 92, 430, 90, 90, 90, 90, 89, 89, -- /* 790 */ 88, 88, 88, 87, 335, 311, 430, 698, 430, 917, -- /* 800 */ 147, 430, 165, 916, 275, 833, 41, 430, 780, 430, -- /* 810 */ 21, 430, 259, 430, 262, 274, 430, 367, 833, 42, -- /* 820 */ 833, 11, 430, 833, 43, 235, 856, 856, 793, 833, -- /* 830 */ 99, 833, 44, 833, 45, 833, 32, 75, 833, 46, -- /* 840 */ 305, 967, 257, 257, 833, 47, 311, 93, 94, 84, -- /* 850 */ 868, 871, 860, 860, 91, 91, 92, 92, 92, 92, -- /* 860 */ 430, 90, 90, 90, 90, 89, 89, 88, 88, 88, -- /* 870 */ 87, 335, 430, 186, 185, 184, 238, 856, 856, 650, -- /* 880 */ 2, 1064, 833, 33, 739, 217, 218, 257, 971, 257, -- /* 890 */ 426, 317, 257, 774, 833, 117, 257, 311, 93, 94, -- /* 900 */ 84, 868, 871, 860, 860, 91, 91, 92, 92, 92, -- /* 910 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88, -- /* 920 */ 88, 87, 335, 430, 318, 124, 212, 163, 856, 856, -- /* 930 */ 943, 900, 898, 833, 118, 759, 726, 725, 257, 755, -- /* 940 */ 289, 289, 733, 734, 961, 833, 119, 682, 311, 93, -- /* 950 */ 82, 84, 868, 871, 860, 860, 91, 91, 92, 92, -- /* 960 */ 92, 92, 430, 90, 90, 90, 90, 89, 89, 88, -- /* 970 */ 88, 88, 87, 335, 430, 716, 246, 322, 331, 856, -- /* 980 */ 856, 256, 114, 357, 833, 53, 808, 913, 913, 932, -- /* 990 */ 156, 416, 420, 424, 930, 809, 833, 34, 364, 311, -- /* 1000 */ 253, 94, 84, 868, 871, 860, 860, 91, 91, 92, -- /* 1010 */ 92, 92, 92, 430, 90, 90, 90, 90, 89, 89, -- /* 1020 */ 88, 88, 88, 87, 335, 430, 114, 114, 114, 960, -- /* 1030 */ 856, 856, 307, 258, 830, 833, 100, 191, 252, 377, -- /* 1040 */ 267, 68, 197, 68, 261, 716, 769, 833, 50, 71, -- /* 1050 */ 911, 911, 263, 84, 868, 871, 860, 860, 91, 91, -- /* 1060 */ 92, 92, 92, 92, 430, 90, 90, 90, 90, 89, -- /* 1070 */ 89, 88, 88, 88, 87, 335, 80, 425, 802, 3, -- /* 1080 */ 1214, 191, 430, 265, 336, 336, 833, 101, 741, 80, -- /* 1090 */ 425, 897, 3, 723, 722, 428, 721, 336, 336, 430, -- /* 1100 */ 893, 270, 430, 197, 833, 102, 430, 800, 428, 430, -- /* 1110 */ 695, 430, 843, 111, 414, 430, 784, 409, 430, 831, -- /* 1120 */ 430, 833, 98, 123, 833, 116, 847, 414, 833, 49, -- /* 1130 */ 779, 833, 113, 833, 106, 226, 123, 833, 105, 847, -- /* 1140 */ 833, 103, 833, 104, 791, 411, 77, 78, 290, 412, -- /* 1150 */ 430, 291, 114, 79, 432, 431, 389, 430, 835, 77, -- /* 1160 */ 78, 897, 839, 408, 410, 430, 79, 432, 431, 372, -- /* 1170 */ 703, 835, 833, 52, 430, 80, 425, 430, 3, 833, -- /* 1180 */ 54, 772, 843, 336, 336, 684, 771, 833, 51, 840, -- /* 1190 */ 840, 840, 842, 19, 428, 672, 833, 26, 671, 833, -- /* 1200 */ 30, 673, 840, 840, 840, 842, 19, 207, 661, 278, -- /* 1210 */ 304, 148, 280, 414, 282, 248, 358, 822, 382, 6, -- /* 1220 */ 348, 161, 273, 80, 425, 847, 3, 934, 895, 720, -- /* 1230 */ 894, 336, 336, 296, 157, 415, 241, 284, 674, 958, -- /* 1240 */ 194, 953, 428, 951, 948, 77, 78, 777, 319, 56, -- /* 1250 */ 59, 135, 79, 432, 431, 121, 66, 835, 146, 128, -- /* 1260 */ 350, 414, 819, 130, 351, 131, 132, 133, 375, 173, -- /* 1270 */ 107, 138, 149, 847, 365, 178, 62, 70, 425, 936, -- /* 1280 */ 3, 827, 889, 371, 255, 336, 336, 792, 840, 840, -- /* 1290 */ 840, 842, 19, 77, 78, 915, 428, 208, 179, 144, -- /* 1300 */ 79, 432, 431, 373, 260, 835, 180, 326, 675, 181, -- /* 1310 */ 308, 744, 388, 743, 731, 414, 718, 742, 730, 712, -- /* 1320 */ 402, 309, 711, 272, 788, 65, 710, 847, 709, 277, -- /* 1330 */ 193, 789, 787, 279, 876, 73, 840, 840, 840, 842, -- /* 1340 */ 19, 786, 281, 418, 283, 422, 227, 77, 78, 330, -- /* 1350 */ 228, 229, 96, 767, 79, 432, 431, 407, 67, 835, -- /* 1360 */ 215, 292, 293, 405, 294, 303, 302, 301, 204, 299, -- /* 1370 */ 295, 202, 676, 681, 7, 433, 669, 203, 205, 206, -- /* 1380 */ 125, 110, 313, 434, 667, 666, 658, 168, 224, 237, -- /* 1390 */ 840, 840, 840, 842, 19, 120, 656, 337, 236, 155, -- /* 1400 */ 167, 341, 233, 314, 108, 905, 903, 826, 127, 126, -- /* 1410 */ 756, 170, 129, 172, 247, 928, 134, 136, 171, 60, -- /* 1420 */ 61, 123, 169, 137, 933, 175, 176, 927, 8, 13, -- /* 1430 */ 177, 254, 918, 139, 191, 924, 140, 370, 678, 150, -- /* 1440 */ 374, 182, 274, 268, 141, 122, 63, 14, 378, 15, -- /* 1450 */ 383, 64, 225, 846, 845, 874, 16, 4, 729, 765, -- /* 1460 */ 770, 162, 395, 209, 211, 142, 801, 878, 796, 312, -- /* 1470 */ 71, 68, 875, 873, 939, 190, 417, 938, 17, 195, -- /* 1480 */ 196, 152, 18, 975, 199, 976, 153, 198, 154, 421, -- /* 1490 */ 877, 844, 696, 81, 200, 297, 343, 1019, 1018, 300, -- /* 1500 */ 653, -+ /* 710 */ 90, 89, 89, 88, 88, 88, 87, 339, 315, 434, -+ /* 720 */ 958, 434, 112, 314, 434, 697, 321, 702, 404, 434, -+ /* 730 */ 797, 363, 434, 1021, 434, 192, 434, 405, 784, 434, -+ /* 740 */ 364, 837, 36, 837, 12, 434, 837, 27, 320, 860, -+ /* 750 */ 860, 837, 37, 20, 837, 38, 837, 39, 837, 28, -+ /* 760 */ 72, 837, 29, 667, 668, 669, 268, 837, 40, 234, -+ /* 770 */ 93, 94, 84, 872, 875, 864, 864, 91, 91, 92, -+ /* 780 */ 92, 92, 92, 434, 90, 90, 90, 90, 89, 89, -+ /* 790 */ 88, 88, 88, 87, 339, 315, 434, 702, 434, 921, -+ /* 800 */ 147, 434, 165, 920, 279, 837, 41, 434, 784, 434, -+ /* 810 */ 21, 434, 263, 434, 266, 278, 434, 371, 837, 42, -+ /* 820 */ 837, 11, 434, 837, 43, 235, 860, 860, 797, 837, -+ /* 830 */ 99, 837, 44, 837, 45, 837, 32, 75, 837, 46, -+ /* 840 */ 309, 971, 261, 261, 837, 47, 315, 93, 94, 84, -+ /* 850 */ 872, 875, 864, 864, 91, 91, 92, 92, 92, 92, -+ /* 860 */ 434, 90, 90, 90, 90, 89, 89, 88, 88, 88, -+ /* 870 */ 87, 339, 434, 186, 185, 184, 238, 860, 860, 654, -+ /* 880 */ 2, 1068, 837, 33, 743, 217, 218, 261, 975, 261, -+ /* 890 */ 430, 321, 261, 778, 837, 117, 261, 315, 93, 94, -+ /* 900 */ 84, 872, 875, 864, 864, 91, 91, 92, 92, 92, -+ /* 910 */ 92, 434, 90, 90, 90, 90, 89, 89, 88, 88, -+ /* 920 */ 88, 87, 339, 434, 322, 124, 212, 163, 860, 860, -+ /* 930 */ 947, 904, 902, 837, 118, 763, 730, 729, 261, 759, -+ /* 940 */ 293, 293, 737, 738, 965, 837, 119, 686, 315, 93, -+ /* 950 */ 82, 84, 872, 875, 864, 864, 91, 91, 92, 92, -+ /* 960 */ 92, 92, 434, 90, 90, 90, 90, 89, 89, 88, -+ /* 970 */ 88, 88, 87, 339, 434, 720, 250, 326, 335, 860, -+ /* 980 */ 860, 260, 114, 361, 837, 53, 812, 917, 917, 936, -+ /* 990 */ 156, 420, 424, 428, 934, 813, 837, 34, 368, 315, -+ /* 1000 */ 257, 94, 84, 872, 875, 864, 864, 91, 91, 92, -+ /* 1010 */ 92, 92, 92, 434, 90, 90, 90, 90, 89, 89, -+ /* 1020 */ 88, 88, 88, 87, 339, 434, 114, 114, 114, 964, -+ /* 1030 */ 860, 860, 311, 262, 834, 837, 100, 191, 256, 381, -+ /* 1040 */ 271, 68, 197, 68, 265, 720, 773, 837, 50, 71, -+ /* 1050 */ 915, 915, 267, 84, 872, 875, 864, 864, 91, 91, -+ /* 1060 */ 92, 92, 92, 92, 434, 90, 90, 90, 90, 89, -+ /* 1070 */ 89, 88, 88, 88, 87, 339, 80, 429, 806, 3, -+ /* 1080 */ 1218, 191, 434, 269, 340, 340, 837, 101, 745, 80, -+ /* 1090 */ 429, 901, 3, 727, 726, 432, 725, 340, 340, 434, -+ /* 1100 */ 897, 274, 434, 197, 837, 102, 434, 804, 432, 434, -+ /* 1110 */ 699, 434, 847, 111, 418, 434, 788, 413, 434, 835, -+ /* 1120 */ 434, 837, 98, 123, 837, 116, 851, 418, 837, 49, -+ /* 1130 */ 783, 837, 113, 837, 106, 226, 123, 837, 105, 851, -+ /* 1140 */ 837, 103, 837, 104, 795, 415, 77, 78, 294, 416, -+ /* 1150 */ 434, 295, 114, 79, 436, 435, 393, 434, 839, 77, -+ /* 1160 */ 78, 901, 843, 412, 414, 434, 79, 436, 435, 376, -+ /* 1170 */ 707, 839, 837, 52, 434, 80, 429, 434, 3, 837, -+ /* 1180 */ 54, 776, 847, 340, 340, 688, 775, 837, 51, 844, -+ /* 1190 */ 844, 844, 846, 19, 432, 676, 837, 26, 675, 837, -+ /* 1200 */ 30, 677, 844, 844, 844, 846, 19, 207, 665, 282, -+ /* 1210 */ 308, 148, 284, 418, 286, 252, 362, 241, 386, 6, -+ /* 1220 */ 352, 161, 277, 80, 429, 851, 3, 938, 899, 724, -+ /* 1230 */ 898, 340, 340, 300, 157, 419, 245, 288, 678, 962, -+ /* 1240 */ 194, 957, 432, 955, 952, 77, 78, 781, 323, 56, -+ /* 1250 */ 59, 135, 79, 436, 435, 96, 411, 839, 146, 826, -+ /* 1260 */ 240, 418, 121, 128, 66, 823, 244, 243, 354, 130, -+ /* 1270 */ 107, 355, 131, 851, 132, 133, 940, 70, 429, 379, -+ /* 1280 */ 3, 173, 138, 831, 149, 340, 340, 369, 844, 844, -+ /* 1290 */ 844, 846, 19, 77, 78, 178, 432, 893, 62, 375, -+ /* 1300 */ 79, 436, 435, 919, 259, 839, 796, 208, 179, 144, -+ /* 1310 */ 377, 264, 180, 392, 679, 418, 181, 312, 748, 747, -+ /* 1320 */ 746, 330, 716, 735, 313, 722, 406, 851, 792, 715, -+ /* 1330 */ 65, 281, 283, 276, 793, 791, 844, 844, 844, 846, -+ /* 1340 */ 19, 714, 713, 734, 285, 193, 287, 77, 78, 880, -+ /* 1350 */ 790, 73, 227, 422, 79, 436, 435, 334, 426, 839, -+ /* 1360 */ 215, 67, 409, 228, 298, 307, 306, 305, 204, 303, -+ /* 1370 */ 229, 771, 680, 296, 297, 299, 202, 685, 7, 437, -+ /* 1380 */ 673, 203, 206, 205, 660, 438, 317, 168, 671, 237, -+ /* 1390 */ 844, 844, 844, 846, 19, 670, 662, 110, 236, 318, -+ /* 1400 */ 125, 224, 341, 120, 155, 233, 167, 345, 108, 909, -+ /* 1410 */ 907, 170, 830, 126, 127, 760, 129, 251, 171, 172, -+ /* 1420 */ 932, 123, 169, 134, 60, 61, 136, 137, 937, 175, -+ /* 1430 */ 176, 931, 8, 13, 177, 922, 258, 139, 191, 928, -+ /* 1440 */ 374, 140, 150, 682, 378, 278, 182, 382, 141, 122, -+ /* 1450 */ 63, 14, 733, 769, 272, 15, 387, 64, 225, 850, -+ /* 1460 */ 849, 878, 16, 882, 774, 4, 162, 209, 399, 316, -+ /* 1470 */ 211, 142, 800, 805, 71, 190, 68, 879, 877, 943, -+ /* 1480 */ 199, 942, 17, 195, 196, 421, 979, 18, 152, 153, -+ /* 1490 */ 198, 980, 154, 425, 881, 848, 347, 700, 81, 200, -+ /* 1500 */ 301, 1023, 304, 657, 983, 983, 1022, +- /* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100, +- /* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, +- /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95, +- /* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824, +- /* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856, +- /* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96, +- /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, +- /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976, +- /* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100, +- /* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, +- /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95, +- /* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325, +- /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90, +- /* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98, ++ /* 0 */ 329, 836, 355, 829, 5, 203, 203, 823, 99, 100, ++ /* 10 */ 90, 982, 982, 857, 860, 849, 849, 97, 97, 98, ++ /* 20 */ 98, 98, 98, 305, 96, 96, 96, 96, 95, 95, ++ /* 30 */ 94, 94, 94, 93, 355, 329, 980, 980, 828, 828, ++ /* 40 */ 830, 950, 358, 99, 100, 90, 982, 982, 857, 860, ++ /* 50 */ 849, 849, 97, 97, 98, 98, 98, 98, 342, 96, ++ /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 355, ++ /* 70 */ 95, 95, 94, 94, 94, 93, 355, 795, 980, 980, ++ /* 80 */ 329, 94, 94, 94, 93, 355, 796, 75, 99, 100, ++ /* 90 */ 90, 982, 982, 857, 860, 849, 849, 97, 97, 98, ++ /* 100 */ 98, 98, 98, 454, 96, 96, 96, 96, 95, 95, ++ /* 110 */ 94, 94, 94, 93, 355, 1337, 155, 155, 2, 329, ++ /* 120 */ 279, 146, 132, 52, 52, 93, 355, 99, 100, 90, ++ /* 130 */ 982, 982, 857, 860, 849, 849, 97, 97, 98, 98, + /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94, +- /* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413, +- /* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853, +- /* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60, ++ /* 150 */ 94, 94, 93, 355, 961, 961, 329, 272, 432, 417, ++ /* 160 */ 415, 61, 756, 756, 99, 100, 90, 982, 982, 857, ++ /* 170 */ 860, 849, 849, 97, 97, 98, 98, 98, 98, 60, + /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, +- /* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99, +- /* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, +- /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95, +- /* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698, +- /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853, +- /* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347, ++ /* 190 */ 355, 329, 274, 333, 277, 281, 962, 963, 250, 99, ++ /* 200 */ 100, 90, 982, 982, 857, 860, 849, 849, 97, 97, ++ /* 210 */ 98, 98, 98, 98, 305, 96, 96, 96, 96, 95, ++ /* 220 */ 95, 94, 94, 94, 93, 355, 329, 941, 1330, 702, ++ /* 230 */ 710, 1330, 242, 416, 99, 100, 90, 982, 982, 857, ++ /* 240 */ 860, 849, 849, 97, 97, 98, 98, 98, 98, 351, + /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, +- /* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99, +- /* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, +- /* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95, +- /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178, +- /* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853, +- /* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375, ++ /* 260 */ 355, 329, 941, 1331, 388, 703, 1331, 385, 383, 99, ++ /* 270 */ 100, 90, 982, 982, 857, 860, 849, 849, 97, 97, ++ /* 280 */ 98, 98, 98, 98, 705, 96, 96, 96, 96, 95, ++ /* 290 */ 95, 94, 94, 94, 93, 355, 329, 92, 89, 178, ++ /* 300 */ 837, 939, 377, 704, 99, 100, 90, 982, 982, 857, ++ /* 310 */ 860, 849, 849, 97, 97, 98, 98, 98, 98, 379, + /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, +- /* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99, +- /* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, ++ /* 330 */ 355, 329, 1279, 950, 358, 822, 939, 743, 743, 99, ++ /* 340 */ 100, 90, 982, 982, 857, 860, 849, 849, 97, 97, + /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95, +- /* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92, +- /* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853, +- /* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920, ++ /* 360 */ 95, 94, 94, 94, 93, 355, 329, 972, 227, 92, ++ /* 370 */ 89, 178, 377, 304, 99, 100, 90, 982, 982, 857, ++ /* 380 */ 860, 849, 849, 97, 97, 98, 98, 98, 98, 924, + /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, +- /* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99, +- /* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, +- /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95, +- /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957, +- /* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853, +- /* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450, ++ /* 400 */ 355, 329, 453, 451, 451, 451, 147, 741, 741, 99, ++ /* 410 */ 100, 90, 982, 982, 857, 860, 849, 849, 97, 97, ++ /* 420 */ 98, 98, 98, 98, 300, 96, 96, 96, 96, 95, ++ /* 430 */ 95, 94, 94, 94, 93, 355, 329, 423, 231, 961, ++ /* 440 */ 961, 158, 25, 426, 99, 100, 90, 982, 982, 857, ++ /* 450 */ 860, 849, 849, 97, 97, 98, 98, 98, 98, 454, + /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, +- /* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52, +- /* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978, +- /* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, +- /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94, +- /* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961, +- /* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845, +- /* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96, +- /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842, +- /* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978, +- /* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, +- /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94, +- /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340, +- /* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845, +- /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96, +- /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445, +- /* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957, +- /* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282, +- /* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245, +- /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83, +- /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246, +- /* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243, +- /* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224, +- /* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427, +- /* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452, +- /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270, +- /* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429, +- /* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52, +- /* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229, +- /* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85, +- /* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355, +- /* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86, +- /* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96, +- /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, +- /* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976, +- /* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789, +- /* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261, +- /* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826, +- /* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95, +- /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957, +- /* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2, +- /* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708, +- /* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778, +- /* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450, +- /* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226, +- /* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10, +- /* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157, +- /* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434, +- /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959, +- /* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10, +- /* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171, +- /* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450, +- /* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824, +- /* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10, +- /* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198, +- /* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825, +- /* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91, ++ /* 470 */ 355, 447, 224, 224, 424, 961, 961, 965, 329, 52, ++ /* 480 */ 52, 962, 963, 176, 419, 78, 99, 100, 90, 982, ++ /* 490 */ 982, 857, 860, 849, 849, 97, 97, 98, 98, 98, ++ /* 500 */ 98, 383, 96, 96, 96, 96, 95, 95, 94, 94, ++ /* 510 */ 94, 93, 355, 329, 432, 422, 302, 962, 963, 965, ++ /* 520 */ 81, 99, 88, 90, 982, 982, 857, 860, 849, 849, ++ /* 530 */ 97, 97, 98, 98, 98, 98, 721, 96, 96, 96, ++ /* 540 */ 96, 95, 95, 94, 94, 94, 93, 355, 329, 846, ++ /* 550 */ 846, 858, 861, 1000, 322, 347, 383, 100, 90, 982, ++ /* 560 */ 982, 857, 860, 849, 849, 97, 97, 98, 98, 98, ++ /* 570 */ 98, 454, 96, 96, 96, 96, 95, 95, 94, 94, ++ /* 580 */ 94, 93, 355, 329, 354, 354, 354, 264, 381, 344, ++ /* 590 */ 932, 52, 52, 90, 982, 982, 857, 860, 849, 849, ++ /* 600 */ 97, 97, 98, 98, 98, 98, 365, 96, 96, 96, ++ /* 610 */ 96, 95, 95, 94, 94, 94, 93, 355, 86, 449, ++ /* 620 */ 850, 3, 1206, 365, 364, 382, 348, 817, 961, 961, ++ /* 630 */ 1303, 86, 449, 733, 3, 212, 169, 291, 409, 286, ++ /* 640 */ 408, 199, 232, 454, 304, 764, 83, 84, 284, 245, ++ /* 650 */ 266, 369, 253, 85, 356, 356, 92, 89, 178, 83, ++ /* 660 */ 84, 242, 416, 52, 52, 452, 85, 356, 356, 246, ++ /* 670 */ 962, 963, 194, 459, 674, 406, 403, 402, 452, 243, ++ /* 680 */ 221, 114, 438, 780, 365, 454, 401, 272, 751, 224, ++ /* 690 */ 224, 132, 132, 198, 836, 438, 456, 455, 432, 431, ++ /* 700 */ 823, 419, 738, 717, 132, 52, 52, 836, 272, 456, ++ /* 710 */ 455, 738, 194, 823, 367, 406, 403, 402, 454, 1274, ++ /* 720 */ 1274, 23, 961, 961, 86, 449, 401, 3, 228, 433, ++ /* 730 */ 898, 828, 828, 830, 831, 19, 203, 724, 52, 52, ++ /* 740 */ 432, 412, 443, 249, 828, 828, 830, 831, 19, 229, ++ /* 750 */ 407, 153, 83, 84, 765, 177, 241, 454, 725, 85, ++ /* 760 */ 356, 356, 120, 157, 962, 963, 58, 980, 413, 359, ++ /* 770 */ 334, 452, 272, 432, 434, 324, 794, 32, 32, 86, ++ /* 780 */ 449, 780, 3, 345, 98, 98, 98, 98, 438, 96, ++ /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 355, ++ /* 800 */ 836, 120, 456, 455, 817, 890, 823, 83, 84, 980, ++ /* 810 */ 817, 132, 414, 923, 85, 356, 356, 132, 411, 793, ++ /* 820 */ 961, 961, 92, 89, 178, 920, 452, 266, 374, 265, ++ /* 830 */ 82, 917, 80, 266, 374, 265, 780, 828, 828, 830, ++ /* 840 */ 831, 19, 937, 438, 96, 96, 96, 96, 95, 95, ++ /* 850 */ 94, 94, 94, 93, 355, 836, 74, 456, 455, 961, ++ /* 860 */ 961, 823, 962, 963, 120, 92, 89, 178, 948, 2, ++ /* 870 */ 921, 968, 272, 1, 979, 76, 449, 766, 3, 712, ++ /* 880 */ 904, 904, 391, 961, 961, 761, 922, 375, 744, 782, ++ /* 890 */ 760, 261, 828, 828, 830, 831, 19, 421, 745, 454, ++ /* 900 */ 24, 962, 963, 83, 84, 373, 961, 961, 177, 226, ++ /* 910 */ 85, 356, 356, 888, 319, 318, 317, 215, 315, 10, ++ /* 920 */ 10, 687, 452, 353, 352, 962, 963, 912, 781, 157, ++ /* 930 */ 120, 961, 961, 341, 780, 420, 715, 314, 454, 438, ++ /* 940 */ 454, 325, 454, 795, 103, 200, 175, 454, 962, 963, ++ /* 950 */ 911, 836, 796, 456, 455, 9, 9, 823, 10, 10, ++ /* 960 */ 52, 52, 51, 51, 180, 720, 248, 10, 10, 171, ++ /* 970 */ 170, 167, 343, 962, 963, 247, 988, 706, 706, 454, ++ /* 980 */ 719, 233, 690, 986, 892, 987, 182, 917, 828, 828, ++ /* 990 */ 830, 831, 19, 183, 260, 427, 132, 181, 398, 10, ++ /* 1000 */ 10, 892, 894, 753, 961, 961, 920, 272, 989, 198, ++ /* 1010 */ 989, 353, 352, 429, 419, 303, 821, 836, 330, 829, ++ /* 1020 */ 120, 336, 133, 823, 272, 98, 98, 98, 98, 91, + /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, +- /* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268, +- /* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450, +- /* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433, +- /* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12, +- /* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162, +- /* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450, +- /* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40, +- /* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28, +- /* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450, +- /* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767, +- /* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47, +- /* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172, +- /* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122, +- /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56, +- /* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817, +- /* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817, +- /* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119, +- /* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111, +- /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911, +- /* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331, +- /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197, +- /* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436, +- /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932, +- /* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202, +- /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883, +- /* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74, +- /* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892, +- /* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432, +- /* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289, +- /* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828, +- /* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435, +- /* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880, +- /* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72, +- /* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383, +- /* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266, +- /* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322, +- /* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421, +- /* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346, +- /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239, +- /* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213, +- /* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677, +- /* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166, +- /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891, +- /* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258, +- /* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187, +- /* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149, +- /* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396, +- /* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131, +- /* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220, +- /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874, +- /* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437, +- /* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829, +- /* 1560 */ 695, 87, 312, 211, 1291, 1290, 309, ++ /* 1040 */ 355, 157, 814, 375, 386, 363, 962, 963, 362, 272, ++ /* 1050 */ 454, 921, 372, 328, 828, 828, 830, 454, 713, 454, ++ /* 1060 */ 268, 384, 892, 454, 880, 750, 257, 922, 259, 437, ++ /* 1070 */ 36, 36, 234, 454, 234, 120, 273, 37, 37, 12, ++ /* 1080 */ 12, 338, 276, 27, 27, 454, 334, 118, 454, 162, ++ /* 1090 */ 746, 284, 454, 38, 38, 454, 989, 360, 989, 454, ++ /* 1100 */ 713, 1213, 454, 132, 454, 39, 39, 454, 40, 40, ++ /* 1110 */ 454, 366, 41, 41, 454, 42, 42, 454, 258, 28, ++ /* 1120 */ 28, 454, 29, 29, 31, 31, 454, 43, 43, 454, ++ /* 1130 */ 44, 44, 454, 718, 45, 45, 454, 11, 11, 771, ++ /* 1140 */ 454, 46, 46, 454, 272, 454, 105, 105, 454, 47, ++ /* 1150 */ 47, 454, 48, 48, 454, 237, 33, 33, 454, 172, ++ /* 1160 */ 49, 49, 454, 50, 50, 34, 34, 278, 122, 122, ++ /* 1170 */ 454, 123, 123, 454, 124, 124, 454, 901, 56, 56, ++ /* 1180 */ 454, 900, 35, 35, 454, 271, 454, 821, 454, 821, ++ /* 1190 */ 106, 106, 454, 53, 53, 389, 107, 107, 454, 821, ++ /* 1200 */ 108, 108, 821, 454, 104, 104, 121, 121, 119, 119, ++ /* 1210 */ 454, 117, 112, 112, 454, 280, 454, 225, 111, 111, ++ /* 1220 */ 454, 734, 454, 109, 109, 454, 677, 678, 679, 915, ++ /* 1230 */ 110, 110, 321, 1002, 55, 55, 57, 57, 696, 335, ++ /* 1240 */ 54, 54, 26, 26, 700, 30, 30, 321, 940, 197, ++ /* 1250 */ 196, 195, 339, 285, 340, 450, 335, 749, 693, 440, ++ /* 1260 */ 444, 448, 120, 72, 390, 223, 175, 349, 761, 936, ++ /* 1270 */ 20, 290, 323, 760, 819, 376, 378, 202, 202, 202, ++ /* 1280 */ 267, 399, 289, 74, 208, 21, 700, 723, 722, 887, ++ /* 1290 */ 120, 120, 120, 120, 120, 758, 282, 832, 77, 74, ++ /* 1300 */ 730, 731, 789, 787, 883, 202, 1003, 208, 897, 896, ++ /* 1310 */ 897, 896, 698, 820, 767, 116, 778, 1293, 435, 436, ++ /* 1320 */ 306, 1003, 394, 307, 827, 701, 695, 684, 159, 293, ++ /* 1330 */ 683, 887, 685, 955, 295, 218, 297, 7, 320, 832, ++ /* 1340 */ 173, 252, 263, 368, 256, 914, 380, 717, 299, 439, ++ /* 1350 */ 312, 168, 958, 997, 135, 404, 994, 288, 885, 884, ++ /* 1360 */ 205, 931, 929, 59, 337, 62, 144, 156, 102, 430, ++ /* 1370 */ 809, 72, 130, 251, 137, 370, 371, 397, 185, 160, ++ /* 1380 */ 387, 189, 67, 393, 139, 140, 141, 779, 142, 148, ++ /* 1390 */ 816, 806, 255, 899, 254, 270, 219, 154, 190, 916, ++ /* 1400 */ 879, 395, 410, 275, 326, 191, 737, 736, 686, 735, ++ /* 1410 */ 346, 728, 192, 327, 715, 425, 6, 71, 350, 79, ++ /* 1420 */ 775, 292, 204, 776, 709, 774, 294, 296, 301, 773, ++ /* 1430 */ 287, 708, 865, 298, 707, 970, 757, 213, 428, 442, ++ /* 1440 */ 238, 727, 446, 73, 239, 240, 692, 22, 956, 457, ++ /* 1450 */ 214, 216, 217, 458, 681, 680, 675, 125, 115, 126, ++ /* 1460 */ 673, 235, 357, 166, 127, 244, 179, 361, 308, 309, ++ /* 1470 */ 310, 311, 895, 113, 815, 331, 893, 136, 128, 332, ++ /* 1480 */ 747, 138, 262, 910, 143, 184, 145, 63, 129, 64, ++ /* 1490 */ 913, 65, 66, 186, 187, 909, 8, 13, 188, 902, ++ /* 1500 */ 202, 991, 269, 149, 392, 150, 689, 161, 396, 289, ++ /* 1510 */ 193, 283, 151, 134, 68, 400, 405, 14, 15, 726, ++ /* 1520 */ 69, 236, 835, 834, 863, 755, 131, 16, 70, 759, ++ /* 1530 */ 4, 201, 174, 418, 220, 222, 788, 152, 867, 783, ++ /* 1540 */ 77, 17, 74, 18, 878, 864, 862, 919, 210, 918, ++ /* 1550 */ 207, 206, 945, 163, 441, 211, 946, 164, 209, 165, ++ /* 1560 */ 445, 866, 833, 699, 87, 1295, 1294, 313, 316, 951, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 19, 144, 145, 146, 147, 24, 1, 2, 27, 80, -@@ -127846,37 +128393,37 @@ static const YYCODETYPE yy_lookahead[] = - /* 1220 */ 216, 186, 177, 19, 20, 69, 22, 203, 177, 182, - /* 1230 */ 177, 27, 28, 202, 200, 228, 216, 216, 155, 39, - /* 1240 */ 122, 159, 38, 159, 41, 89, 90, 91, 159, 241, -- /* 1250 */ 241, 22, 96, 97, 98, 71, 130, 101, 222, 191, -- /* 1260 */ 18, 57, 203, 194, 159, 194, 194, 194, 18, 158, -- /* 1270 */ 244, 191, 222, 69, 159, 158, 137, 19, 20, 203, -- /* 1280 */ 22, 191, 203, 46, 236, 27, 28, 159, 132, 133, -- /* 1290 */ 134, 135, 136, 89, 90, 237, 38, 159, 158, 22, -- /* 1300 */ 96, 97, 98, 179, 159, 101, 158, 48, 159, 158, -- /* 1310 */ 179, 176, 107, 176, 184, 57, 106, 176, 184, 176, -- /* 1320 */ 125, 179, 178, 176, 218, 107, 176, 69, 176, 217, -- /* 1330 */ 159, 218, 218, 217, 159, 137, 132, 133, 134, 135, -- /* 1340 */ 136, 218, 217, 179, 217, 179, 227, 89, 90, 95, -- /* 1350 */ 230, 230, 129, 207, 96, 97, 98, 126, 128, 101, -- /* 1360 */ 5, 206, 205, 127, 204, 10, 11, 12, 13, 14, -- /* 1370 */ 203, 25, 17, 162, 26, 161, 13, 153, 153, 6, -- /* 1380 */ 247, 180, 250, 151, 151, 151, 151, 32, 180, 34, -- /* 1390 */ 132, 133, 134, 135, 136, 167, 4, 3, 43, 22, -- /* 1400 */ 15, 68, 142, 250, 16, 23, 23, 120, 111, 131, -- /* 1410 */ 20, 56, 123, 125, 16, 1, 123, 131, 63, 79, -- /* 1420 */ 79, 66, 67, 111, 28, 36, 122, 1, 5, 22, -- /* 1430 */ 107, 140, 54, 54, 26, 61, 107, 44, 20, 24, -- /* 1440 */ 19, 105, 112, 23, 22, 40, 22, 22, 53, 22, -- /* 1450 */ 53, 22, 53, 23, 23, 23, 22, 22, 30, 116, -- /* 1460 */ 23, 122, 26, 23, 23, 22, 28, 11, 124, 114, -- /* 1470 */ 26, 26, 23, 23, 23, 36, 24, 23, 36, 26, -- /* 1480 */ 22, 22, 36, 23, 122, 23, 22, 26, 22, 24, -- /* 1490 */ 23, 23, 23, 22, 122, 23, 141, 122, 122, 15, -- /* 1500 */ 1, -+ /* 1250 */ 241, 22, 96, 97, 98, 129, 126, 101, 222, 207, -+ /* 1260 */ 206, 57, 71, 191, 130, 207, 203, 206, 18, 194, -+ /* 1270 */ 244, 159, 194, 69, 194, 194, 203, 19, 20, 18, -+ /* 1280 */ 22, 158, 191, 191, 222, 27, 28, 159, 132, 133, -+ /* 1290 */ 134, 135, 136, 89, 90, 158, 38, 203, 137, 46, -+ /* 1300 */ 96, 97, 98, 237, 236, 101, 159, 159, 158, 22, -+ /* 1310 */ 179, 159, 158, 107, 159, 57, 158, 179, 176, 176, -+ /* 1320 */ 176, 48, 176, 184, 179, 106, 125, 69, 218, 178, -+ /* 1330 */ 107, 217, 217, 176, 218, 218, 132, 133, 134, 135, -+ /* 1340 */ 136, 176, 176, 184, 217, 159, 217, 89, 90, 159, -+ /* 1350 */ 218, 137, 227, 179, 96, 97, 98, 95, 179, 101, -+ /* 1360 */ 5, 128, 127, 230, 204, 10, 11, 12, 13, 14, -+ /* 1370 */ 230, 207, 17, 206, 205, 203, 25, 162, 26, 161, -+ /* 1380 */ 13, 153, 6, 153, 4, 151, 250, 32, 151, 34, -+ /* 1390 */ 132, 133, 134, 135, 136, 151, 151, 180, 43, 250, -+ /* 1400 */ 247, 180, 3, 167, 22, 142, 15, 68, 16, 23, -+ /* 1410 */ 23, 56, 120, 131, 111, 20, 123, 16, 63, 125, -+ /* 1420 */ 1, 66, 67, 123, 79, 79, 131, 111, 28, 36, -+ /* 1430 */ 122, 1, 5, 22, 107, 54, 140, 54, 26, 61, -+ /* 1440 */ 44, 107, 24, 20, 19, 112, 105, 53, 22, 40, -+ /* 1450 */ 22, 22, 30, 116, 23, 22, 53, 22, 53, 23, -+ /* 1460 */ 23, 23, 22, 11, 23, 22, 122, 23, 26, 114, -+ /* 1470 */ 23, 22, 124, 28, 26, 36, 26, 23, 23, 23, -+ /* 1480 */ 122, 23, 36, 26, 22, 24, 23, 36, 22, 22, -+ /* 1490 */ 26, 23, 22, 24, 23, 23, 141, 23, 22, 122, -+ /* 1500 */ 23, 122, 15, 1, 252, 252, 122, + /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28, +@@ -135521,32 +136199,32 @@ static const YYCODETYPE yy_lookahead[] = + /* 1330 */ 152, 97, 152, 152, 210, 233, 210, 198, 150, 97, + /* 1340 */ 184, 201, 239, 214, 214, 201, 239, 180, 214, 227, + /* 1350 */ 200, 198, 155, 67, 243, 176, 69, 175, 175, 175, +- /* 1360 */ 122, 159, 159, 240, 159, 240, 22, 220, 27, 130, +- /* 1370 */ 201, 18, 159, 18, 189, 158, 158, 220, 192, 159, +- /* 1380 */ 137, 236, 192, 192, 192, 189, 74, 189, 159, 235, +- /* 1390 */ 159, 158, 22, 177, 201, 201, 159, 107, 158, 177, +- /* 1400 */ 159, 174, 158, 76, 174, 182, 174, 106, 182, 125, +- /* 1410 */ 174, 107, 177, 22, 159, 216, 215, 137, 159, 53, +- /* 1420 */ 216, 176, 215, 174, 174, 216, 215, 215, 174, 229, +- /* 1430 */ 216, 129, 224, 177, 126, 229, 127, 177, 128, 25, +- /* 1440 */ 162, 226, 26, 161, 13, 153, 6, 153, 151, 151, +- /* 1450 */ 151, 151, 205, 165, 178, 178, 165, 4, 3, 22, +- /* 1460 */ 165, 142, 15, 94, 202, 204, 203, 201, 16, 23, +- /* 1470 */ 249, 23, 120, 249, 246, 111, 131, 123, 20, 16, +- /* 1480 */ 1, 125, 123, 111, 56, 64, 37, 37, 131, 122, +- /* 1490 */ 1, 37, 5, 37, 22, 107, 26, 80, 140, 80, +- /* 1500 */ 87, 72, 107, 20, 24, 19, 112, 105, 23, 79, +- /* 1510 */ 22, 79, 22, 22, 22, 58, 22, 79, 23, 68, +- /* 1520 */ 23, 23, 26, 116, 22, 26, 23, 22, 122, 23, +- /* 1530 */ 23, 56, 64, 22, 124, 26, 26, 64, 64, 23, +- /* 1540 */ 23, 23, 23, 11, 23, 22, 26, 23, 22, 24, +- /* 1550 */ 1, 23, 22, 26, 251, 24, 23, 22, 122, 23, +- /* 1560 */ 23, 22, 15, 122, 122, 122, 23, ++ /* 1360 */ 122, 159, 159, 240, 159, 240, 22, 220, 129, 126, ++ /* 1370 */ 205, 130, 27, 204, 189, 18, 159, 18, 158, 220, ++ /* 1380 */ 159, 158, 137, 74, 192, 192, 192, 159, 192, 189, ++ /* 1390 */ 189, 205, 201, 236, 204, 235, 159, 22, 158, 201, ++ /* 1400 */ 201, 177, 107, 159, 177, 158, 174, 174, 159, 174, ++ /* 1410 */ 76, 182, 158, 177, 106, 125, 22, 107, 53, 137, ++ /* 1420 */ 216, 215, 159, 216, 174, 216, 215, 215, 159, 216, ++ /* 1430 */ 174, 176, 224, 215, 174, 174, 205, 25, 127, 177, ++ /* 1440 */ 226, 182, 177, 128, 229, 229, 162, 26, 13, 161, ++ /* 1450 */ 153, 153, 6, 151, 151, 151, 151, 165, 178, 165, ++ /* 1460 */ 4, 178, 3, 22, 165, 142, 15, 94, 204, 203, ++ /* 1470 */ 202, 201, 23, 16, 120, 249, 23, 131, 111, 249, ++ /* 1480 */ 20, 123, 16, 1, 123, 125, 131, 37, 111, 37, ++ /* 1490 */ 56, 37, 37, 64, 122, 1, 5, 22, 107, 80, ++ /* 1500 */ 26, 87, 140, 80, 72, 107, 20, 24, 19, 112, ++ /* 1510 */ 105, 23, 22, 246, 22, 79, 79, 22, 22, 58, ++ /* 1520 */ 22, 79, 23, 23, 23, 116, 68, 22, 26, 23, ++ /* 1530 */ 22, 64, 122, 26, 23, 23, 56, 22, 11, 124, ++ /* 1540 */ 26, 64, 26, 64, 23, 23, 23, 23, 122, 23, ++ /* 1550 */ 22, 26, 23, 22, 24, 122, 23, 22, 26, 22, ++ /* 1560 */ 24, 23, 23, 23, 22, 122, 122, 23, 15, 1, }; - #define YY_SHIFT_USE_DFLT (-89) --#define YY_SHIFT_COUNT (435) -+#define YY_SHIFT_COUNT (439) - #define YY_SHIFT_MIN (-88) --#define YY_SHIFT_MAX (1499) -+#define YY_SHIFT_MAX (1502) +-#define YY_SHIFT_USE_DFLT (1567) +-#define YY_SHIFT_COUNT (455) ++#define YY_SHIFT_USE_DFLT (1570) ++#define YY_SHIFT_COUNT (459) + #define YY_SHIFT_MIN (-94) +-#define YY_SHIFT_MAX (1549) ++#define YY_SHIFT_MAX (1568) static const short yy_shift_ofst[] = { - /* 0 */ 5, 1057, 1355, 1070, 1204, 1204, 1204, 90, 60, -19, - /* 10 */ 58, 58, 186, 1204, 1204, 1204, 1204, 1204, 1204, 1204, -@@ -127902,31 +128449,31 @@ static const short yy_shift_ofst[] = { - /* 210 */ 711, 711, 704, 215, 1065, 756, 434, 709, 709, 712, - /* 220 */ 434, 712, 534, 858, 641, 953, 709, -88, 953, 953, - /* 230 */ 867, 489, 447, 1200, 1118, 1118, 1203, 1203, 1118, 1229, -- /* 240 */ 1184, 1126, 1242, 1242, 1242, 1242, 1118, 1250, 1126, 1229, -- /* 250 */ 1184, 1184, 1126, 1118, 1250, 1139, 1237, 1118, 1118, 1250, -- /* 260 */ 1277, 1118, 1250, 1118, 1250, 1277, 1205, 1205, 1205, 1259, -- /* 270 */ 1277, 1205, 1210, 1205, 1259, 1205, 1205, 1195, 1218, 1195, -- /* 280 */ 1218, 1195, 1218, 1195, 1218, 1118, 1118, 1198, 1277, 1254, -- /* 290 */ 1254, 1277, 1223, 1231, 1230, 1236, 1126, 1346, 1348, 1363, -- /* 300 */ 1363, 1373, 1373, 1373, 1373, -89, -89, -89, -89, -89, -- /* 310 */ -89, 477, 547, 386, 818, 750, 765, 700, 1006, 731, -- /* 320 */ 1011, 1015, 1016, 1017, 948, 836, 935, 703, 1023, 1055, -- /* 330 */ 1064, 1077, 855, 918, 1087, 1085, 611, 1392, 1394, 1377, -- /* 340 */ 1260, 1385, 1333, 1388, 1382, 1383, 1287, 1278, 1297, 1289, -- /* 350 */ 1390, 1288, 1398, 1414, 1293, 1286, 1340, 1341, 1312, 1396, -- /* 360 */ 1389, 1304, 1426, 1423, 1407, 1323, 1291, 1378, 1408, 1379, -- /* 370 */ 1374, 1393, 1329, 1415, 1418, 1421, 1330, 1336, 1422, 1395, -- /* 380 */ 1424, 1425, 1420, 1427, 1397, 1428, 1429, 1399, 1405, 1430, -- /* 390 */ 1431, 1432, 1343, 1434, 1437, 1435, 1436, 1339, 1440, 1441, -- /* 400 */ 1438, 1439, 1443, 1344, 1444, 1442, 1445, 1446, 1444, 1449, -- /* 410 */ 1450, 1451, 1453, 1454, 1458, 1456, 1460, 1459, 1452, 1461, -- /* 420 */ 1462, 1464, 1465, 1461, 1467, 1466, 1468, 1469, 1471, 1362, -- /* 430 */ 1372, 1375, 1376, 1472, 1484, 1499, -+ /* 240 */ 1126, 1130, 1191, 1126, 1130, 1134, 1250, 1250, 1250, 1250, -+ /* 250 */ 1118, 1261, 1134, 1229, 1191, 1191, 1134, 1118, 1261, 1161, -+ /* 260 */ 1253, 1118, 1118, 1261, 1287, 1118, 1261, 1118, 1261, 1287, -+ /* 270 */ 1206, 1206, 1206, 1273, 1287, 1206, 1219, 1206, 1273, 1206, -+ /* 280 */ 1206, 1201, 1223, 1201, 1223, 1201, 1223, 1201, 1223, 1118, -+ /* 290 */ 1118, 1214, 1287, 1262, 1262, 1287, 1126, 1130, 1233, 1235, -+ /* 300 */ 1134, 1351, 1352, 1367, 1367, 1376, 1376, 1376, 1376, -89, -+ /* 310 */ -89, -89, -89, -89, -89, 477, 547, 386, 818, 750, -+ /* 320 */ 765, 700, 1006, 731, 1011, 1015, 1016, 1017, 948, 836, -+ /* 330 */ 935, 703, 1023, 1055, 1064, 1077, 855, 918, 1087, 1085, -+ /* 340 */ 611, 1380, 1399, 1382, 1263, 1391, 1339, 1392, 1386, 1387, -+ /* 350 */ 1292, 1282, 1303, 1293, 1395, 1294, 1401, 1419, 1300, 1295, -+ /* 360 */ 1345, 1346, 1316, 1400, 1393, 1308, 1430, 1427, 1411, 1327, -+ /* 370 */ 1296, 1381, 1412, 1383, 1378, 1396, 1334, 1418, 1423, 1425, -+ /* 380 */ 1333, 1341, 1426, 1394, 1428, 1429, 1431, 1433, 1403, 1422, -+ /* 390 */ 1435, 1405, 1409, 1436, 1437, 1438, 1337, 1440, 1441, 1443, -+ /* 400 */ 1442, 1344, 1444, 1447, 1445, 1439, 1449, 1348, 1448, 1446, -+ /* 410 */ 1450, 1451, 1448, 1454, 1455, 1456, 1457, 1458, 1462, 1452, -+ /* 420 */ 1463, 1466, 1461, 1464, 1468, 1467, 1469, 1464, 1471, 1470, -+ /* 430 */ 1472, 1474, 1476, 1358, 1377, 1379, 1384, 1477, 1487, 1502, + /* 0 */ 40, 599, 904, 612, 760, 760, 760, 760, 725, -19, + /* 10 */ 16, 16, 100, 760, 760, 760, 760, 760, 760, 760, +@@ -135560,11 +136238,11 @@ static const short yy_shift_ofst[] = { + /* 90 */ 856, 760, 760, 760, 760, 760, 760, 760, 760, 760, + /* 100 */ 760, 760, 760, 760, 987, 746, 746, 746, 746, 746, + /* 110 */ 801, 23, 32, 949, 961, 979, 964, 964, 949, 73, +- /* 120 */ 113, -51, 1567, 1567, 1567, 536, 536, 536, 99, 99, ++ /* 120 */ 113, -51, 1570, 1570, 1570, 536, 536, 536, 99, 99, + /* 130 */ 813, 813, 667, 205, 240, 949, 949, 949, 949, 949, + /* 140 */ 949, 949, 949, 949, 949, 949, 949, 949, 949, 949, + /* 150 */ 949, 949, 949, 949, 949, 332, 1011, 422, 422, 113, +- /* 160 */ 30, 30, 30, 30, 30, 30, 1567, 1567, 1567, 922, ++ /* 160 */ 30, 30, 30, 30, 30, 30, 1570, 1570, 1570, 922, + /* 170 */ -94, -94, 384, 613, 828, 420, 765, 804, 851, 949, + /* 180 */ 949, 949, 949, 949, 949, 949, 949, 949, 949, 949, + /* 190 */ 949, 949, 949, 949, 949, 672, 672, 672, 949, 949, +@@ -135573,32 +136251,32 @@ static const short yy_shift_ofst[] = { + /* 220 */ 712, 712, 712, 810, 45, 769, 1219, 1133, 418, 418, + /* 230 */ 569, 1133, 569, 830, 607, 663, 882, 418, 693, 882, + /* 240 */ 882, 848, 1152, 1065, 1286, 1238, 1238, 1287, 1287, 1238, +- /* 250 */ 1344, 1341, 1239, 1353, 1353, 1353, 1353, 1238, 1355, 1239, +- /* 260 */ 1344, 1341, 1341, 1239, 1238, 1355, 1243, 1312, 1238, 1238, +- /* 270 */ 1355, 1370, 1238, 1355, 1238, 1355, 1370, 1290, 1290, 1290, +- /* 280 */ 1327, 1370, 1290, 1301, 1290, 1327, 1290, 1290, 1284, 1304, +- /* 290 */ 1284, 1304, 1284, 1304, 1284, 1304, 1238, 1391, 1238, 1280, +- /* 300 */ 1370, 1366, 1366, 1370, 1302, 1308, 1310, 1309, 1239, 1414, +- /* 310 */ 1416, 1431, 1431, 1440, 1440, 1440, 1440, 1567, 1567, 1567, +- /* 320 */ 1567, 1567, 1567, 1567, 1567, 519, 978, 1210, 1225, 104, +- /* 330 */ 1141, 1189, 1246, 1248, 1251, 1252, 1253, 1257, 1258, 1273, +- /* 340 */ 1003, 1187, 1293, 1170, 1272, 1279, 1234, 1281, 1176, 1177, +- /* 350 */ 1289, 1242, 1195, 1453, 1455, 1437, 1319, 1447, 1369, 1452, +- /* 360 */ 1446, 1448, 1352, 1345, 1364, 1354, 1458, 1356, 1463, 1479, +- /* 370 */ 1359, 1357, 1449, 1450, 1454, 1456, 1372, 1428, 1421, 1367, +- /* 380 */ 1489, 1487, 1472, 1388, 1358, 1417, 1470, 1419, 1413, 1429, +- /* 390 */ 1395, 1480, 1483, 1486, 1394, 1402, 1488, 1430, 1490, 1491, +- /* 400 */ 1485, 1492, 1432, 1457, 1494, 1438, 1451, 1495, 1497, 1498, +- /* 410 */ 1496, 1407, 1502, 1503, 1505, 1499, 1406, 1506, 1507, 1475, +- /* 420 */ 1468, 1511, 1410, 1509, 1473, 1510, 1474, 1516, 1509, 1517, +- /* 430 */ 1518, 1519, 1520, 1521, 1523, 1532, 1524, 1526, 1525, 1527, +- /* 440 */ 1528, 1530, 1531, 1527, 1533, 1535, 1536, 1537, 1539, 1436, +- /* 450 */ 1441, 1442, 1443, 1543, 1547, 1549, ++ /* 250 */ 1344, 1239, 1243, 1345, 1239, 1243, 1241, 1357, 1357, 1357, ++ /* 260 */ 1357, 1238, 1359, 1241, 1344, 1345, 1345, 1241, 1238, 1359, ++ /* 270 */ 1245, 1309, 1238, 1238, 1359, 1375, 1238, 1359, 1238, 1359, ++ /* 280 */ 1375, 1295, 1295, 1295, 1334, 1375, 1295, 1308, 1295, 1334, ++ /* 290 */ 1295, 1295, 1290, 1310, 1290, 1310, 1290, 1310, 1290, 1310, ++ /* 300 */ 1238, 1394, 1238, 1282, 1375, 1365, 1365, 1375, 1239, 1243, ++ /* 310 */ 1315, 1311, 1241, 1412, 1421, 1435, 1435, 1446, 1446, 1446, ++ /* 320 */ 1446, 1570, 1570, 1570, 1570, 1570, 1570, 1570, 1570, 519, ++ /* 330 */ 978, 1210, 1225, 104, 1141, 1189, 1246, 1248, 1251, 1252, ++ /* 340 */ 1253, 1257, 1258, 1273, 1003, 1187, 1293, 1170, 1272, 1279, ++ /* 350 */ 1234, 1281, 1176, 1177, 1289, 1242, 1195, 1456, 1459, 1441, ++ /* 360 */ 1323, 1451, 1373, 1457, 1449, 1453, 1354, 1346, 1367, 1358, ++ /* 370 */ 1460, 1360, 1466, 1482, 1361, 1355, 1450, 1452, 1454, 1455, ++ /* 380 */ 1377, 1434, 1429, 1372, 1494, 1491, 1475, 1391, 1362, 1419, ++ /* 390 */ 1474, 1423, 1414, 1432, 1398, 1483, 1486, 1489, 1397, 1405, ++ /* 400 */ 1490, 1436, 1492, 1495, 1488, 1496, 1437, 1461, 1498, 1442, ++ /* 410 */ 1458, 1499, 1500, 1501, 1502, 1409, 1505, 1506, 1508, 1507, ++ /* 420 */ 1410, 1511, 1512, 1480, 1467, 1515, 1415, 1514, 1477, 1516, ++ /* 430 */ 1479, 1521, 1514, 1522, 1523, 1524, 1525, 1526, 1528, 1527, ++ /* 440 */ 1529, 1531, 1530, 1532, 1533, 1535, 1536, 1532, 1538, 1537, ++ /* 450 */ 1539, 1540, 1542, 1426, 1433, 1443, 1444, 1544, 1553, 1568, }; - #define YY_REDUCE_USE_DFLT (-144) --#define YY_REDUCE_COUNT (310) -+#define YY_REDUCE_COUNT (314) - #define YY_REDUCE_MIN (-143) --#define YY_REDUCE_MAX (1235) -+#define YY_REDUCE_MAX (1245) + #define YY_REDUCE_USE_DFLT (-130) +-#define YY_REDUCE_COUNT (324) ++#define YY_REDUCE_COUNT (328) + #define YY_REDUCE_MIN (-129) +-#define YY_REDUCE_MAX (1300) ++#define YY_REDUCE_MAX (1305) static const short yy_reduce_ofst[] = { - /* 0 */ -143, 954, 86, 21, -50, 23, 79, 134, 226, -120, - /* 10 */ -127, 146, 161, 291, 349, 366, 311, 382, 374, 231, -@@ -127952,60 +128499,60 @@ static const short yy_reduce_ofst[] = { - /* 210 */ 1000, 1002, 901, 1012, 1019, 1060, 1014, 1004, 1020, 975, - /* 220 */ 1024, 976, 1040, 1035, 1047, 1045, 1021, 1007, 1051, 1053, - /* 230 */ 1031, 1034, 1083, 1026, 1082, 1084, 1008, 1009, 1089, 1036, -- /* 240 */ 1068, 1059, 1069, 1071, 1072, 1073, 1105, 1111, 1076, 1050, -- /* 250 */ 1080, 1090, 1079, 1115, 1117, 1058, 1048, 1128, 1138, 1140, -- /* 260 */ 1124, 1145, 1148, 1149, 1151, 1131, 1135, 1137, 1141, 1130, -- /* 270 */ 1142, 1143, 1144, 1147, 1134, 1150, 1152, 1106, 1112, 1113, -- /* 280 */ 1116, 1114, 1125, 1123, 1127, 1171, 1175, 1119, 1164, 1120, -- /* 290 */ 1121, 1166, 1146, 1155, 1157, 1160, 1167, 1211, 1214, 1224, -- /* 300 */ 1225, 1232, 1233, 1234, 1235, 1132, 1153, 1133, 1201, 1208, -- /* 310 */ 1228, -+ /* 240 */ 1052, 1054, 1072, 1058, 1061, 1063, 1075, 1078, 1080, 1081, -+ /* 250 */ 1112, 1123, 1073, 1062, 1091, 1092, 1094, 1128, 1137, 1066, -+ /* 260 */ 1068, 1147, 1148, 1150, 1131, 1152, 1154, 1155, 1158, 1138, -+ /* 270 */ 1142, 1143, 1144, 1139, 1145, 1146, 1151, 1157, 1159, 1165, -+ /* 280 */ 1166, 1110, 1114, 1116, 1115, 1117, 1127, 1132, 1129, 1186, -+ /* 290 */ 1190, 1125, 1174, 1133, 1140, 1179, 1164, 1167, 1169, 1160, -+ /* 300 */ 1172, 1215, 1218, 1228, 1230, 1234, 1237, 1244, 1245, 1136, -+ /* 310 */ 1149, 1153, 1217, 1221, 1236, + /* 0 */ -29, 566, 525, 605, -49, 307, 491, 533, 668, 435, + /* 10 */ 601, 644, 148, 747, 786, 795, 419, 788, 827, 790, +@@ -135625,62 +136303,62 @@ static const short yy_reduce_ofst[] = { + /* 220 */ 1119, 1124, 1126, 926, 1131, 1139, 1188, 1140, 1129, 1130, + /* 230 */ 1103, 1144, 1107, 1179, 1156, 1167, 1182, 1134, 1122, 1183, + /* 240 */ 1184, 1150, 1153, 1197, 1111, 1202, 1203, 1123, 1125, 1205, +- /* 250 */ 1147, 1185, 1169, 1186, 1190, 1191, 1192, 1213, 1217, 1193, +- /* 260 */ 1157, 1196, 1198, 1194, 1220, 1218, 1145, 1154, 1229, 1231, +- /* 270 */ 1233, 1216, 1237, 1240, 1241, 1244, 1222, 1227, 1230, 1232, +- /* 280 */ 1223, 1235, 1236, 1245, 1249, 1226, 1250, 1254, 1199, 1201, +- /* 290 */ 1204, 1207, 1209, 1211, 1214, 1212, 1255, 1208, 1259, 1215, +- /* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278, +- /* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228, +- /* 320 */ 1288, 1291, 1276, 1277, 1295, ++ /* 250 */ 1147, 1165, 1169, 1185, 1186, 1190, 1191, 1192, 1193, 1194, ++ /* 260 */ 1196, 1217, 1220, 1198, 1159, 1200, 1201, 1199, 1221, 1223, ++ /* 270 */ 1157, 1160, 1228, 1237, 1240, 1224, 1244, 1247, 1249, 1254, ++ /* 280 */ 1227, 1232, 1233, 1235, 1229, 1236, 1250, 1255, 1256, 1259, ++ /* 290 */ 1260, 1261, 1204, 1206, 1207, 1211, 1209, 1212, 1213, 1218, ++ /* 300 */ 1263, 1208, 1269, 1214, 1262, 1215, 1216, 1265, 1231, 1264, ++ /* 310 */ 1266, 1268, 1270, 1284, 1288, 1297, 1298, 1302, 1303, 1304, ++ /* 320 */ 1305, 1226, 1230, 1267, 1292, 1294, 1280, 1283, 1299, }; static const YYACTIONTYPE yy_default[] = { -- /* 0 */ 982, 1300, 1300, 1300, 1214, 1214, 1214, 1305, 1300, 1109, -- /* 10 */ 1138, 1138, 1274, 1305, 1305, 1305, 1305, 1305, 1305, 1212, -- /* 20 */ 1305, 1305, 1305, 1300, 1305, 1113, 1144, 1305, 1305, 1305, -- /* 30 */ 1305, 1305, 1305, 1305, 1305, 1273, 1275, 1152, 1151, 1254, -- /* 40 */ 1125, 1149, 1142, 1146, 1215, 1208, 1209, 1207, 1211, 1216, -- /* 50 */ 1305, 1145, 1177, 1192, 1176, 1305, 1305, 1305, 1305, 1305, -- /* 60 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 70 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 80 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 90 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1186, 1191, -- /* 100 */ 1198, 1190, 1187, 1179, 1178, 1180, 1181, 1305, 1305, 1008, -- /* 110 */ 1074, 1305, 1305, 1182, 1305, 1020, 1183, 1195, 1194, 1193, -- /* 120 */ 1015, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 130 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 140 */ 1305, 1305, 1305, 1305, 1305, 982, 1300, 1305, 1305, 1300, -- /* 150 */ 1300, 1300, 1300, 1300, 1300, 1292, 1113, 1103, 1305, 1305, -- /* 160 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1280, 1278, -- /* 170 */ 1305, 1227, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 180 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 190 */ 1305, 1305, 1305, 1109, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 200 */ 1305, 1305, 1305, 1305, 1305, 1305, 988, 1305, 1247, 1109, -- /* 210 */ 1109, 1109, 1111, 1089, 1101, 990, 1148, 1127, 1127, 1259, -- /* 220 */ 1148, 1259, 1045, 1068, 1042, 1138, 1127, 1210, 1138, 1138, -- /* 230 */ 1110, 1101, 1305, 1285, 1118, 1118, 1277, 1277, 1118, 1157, -- /* 240 */ 1078, 1148, 1085, 1085, 1085, 1085, 1118, 1005, 1148, 1157, -- /* 250 */ 1078, 1078, 1148, 1118, 1005, 1253, 1251, 1118, 1118, 1005, -- /* 260 */ 1220, 1118, 1005, 1118, 1005, 1220, 1076, 1076, 1076, 1060, -- /* 270 */ 1220, 1076, 1045, 1076, 1060, 1076, 1076, 1131, 1126, 1131, -- /* 280 */ 1126, 1131, 1126, 1131, 1126, 1118, 1118, 1305, 1220, 1224, -- /* 290 */ 1224, 1220, 1143, 1132, 1141, 1139, 1148, 1011, 1063, 998, -- /* 300 */ 998, 987, 987, 987, 987, 1297, 1297, 1292, 1047, 1047, -- /* 310 */ 1030, 1305, 1305, 1305, 1305, 1305, 1305, 1022, 1305, 1229, -- /* 320 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 330 */ 1305, 1305, 1305, 1305, 1305, 1305, 1164, 1305, 983, 1287, -- /* 340 */ 1305, 1305, 1284, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 350 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 360 */ 1305, 1257, 1305, 1305, 1305, 1305, 1305, 1305, 1250, 1249, -- /* 370 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 380 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, -- /* 390 */ 1305, 1305, 1092, 1305, 1305, 1305, 1096, 1305, 1305, 1305, -- /* 400 */ 1305, 1305, 1305, 1305, 1140, 1305, 1133, 1305, 1213, 1305, -- /* 410 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1302, -- /* 420 */ 1305, 1305, 1305, 1301, 1305, 1305, 1305, 1305, 1305, 1166, -- /* 430 */ 1305, 1165, 1169, 1305, 996, 1305, -+ /* 0 */ 986, 1304, 1304, 1304, 1218, 1218, 1218, 1309, 1304, 1113, -+ /* 10 */ 1142, 1142, 1278, 1309, 1309, 1309, 1309, 1309, 1309, 1216, -+ /* 20 */ 1309, 1309, 1309, 1304, 1309, 1117, 1148, 1309, 1309, 1309, -+ /* 30 */ 1309, 1309, 1309, 1309, 1309, 1277, 1279, 1156, 1155, 1258, -+ /* 40 */ 1129, 1153, 1146, 1150, 1219, 1212, 1213, 1211, 1215, 1220, -+ /* 50 */ 1309, 1149, 1181, 1196, 1180, 1309, 1309, 1309, 1309, 1309, -+ /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1190, 1195, -+ /* 100 */ 1202, 1194, 1191, 1183, 1182, 1184, 1185, 1309, 1309, 1012, -+ /* 110 */ 1078, 1309, 1309, 1186, 1309, 1024, 1187, 1199, 1198, 1197, -+ /* 120 */ 1019, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 140 */ 1309, 1309, 1309, 1309, 1309, 986, 1304, 1309, 1309, 1304, -+ /* 150 */ 1304, 1304, 1304, 1304, 1304, 1296, 1117, 1107, 1309, 1309, -+ /* 160 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1284, 1282, -+ /* 170 */ 1309, 1231, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 190 */ 1309, 1309, 1309, 1113, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 992, 1309, 1251, 1113, -+ /* 210 */ 1113, 1113, 1115, 1093, 1105, 994, 1152, 1131, 1131, 1263, -+ /* 220 */ 1152, 1263, 1049, 1072, 1046, 1142, 1131, 1214, 1142, 1142, -+ /* 230 */ 1114, 1105, 1309, 1289, 1122, 1122, 1281, 1281, 1122, 1161, -+ /* 240 */ 1147, 1136, 1082, 1147, 1136, 1152, 1089, 1089, 1089, 1089, -+ /* 250 */ 1122, 1009, 1152, 1161, 1082, 1082, 1152, 1122, 1009, 1257, -+ /* 260 */ 1255, 1122, 1122, 1009, 1224, 1122, 1009, 1122, 1009, 1224, -+ /* 270 */ 1080, 1080, 1080, 1064, 1224, 1080, 1049, 1080, 1064, 1080, -+ /* 280 */ 1080, 1135, 1130, 1135, 1130, 1135, 1130, 1135, 1130, 1122, -+ /* 290 */ 1122, 1309, 1224, 1228, 1228, 1224, 1147, 1136, 1145, 1143, -+ /* 300 */ 1152, 1015, 1067, 1002, 1002, 991, 991, 991, 991, 1301, -+ /* 310 */ 1301, 1296, 1051, 1051, 1034, 1309, 1309, 1309, 1309, 1309, -+ /* 320 */ 1309, 1026, 1309, 1233, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 340 */ 1168, 1309, 987, 1291, 1309, 1309, 1288, 1309, 1309, 1309, -+ /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 360 */ 1309, 1309, 1309, 1309, 1309, 1261, 1309, 1309, 1309, 1309, -+ /* 370 */ 1309, 1309, 1254, 1253, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1096, 1309, 1309, 1309, -+ /* 400 */ 1100, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1144, 1309, -+ /* 410 */ 1137, 1309, 1217, 1309, 1309, 1309, 1309, 1309, 1309, 1309, -+ /* 420 */ 1309, 1309, 1309, 1306, 1309, 1309, 1309, 1305, 1309, 1309, -+ /* 430 */ 1309, 1309, 1309, 1170, 1309, 1169, 1173, 1309, 1000, 1309, +- /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096, +- /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201, +- /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332, +- /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140, +- /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198, +- /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332, +- /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169, +- /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172, +- /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332, +- /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332, +- /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332, +- /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332, +- /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231, +- /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114, +- /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125, +- /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105, +- /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135, +- /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105, +- /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068, +- /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113, +- /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332, +- /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022, +- /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266, +- /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332, +- /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332, +- /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320, +- /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332, +- /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, +- /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332, +- /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332, +- /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272, +- /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154, +- /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332, ++ /* 0 */ 1284, 1274, 1274, 1274, 1206, 1206, 1206, 1206, 1274, 1100, ++ /* 10 */ 1129, 1129, 1258, 1336, 1336, 1336, 1336, 1336, 1336, 1205, ++ /* 20 */ 1336, 1336, 1336, 1336, 1274, 1104, 1135, 1336, 1336, 1336, ++ /* 30 */ 1336, 1207, 1208, 1336, 1336, 1336, 1257, 1259, 1145, 1144, ++ /* 40 */ 1143, 1142, 1240, 1116, 1140, 1133, 1137, 1207, 1201, 1202, ++ /* 50 */ 1200, 1204, 1208, 1336, 1136, 1171, 1185, 1170, 1336, 1336, ++ /* 60 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 70 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 80 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 90 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 100 */ 1336, 1336, 1336, 1336, 1179, 1184, 1191, 1183, 1180, 1173, ++ /* 110 */ 1172, 1174, 1175, 1336, 1023, 1071, 1336, 1336, 1336, 1176, ++ /* 120 */ 1336, 1177, 1188, 1187, 1186, 1265, 1292, 1291, 1336, 1336, ++ /* 130 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 140 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 150 */ 1336, 1336, 1336, 1336, 1336, 1284, 1274, 1029, 1029, 1336, ++ /* 160 */ 1274, 1274, 1274, 1274, 1274, 1274, 1270, 1104, 1095, 1336, ++ /* 170 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 180 */ 1262, 1260, 1336, 1221, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 190 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 200 */ 1336, 1336, 1336, 1336, 1100, 1336, 1336, 1336, 1336, 1336, ++ /* 210 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1286, 1336, 1235, ++ /* 220 */ 1100, 1100, 1100, 1102, 1084, 1094, 1008, 1139, 1118, 1118, ++ /* 230 */ 1325, 1139, 1325, 1046, 1306, 1043, 1129, 1118, 1203, 1129, ++ /* 240 */ 1129, 1101, 1094, 1336, 1328, 1109, 1109, 1327, 1327, 1109, ++ /* 250 */ 1150, 1134, 1123, 1074, 1134, 1123, 1139, 1080, 1080, 1080, ++ /* 260 */ 1080, 1109, 1020, 1139, 1150, 1074, 1074, 1139, 1109, 1020, ++ /* 270 */ 1239, 1322, 1109, 1109, 1020, 1214, 1109, 1020, 1109, 1020, ++ /* 280 */ 1214, 1072, 1072, 1072, 1061, 1214, 1072, 1046, 1072, 1061, ++ /* 290 */ 1072, 1072, 1122, 1117, 1122, 1117, 1122, 1117, 1122, 1117, ++ /* 300 */ 1109, 1209, 1109, 1336, 1214, 1218, 1218, 1214, 1134, 1123, ++ /* 310 */ 1132, 1130, 1139, 1026, 1064, 1289, 1289, 1285, 1285, 1285, ++ /* 320 */ 1285, 1333, 1333, 1270, 1301, 1301, 1048, 1048, 1301, 1336, ++ /* 330 */ 1336, 1336, 1336, 1336, 1336, 1296, 1336, 1223, 1336, 1336, ++ /* 340 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 350 */ 1336, 1336, 1336, 1336, 1336, 1336, 1156, 1336, 1004, 1267, ++ /* 360 */ 1336, 1336, 1266, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 370 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 380 */ 1336, 1336, 1336, 1324, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 390 */ 1238, 1237, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 400 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 410 */ 1336, 1336, 1336, 1336, 1336, 1086, 1336, 1336, 1336, 1310, ++ /* 420 */ 1336, 1336, 1336, 1336, 1336, 1336, 1336, 1131, 1336, 1124, ++ /* 430 */ 1336, 1336, 1315, 1336, 1336, 1336, 1336, 1336, 1336, 1336, ++ /* 440 */ 1336, 1336, 1336, 1276, 1336, 1336, 1336, 1275, 1336, 1336, ++ /* 450 */ 1336, 1336, 1336, 1158, 1336, 1157, 1161, 1336, 1014, 1336, }; /********** End of lemon-generated parsing tables *****************************/ -@@ -128417,10 +128964,10 @@ static const char *const yyRuleName[] = - /* 167 */ "limit_opt ::= LIMIT expr", - /* 168 */ "limit_opt ::= LIMIT expr OFFSET expr", - /* 169 */ "limit_opt ::= LIMIT expr COMMA expr", -- /* 170 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt", -+ /* 170 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt orderby_opt limit_opt", - /* 171 */ "where_opt ::=", - /* 172 */ "where_opt ::= WHERE expr", -- /* 173 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt", -+ /* 173 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt orderby_opt limit_opt", - /* 174 */ "setlist ::= setlist COMMA nm EQ expr", - /* 175 */ "setlist ::= nm EQ expr", - /* 176 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select", -@@ -129148,10 +129695,10 @@ static const struct { - { 207, 2 }, - { 207, 4 }, - { 207, 4 }, +@@ -136085,10 +136763,10 @@ static const char *const yyRuleName[] = + /* 131 */ "limit_opt ::= LIMIT expr", + /* 132 */ "limit_opt ::= LIMIT expr OFFSET expr", + /* 133 */ "limit_opt ::= LIMIT expr COMMA expr", +- /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt", ++ /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt orderby_opt limit_opt", + /* 135 */ "where_opt ::=", + /* 136 */ "where_opt ::= WHERE expr", +- /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt", ++ /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt orderby_opt limit_opt", + /* 138 */ "setlist ::= setlist COMMA nm EQ expr", + /* 139 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", + /* 140 */ "setlist ::= nm EQ expr", +@@ -136858,10 +137536,10 @@ static const struct { + { 205, 2 }, + { 205, 4 }, + { 205, 4 }, - { 149, 6 }, + { 149, 8 }, - { 203, 0 }, - { 203, 2 }, + { 201, 0 }, + { 201, 2 }, - { 149, 8 }, + { 149, 10 }, - { 220, 5 }, - { 220, 3 }, - { 149, 6 }, -@@ -129918,19 +130465,43 @@ static void yy_reduce( - case 169: /* limit_opt ::= LIMIT expr COMMA expr */ - {yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr;} + { 218, 5 }, + { 218, 7 }, + { 218, 3 }, +@@ -137659,19 +138337,43 @@ static void yy_reduce( + case 133: /* limit_opt ::= LIMIT expr COMMA expr */ + {yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;} break; -- case 170: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */ -+ case 170: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt orderby_opt limit_opt */ +- case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */ ++ case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt orderby_opt limit_opt */ { -- sqlite3WithPush(pParse, yymsp[-5].minor.yy451, 1); -- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0); -- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314); -+ sqlite3WithPush(pParse, yymsp[-7].minor.yy451, 1); -+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0); +- sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1); +- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0); +- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72); ++ sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1); ++ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0); +#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) -+ yymsp[-2].minor.yy314 = sqlite3LimitWhere(pParse, yymsp[-4].minor.yy259, yymsp[-2].minor.yy314, yymsp[-1].minor.yy322, yymsp[0].minor.yy292.pLimit, yymsp[0].minor.yy292.pOffset, "DELETE"); ++ yymsp[-2].minor.yy72 = sqlite3LimitWhere(pParse, yymsp[-4].minor.yy185, yymsp[-2].minor.yy72, yymsp[-1].minor.yy148, yymsp[0].minor.yy354.pLimit, yymsp[0].minor.yy354.pOffset, "DELETE"); +#else -+ if( yymsp[-1].minor.yy322 || yymsp[0].minor.yy292.pLimit ){ -+ sqlite3ErrorMsg(pParse, "%s on DELETE not supported", yymsp[-1].minor.yy322?"ORDER BY":"LIMIT"); -+ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy314); -+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322); -+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy292.pLimit); -+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy292.pOffset); -+ yymsp[-2].minor.yy314 = 0; ++ if( yymsp[-1].minor.yy148 || yymsp[0].minor.yy354.pLimit ){ ++ sqlite3ErrorMsg(pParse, "%s on DELETE not supported", yymsp[-1].minor.yy148?"ORDER BY":"LIMIT"); ++ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy72); ++ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148); ++ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy354.pLimit); ++ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy354.pOffset); ++ yymsp[-2].minor.yy72 = 0; + } +#endif -+ sqlite3DeleteFrom(pParse,yymsp[-4].minor.yy259,yymsp[-2].minor.yy314); ++ sqlite3DeleteFrom(pParse,yymsp[-4].minor.yy185,yymsp[-2].minor.yy72); } break; -- case 173: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */ -+ case 173: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt orderby_opt limit_opt */ +- case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */ ++ case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt orderby_opt limit_opt */ { -- sqlite3WithPush(pParse, yymsp[-7].minor.yy451, 1); -- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0); -- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); -- sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy4); -+ sqlite3WithPush(pParse, yymsp[-9].minor.yy451, 1); -+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy259, &yymsp[-5].minor.yy0); -+ sqlite3ExprListCheckLength(pParse,yymsp[-3].minor.yy322,"set list"); +- sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1); +- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0); +- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list"); +- sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194); ++ sqlite3WithPush(pParse, yymsp[-9].minor.yy285, 1); ++ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-5].minor.yy0); ++ sqlite3ExprListCheckLength(pParse,yymsp[-3].minor.yy148,"set list"); +#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) -+ yymsp[-2].minor.yy314 = sqlite3LimitWhere(pParse, yymsp[-6].minor.yy259, yymsp[-2].minor.yy314, yymsp[-1].minor.yy322, yymsp[0].minor.yy292.pLimit, yymsp[0].minor.yy292.pOffset, "UPDATE"); ++ yymsp[-2].minor.yy72 = sqlite3LimitWhere(pParse, yymsp[-6].minor.yy185, yymsp[-2].minor.yy72, yymsp[-1].minor.yy148, yymsp[0].minor.yy354.pLimit, yymsp[0].minor.yy354.pOffset, "UPDATE"); +#else -+ if( yymsp[-1].minor.yy322 || yymsp[0].minor.yy292.pLimit ){ -+ sqlite3ErrorMsg(pParse, "%s on UPDATE not supported", yymsp[-1].minor.yy322?"ORDER BY":"LIMIT"); -+ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy314); -+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322); -+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy292.pLimit); -+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy292.pOffset); -+ yymsp[-2].minor.yy314 = 0; ++ if( yymsp[-1].minor.yy148 || yymsp[0].minor.yy354.pLimit ){ ++ sqlite3ErrorMsg(pParse, "%s on UPDATE not supported", yymsp[-1].minor.yy148?"ORDER BY":"LIMIT"); ++ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy72); ++ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148); ++ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy354.pLimit); ++ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy354.pOffset); ++ yymsp[-2].minor.yy72 = 0; + } +#endif -+ sqlite3Update(pParse,yymsp[-6].minor.yy259,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-7].minor.yy4); ++ sqlite3Update(pParse,yymsp[-6].minor.yy185,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-7].minor.yy194); } break; - case 174: /* setlist ::= setlist COMMA nm EQ expr */ -@@ -130560,7 +131131,7 @@ static void yy_reduce( + case 138: /* setlist ::= setlist COMMA nm EQ expr */ +@@ -138347,7 +139049,7 @@ static void yy_reduce( break; /********** End reduce actions ************************************************/ }; -- assert( yyruleno>=0 && yyrulenoyyidx -= yysize; -@@ -132064,7 +132635,7 @@ SQLITE_PRIVATE int sqlite3Fts5Init(sqlit + yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); +@@ -139382,7 +140084,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Pars + sqlite3 *db = pParse->db; /* The database connection */ + int mxSqlLen; /* Max length of an SQL string */ + #ifdef sqlite3Parser_ENGINEALWAYSONSTACK +- unsigned char zSpace[sizeof(yyParser)]; /* Space for parser engine object */ ++ yyParser sEngine; /* Space to hold the Lemon-generated Parser object */ + #endif + + assert( zSql!=0 ); +@@ -139395,7 +140097,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Pars + assert( pzErrMsg!=0 ); + /* sqlite3ParserTrace(stdout, "parser: "); */ + #ifdef sqlite3Parser_ENGINEALWAYSONSTACK +- pEngine = zSpace; ++ pEngine = &sEngine; + sqlite3ParserInit(pEngine); + #else + pEngine = sqlite3ParserAlloc(sqlite3Malloc); +@@ -139939,7 +140641,7 @@ SQLITE_PRIVATE int sqlite3Fts5Init(sqlit /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant ** contains the text of SQLITE_VERSION macro. */ @@ -19474,7 +28141,7 @@ #endif /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns -@@ -132108,7 +132679,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_th +@@ -139983,7 +140685,7 @@ SQLITE_API int sqlite3_threadsafe(void){ ** I/O active are written using this function. These messages ** are intended for debugging activity only. */ @@ -19483,7 +28150,7 @@ #endif /* -@@ -132118,7 +132689,7 @@ SQLITE_API void (SQLITE_CDECL *sqlite3Io +@@ -139993,7 +140695,7 @@ SQLITE_API void (SQLITE_CDECL *sqlite3Io ** ** See also the "PRAGMA temp_store_directory" SQL command. */ @@ -19492,7 +28159,7 @@ /* ** If the following global variable points to a string which is the -@@ -132127,7 +132698,7 @@ SQLITE_API char *sqlite3_temp_directory +@@ -140002,7 +140704,7 @@ SQLITE_API char *sqlite3_temp_directory ** ** See also the "PRAGMA data_store_directory" SQL command. */ @@ -19501,7 +28168,7 @@ /* ** Initialize SQLite. -@@ -132662,6 +133233,12 @@ SQLITE_API int SQLITE_CDECL sqlite3_conf +@@ -140536,6 +141238,19 @@ SQLITE_API int sqlite3_config(int op, .. break; } @@ -19511,18 +28178,54 @@ + break; + } + - default: { - rc = SQLITE_ERROR; ++ case 65: /* SQLITE_CONFIG_ENABLE_UNKOWN_SQL_FUNCTION */ { ++ /* Enable unknown sql function (cannot be switched off) */ ++ sqlite3GlobalConfig.bEnableUnknownSqlFunction = 1; ++ break; ++ } ++ ++ + case SQLITE_CONFIG_STMTJRNL_SPILL: { + sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int); break; -@@ -133697,6 +134274,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc( +@@ -140693,7 +141408,7 @@ SQLITE_API int sqlite3_db_config(sqlite3 + va_start(ap, op); + switch( op ){ + case SQLITE_DBCONFIG_MAINDBNAME: { +- db->aDb[0].zDbSName = va_arg(ap,char*); ++ db->aDb[0].zDbSName = va_arg(ap,const char*); + rc = SQLITE_OK; + break; + } +@@ -140842,7 +141557,8 @@ SQLITE_API void sqlite3_set_last_insert_ + /* + ** Return the number of changes in the most recent call to sqlite3_exec(). + */ +-SQLITE_API int sqlite3_changes(sqlite3 *db){ ++#undef sqlite3_changes ++SQLITE_API u64 sqlite3_changes(sqlite3 *db){ + #ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; +@@ -140855,7 +141571,8 @@ SQLITE_API int sqlite3_changes(sqlite3 * + /* + ** Return the number of changes since the database handle was opened. + */ +-SQLITE_API int sqlite3_total_changes(sqlite3 *db){ ++#undef sqlite3_total_changes ++SQLITE_API u64 sqlite3_total_changes(sqlite3 *db){ + #ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; +@@ -141600,6 +142317,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc( /* ** Create new user functions. */ +#undef sqlite3_create_function - SQLITE_API int SQLITE_STDCALL sqlite3_create_function( + SQLITE_API int sqlite3_create_function( sqlite3 *db, const char *zFunc, -@@ -133963,7 +134541,7 @@ SQLITE_PRIVATE int sqlite3WalDefaultHook +@@ -141915,7 +142633,7 @@ SQLITE_PRIVATE int sqlite3WalDefaultHook ){ if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){ sqlite3BeginBenignMalloc(); @@ -19531,15 +28234,15 @@ sqlite3EndBenignMalloc(); } return SQLITE_OK; -@@ -134084,6 +134662,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wa +@@ -142043,6 +142761,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 SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){ + SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){ /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */ -@@ -134513,14 +135092,14 @@ SQLITE_PRIVATE int sqlite3ParseUri( +@@ -142475,14 +143194,14 @@ SQLITE_PRIVATE int sqlite3ParseUri( int eState; /* Parser state when parsing URI */ int iIn; /* Input character index */ int iOut = 0; /* Output character index */ @@ -19553,10 +28256,10 @@ for(iIn=0; iInzContentTbl==0 ){ + if( !zFunc ){ + zFunction = ""; + }else{ +- zFree = zFunction = fts3QuoteId(zFunc); ++ zFunction = zFree = fts3QuoteId(zFunc); + } + fts3Appendf(pRc, &zRet, "docid"); + for(i=0; inColumn; i++){ +@@ -146137,13 +146859,13 @@ static char *fts3ReadExprList(Fts3Table + static char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){ + char *zRet = 0; + char *zFree = 0; +- char *zFunction; ++ const char *zFunction; + int i; + + if( !zFunc ){ + zFunction = ""; + }else{ +- zFree = zFunction = fts3QuoteId(zFunc); ++ zFunction = zFree = fts3QuoteId(zFunc); + } + fts3Appendf(pRc, &zRet, "?"); + for(i=0; inColumn; i++){ +@@ -149181,6 +149903,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlit #ifndef SQLITE_DISABLE_FTS3_UNICODE || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode) @@ -19634,7 +28379,7 @@ #endif #ifdef SQLITE_ENABLE_ICU || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu)) -@@ -143682,7 +144265,7 @@ SQLITE_PRIVATE int sqlite3Fts3InitAux(sq +@@ -151738,7 +152461,7 @@ SQLITE_PRIVATE int sqlite3Fts3InitAux(sq }; int rc; /* Return code */ @@ -19643,7 +28388,16 @@ return rc; } -@@ -147236,7 +147819,7 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sq +@@ -152145,7 +152868,7 @@ static int getNextNode( + int *pnConsumed /* OUT: Number of bytes consumed */ + ){ + static const struct Fts3Keyword { +- char *z; /* Keyword text */ ++ const char *z; /* Keyword text */ + unsigned char n; /* Length of the keyword */ + unsigned char parenOnly; /* Only valid in paren mode */ + unsigned char eType; /* Keyword code */ +@@ -155314,7 +156037,7 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sq }; int rc; /* Return code */ @@ -19652,7 +28406,7 @@ return rc; } -@@ -155046,6 +155629,7 @@ SQLITE_PRIVATE void sqlite3Fts3UnicodeTo +@@ -163129,6 +163852,7 @@ SQLITE_PRIVATE void sqlite3Fts3UnicodeTo */ #ifndef SQLITE_DISABLE_FTS3_UNICODE @@ -19660,7 +28414,7 @@ #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) /* #include */ -@@ -155057,7 +155641,7 @@ SQLITE_PRIVATE void sqlite3Fts3UnicodeTo +@@ -163140,7 +163864,7 @@ SQLITE_PRIVATE void sqlite3Fts3UnicodeTo ** The results are undefined if the value passed to this function ** is less than zero. */ @@ -19669,7 +28423,7 @@ /* Each unsigned integer in the following array corresponds to a contiguous ** range of unicode codepoints that are not either letters or numbers (i.e. ** codepoints for which this function should return 0). -@@ -155074,84 +155658,92 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal +@@ -163157,84 +163881,97 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal 0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01, 0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401, 0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01, @@ -19702,7 +28456,36 @@ - 0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001, - 0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802, - 0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F, -- 0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002, ++ 0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163403, ++ 0x00164437, 0x0017CC02, 0x0018001D, 0x00187802, 0x00192C15, ++ 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F, 0x001B9C07, ++ 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401, 0x001CC01B, ++ 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804, 0x00206C09, ++ 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403, 0x00217801, ++ 0x00235030, 0x0024E803, 0x0024F812, 0x00254407, 0x00258804, ++ 0x0025C001, 0x00260403, 0x0026F001, 0x0026F807, 0x00271C02, ++ 0x00272C03, 0x00275C01, 0x00278802, 0x0027C802, 0x0027E802, ++ 0x00280403, 0x0028F001, 0x0028F805, 0x00291C02, 0x00292C03, ++ 0x00294401, 0x0029C002, 0x0029D401, 0x002A0403, 0x002AF001, ++ 0x002AF808, 0x002B1C03, 0x002B2C03, 0x002B8802, 0x002BC002, ++ 0x002C0403, 0x002CF001, 0x002CF807, 0x002D1C02, 0x002D2C03, ++ 0x002D5802, 0x002D8802, 0x002DC001, 0x002E0801, 0x002EF805, ++ 0x002F1803, 0x002F2804, 0x002F5C01, 0x002FCC08, 0x00300004, ++ 0x0030F807, 0x00311803, 0x00312804, 0x00315402, 0x00318802, ++ 0x0031FC01, 0x00320403, 0x0032F001, 0x0032F807, 0x00331803, ++ 0x00332804, 0x00335402, 0x00338802, 0x00340403, 0x0034F807, ++ 0x00351803, 0x00352804, 0x00353C01, 0x00355C01, 0x00358802, ++ 0x0035E401, 0x00360802, 0x00372801, 0x00373C06, 0x00375801, ++ 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007, 0x0038FC01, ++ 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006, 0x003AEC02, ++ 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417, 0x003E340B, ++ 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14, 0x00412806, ++ 0x00415804, 0x00417803, 0x00418803, 0x00419C07, 0x0041C404, ++ 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01, 0x004D740C, ++ 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001, 0x005A6C02, ++ 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802, 0x005DC802, ++ 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F, 0x00621402, + 0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002, - 0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802, - 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006, - 0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D, @@ -19711,8 +28494,16 @@ - 0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403, - 0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805, - 0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04, -- 0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401, -- 0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005, ++ 0x00677822, 0x00685C05, 0x00687802, 0x0069540A, 0x0069801D, ++ 0x0069FC01, 0x006A8007, 0x006AA006, 0x006AC00F, 0x006C0005, ++ 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D, 0x006F980E, ++ 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802, 0x00730008, ++ 0x00734019, 0x0073B401, 0x0073C803, 0x0073E002, 0x00770036, ++ 0x0077EC05, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403, ++ 0x007FB403, 0x007FF402, 0x00800065, 0x0081980A, 0x0081E805, ++ 0x00822805, 0x0082801F, 0x00834021, 0x00840002, 0x00840C04, + 0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401, + 0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005, - 0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B, - 0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A, - 0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001, @@ -19730,83 +28521,58 @@ - 0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803, - 0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07, - 0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02, -+ 0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163403, -+ 0x00164437, 0x0017CC02, 0x0018001D, 0x00187802, 0x00192C15, -+ 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F, 0x001B9C07, -+ 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401, 0x001CC01B, -+ 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804, 0x00206C09, -+ 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403, 0x00217801, -+ 0x00238C21, 0x0024E803, 0x0024F812, 0x00254407, 0x00258804, -+ 0x0025C001, 0x00260403, 0x0026F001, 0x0026F807, 0x00271C02, -+ 0x00272C03, 0x00275C01, 0x00278802, 0x0027C802, 0x0027E802, -+ 0x00280403, 0x0028F001, 0x0028F805, 0x00291C02, 0x00292C03, -+ 0x00294401, 0x0029C002, 0x0029D401, 0x002A0403, 0x002AF001, -+ 0x002AF808, 0x002B1C03, 0x002B2C03, 0x002B8802, 0x002BC002, -+ 0x002C0403, 0x002CF001, 0x002CF807, 0x002D1C02, 0x002D2C03, -+ 0x002D5802, 0x002D8802, 0x002DC001, 0x002E0801, 0x002EF805, -+ 0x002F1803, 0x002F2804, 0x002F5C01, 0x002FCC08, 0x00300004, -+ 0x0030F807, 0x00311803, 0x00312804, 0x00315402, 0x00318802, -+ 0x0031FC01, 0x00320403, 0x0032F001, 0x0032F807, 0x00331803, -+ 0x00332804, 0x00335402, 0x00338802, 0x00340403, 0x0034F807, -+ 0x00351803, 0x00352804, 0x00355C01, 0x00358802, 0x0035E401, -+ 0x00360802, 0x00372801, 0x00373C06, 0x00375801, 0x00376008, -+ 0x0037C803, 0x0038C401, 0x0038D007, 0x0038FC01, 0x00391C09, -+ 0x00396802, 0x003AC401, 0x003AD006, 0x003AEC02, 0x003B2006, -+ 0x003C041F, 0x003CD00C, 0x003DC417, 0x003E340B, 0x003E6424, -+ 0x003EF80F, 0x003F380D, 0x0040AC14, 0x00412806, 0x00415804, -+ 0x00417803, 0x00418803, 0x00419C07, 0x0041C404, 0x0042080C, -+ 0x00423C01, 0x00426806, 0x0043EC01, 0x004D740C, 0x004E400A, -+ 0x00500001, 0x0059B402, 0x005A0001, 0x005A6C02, 0x005BAC03, -+ 0x005C4803, 0x005CC805, 0x005D4802, 0x005DC802, 0x005ED023, -+ 0x005F6004, 0x005F7401, 0x0060000F, 0x0062A401, 0x0064800C, -+ 0x0064C00C, 0x00650001, 0x00651002, 0x00677822, 0x00685C05, -+ 0x00687802, 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, -+ 0x006AA006, 0x006AC00F, 0x006C0005, 0x006CD011, 0x006D6823, -+ 0x006E0003, 0x006E840D, 0x006F980E, 0x006FF004, 0x00709014, -+ 0x0070EC05, 0x0071F802, 0x00730008, 0x00734019, 0x0073B401, -+ 0x0073C803, 0x0073E002, 0x00770036, 0x0077F004, 0x007EF401, -+ 0x007EFC03, 0x007F3403, 0x007F7403, 0x007FB403, 0x007FF402, -+ 0x00800065, 0x0081980A, 0x0081E805, 0x00822805, 0x0082801F, -+ 0x00834021, 0x00840002, 0x00840C04, 0x00842002, 0x00845001, -+ 0x00845803, 0x00847806, 0x00849401, 0x00849C01, 0x0084A401, -+ 0x0084B801, 0x0084E802, 0x00850005, 0x00852804, 0x00853C01, -+ 0x00862802, 0x0086426B, 0x00900027, 0x0091000B, 0x0092704E, -+ 0x00940276, 0x009E53E0, 0x00ADD820, 0x00AE6022, 0x00AEF40C, -+ 0x00AF2808, 0x00AFB004, 0x00B39406, 0x00B3BC03, 0x00B3E404, -+ 0x00B3F802, 0x00B5C001, 0x00B5FC01, 0x00B7804F, 0x00B8C013, -+ 0x00BA001A, 0x00BA6C59, 0x00BC00D6, 0x00BFC00C, 0x00C00005, -+ 0x00C02019, 0x00C0A807, 0x00C0D802, 0x00C0F403, 0x00C26404, -+ 0x00C28001, 0x00C3EC01, 0x00C64002, 0x00C6580A, 0x00C70024, -+ 0x00C8001F, 0x00C8A81E, 0x00C94001, 0x00C98020, 0x00CA2827, -+ 0x00CB003F, 0x00CC0100, 0x01370040, 0x02924037, 0x0293F802, -+ 0x02983403, 0x0299BC10, 0x029A7802, 0x029BC008, 0x029C0017, -+ 0x029C8002, 0x029E2402, 0x02A00801, 0x02A01801, 0x02A02C01, -+ 0x02A08C09, 0x02A0D804, 0x02A1D004, 0x02A20002, 0x02A2D011, -+ 0x02A33802, 0x02A38012, 0x02A3E003, 0x02A3F001, 0x02A4980A, -+ 0x02A51C0D, 0x02A57C01, 0x02A60004, 0x02A6CC1B, 0x02A77802, -+ 0x02A79401, 0x02A8A40E, 0x02A90C01, 0x02A93002, 0x02A97004, -+ 0x02A9DC03, 0x02A9EC03, 0x02AAC001, 0x02AAC803, 0x02AADC02, -+ 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07, 0x02ABD402, -+ 0x02AD6C01, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02, - 0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802, +- 0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802, - 0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013, - 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06, - 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003, - 0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01, - 0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403, -+ 0x03F7F002, 0x03F8001A, 0x03F88033, 0x03F95013, 0x03F9A004, -+ 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06, 0x03FD6C0B, -+ 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003, 0x0404DC09, -+ 0x0405E411, 0x04063001, 0x0406400C, 0x04068001, 0x0407402E, -+ 0x040B8001, 0x040DD805, 0x040E7C01, 0x040F4001, 0x0415BC01, -+ 0x04215C01, 0x0421DC02, 0x04247C01, 0x0424FC01, 0x04280403, - 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009, +- 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009, - 0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003, - 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003, - 0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E, - 0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046, -- 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401, -- 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401, ++ 0x00852804, 0x00853C01, 0x00862802, 0x0086426F, 0x00900027, ++ 0x0091000B, 0x0092704E, 0x00940276, 0x009E53E0, 0x00ADD820, ++ 0x00AE6022, 0x00AEF40C, 0x00AF2808, 0x00AFB004, 0x00B39406, ++ 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001, 0x00B5FC01, ++ 0x00B7804F, 0x00B8C015, 0x00BA001A, 0x00BA6C59, 0x00BC00D6, ++ 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807, 0x00C0D802, ++ 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01, 0x00C64002, ++ 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E, 0x00C94001, ++ 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100, 0x01370040, ++ 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10, 0x029A7802, ++ 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402, 0x02A00801, ++ 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804, 0x02A1D004, ++ 0x02A20002, 0x02A2D012, 0x02A33802, 0x02A38012, 0x02A3E003, ++ 0x02A3F001, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004, ++ 0x02A6CC1B, 0x02A77802, 0x02A79401, 0x02A8A40E, 0x02A90C01, ++ 0x02A93002, 0x02A97004, 0x02A9DC03, 0x02A9EC03, 0x02AAC001, ++ 0x02AAC803, 0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, ++ 0x02ABAC07, 0x02ABD402, 0x02AD6C01, 0x02AF8C0B, 0x03600001, ++ 0x036DFC02, 0x036FFC02, 0x037FFC01, 0x03EC7801, 0x03ECA401, ++ 0x03EEC810, 0x03F4F802, 0x03F7F002, 0x03F8001A, 0x03F88033, ++ 0x03F95013, 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, ++ 0x03FCEC06, 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, ++ 0x04040003, 0x0404DC09, 0x0405E411, 0x04063003, 0x0406400C, ++ 0x04068001, 0x0407402E, 0x040B8001, 0x040DD805, 0x040E7C01, ++ 0x040F4001, 0x0415BC01, 0x04215C01, 0x0421DC02, 0x04247C01, ++ 0x0424FC01, 0x04280403, 0x04281402, 0x04283004, 0x0428E003, ++ 0x0428FC01, 0x04294009, 0x0429FC01, 0x042B2001, 0x042B9402, ++ 0x042BC007, 0x042CE407, 0x042E6404, 0x04400003, 0x0440E016, ++ 0x0441FC04, 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, ++ 0x0445CC03, 0x04460003, 0x0446CC0E, 0x04471409, 0x04476C01, ++ 0x04477403, 0x0448B013, 0x044AA401, 0x044B7C0C, 0x044C0004, ++ 0x044CF001, 0x044CF807, 0x044D1C02, 0x044D2C03, 0x044D5C01, ++ 0x044D8802, 0x044D9807, 0x044DC005, 0x0450D412, 0x04512C05, ++ 0x04516C01, 0x04517401, 0x0452C014, 0x04531801, 0x0456BC07, ++ 0x0456E020, 0x04577002, 0x0458C014, 0x0459800D, 0x045AAC0D, ++ 0x045C740F, 0x045CF004, 0x0470BC08, 0x0470E008, 0x04710405, ++ 0x0471C002, 0x04724816, 0x0472A40E, 0x0491C005, 0x05A9B802, ++ 0x05ABC006, 0x05ACC010, 0x05AD1002, 0x05BD442E, 0x05BE3C04, ++ 0x06F27008, 0x074000F6, 0x07440027, 0x0744A4C0, 0x07480046, + 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401, + 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401, - 0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F, - 0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C, - 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002, @@ -19815,30 +28581,20 @@ - 0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46, - 0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060, - 0x380400F0, -+ 0x0429FC01, 0x042B2001, 0x042B9402, 0x042BC007, 0x042CE407, -+ 0x042E6404, 0x04400003, 0x0440E016, 0x0441FC04, 0x0442C012, -+ 0x04440003, 0x04449C0E, 0x04450004, 0x0445CC03, 0x04460003, -+ 0x0446CC0E, 0x04471409, 0x04476C01, 0x04477403, 0x0448B012, -+ 0x044AA401, 0x044B7C0C, 0x044C0004, 0x044CF001, 0x044CF807, -+ 0x044D1C02, 0x044D2C03, 0x044D5C01, 0x044D8802, 0x044D9807, -+ 0x044DC005, 0x0452C014, 0x04531801, 0x0456BC07, 0x0456E020, -+ 0x04577002, 0x0458C014, 0x045AAC0D, 0x045C740F, 0x045CF004, -+ 0x0491C005, 0x05A9B802, 0x05ABC006, 0x05ACC010, 0x05AD1002, -+ 0x05BD442E, 0x05BE3C04, 0x06F27008, 0x074000F6, 0x07440027, -+ 0x0744A4C0, 0x07480046, 0x074C0057, 0x075B0401, 0x075B6C01, -+ 0x075BEC01, 0x075C5401, 0x075CD401, 0x075D3C01, 0x075DBC01, -+ 0x075E2401, 0x075EA401, 0x075F0C01, 0x0760028C, 0x076A6C05, -+ 0x076A840F, 0x07A34007, 0x07BBC002, 0x07C0002C, 0x07C0C064, ++ 0x075F0C01, 0x0760028C, 0x076A6C05, 0x076A840F, 0x07800007, ++ 0x07802011, 0x07806C07, 0x07808C02, 0x07809805, 0x07A34007, ++ 0x07A51007, 0x07A57802, 0x07BBC002, 0x07C0002C, 0x07C0C064, + 0x07C2800F, 0x07C2C40F, 0x07C3040F, 0x07C34425, 0x07C4401F, -+ 0x07C4C03C, 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, -+ 0x07C94002, 0x07CC027A, 0x07D5EC29, 0x07D6952C, 0x07DB800D, -+ 0x07DBC004, 0x07DC0074, 0x07DE0055, 0x07E0000C, 0x07E04038, -+ 0x07E1400A, 0x07E18028, 0x07E2401E, 0x07E44009, 0x07E60005, -+ 0x07E70001, 0x38000401, 0x38008060, 0x380400F0, ++ 0x07C4C03C, 0x07C5C03D, 0x07C7981D, 0x07C8402C, 0x07C90009, ++ 0x07C94002, 0x07CC03D3, 0x07DB800D, 0x07DBC007, 0x07DC0074, ++ 0x07DE0055, 0x07E0000C, 0x07E04038, 0x07E1400A, 0x07E18028, ++ 0x07E2401E, 0x07E4400F, 0x07E48008, 0x07E4C001, 0x07E4CC0C, ++ 0x07E5000C, 0x07E5400F, 0x07E60012, 0x07E70001, 0x38000401, ++ 0x38008060, 0x380400F0, }; static const unsigned int aAscii[4] = { 0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001, -@@ -155190,7 +155782,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal +@@ -163273,7 +164010,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsal ** uppercase letter are undefined. */ static int remove_diacritic(int c){ @@ -19847,7 +28603,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, -@@ -155205,7 +155797,7 @@ static int remove_diacritic(int c){ +@@ -163288,7 +164025,7 @@ static int remove_diacritic(int c){ 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62924, 63050, 63082, 63274, 63390, }; @@ -19856,7 +28612,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', -@@ -155239,7 +155831,7 @@ static int remove_diacritic(int c){ +@@ -163322,7 +164059,7 @@ static int remove_diacritic(int c){ ** Return true if the argument interpreted as a unicode codepoint ** is a diacritical modifier character. */ @@ -19865,7 +28621,7 @@ unsigned int mask0 = 0x08029FDF; unsigned int mask1 = 0x000361F8; if( c<768 || c>817 ) return 0; -@@ -155258,7 +155850,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdi +@@ -163341,7 +164078,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdi ** The results are undefined if the value passed to this function ** is less than zero. */ @@ -19874,18 +28630,35 @@ /* Each entry in the following array defines a rule for folding a range ** of codepoints to lower case. The rule applies to a range of nRange ** codepoints starting at codepoint iCode. -@@ -155283,8 +155875,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +@@ -163364,73 +164101,81 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold + unsigned char flags; + unsigned char nRange; } aEntry[] = { - {65, 14, 26}, {181, 64, 1}, {192, 14, 23}, +- {65, 14, 26}, {181, 64, 1}, {192, 14, 23}, ++ {65, 14, 26}, {181, 66, 1}, {192, 14, 23}, {216, 14, 7}, {256, 1, 48}, {306, 1, 6}, - {313, 1, 16}, {330, 1, 46}, {376, 116, 1}, - {377, 1, 6}, {383, 104, 1}, {385, 50, 1}, -+ {313, 1, 16}, {330, 1, 46}, {376, 132, 1}, -+ {377, 1, 6}, {383, 120, 1}, {385, 50, 1}, - {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}, -@@ -155297,52 +155889,56 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +- {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}, +- {403, 42, 1}, {404, 46, 1}, {406, 52, 1}, +- {407, 48, 1}, {408, 0, 1}, {412, 52, 1}, +- {413, 54, 1}, {415, 56, 1}, {416, 1, 6}, +- {422, 60, 1}, {423, 0, 1}, {425, 60, 1}, +- {428, 0, 1}, {430, 60, 1}, {431, 0, 1}, +- {433, 58, 2}, {435, 1, 4}, {439, 62, 1}, ++ {313, 1, 16}, {330, 1, 46}, {376, 150, 1}, ++ {377, 1, 6}, {383, 138, 1}, {385, 52, 1}, ++ {386, 1, 4}, {390, 46, 1}, {391, 0, 1}, ++ {393, 44, 2}, {395, 0, 1}, {398, 34, 1}, ++ {399, 40, 1}, {400, 42, 1}, {401, 0, 1}, ++ {403, 44, 1}, {404, 48, 1}, {406, 54, 1}, ++ {407, 50, 1}, {408, 0, 1}, {412, 54, 1}, ++ {413, 56, 1}, {415, 58, 1}, {416, 1, 6}, ++ {422, 62, 1}, {423, 0, 1}, {425, 62, 1}, ++ {428, 0, 1}, {430, 62, 1}, {431, 0, 1}, ++ {433, 60, 2}, {435, 1, 4}, {439, 64, 1}, {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}, @@ -19894,12 +28667,7 @@ - {546, 1, 18}, {570, 70, 1}, {571, 0, 1}, - {573, 108, 1}, {574, 68, 1}, {577, 0, 1}, - {579, 106, 1}, {580, 28, 1}, {581, 30, 1}, -+ {497, 2, 1}, {498, 1, 4}, {502, 138, 1}, -+ {503, 150, 1}, {504, 1, 40}, {544, 126, 1}, -+ {546, 1, 18}, {570, 72, 1}, {571, 0, 1}, -+ {573, 124, 1}, {574, 70, 1}, {577, 0, 1}, -+ {579, 122, 1}, {580, 28, 1}, {581, 30, 1}, - {582, 1, 10}, {837, 36, 1}, {880, 1, 4}, +- {582, 1, 10}, {837, 36, 1}, {880, 1, 4}, - {886, 0, 1}, {902, 18, 1}, {904, 16, 3}, - {908, 26, 1}, {910, 24, 2}, {913, 14, 17}, - {931, 14, 9}, {962, 0, 1}, {975, 4, 1}, @@ -19933,63 +28701,92 @@ - {42878, 1, 10}, {42891, 0, 1}, {42893, 74, 1}, - {42896, 1, 4}, {42912, 1, 10}, {42922, 72, 1}, - {65313, 14, 26}, -+ {886, 0, 1}, {895, 36, 1}, {902, 18, 1}, -+ {904, 16, 3}, {908, 26, 1}, {910, 24, 2}, ++ {497, 2, 1}, {498, 1, 4}, {502, 156, 1}, ++ {503, 168, 1}, {504, 1, 40}, {544, 144, 1}, ++ {546, 1, 18}, {570, 74, 1}, {571, 0, 1}, ++ {573, 142, 1}, {574, 72, 1}, {577, 0, 1}, ++ {579, 140, 1}, {580, 30, 1}, {581, 32, 1}, ++ {582, 1, 10}, {837, 38, 1}, {880, 1, 4}, ++ {886, 0, 1}, {895, 38, 1}, {902, 20, 1}, ++ {904, 18, 3}, {908, 28, 1}, {910, 26, 2}, + {913, 14, 17}, {931, 14, 9}, {962, 0, 1}, -+ {975, 4, 1}, {976, 156, 1}, {977, 158, 1}, -+ {981, 162, 1}, {982, 160, 1}, {984, 1, 24}, -+ {1008, 152, 1}, {1009, 154, 1}, {1012, 146, 1}, -+ {1013, 144, 1}, {1015, 0, 1}, {1017, 168, 1}, -+ {1018, 0, 1}, {1021, 126, 3}, {1024, 34, 16}, ++ {975, 4, 1}, {976, 174, 1}, {977, 176, 1}, ++ {981, 180, 1}, {982, 178, 1}, {984, 1, 24}, ++ {1008, 170, 1}, {1009, 172, 1}, {1012, 164, 1}, ++ {1013, 162, 1}, {1015, 0, 1}, {1017, 186, 1}, ++ {1018, 0, 1}, {1021, 144, 3}, {1024, 36, 16}, + {1040, 14, 32}, {1120, 1, 34}, {1162, 1, 54}, + {1216, 6, 1}, {1217, 1, 14}, {1232, 1, 96}, -+ {1329, 22, 38}, {4256, 68, 38}, {4295, 68, 1}, -+ {4301, 68, 1}, {5112, 166, 6}, {7680, 1, 150}, -+ {7835, 148, 1}, {7838, 112, 1}, {7840, 1, 96}, -+ {7944, 166, 8}, {7960, 166, 6}, {7976, 166, 8}, -+ {7992, 166, 8}, {8008, 166, 6}, {8025, 167, 8}, -+ {8040, 166, 8}, {8072, 166, 8}, {8088, 166, 8}, -+ {8104, 166, 8}, {8120, 166, 2}, {8122, 142, 2}, -+ {8124, 164, 1}, {8126, 116, 1}, {8136, 140, 4}, -+ {8140, 164, 1}, {8152, 166, 2}, {8154, 136, 2}, -+ {8168, 166, 2}, {8170, 134, 2}, {8172, 168, 1}, -+ {8184, 128, 2}, {8186, 130, 2}, {8188, 164, 1}, -+ {8486, 114, 1}, {8490, 108, 1}, {8491, 110, 1}, -+ {8498, 12, 1}, {8544, 8, 16}, {8579, 0, 1}, -+ {9398, 10, 26}, {11264, 22, 47}, {11360, 0, 1}, -+ {11362, 104, 1}, {11363, 118, 1}, {11364, 106, 1}, -+ {11367, 1, 6}, {11373, 100, 1}, {11374, 102, 1}, -+ {11375, 96, 1}, {11376, 98, 1}, {11378, 0, 1}, -+ {11381, 0, 1}, {11390, 94, 2}, {11392, 1, 100}, -+ {11499, 1, 4}, {11506, 0, 1}, {42560, 1, 46}, -+ {42624, 1, 28}, {42786, 1, 14}, {42802, 1, 62}, -+ {42873, 1, 4}, {42877, 92, 1}, {42878, 1, 10}, -+ {42891, 0, 1}, {42893, 84, 1}, {42896, 1, 4}, -+ {42902, 1, 20}, {42922, 78, 1}, {42923, 74, 1}, -+ {42924, 76, 1}, {42925, 80, 1}, {42928, 88, 1}, -+ {42929, 82, 1}, {42930, 86, 1}, {42931, 66, 1}, -+ {42932, 1, 4}, {43888, 90, 80}, {65313, 14, 26}, ++ {1329, 24, 38}, {4256, 70, 38}, {4295, 70, 1}, ++ {4301, 70, 1}, {5112, 184, 6}, {7296, 122, 1}, ++ {7297, 124, 1}, {7298, 126, 1}, {7299, 130, 2}, ++ {7301, 128, 1}, {7302, 132, 1}, {7303, 134, 1}, ++ {7304, 96, 1}, {7680, 1, 150}, {7835, 166, 1}, ++ {7838, 116, 1}, {7840, 1, 96}, {7944, 184, 8}, ++ {7960, 184, 6}, {7976, 184, 8}, {7992, 184, 8}, ++ {8008, 184, 6}, {8025, 185, 8}, {8040, 184, 8}, ++ {8072, 184, 8}, {8088, 184, 8}, {8104, 184, 8}, ++ {8120, 184, 2}, {8122, 160, 2}, {8124, 182, 1}, ++ {8126, 120, 1}, {8136, 158, 4}, {8140, 182, 1}, ++ {8152, 184, 2}, {8154, 154, 2}, {8168, 184, 2}, ++ {8170, 152, 2}, {8172, 186, 1}, {8184, 146, 2}, ++ {8186, 148, 2}, {8188, 182, 1}, {8486, 118, 1}, ++ {8490, 112, 1}, {8491, 114, 1}, {8498, 12, 1}, ++ {8544, 8, 16}, {8579, 0, 1}, {9398, 10, 26}, ++ {11264, 24, 47}, {11360, 0, 1}, {11362, 108, 1}, ++ {11363, 136, 1}, {11364, 110, 1}, {11367, 1, 6}, ++ {11373, 104, 1}, {11374, 106, 1}, {11375, 100, 1}, ++ {11376, 102, 1}, {11378, 0, 1}, {11381, 0, 1}, ++ {11390, 98, 2}, {11392, 1, 100}, {11499, 1, 4}, ++ {11506, 0, 1}, {42560, 1, 46}, {42624, 1, 28}, ++ {42786, 1, 14}, {42802, 1, 62}, {42873, 1, 4}, ++ {42877, 94, 1}, {42878, 1, 10}, {42891, 0, 1}, ++ {42893, 86, 1}, {42896, 1, 4}, {42902, 1, 20}, ++ {42922, 80, 1}, {42923, 76, 1}, {42924, 78, 1}, ++ {42925, 82, 1}, {42926, 80, 1}, {42928, 90, 1}, ++ {42929, 84, 1}, {42930, 88, 1}, {42931, 68, 1}, ++ {42932, 1, 4}, {43888, 92, 80}, {65313, 14, 26}, }; static const unsigned short aiOff[] = { 1, 2, 8, 15, 16, 26, 28, 32, - 37, 38, 40, 48, 63, 64, 69, 71, - 79, 80, 116, 202, 203, 205, 206, 207, - 209, 210, 211, 213, 214, 217, 218, 219, +- 37, 38, 40, 48, 63, 64, 69, 71, +- 79, 80, 116, 202, 203, 205, 206, 207, +- 209, 210, 211, 213, 214, 217, 218, 219, - 775, 7264, 10792, 10795, 23228, 23256, 30204, 54721, -+ 775, 928, 7264, 10792, 10795, 23217, 23221, 23228, -+ 23231, 23254, 23256, 23275, 23278, 26672, 30204, 54721, - 54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, - 57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, - 65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, -@@ -155388,10 +155984,17 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold +- 54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, +- 57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, +- 65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, +- 65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, +- 65514, 65521, 65527, 65528, 65529, ++ 34, 37, 38, 40, 48, 63, 64, 69, ++ 71, 79, 80, 116, 202, 203, 205, 206, ++ 207, 209, 210, 211, 213, 214, 217, 218, ++ 219, 775, 928, 7264, 10792, 10795, 23217, 23221, ++ 23228, 23231, 23254, 23256, 23275, 23278, 26672, 30204, ++ 35267, 54721, 54753, 54754, 54756, 54787, 54793, 54809, ++ 57153, 57274, 57921, 58019, 58363, 59314, 59315, 59324, ++ 59325, 59326, 59332, 59356, 61722, 65268, 65341, 65373, ++ 65406, 65408, 65410, 65415, 65424, 65436, 65439, 65450, ++ 65462, 65472, 65476, 65478, 65480, 65482, 65488, 65506, ++ 65511, 65514, 65521, 65527, 65528, 65529, + }; + + int ret = c; +@@ -163470,10 +164215,23 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold else if( c>=66560 && c<66600 ){ ret = c + 40; } ++ else if( c>=66736 && c<66772 ){ ++ ret = c + 40; ++ } + else if( c>=68736 && c<68787 ){ + ret = c + 64; + } + else if( c>=71840 && c<71872 ){ + ret = c + 32; ++ } ++ else if( c>=125184 && c<125218 ){ ++ ret = c + 34; + } return ret; @@ -19999,16 +28796,16 @@ #endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */ /************** End of fts3_unicode2.c ***************************************/ -@@ -155931,7 +156534,7 @@ static int nodeAcquire( - rc = sqlite3_step(pRtree->pReadNode); - if( rc==SQLITE_ROW ){ - const u8 *zBlob = sqlite3_column_blob(pRtree->pReadNode, 0); -- if( pRtree->iNodeSize==sqlite3_column_bytes(pRtree->pReadNode, 0) ){ -+ if( pRtree->iNodeSize==(int)sqlite3_column_bytes(pRtree->pReadNode, 0) ){ - pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize); - if( !pNode ){ - rc2 = SQLITE_NOMEM; -@@ -158388,7 +158991,7 @@ static int rtreeQueryStat1(sqlite3 *db, +@@ -165785,7 +166543,7 @@ static int splitNodeStartree( + int iBestSplit = 0; + RtreeDValue fBestMargin = RTREE_ZERO; + +- int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int)); ++ size_t nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int)); + + aaSorted = (int **)sqlite3_malloc(nByte); + if( !aaSorted ){ +@@ -166729,7 +167487,7 @@ static int rtreeQueryStat1(sqlite3 *db, return rc; } @@ -20017,25 +28814,16 @@ 0, /* iVersion */ rtreeCreate, /* xCreate - create a table */ rtreeConnect, /* xConnect - connect to an existing table */ -@@ -158424,7 +159027,7 @@ static int rtreeSqlInit( +@@ -166765,7 +167523,7 @@ static int rtreeSqlInit( int rc = SQLITE_OK; - #define N_STATEMENT 9 + #define N_STATEMENT 8 - static const char *azSql[N_STATEMENT] = { + static const char *const azSql[N_STATEMENT] = { - /* Read and write the xxx_node table */ - "SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1", + /* Write the xxx_node table */ "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)", -@@ -158863,7 +159466,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_rt - pGeomCtx->xQueryFunc = 0; - pGeomCtx->xDestructor = 0; - pGeomCtx->pContext = pContext; -- return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, -+ return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_UTF8, - (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback - ); - } -@@ -159090,7 +159693,7 @@ static void icuLikeFunc( + "DELETE FROM '%q'.'%q_node' WHERE nodeno = :1", +@@ -167461,7 +168219,7 @@ static void icuLikeFunc( /* The escape character string must consist of a single UTF-8 character. ** Otherwise, return an error. */ @@ -20044,43 +28832,36 @@ const unsigned char *zE = sqlite3_value_text(argv[2]); int i = 0; if( zE==0 ) return; -@@ -159239,8 +159842,8 @@ static void icuRegexpFunc(sqlite3_contex +@@ -167610,8 +168368,8 @@ static void icuRegexpFunc(sqlite3_contex static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){ - const UChar *zInput; - UChar *zOutput; -- int nInput; -- int nOutput; -+ size_t nInput; -+ size_t nOutput; - - UErrorCode status = U_ZERO_ERROR; - const char *zLocale = 0; -@@ -159369,7 +159972,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite - void *pContext; /* sqlite3_user_data() context */ - void (*xFunc)(sqlite3_context*,int,sqlite3_value**); - } scalars[] = { -- {"regexp", 2, SQLITE_ANY, 0, icuRegexpFunc}, -+ {"regexp", 2, SQLITE_UTF8, 0, icuRegexpFunc}, - - {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16}, - {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16}, -@@ -159392,8 +159995,8 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite - + const UChar *zInput; /* Pointer to input string */ + UChar *zOutput = 0; /* Pointer to output buffer */ +- int nInput; /* Size of utf-16 input string in bytes */ +- int nOut; /* Size of output buffer in bytes */ ++ size_t nInput; /* Size of utf-16 input string in bytes */ ++ size_t nOut; /* Size of output buffer in bytes */ + int cnt; + int bToUpper; /* True for toupper(), false for tolower() */ + UErrorCode status; +@@ -167773,10 +168531,10 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite + for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){ - struct IcuScalar *p = &scalars[i]; + const 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 + db, p->zName, p->nArg, p->enc, + p->iContext ? (void*)db : (void*)0, +- p->xFunc, 0, 0 ++ p->xFunc, 0, 0, 0 ); } -@@ -159412,6 +160015,16 @@ SQLITE_API int SQLITE_STDCALL sqlite3_ic +@@ -167795,6 +168553,16 @@ SQLITE_API int sqlite3_icu_init( SQLITE_EXTENSION_INIT2(pApi) return sqlite3IcuInit(db); } +#if !defined(_WIN32) && !defined(SQLITE_TEST) -+SQLITE_API int SQLITE_STDCALL sqlite3_extension_init( ++SQLITE_API int sqlite3_extension_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi @@ -20092,43 +28873,153 @@ #endif #endif -@@ -164371,7 +164984,7 @@ static int statConnect( +@@ -169660,7 +170428,7 @@ static void *rbuMalloc(sqlite3rbu *p, in + void *pRet = 0; + if( p->rc==SQLITE_OK ){ + assert( nByte>0 ); +- pRet = sqlite3_malloc64(nByte); ++ pRet = sqlite3_malloc(nByte); + if( pRet==0 ){ + p->rc = SQLITE_NOMEM; + }else{ +@@ -169707,7 +170475,7 @@ static char *rbuStrndup(const char *zStr + assert( *pRc==SQLITE_OK ); + if( zStr ){ + size_t nCopy = strlen(zStr) + 1; +- zRet = (char*)sqlite3_malloc64(nCopy); ++ zRet = (char*)sqlite3_malloc(nCopy); + if( zRet ){ + memcpy(zRet, zStr, nCopy); + }else{ +@@ -171311,7 +172079,7 @@ static int rbuCaptureWalRead(sqlite3rbu + if( pRbu->nFrame==pRbu->nFrameAlloc ){ + int nNew = (pRbu->nFrameAlloc ? pRbu->nFrameAlloc : 64) * 2; + RbuFrame *aNew; +- aNew = (RbuFrame*)sqlite3_realloc64(pRbu->aFrame, nNew * sizeof(RbuFrame)); ++ aNew = (RbuFrame*)sqlite3_realloc(pRbu->aFrame, nNew * sizeof(RbuFrame)); + if( aNew==0 ) return SQLITE_NOMEM; + pRbu->aFrame = aNew; + pRbu->nFrameAlloc = nNew; +@@ -171376,7 +172144,7 @@ static LPWSTR rbuWinUtf8ToUnicode(const + if( nChar==0 ){ + return 0; + } +- zWideFilename = sqlite3_malloc64( nChar*sizeof(zWideFilename[0]) ); ++ zWideFilename = sqlite3_malloc( nChar*sizeof(zWideFilename[0]) ); + if( zWideFilename==0 ){ + return 0; + } +@@ -172179,7 +172947,7 @@ static sqlite3rbu *openRbuHandle( + size_t nRbu = strlen(zRbu); + size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1; + +- p = (sqlite3rbu*)sqlite3_malloc64(nByte); ++ p = (sqlite3rbu*)sqlite3_malloc(nByte); + if( p ){ + RbuState *pState = 0; + +@@ -172327,7 +173095,7 @@ static sqlite3rbu *openRbuHandle( + */ + static sqlite3rbu *rbuMisuseError(void){ + sqlite3rbu *pRet; +- pRet = sqlite3_malloc64(sizeof(sqlite3rbu)); ++ pRet = sqlite3_malloc(sizeof(sqlite3rbu)); + if( pRet ){ + memset(pRet, 0, sizeof(sqlite3rbu)); + pRet->rc = SQLITE_MISUSE; +@@ -172998,8 +173766,8 @@ static int rbuVfsShmMap( + assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) ); + if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){ + if( iRegion<=p->nShm ){ +- int nByte = (iRegion+1) * sizeof(char*); +- char **apNew = (char**)sqlite3_realloc64(p->apShm, nByte); ++ size_t nByte = (iRegion+1) * sizeof(char*); ++ char **apNew = (char**)sqlite3_realloc(p->apShm, nByte); + if( apNew==0 ){ + rc = SQLITE_NOMEM; + }else{ +@@ -173010,7 +173778,7 @@ static int rbuVfsShmMap( + } + + if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){ +- char *pNew = (char*)sqlite3_malloc64(szRegion); ++ char *pNew = (char*)sqlite3_malloc(szRegion); + if( pNew==0 ){ + rc = SQLITE_NOMEM; + }else{ +@@ -173166,7 +173934,7 @@ static int rbuVfsOpen( + zBase = rbuMainToWal(zBase, SQLITE_OPEN_URI); + } + nCopy = strlen(zBase); +- zCopy = sqlite3_malloc64(nCopy+2); ++ zCopy = sqlite3_malloc(nCopy+2); + if( zCopy ){ + memcpy(zCopy, zBase, nCopy); + zCopy[nCopy-3] = 'o'; +@@ -173410,7 +174178,7 @@ SQLITE_API int sqlite3rbu_create_vfs(con + + nName = strlen(zName); + nByte = sizeof(rbu_vfs) + nName + 1; +- pNew = (rbu_vfs*)sqlite3_malloc64(nByte); ++ pNew = (rbu_vfs*)sqlite3_malloc(nByte); + if( pNew==0 ){ + rc = SQLITE_NOMEM; + }else{ +@@ -173570,7 +174338,7 @@ struct StatCursor { + char *zName; /* Value of 'name' column */ + char *zPath; /* Value of 'path' column */ + u32 iPageno; /* Value of 'pageno' column */ +- char *zPagetype; /* Value of 'pagetype' column */ ++ const char *zPagetype; /* Value of 'pagetype' column */ + int nCell; /* Value of 'ncell' column */ + int nPayload; /* Value of 'payload' column */ + int nUnused; /* Value of 'unused' column */ +@@ -173616,7 +174384,7 @@ static int statConnect( } rc = sqlite3_declare_vtab(db, VTAB_SCHEMA); if( rc==SQLITE_OK ){ - pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable)); + pTab = (StatTable *)sqlite3Malloc(sizeof(StatTable)); - if( pTab==0 ) rc = SQLITE_NOMEM; + if( pTab==0 ) rc = SQLITE_NOMEM_BKPT; } -@@ -164451,7 +165064,7 @@ static int statOpen(sqlite3_vtab *pVTab, +@@ -173696,7 +174464,7 @@ static int statOpen(sqlite3_vtab *pVTab, StatTable *pTab = (StatTable *)pVTab; StatCursor *pCsr; - pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor)); + pCsr = (StatCursor *)sqlite3Malloc(sizeof(StatCursor)); if( pCsr==0 ){ - return SQLITE_NOMEM; + return SQLITE_NOMEM_BKPT; }else{ -@@ -164558,7 +165171,7 @@ static int statDecodePage(Btree *pBt, St +@@ -173803,7 +174571,7 @@ static int statDecodePage(Btree *pBt, St sqlite3BtreeEnter(pBt); nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt); sqlite3BtreeLeave(pBt); - p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell)); + p->aCell = sqlite3Malloc((p->nCell+1) * sizeof(StatCell)); - if( p->aCell==0 ) return SQLITE_NOMEM; + if( p->aCell==0 ) return SQLITE_NOMEM_BKPT; memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell)); -@@ -164591,7 +165204,7 @@ static int statDecodePage(Btree *pBt, St +@@ -173836,7 +174604,7 @@ static int statDecodePage(Btree *pBt, St int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4); pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4); pCell->nOvfl = nOvfl; - pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl); + pCell->aOvfl = sqlite3Malloc(sizeof(u32)*nOvfl); - if( pCell->aOvfl==0 ) return SQLITE_NOMEM; + if( pCell->aOvfl==0 ) return SQLITE_NOMEM_BKPT; pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]); for(j=1; jpVtab); + char *zSql; + int rc = SQLITE_OK; +- char *zMaster; ++ const char *zMaster; + + if( idxNum==1 ){ + const char *zDbase = (const char*)sqlite3_value_text(argv[0]); +@@ -174128,7 +174896,7 @@ static int statRowid(sqlite3_vtab_cursor ** Invoke this routine to register the "dbstat" virtual table module */ SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ @@ -20137,7 +29028,7 @@ 0, /* iVersion */ statConnect, /* xCreate */ statConnect, /* xConnect */ -@@ -164905,7 +165518,7 @@ SQLITE_PRIVATE int sqlite3DbstatRegister +@@ -174150,7 +174918,7 @@ SQLITE_PRIVATE int sqlite3DbstatRegister 0, /* xFindMethod */ 0, /* xRename */ }; @@ -20146,15 +29037,58 @@ } #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } -@@ -164997,7 +165610,6 @@ static const char jsonIsSpace[] = { +@@ -174952,7 +175720,6 @@ static int sessionPreupdateEqual( + a += sessionSerialLen(a); + }else{ + sqlite3_value *pVal; /* Value returned by preupdate_new/old */ +- int rc; /* Error code from preupdate_new/old */ + int eType = *a++; /* Type of value from change record */ + + /* The following calls to preupdate_new() and preupdate_old() can not +@@ -174962,12 +175729,11 @@ static int sessionPreupdateEqual( + ** this (that the method has already been called). */ + if( op==SQLITE_INSERT ){ + /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */ +- rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal); ++ pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal); + }else{ + /* assert( db->pPreUpdate->pUnpacked ); */ +- rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal); ++ pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal); + } +- assert( rc==SQLITE_OK ); + if( sqlite3_value_type(pVal)!=eType ) return 0; + + /* A SessionChange object never has a NULL value in a PK column */ +@@ -174990,7 +175756,7 @@ static int sessionPreupdateEqual( + int n; + const u8 *z; + a += sessionVarintGet(a, &n); +- if( sqlite3_value_bytes(pVal)!=n ) return 0; ++ if( sqlite3_value_bytes(pVal)!=(size_t)n ) return 0; + if( eType==SQLITE_TEXT ){ + z = sqlite3_value_text(pVal); + }else{ +@@ -176141,7 +176907,7 @@ static int sessionAppendUpdate( + assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); + nAdvance = nHdr + n; + if( eType==sqlite3_column_type(pStmt, i) +- && n==sqlite3_column_bytes(pStmt, i) ++ && (size_t)n==sqlite3_column_bytes(pStmt, i) + && (n==0 || 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), n)) + ){ + break; +@@ -178905,8 +179671,8 @@ static const char jsonIsSpace[] = { #ifndef SQLITE_AMALGAMATION /* Unsigned integer types. These are already defined in the sqliteInt.h, ** but the definitions need to be repeated for separate compilation. */ - typedef sqlite3_uint64 u64; typedef unsigned int u32; ++ typedef unsigned short int u16; typedef unsigned char u8; #endif -@@ -165014,8 +165626,8 @@ typedef struct JsonParse JsonParse; + +@@ -178922,8 +179688,8 @@ typedef struct JsonParse JsonParse; struct JsonString { sqlite3_context *pCtx; /* Function context - put error messages here */ char *zBuf; /* Append JSON content here */ @@ -20165,7 +29099,7 @@ u8 bStatic; /* True if zBuf is static space */ u8 bErr; /* True if an error has been encountered */ char zSpace[100]; /* Initial static space */ -@@ -165038,7 +165650,7 @@ struct JsonString { +@@ -178946,7 +179712,7 @@ struct JsonString { /* ** Names of the various JSON types: */ @@ -20174,7 +29108,26 @@ "null", "true", "false", "integer", "real", "text", "array", "object" }; -@@ -165121,11 +165733,11 @@ static void jsonOom(JsonString *p){ +@@ -178986,8 +179752,18 @@ struct JsonParse { + u32 *aUp; /* Index of parent of each node */ + u8 oom; /* Set to true if out of memory */ + u8 nErr; /* Number of errors seen */ ++ u16 iDepth; /* Nesting depth */ + }; + ++/* ++** Maximum nesting depth of JSON for this implementation. ++** ++** This limit is needed to avoid a stack overflow in the recursive ++** descent parser. A depth of 2000 is far deeper than any sane JSON ++** should go. ++*/ ++#define JSON_MAX_DEPTH 2000 ++ + /************************************************************************** + ** Utility routines for dealing with JsonString objects + **************************************************************************/ +@@ -179031,11 +179807,11 @@ static void jsonOom(JsonString *p){ ** Return zero on success. Return non-zero on an OOM error */ static int jsonGrow(JsonString *p, u32 N){ @@ -20188,7 +29141,7 @@ if( zNew==0 ){ jsonOom(p); return SQLITE_NOMEM; -@@ -165134,7 +165746,7 @@ static int jsonGrow(JsonString *p, u32 N +@@ -179044,7 +179820,7 @@ static int jsonGrow(JsonString *p, u32 N p->zBuf = zNew; p->bStatic = 0; }else{ @@ -20197,25 +29150,238 @@ if( zNew==0 ){ jsonOom(p); return SQLITE_NOMEM; -@@ -166872,7 +167484,7 @@ static int jsonEachFilter( +@@ -179544,15 +180320,18 @@ static int jsonParseValue(JsonParse *pPa + int iThis; + int x; + JsonNode *pNode; +- while( safe_isspace(pParse->zJson[i]) ){ i++; } +- if( (c = pParse->zJson[i])=='{' ){ ++ const char *z = pParse->zJson; ++ while( safe_isspace(z[i]) ){ i++; } ++ if( (c = z[i])=='{' ){ + /* Parse object */ + iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); + if( iThis<0 ) return -1; + for(j=i+1;;j++){ +- while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ while( safe_isspace(z[j]) ){ j++; } ++ if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; + x = jsonParseValue(pParse, j); + if( x<0 ){ ++ pParse->iDepth--; + if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; + return -1; + } +@@ -179561,14 +180340,15 @@ static int jsonParseValue(JsonParse *pPa + if( pNode->eType!=JSON_STRING ) return -1; + pNode->jnFlags |= JNODE_LABEL; + j = x; +- while( safe_isspace(pParse->zJson[j]) ){ j++; } +- if( pParse->zJson[j]!=':' ) return -1; ++ while( safe_isspace(z[j]) ){ j++; } ++ if( z[j]!=':' ) return -1; + j++; + x = jsonParseValue(pParse, j); ++ pParse->iDepth--; + if( x<0 ) return -1; + j = x; +- while( safe_isspace(pParse->zJson[j]) ){ j++; } +- c = pParse->zJson[j]; ++ while( safe_isspace(z[j]) ){ j++; } ++ c = z[j]; + if( c==',' ) continue; + if( c!='}' ) return -1; + break; +@@ -179580,15 +180360,17 @@ static int jsonParseValue(JsonParse *pPa + iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); + if( iThis<0 ) return -1; + for(j=i+1;;j++){ +- while( safe_isspace(pParse->zJson[j]) ){ j++; } ++ while( safe_isspace(z[j]) ){ j++; } ++ if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; + x = jsonParseValue(pParse, j); ++ pParse->iDepth--; + if( x<0 ){ + if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; + return -1; + } + j = x; +- while( safe_isspace(pParse->zJson[j]) ){ j++; } +- c = pParse->zJson[j]; ++ while( safe_isspace(z[j]) ){ j++; } ++ c = z[j]; + if( c==',' ) continue; + if( c!=']' ) return -1; + break; +@@ -179600,13 +180382,16 @@ static int jsonParseValue(JsonParse *pPa + u8 jnFlags = 0; + j = i+1; + for(;;){ +- c = pParse->zJson[j]; +- if( c==0 ) return -1; ++ c = z[j]; ++ if( (c & ~0x1f)==0 ){ ++ /* Control characters are not allowed in strings */ ++ return -1; ++ } + if( c=='\\' ){ +- c = pParse->zJson[++j]; ++ c = z[++j]; + if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' + || c=='n' || c=='r' || c=='t' +- || (c=='u' && jsonIs4Hex(pParse->zJson+j+1)) ){ ++ || (c=='u' && jsonIs4Hex(z+j+1)) ){ + jnFlags = JNODE_ESCAPE; + }else{ + return -1; +@@ -179616,55 +180401,60 @@ static int jsonParseValue(JsonParse *pPa + } + j++; + } +- jsonParseAddNode(pParse, JSON_STRING, j+1-i, &pParse->zJson[i]); ++ jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]); + if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags; + return j+1; + }else if( c=='n' +- && strncmp(pParse->zJson+i,"null",4)==0 +- && !safe_isalnum(pParse->zJson[i+4]) ){ ++ && strncmp(z+i,"null",4)==0 ++ && !safe_isalnum(z[i+4]) ){ + jsonParseAddNode(pParse, JSON_NULL, 0, 0); + return i+4; + }else if( c=='t' +- && strncmp(pParse->zJson+i,"true",4)==0 +- && !safe_isalnum(pParse->zJson[i+4]) ){ ++ && strncmp(z+i,"true",4)==0 ++ && !safe_isalnum(z[i+4]) ){ + jsonParseAddNode(pParse, JSON_TRUE, 0, 0); + return i+4; + }else if( c=='f' +- && strncmp(pParse->zJson+i,"false",5)==0 +- && !safe_isalnum(pParse->zJson[i+5]) ){ ++ && strncmp(z+i,"false",5)==0 ++ && !safe_isalnum(z[i+5]) ){ + jsonParseAddNode(pParse, JSON_FALSE, 0, 0); + return i+5; + }else if( c=='-' || (c>='0' && c<='9') ){ + /* Parse number */ + u8 seenDP = 0; + u8 seenE = 0; ++ assert( '-' < '0' ); ++ if( c<='0' ){ ++ j = c=='-' ? i+1 : i; ++ if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1; ++ } + j = i+1; + for(;; j++){ +- c = pParse->zJson[j]; ++ c = z[j]; + if( c>='0' && c<='9' ) continue; + if( c=='.' ){ +- if( pParse->zJson[j-1]=='-' ) return -1; ++ if( z[j-1]=='-' ) return -1; + if( seenDP ) return -1; + seenDP = 1; + continue; + } + if( c=='e' || c=='E' ){ +- if( pParse->zJson[j-1]<'0' ) return -1; ++ if( z[j-1]<'0' ) return -1; + if( seenE ) return -1; + seenDP = seenE = 1; +- c = pParse->zJson[j+1]; ++ c = z[j+1]; + if( c=='+' || c=='-' ){ + j++; +- c = pParse->zJson[j+1]; ++ c = z[j+1]; + } + if( c<'0' || c>'9' ) return -1; + continue; + } + break; + } +- if( pParse->zJson[j-1]<'0' ) return -1; ++ if( z[j-1]<'0' ) return -1; + jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT, +- j - i, &pParse->zJson[i]); ++ j - i, &z[i]); + return j; + }else if( c=='}' ){ + return -2; /* End of {...} */ +@@ -179696,6 +180486,7 @@ static int jsonParse( + i = jsonParseValue(pParse, 0); + if( pParse->oom ) i = -1; + if( i>0 ){ ++ assert( pParse->iDepth==0 ); + while( safe_isspace(zJson[i]) ) i++; + if( zJson[i] ) i = -1; + } +@@ -180948,7 +181739,7 @@ static int jsonEachFilter( + JsonEachCursor *p = (JsonEachCursor*)cur; + const char *z; + const char *zRoot = 0; +- sqlite3_int64 n; ++ size_t n; + + UNUSED_PARAM(idxStr); + UNUSED_PARAM(argc); +@@ -180956,10 +181747,10 @@ static int jsonEachFilter( + if( idxNum==0 ) return SQLITE_OK; z = (const char*)sqlite3_value_text(argv[0]); if( z==0 ) return SQLITE_OK; - n = sqlite3_value_bytes(argv[0]); +- n = sqlite3_value_bytes(argv[0]); - p->zJson = sqlite3_malloc64( n+1 ); ++ n = (size_t)sqlite3_value_bytes(argv[0]); + p->zJson = sqlite3_malloc( n+1 ); if( p->zJson==0 ) return SQLITE_NOMEM; - memcpy(p->zJson, z, (size_t)n+1); +- memcpy(p->zJson, z, (size_t)n+1); ++ memcpy(p->zJson, z, n+1); if( jsonParse(&p->sParse, 0, p->zJson) ){ -@@ -166894,7 +167506,7 @@ static int jsonEachFilter( + int rc = SQLITE_NOMEM; + if( p->sParse.oom==0 ){ +@@ -180978,10 +181769,10 @@ static int jsonEachFilter( + const char *zErr = 0; zRoot = (const char*)sqlite3_value_text(argv[1]); if( zRoot==0 ) return SQLITE_OK; - n = sqlite3_value_bytes(argv[1]); +- n = sqlite3_value_bytes(argv[1]); - p->zRoot = sqlite3_malloc64( n+1 ); ++ n = (size_t)sqlite3_value_bytes(argv[1]); + p->zRoot = sqlite3_malloc( n+1 ); if( p->zRoot==0 ) return SQLITE_NOMEM; - memcpy(p->zRoot, zRoot, (size_t)n+1); +- memcpy(p->zRoot, zRoot, (size_t)n+1); ++ memcpy(p->zRoot, zRoot, n+1); if( zRoot[0]!='$' ){ -@@ -167578,7 +168190,7 @@ struct fts5_api { + zErr = zRoot; + }else{ +@@ -181019,7 +181810,7 @@ static int jsonEachFilter( + } + + /* The methods of the json_each virtual table */ +-static sqlite3_module jsonEachModule = { ++static const sqlite3_module jsonEachModule = { + 0, /* iVersion */ + 0, /* xCreate */ + jsonEachConnect, /* xConnect */ +@@ -181046,7 +181837,7 @@ static sqlite3_module jsonEachModule = { + }; + + /* The methods of the json_tree virtual table. */ +-static sqlite3_module jsonTreeModule = { ++static const sqlite3_module jsonTreeModule = { + 0, /* iVersion */ + 0, /* xCreate */ + jsonEachConnect, /* xConnect */ +@@ -181122,7 +181913,7 @@ SQLITE_PRIVATE int sqlite3Json1Init(sqli + #ifndef SQLITE_OMIT_VIRTUALTABLE + static const struct { + const char *zName; +- sqlite3_module *pModule; ++ const sqlite3_module *pModule; + } aMod[] = { + { "json_each", &jsonEachModule }, + { "json_tree", &jsonTreeModule }, +@@ -181725,7 +182516,7 @@ struct fts5_api { fts5_api *pApi, const char *zName, void *pContext, @@ -20224,7 +29390,7 @@ void (*xDestroy)(void*) ); -@@ -167648,8 +168260,12 @@ typedef sqlite3_uint64 u64; +@@ -181797,8 +182588,12 @@ typedef sqlite3_uint64 u64; #define ALWAYS(x) 1 #define NEVER(x) 0 @@ -20237,17 +29403,27 @@ /* ** Constants for the largest and smallest possible 64-bit signed integers. -@@ -167659,6 +168275,9 @@ typedef sqlite3_uint64 u64; +@@ -181808,6 +182603,10 @@ typedef sqlite3_uint64 u64; #endif +#ifndef SQLITE_PRIVATE +# define SQLITE_PRIVATE static +#endif ++ + /* Truncate very long tokens to this many bytes. Hard limit is + ** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset + ** field that occurs at the start of each leaf page (see fts5_index.c). */ +@@ -182013,7 +182812,7 @@ static void sqlite3Fts5BufferAppendStrin + static void sqlite3Fts5BufferFree(Fts5Buffer*); + static void sqlite3Fts5BufferZero(Fts5Buffer*); + static void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*); +-static void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...); ++static void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, const char *zFmt, ...); - /* - ** Maximum number of prefix indexes on single FTS5 table. This must be -@@ -167899,8 +168518,8 @@ static int sqlite3Fts5PoslistNext64( + static char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...); + +@@ -182068,8 +182867,8 @@ static int sqlite3Fts5PoslistNext64( ); /* Malloc utility */ @@ -20258,7 +29434,7 @@ /* Character set tests (like isspace(), isalpha() etc.) */ static int sqlite3Fts5IsBareword(char t); -@@ -168399,7 +169018,7 @@ static int sqlite3Fts5UnicodeFold(int c, +@@ -182615,7 +183414,7 @@ static int sqlite3Fts5UnicodeFold(int c, ** Alternative datatype for the argument to the malloc() routine passed ** into sqlite3ParserAlloc(). The default is size_t. */ @@ -20267,26 +29443,35 @@ /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols -@@ -169267,7 +169886,7 @@ static void fts5yy_reduce( +@@ -183581,7 +184380,7 @@ static void fts5yy_reduce( break; /********** End reduce actions ************************************************/ }; -- assert( fts5yyruleno>=0 && fts5yyrulenofts5yyidx -= fts5yysize; -@@ -170089,7 +170708,7 @@ static int sqlite3Fts5AuxInit(fts5_api * + fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto); +@@ -184531,7 +185330,7 @@ static int sqlite3Fts5AuxInit(fts5_api * { "bm25", 0, fts5Bm25Function, 0 }, }; int rc = SQLITE_OK; /* Return code */ - int i; /* To iterate through builtin functions */ + unsigned int i; /* To iterate through builtin functions */ - for(i=0; rc==SQLITE_OK && i<(int)ArraySize(aBuiltin); i++){ + for(i=0; rc==SQLITE_OK && ixCreateFunction(pApi, -@@ -170334,7 +170953,7 @@ static int sqlite3Fts5PoslistWriterAppen - return rc; +@@ -184647,7 +185446,7 @@ static void sqlite3Fts5BufferAppendStrin + static void sqlite3Fts5BufferAppendPrintf( + int *pRc, + Fts5Buffer *pBuf, +- char *zFmt, ... ++ const char *zFmt, ... + ){ + if( *pRc==SQLITE_OK ){ + char *zTmp; +@@ -184791,7 +185590,7 @@ static int sqlite3Fts5PoslistWriterAppen + return SQLITE_OK; } -static void *sqlite3Fts5MallocZero(int *pRc, int nByte){ @@ -20294,7 +29479,7 @@ void *pRet = 0; if( *pRc==SQLITE_OK ){ pRet = sqlite3_malloc(nByte); -@@ -170355,11 +170974,11 @@ static void *sqlite3Fts5MallocZero(int * +@@ -184812,11 +185611,11 @@ static void *sqlite3Fts5MallocZero(int * ** It is the responsibility of the caller to eventually free the returned ** buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. */ @@ -20309,7 +29494,7 @@ } zRet = (char*)sqlite3_malloc(nIn+1); if( zRet ){ -@@ -170670,7 +171289,7 @@ static int fts5ConfigParseSpecial( +@@ -185237,7 +186036,7 @@ static int fts5ConfigParseSpecial( if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){ const char *p = (const char*)zArg; @@ -20318,7 +29503,7 @@ char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg); char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2); char *pSpace = pDel; -@@ -170888,7 +171507,7 @@ static int sqlite3Fts5ConfigParse( +@@ -185471,7 +186270,7 @@ static int sqlite3Fts5ConfigParse( int rc = SQLITE_OK; /* Return code */ Fts5Config *pRet; /* New object to return */ int i; @@ -20327,7 +29512,7 @@ *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config)); if( pRet==0 ) return SQLITE_NOMEM; -@@ -171337,7 +171956,7 @@ typedef struct Fts5ExprTerm Fts5ExprTerm +@@ -185933,7 +186732,7 @@ typedef struct Fts5ExprTerm Fts5ExprTerm /* ** Functions generated by lemon from fts5parse.y. */ @@ -20336,8 +29521,8 @@ static void sqlite3Fts5ParserFree(void*, void (*freeProc)(void*)); static void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*); #ifndef NDEBUG -@@ -171350,7 +171969,7 @@ struct Fts5Expr { - Fts5Index *pIndex; +@@ -185947,7 +186746,7 @@ struct Fts5Expr { + Fts5Config *pConfig; Fts5ExprNode *pRoot; int bDesc; /* Iterate in descending rowid order */ - int nPhrase; /* Number of phrases in expression */ @@ -20345,7 +29530,7 @@ Fts5ExprPhrase **apExprPhrase; /* Pointers to phrase objects */ }; -@@ -171505,7 +172124,7 @@ static int fts5ExprGetToken( +@@ -186112,7 +186911,7 @@ static int fts5ExprGetToken( return tok; } @@ -20354,34 +29539,34 @@ static void fts5ParseFree(void *p){ sqlite3_free(p); } static int sqlite3Fts5ExprNew( -@@ -171631,7 +172250,7 @@ static int fts5ExprSynonymPoslist( - rc = sqlite3Fts5IterPoslist(pIter, pColset, &a, &n, &dummy); - if( rc!=SQLITE_OK ) goto synonym_poslist_out; +@@ -186244,7 +187043,7 @@ static int fts5ExprSynonymList( + if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){ + if( pIter->nData==0 ) continue; if( nIter==nAlloc ){ - int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2; + size_t nByte = sizeof(Fts5PoslistReader) * nAlloc * 2; Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte); if( aNew==0 ){ rc = SQLITE_NOMEM; -@@ -171716,7 +172335,7 @@ static int fts5ExprPhraseIsMatch( +@@ -186324,7 +187123,7 @@ static int fts5ExprPhraseIsMatch( /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ - if( pPhrase->nTerm>(int)ArraySize(aStatic) ){ + if( pPhrase->nTerm>ArraySize(aStatic) ){ - int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm; + size_t nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm; aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte); if( !aIter ) return SQLITE_NOMEM; } -@@ -171852,7 +172471,7 @@ static int fts5ExprNearIsMatch(int *pRc, +@@ -186457,7 +187256,7 @@ static int fts5ExprNearIsMatch(int *pRc, /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ - if( pNear->nPhrase>(int)ArraySize(aStatic) ){ + if( pNear->nPhrase>ArraySize(aStatic) ){ - int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase; + size_t nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase; a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte); }else{ memset(aStatic, 0, sizeof(aStatic)); -@@ -172677,7 +173296,7 @@ static Fts5ExprNearset *sqlite3Fts5Parse +@@ -187353,7 +188152,7 @@ static Fts5ExprNearset *sqlite3Fts5Parse return pNear; } if( pNear==0 ){ @@ -20390,16 +29575,16 @@ pRet = sqlite3_malloc(nByte); if( pRet==0 ){ pParse->rc = SQLITE_NOMEM; -@@ -172735,7 +173354,7 @@ static int fts5ParseTokenize( - assert( pPhrase==0 || pPhrase->nTerm>0 ); - if( pPhrase && (tflags & FTS5_TOKEN_COLOCATED) ){ +@@ -187428,7 +188227,7 @@ static int fts5ParseTokenize( + + if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ Fts5ExprTerm *pSyn; -- int nByte = sizeof(Fts5ExprTerm) + nToken+1; -+ size_t nByte = sizeof(Fts5ExprTerm) + nToken+1; +- int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; ++ size_t nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte); if( pSyn==0 ){ rc = SQLITE_NOMEM; -@@ -173085,7 +173704,7 @@ static Fts5ExprNode *sqlite3Fts5ParseNod +@@ -187869,7 +188668,7 @@ static Fts5ExprNode *sqlite3Fts5ParseNod if( pParse->rc==SQLITE_OK ){ int nChild = 0; /* Number of children of returned node */ @@ -20408,7 +29593,7 @@ assert( (eType!=FTS5_STRING && !pNear) || (eType==FTS5_STRING && !pLeft && !pRight) -@@ -173136,7 +173755,7 @@ static Fts5ExprNode *sqlite3Fts5ParseNod +@@ -187998,7 +188797,7 @@ static Fts5ExprNode *sqlite3Fts5ParseImp } static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ @@ -20417,7 +29602,7 @@ Fts5ExprTerm *p; char *zQuoted; -@@ -173494,13 +174113,13 @@ static int sqlite3Fts5ExprInit(Fts5Globa +@@ -188362,13 +189161,13 @@ static int sqlite3Fts5ExprInit(Fts5Globa { "fts5_isalnum", fts5ExprIsAlnum }, { "fts5_fold", fts5ExprFold }, }; @@ -20426,14 +29611,14 @@ int rc = SQLITE_OK; void *pCtx = (void*)pGlobal; - for(i=0; rc==SQLITE_OK && i<(int)ArraySize(aFunc); i++){ + for(i=0; rc==SQLITE_OK && iz, -1, SQLITE_UTF8, pCtx, p->x, 0, 0); + rc = sqlite3_create_function_v2(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0, 0); } /* Avoid a warning indicating that sqlite3Fts5ParserTrace() is unused */ -@@ -173522,7 +174141,7 @@ static int sqlite3Fts5ExprPhraseCount(Ft +@@ -188390,7 +189189,7 @@ static int sqlite3Fts5ExprPhraseCount(Ft ** Return the number of terms in the iPhrase'th phrase in pExpr. */ static int sqlite3Fts5ExprPhraseSize(Fts5Expr *pExpr, int iPhrase){ @@ -20442,7 +29627,34 @@ return pExpr->apExprPhrase[iPhrase]->nTerm; } -@@ -174581,7 +175200,7 @@ static u16 fts5GetU16(const u8 *aIn){ +@@ -188422,7 +189221,7 @@ static Fts5PoslistPopulator *sqlite3Fts5 + Fts5PoslistPopulator *pRet; + pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); + if( pRet ){ +- int i; ++ size_t i; + memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); + for(i=0; inPhrase; i++){ + Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; +@@ -188468,7 +189267,7 @@ static int fts5ExprPopulatePoslistsCb( + ){ + Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx; + Fts5Expr *pExpr = p->pExpr; +- int i; ++ size_t i; + + UNUSED_PARAM2(iUnused1, iUnused2); + +@@ -188500,7 +189299,7 @@ static int sqlite3Fts5ExprPopulatePoslis + int iCol, + const char *z, int n + ){ +- int i; ++ size_t i; + Fts5ExprCtx sCtx; + sCtx.pExpr = pExpr; + sCtx.aPopulator = aPopulator; +@@ -189724,7 +190523,7 @@ static u16 fts5GetU16(const u8 *aIn){ ** If an OOM error is encountered, return NULL and set the error code in ** the Fts5Index handle passed as the first argument. */ @@ -20451,7 +29663,7 @@ return sqlite3Fts5MallocZero(&p->rc, nByte); } -@@ -174863,7 +175482,7 @@ static int fts5StructureDecode( +@@ -190007,7 +190806,7 @@ static int fts5StructureDecode( int iLvl; int nLevel = 0; int nSegment = 0; @@ -20460,24 +29672,26 @@ Fts5Structure *pRet = 0; /* Structure object to return */ /* Grab the cookie value */ -@@ -177945,14 +178564,14 @@ static int sqlite3Fts5IndexOptimize(Fts5 - assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) ); - nSeg = pStruct->nSegment; - if( nSeg>1 ){ -- int nByte = sizeof(Fts5Structure); -+ size_t nByte = sizeof(Fts5Structure); - nByte += (pStruct->nLevel+1) * sizeof(Fts5StructureLevel); - pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte); - } - } - if( pNew ){ - Fts5StructureLevel *pLvl; -- int nByte = nSeg * sizeof(Fts5StructureSegment); -+ size_t nByte = nSeg * sizeof(Fts5StructureSegment); - pNew->nLevel = pStruct->nLevel+1; - pNew->nRef = 1; - pNew->nWriteCounter = pStruct->nWriteCounter; -@@ -179801,12 +180420,12 @@ static void fts5RowidFunction( +@@ -192996,9 +193795,6 @@ static void fts5WriteFlushLeaf(Fts5Index + Fts5PageWriter *pPage = &pWriter->writer; + i64 iRowid; + +-static int nCall = 0; +-nCall++; +- + assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) ); + + /* Set the szLeaf header field. */ +@@ -193775,7 +194571,7 @@ static Fts5Structure *fts5IndexOptimizeS + Fts5Structure *pStruct + ){ + Fts5Structure *pNew = 0; +- int nByte = sizeof(Fts5Structure); ++ size_t nByte = sizeof(Fts5Structure); + int nSeg = pStruct->nSegment; + int i; + +@@ -195613,8 +196409,8 @@ static void fts5RowidFunction( ** SQLite error code is returned instead. */ static int sqlite3Fts5IndexInit(sqlite3 *db){ @@ -20486,6 +29700,11 @@ + int rc = sqlite3_create_function_v2( + db, "fts5_decode", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0, 0 ); + + if( rc==SQLITE_OK ){ +@@ -195625,8 +196421,8 @@ static int sqlite3Fts5IndexInit(sqlite3 + } + if( rc==SQLITE_OK ){ - rc = sqlite3_create_function( - db, "fts5_rowid", -1, SQLITE_UTF8, 0, fts5RowidFunction, 0, 0 @@ -20494,7 +29713,7 @@ ); } return rc; -@@ -179837,7 +180456,9 @@ static int sqlite3Fts5IndexInit(sqlite3 +@@ -195665,7 +196461,9 @@ static int sqlite3Fts5IndexReset(Fts5Ind ** assert() conditions in the fts5 code are activated - conditions that are ** only true if it is guaranteed that the fts5 database is not corrupt. */ @@ -20504,7 +29723,7 @@ typedef struct Fts5Auxdata Fts5Auxdata; -@@ -179942,7 +180563,7 @@ struct Fts5Table { +@@ -195770,7 +196568,7 @@ struct Fts5Table { struct Fts5MatchPhrase { Fts5Buffer *pPoslist; /* Pointer to current poslist */ @@ -20513,39 +29732,34 @@ }; /* -@@ -180349,10 +180970,10 @@ static int fts5BestIndexMethod(sqlite3_v +@@ -196178,7 +196976,7 @@ static int fts5BestIndexMethod(sqlite3_v aColMap[2] = pConfig->nCol+1; /* Set idxFlags flags for all WHERE clause terms that will be used. */ - for(i=0; inConstraint; i++){ + for(i=0; (int)inConstraint; i++){ struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; -- int j; -- for(j=0; j<(int)ArraySize(aConstraint); j++){ -+ size_t j; -+ for(j=0; jiColumn==aColMap[pC->iCol] && p->op & pC->op ){ - if( p->usable ){ -@@ -180418,7 +181039,7 @@ static int fts5OpenMethod(sqlite3_vtab * + int j; + for(j=0; jpConfig; - Fts5Cursor *pCsr; /* New cursor object */ + Fts5Cursor *pCsr = 0; /* New cursor object */ - int nByte; /* Bytes of space to allocate */ + size_t nByte; /* Bytes of space to allocate */ - int rc = SQLITE_OK; /* Return code */ + int rc; /* Return code */ - nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int); -@@ -180687,7 +181308,7 @@ static int fts5CursorFirstSorted(Fts5Tab + rc = fts5NewTransaction(pTab); +@@ -196531,7 +197329,7 @@ static int fts5CursorFirstSorted(Fts5Tab Fts5Config *pConfig = pTab->pConfig; Fts5Sorter *pSorter; int nPhrase; - int nByte; + size_t nByte; - int rc = SQLITE_OK; + int rc; const char *zRank = pCsr->zRank; const char *zRankArgs = pCsr->zRankArgs; -@@ -182070,10 +182691,10 @@ static int fts5CreateAux( +@@ -198076,10 +198874,10 @@ static int fts5CreateAux( int rc = sqlite3_overload_function(pGlobal->db, zName, -1); if( rc==SQLITE_OK ){ Fts5Auxiliary *pAux; @@ -20559,7 +29773,7 @@ nByte = sizeof(Fts5Auxiliary) + nName; pAux = (Fts5Auxiliary*)sqlite3_malloc(nByte); if( pAux ){ -@@ -182102,16 +182723,16 @@ static int fts5CreateTokenizer( +@@ -198108,16 +198906,16 @@ static int fts5CreateTokenizer( fts5_api *pApi, /* Global context (one per db handle) */ const char *zName, /* Name of new function */ void *pUserData, /* User data for aux. function */ @@ -20580,7 +29794,7 @@ nByte = sizeof(Fts5TokenizerModule) + nName; pNew = (Fts5TokenizerModule*)sqlite3_malloc(nByte); if( pNew ){ -@@ -182300,13 +182921,13 @@ static int fts5Init(sqlite3 *db){ +@@ -198308,13 +199106,13 @@ static int fts5Init(sqlite3 *db){ if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api); if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db); if( rc==SQLITE_OK ){ @@ -20598,7 +29812,7 @@ ); } } -@@ -183482,7 +184103,7 @@ static int sqlite3Fts5StorageConfigValue +@@ -199527,7 +200325,7 @@ static int sqlite3Fts5StorageConfigValue ** For tokenizers with no "unicode" modifier, the set of token characters ** is the same as the set of ASCII range alphanumeric characters. */ @@ -20607,7 +29821,7 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00..0x0F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10..0x1F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20..0x2F */ -@@ -184668,17 +185289,18 @@ static int fts5PorterTokenize( +@@ -200720,17 +201518,18 @@ static int fts5PorterTokenize( ** Register all built-in tokenizers with FTS5. */ static int sqlite3Fts5TokenizerInit(fts5_api *pApi){ @@ -20626,9 +29840,9 @@ - int i; /* To iterate through builtin functions */ + unsigned int i; /* To iterate through builtin functions */ - for(i=0; rc==SQLITE_OK && i<(int)ArraySize(aBuiltin); i++){ + for(i=0; rc==SQLITE_OK && ixCreateTokenizer(pApi, -@@ -184738,84 +185360,92 @@ static int sqlite3Fts5UnicodeIsalnum(int +@@ -200790,91 +201589,104 @@ static int sqlite3Fts5UnicodeIsalnum(int 0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01, 0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401, 0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01, @@ -20661,7 +29875,36 @@ - 0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001, - 0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802, - 0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F, -- 0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002, ++ 0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163403, ++ 0x00164437, 0x0017CC02, 0x0018001D, 0x00187802, 0x00192C15, ++ 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F, 0x001B9C07, ++ 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401, 0x001CC01B, ++ 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804, 0x00206C09, ++ 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403, 0x00217801, ++ 0x00235030, 0x0024E803, 0x0024F812, 0x00254407, 0x00258804, ++ 0x0025C001, 0x00260403, 0x0026F001, 0x0026F807, 0x00271C02, ++ 0x00272C03, 0x00275C01, 0x00278802, 0x0027C802, 0x0027E802, ++ 0x00280403, 0x0028F001, 0x0028F805, 0x00291C02, 0x00292C03, ++ 0x00294401, 0x0029C002, 0x0029D401, 0x002A0403, 0x002AF001, ++ 0x002AF808, 0x002B1C03, 0x002B2C03, 0x002B8802, 0x002BC002, ++ 0x002C0403, 0x002CF001, 0x002CF807, 0x002D1C02, 0x002D2C03, ++ 0x002D5802, 0x002D8802, 0x002DC001, 0x002E0801, 0x002EF805, ++ 0x002F1803, 0x002F2804, 0x002F5C01, 0x002FCC08, 0x00300004, ++ 0x0030F807, 0x00311803, 0x00312804, 0x00315402, 0x00318802, ++ 0x0031FC01, 0x00320403, 0x0032F001, 0x0032F807, 0x00331803, ++ 0x00332804, 0x00335402, 0x00338802, 0x00340403, 0x0034F807, ++ 0x00351803, 0x00352804, 0x00353C01, 0x00355C01, 0x00358802, ++ 0x0035E401, 0x00360802, 0x00372801, 0x00373C06, 0x00375801, ++ 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007, 0x0038FC01, ++ 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006, 0x003AEC02, ++ 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417, 0x003E340B, ++ 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14, 0x00412806, ++ 0x00415804, 0x00417803, 0x00418803, 0x00419C07, 0x0041C404, ++ 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01, 0x004D740C, ++ 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001, 0x005A6C02, ++ 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802, 0x005DC802, ++ 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F, 0x00621402, + 0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002, - 0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802, - 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006, - 0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D, @@ -20670,8 +29913,16 @@ - 0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403, - 0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805, - 0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04, -- 0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401, -- 0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005, ++ 0x00677822, 0x00685C05, 0x00687802, 0x0069540A, 0x0069801D, ++ 0x0069FC01, 0x006A8007, 0x006AA006, 0x006AC00F, 0x006C0005, ++ 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D, 0x006F980E, ++ 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802, 0x00730008, ++ 0x00734019, 0x0073B401, 0x0073C803, 0x0073E002, 0x00770036, ++ 0x0077EC05, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403, ++ 0x007FB403, 0x007FF402, 0x00800065, 0x0081980A, 0x0081E805, ++ 0x00822805, 0x0082801F, 0x00834021, 0x00840002, 0x00840C04, + 0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401, + 0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005, - 0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B, - 0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A, - 0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001, @@ -20689,83 +29940,58 @@ - 0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803, - 0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07, - 0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02, -+ 0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163403, -+ 0x00164437, 0x0017CC02, 0x0018001D, 0x00187802, 0x00192C15, -+ 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F, 0x001B9C07, -+ 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401, 0x001CC01B, -+ 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804, 0x00206C09, -+ 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403, 0x00217801, -+ 0x00238C21, 0x0024E803, 0x0024F812, 0x00254407, 0x00258804, -+ 0x0025C001, 0x00260403, 0x0026F001, 0x0026F807, 0x00271C02, -+ 0x00272C03, 0x00275C01, 0x00278802, 0x0027C802, 0x0027E802, -+ 0x00280403, 0x0028F001, 0x0028F805, 0x00291C02, 0x00292C03, -+ 0x00294401, 0x0029C002, 0x0029D401, 0x002A0403, 0x002AF001, -+ 0x002AF808, 0x002B1C03, 0x002B2C03, 0x002B8802, 0x002BC002, -+ 0x002C0403, 0x002CF001, 0x002CF807, 0x002D1C02, 0x002D2C03, -+ 0x002D5802, 0x002D8802, 0x002DC001, 0x002E0801, 0x002EF805, -+ 0x002F1803, 0x002F2804, 0x002F5C01, 0x002FCC08, 0x00300004, -+ 0x0030F807, 0x00311803, 0x00312804, 0x00315402, 0x00318802, -+ 0x0031FC01, 0x00320403, 0x0032F001, 0x0032F807, 0x00331803, -+ 0x00332804, 0x00335402, 0x00338802, 0x00340403, 0x0034F807, -+ 0x00351803, 0x00352804, 0x00355C01, 0x00358802, 0x0035E401, -+ 0x00360802, 0x00372801, 0x00373C06, 0x00375801, 0x00376008, -+ 0x0037C803, 0x0038C401, 0x0038D007, 0x0038FC01, 0x00391C09, -+ 0x00396802, 0x003AC401, 0x003AD006, 0x003AEC02, 0x003B2006, -+ 0x003C041F, 0x003CD00C, 0x003DC417, 0x003E340B, 0x003E6424, -+ 0x003EF80F, 0x003F380D, 0x0040AC14, 0x00412806, 0x00415804, -+ 0x00417803, 0x00418803, 0x00419C07, 0x0041C404, 0x0042080C, -+ 0x00423C01, 0x00426806, 0x0043EC01, 0x004D740C, 0x004E400A, -+ 0x00500001, 0x0059B402, 0x005A0001, 0x005A6C02, 0x005BAC03, -+ 0x005C4803, 0x005CC805, 0x005D4802, 0x005DC802, 0x005ED023, -+ 0x005F6004, 0x005F7401, 0x0060000F, 0x0062A401, 0x0064800C, -+ 0x0064C00C, 0x00650001, 0x00651002, 0x00677822, 0x00685C05, -+ 0x00687802, 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, -+ 0x006AA006, 0x006AC00F, 0x006C0005, 0x006CD011, 0x006D6823, -+ 0x006E0003, 0x006E840D, 0x006F980E, 0x006FF004, 0x00709014, -+ 0x0070EC05, 0x0071F802, 0x00730008, 0x00734019, 0x0073B401, -+ 0x0073C803, 0x0073E002, 0x00770036, 0x0077F004, 0x007EF401, -+ 0x007EFC03, 0x007F3403, 0x007F7403, 0x007FB403, 0x007FF402, -+ 0x00800065, 0x0081980A, 0x0081E805, 0x00822805, 0x0082801F, -+ 0x00834021, 0x00840002, 0x00840C04, 0x00842002, 0x00845001, -+ 0x00845803, 0x00847806, 0x00849401, 0x00849C01, 0x0084A401, -+ 0x0084B801, 0x0084E802, 0x00850005, 0x00852804, 0x00853C01, -+ 0x00862802, 0x0086426B, 0x00900027, 0x0091000B, 0x0092704E, -+ 0x00940276, 0x009E53E0, 0x00ADD820, 0x00AE6022, 0x00AEF40C, -+ 0x00AF2808, 0x00AFB004, 0x00B39406, 0x00B3BC03, 0x00B3E404, -+ 0x00B3F802, 0x00B5C001, 0x00B5FC01, 0x00B7804F, 0x00B8C013, -+ 0x00BA001A, 0x00BA6C59, 0x00BC00D6, 0x00BFC00C, 0x00C00005, -+ 0x00C02019, 0x00C0A807, 0x00C0D802, 0x00C0F403, 0x00C26404, -+ 0x00C28001, 0x00C3EC01, 0x00C64002, 0x00C6580A, 0x00C70024, -+ 0x00C8001F, 0x00C8A81E, 0x00C94001, 0x00C98020, 0x00CA2827, -+ 0x00CB003F, 0x00CC0100, 0x01370040, 0x02924037, 0x0293F802, -+ 0x02983403, 0x0299BC10, 0x029A7802, 0x029BC008, 0x029C0017, -+ 0x029C8002, 0x029E2402, 0x02A00801, 0x02A01801, 0x02A02C01, -+ 0x02A08C09, 0x02A0D804, 0x02A1D004, 0x02A20002, 0x02A2D011, -+ 0x02A33802, 0x02A38012, 0x02A3E003, 0x02A3F001, 0x02A4980A, -+ 0x02A51C0D, 0x02A57C01, 0x02A60004, 0x02A6CC1B, 0x02A77802, -+ 0x02A79401, 0x02A8A40E, 0x02A90C01, 0x02A93002, 0x02A97004, -+ 0x02A9DC03, 0x02A9EC03, 0x02AAC001, 0x02AAC803, 0x02AADC02, -+ 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07, 0x02ABD402, -+ 0x02AD6C01, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02, - 0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802, +- 0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802, - 0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013, - 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06, - 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003, - 0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01, - 0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403, -+ 0x03F7F002, 0x03F8001A, 0x03F88033, 0x03F95013, 0x03F9A004, -+ 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06, 0x03FD6C0B, -+ 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003, 0x0404DC09, -+ 0x0405E411, 0x04063001, 0x0406400C, 0x04068001, 0x0407402E, -+ 0x040B8001, 0x040DD805, 0x040E7C01, 0x040F4001, 0x0415BC01, -+ 0x04215C01, 0x0421DC02, 0x04247C01, 0x0424FC01, 0x04280403, - 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009, +- 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009, - 0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003, - 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003, - 0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E, - 0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046, -- 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401, -- 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401, ++ 0x00852804, 0x00853C01, 0x00862802, 0x0086426F, 0x00900027, ++ 0x0091000B, 0x0092704E, 0x00940276, 0x009E53E0, 0x00ADD820, ++ 0x00AE6022, 0x00AEF40C, 0x00AF2808, 0x00AFB004, 0x00B39406, ++ 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001, 0x00B5FC01, ++ 0x00B7804F, 0x00B8C015, 0x00BA001A, 0x00BA6C59, 0x00BC00D6, ++ 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807, 0x00C0D802, ++ 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01, 0x00C64002, ++ 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E, 0x00C94001, ++ 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100, 0x01370040, ++ 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10, 0x029A7802, ++ 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402, 0x02A00801, ++ 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804, 0x02A1D004, ++ 0x02A20002, 0x02A2D012, 0x02A33802, 0x02A38012, 0x02A3E003, ++ 0x02A3F001, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004, ++ 0x02A6CC1B, 0x02A77802, 0x02A79401, 0x02A8A40E, 0x02A90C01, ++ 0x02A93002, 0x02A97004, 0x02A9DC03, 0x02A9EC03, 0x02AAC001, ++ 0x02AAC803, 0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, ++ 0x02ABAC07, 0x02ABD402, 0x02AD6C01, 0x02AF8C0B, 0x03600001, ++ 0x036DFC02, 0x036FFC02, 0x037FFC01, 0x03EC7801, 0x03ECA401, ++ 0x03EEC810, 0x03F4F802, 0x03F7F002, 0x03F8001A, 0x03F88033, ++ 0x03F95013, 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, ++ 0x03FCEC06, 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, ++ 0x04040003, 0x0404DC09, 0x0405E411, 0x04063003, 0x0406400C, ++ 0x04068001, 0x0407402E, 0x040B8001, 0x040DD805, 0x040E7C01, ++ 0x040F4001, 0x0415BC01, 0x04215C01, 0x0421DC02, 0x04247C01, ++ 0x0424FC01, 0x04280403, 0x04281402, 0x04283004, 0x0428E003, ++ 0x0428FC01, 0x04294009, 0x0429FC01, 0x042B2001, 0x042B9402, ++ 0x042BC007, 0x042CE407, 0x042E6404, 0x04400003, 0x0440E016, ++ 0x0441FC04, 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, ++ 0x0445CC03, 0x04460003, 0x0446CC0E, 0x04471409, 0x04476C01, ++ 0x04477403, 0x0448B013, 0x044AA401, 0x044B7C0C, 0x044C0004, ++ 0x044CF001, 0x044CF807, 0x044D1C02, 0x044D2C03, 0x044D5C01, ++ 0x044D8802, 0x044D9807, 0x044DC005, 0x0450D412, 0x04512C05, ++ 0x04516C01, 0x04517401, 0x0452C014, 0x04531801, 0x0456BC07, ++ 0x0456E020, 0x04577002, 0x0458C014, 0x0459800D, 0x045AAC0D, ++ 0x045C740F, 0x045CF004, 0x0470BC08, 0x0470E008, 0x04710405, ++ 0x0471C002, 0x04724816, 0x0472A40E, 0x0491C005, 0x05A9B802, ++ 0x05ABC006, 0x05ACC010, 0x05AD1002, 0x05BD442E, 0x05BE3C04, ++ 0x06F27008, 0x074000F6, 0x07440027, 0x0744A4C0, 0x07480046, + 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401, + 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401, - 0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F, - 0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C, - 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002, @@ -20774,30 +30000,28 @@ - 0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46, - 0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060, - 0x380400F0, -+ 0x0429FC01, 0x042B2001, 0x042B9402, 0x042BC007, 0x042CE407, -+ 0x042E6404, 0x04400003, 0x0440E016, 0x0441FC04, 0x0442C012, -+ 0x04440003, 0x04449C0E, 0x04450004, 0x0445CC03, 0x04460003, -+ 0x0446CC0E, 0x04471409, 0x04476C01, 0x04477403, 0x0448B012, -+ 0x044AA401, 0x044B7C0C, 0x044C0004, 0x044CF001, 0x044CF807, -+ 0x044D1C02, 0x044D2C03, 0x044D5C01, 0x044D8802, 0x044D9807, -+ 0x044DC005, 0x0452C014, 0x04531801, 0x0456BC07, 0x0456E020, -+ 0x04577002, 0x0458C014, 0x045AAC0D, 0x045C740F, 0x045CF004, -+ 0x0491C005, 0x05A9B802, 0x05ABC006, 0x05ACC010, 0x05AD1002, -+ 0x05BD442E, 0x05BE3C04, 0x06F27008, 0x074000F6, 0x07440027, -+ 0x0744A4C0, 0x07480046, 0x074C0057, 0x075B0401, 0x075B6C01, -+ 0x075BEC01, 0x075C5401, 0x075CD401, 0x075D3C01, 0x075DBC01, -+ 0x075E2401, 0x075EA401, 0x075F0C01, 0x0760028C, 0x076A6C05, -+ 0x076A840F, 0x07A34007, 0x07BBC002, 0x07C0002C, 0x07C0C064, ++ 0x075F0C01, 0x0760028C, 0x076A6C05, 0x076A840F, 0x07800007, ++ 0x07802011, 0x07806C07, 0x07808C02, 0x07809805, 0x07A34007, ++ 0x07A51007, 0x07A57802, 0x07BBC002, 0x07C0002C, 0x07C0C064, + 0x07C2800F, 0x07C2C40F, 0x07C3040F, 0x07C34425, 0x07C4401F, -+ 0x07C4C03C, 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, -+ 0x07C94002, 0x07CC027A, 0x07D5EC29, 0x07D6952C, 0x07DB800D, -+ 0x07DBC004, 0x07DC0074, 0x07DE0055, 0x07E0000C, 0x07E04038, -+ 0x07E1400A, 0x07E18028, 0x07E2401E, 0x07E44009, 0x07E60005, -+ 0x07E70001, 0x38000401, 0x38008060, 0x380400F0, ++ 0x07C4C03C, 0x07C5C03D, 0x07C7981D, 0x07C8402C, 0x07C90009, ++ 0x07C94002, 0x07CC03D3, 0x07DB800D, 0x07DBC007, 0x07DC0074, ++ 0x07DE0055, 0x07E0000C, 0x07E04038, 0x07E1400A, 0x07E18028, ++ 0x07E2401E, 0x07E4400F, 0x07E48008, 0x07E4C001, 0x07E4CC0C, ++ 0x07E5000C, 0x07E5400F, 0x07E60012, 0x07E70001, 0x38000401, ++ 0x38008060, 0x380400F0, }; static const unsigned int aAscii[4] = { 0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001, -@@ -184854,7 +185484,7 @@ static int sqlite3Fts5UnicodeIsalnum(int + }; + + if( (unsigned int)c<128 ){ +- return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 ); ++ return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 ); + }else if( (unsigned int)c<(1<<22) ){ + unsigned int key = (((unsigned int)c)<<10) | 0x000003FF; + int iRes = 0; +@@ -200906,7 +201718,7 @@ static int sqlite3Fts5UnicodeIsalnum(int ** uppercase letter are undefined. */ static int fts5_remove_diacritic(int c){ @@ -20806,7 +30030,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, -@@ -184869,7 +185499,7 @@ static int fts5_remove_diacritic(int c){ +@@ -200921,7 +201733,7 @@ static int fts5_remove_diacritic(int c){ 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62924, 63050, 63082, 63274, 63390, }; @@ -20815,18 +30039,35 @@ '\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', -@@ -184947,8 +185577,8 @@ static int sqlite3Fts5UnicodeFold(int c, +@@ -200997,73 +201809,81 @@ static int sqlite3Fts5UnicodeFold(int c, + unsigned char flags; + unsigned char nRange; } aEntry[] = { - {65, 14, 26}, {181, 64, 1}, {192, 14, 23}, +- {65, 14, 26}, {181, 64, 1}, {192, 14, 23}, ++ {65, 14, 26}, {181, 66, 1}, {192, 14, 23}, {216, 14, 7}, {256, 1, 48}, {306, 1, 6}, - {313, 1, 16}, {330, 1, 46}, {376, 116, 1}, - {377, 1, 6}, {383, 104, 1}, {385, 50, 1}, -+ {313, 1, 16}, {330, 1, 46}, {376, 132, 1}, -+ {377, 1, 6}, {383, 120, 1}, {385, 50, 1}, - {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}, -@@ -184961,52 +185591,56 @@ static int sqlite3Fts5UnicodeFold(int c, +- {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}, +- {403, 42, 1}, {404, 46, 1}, {406, 52, 1}, +- {407, 48, 1}, {408, 0, 1}, {412, 52, 1}, +- {413, 54, 1}, {415, 56, 1}, {416, 1, 6}, +- {422, 60, 1}, {423, 0, 1}, {425, 60, 1}, +- {428, 0, 1}, {430, 60, 1}, {431, 0, 1}, +- {433, 58, 2}, {435, 1, 4}, {439, 62, 1}, ++ {313, 1, 16}, {330, 1, 46}, {376, 150, 1}, ++ {377, 1, 6}, {383, 138, 1}, {385, 52, 1}, ++ {386, 1, 4}, {390, 46, 1}, {391, 0, 1}, ++ {393, 44, 2}, {395, 0, 1}, {398, 34, 1}, ++ {399, 40, 1}, {400, 42, 1}, {401, 0, 1}, ++ {403, 44, 1}, {404, 48, 1}, {406, 54, 1}, ++ {407, 50, 1}, {408, 0, 1}, {412, 54, 1}, ++ {413, 56, 1}, {415, 58, 1}, {416, 1, 6}, ++ {422, 62, 1}, {423, 0, 1}, {425, 62, 1}, ++ {428, 0, 1}, {430, 62, 1}, {431, 0, 1}, ++ {433, 60, 2}, {435, 1, 4}, {439, 64, 1}, {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}, @@ -20835,12 +30076,7 @@ - {546, 1, 18}, {570, 70, 1}, {571, 0, 1}, - {573, 108, 1}, {574, 68, 1}, {577, 0, 1}, - {579, 106, 1}, {580, 28, 1}, {581, 30, 1}, -+ {497, 2, 1}, {498, 1, 4}, {502, 138, 1}, -+ {503, 150, 1}, {504, 1, 40}, {544, 126, 1}, -+ {546, 1, 18}, {570, 72, 1}, {571, 0, 1}, -+ {573, 124, 1}, {574, 70, 1}, {577, 0, 1}, -+ {579, 122, 1}, {580, 28, 1}, {581, 30, 1}, - {582, 1, 10}, {837, 36, 1}, {880, 1, 4}, +- {582, 1, 10}, {837, 36, 1}, {880, 1, 4}, - {886, 0, 1}, {902, 18, 1}, {904, 16, 3}, - {908, 26, 1}, {910, 24, 2}, {913, 14, 17}, - {931, 14, 9}, {962, 0, 1}, {975, 4, 1}, @@ -20874,68 +30110,97 @@ - {42878, 1, 10}, {42891, 0, 1}, {42893, 74, 1}, - {42896, 1, 4}, {42912, 1, 10}, {42922, 72, 1}, - {65313, 14, 26}, -+ {886, 0, 1}, {895, 36, 1}, {902, 18, 1}, -+ {904, 16, 3}, {908, 26, 1}, {910, 24, 2}, ++ {497, 2, 1}, {498, 1, 4}, {502, 156, 1}, ++ {503, 168, 1}, {504, 1, 40}, {544, 144, 1}, ++ {546, 1, 18}, {570, 74, 1}, {571, 0, 1}, ++ {573, 142, 1}, {574, 72, 1}, {577, 0, 1}, ++ {579, 140, 1}, {580, 30, 1}, {581, 32, 1}, ++ {582, 1, 10}, {837, 38, 1}, {880, 1, 4}, ++ {886, 0, 1}, {895, 38, 1}, {902, 20, 1}, ++ {904, 18, 3}, {908, 28, 1}, {910, 26, 2}, + {913, 14, 17}, {931, 14, 9}, {962, 0, 1}, -+ {975, 4, 1}, {976, 156, 1}, {977, 158, 1}, -+ {981, 162, 1}, {982, 160, 1}, {984, 1, 24}, -+ {1008, 152, 1}, {1009, 154, 1}, {1012, 146, 1}, -+ {1013, 144, 1}, {1015, 0, 1}, {1017, 168, 1}, -+ {1018, 0, 1}, {1021, 126, 3}, {1024, 34, 16}, ++ {975, 4, 1}, {976, 174, 1}, {977, 176, 1}, ++ {981, 180, 1}, {982, 178, 1}, {984, 1, 24}, ++ {1008, 170, 1}, {1009, 172, 1}, {1012, 164, 1}, ++ {1013, 162, 1}, {1015, 0, 1}, {1017, 186, 1}, ++ {1018, 0, 1}, {1021, 144, 3}, {1024, 36, 16}, + {1040, 14, 32}, {1120, 1, 34}, {1162, 1, 54}, + {1216, 6, 1}, {1217, 1, 14}, {1232, 1, 96}, -+ {1329, 22, 38}, {4256, 68, 38}, {4295, 68, 1}, -+ {4301, 68, 1}, {5112, 166, 6}, {7680, 1, 150}, -+ {7835, 148, 1}, {7838, 112, 1}, {7840, 1, 96}, -+ {7944, 166, 8}, {7960, 166, 6}, {7976, 166, 8}, -+ {7992, 166, 8}, {8008, 166, 6}, {8025, 167, 8}, -+ {8040, 166, 8}, {8072, 166, 8}, {8088, 166, 8}, -+ {8104, 166, 8}, {8120, 166, 2}, {8122, 142, 2}, -+ {8124, 164, 1}, {8126, 116, 1}, {8136, 140, 4}, -+ {8140, 164, 1}, {8152, 166, 2}, {8154, 136, 2}, -+ {8168, 166, 2}, {8170, 134, 2}, {8172, 168, 1}, -+ {8184, 128, 2}, {8186, 130, 2}, {8188, 164, 1}, -+ {8486, 114, 1}, {8490, 108, 1}, {8491, 110, 1}, -+ {8498, 12, 1}, {8544, 8, 16}, {8579, 0, 1}, -+ {9398, 10, 26}, {11264, 22, 47}, {11360, 0, 1}, -+ {11362, 104, 1}, {11363, 118, 1}, {11364, 106, 1}, -+ {11367, 1, 6}, {11373, 100, 1}, {11374, 102, 1}, -+ {11375, 96, 1}, {11376, 98, 1}, {11378, 0, 1}, -+ {11381, 0, 1}, {11390, 94, 2}, {11392, 1, 100}, -+ {11499, 1, 4}, {11506, 0, 1}, {42560, 1, 46}, -+ {42624, 1, 28}, {42786, 1, 14}, {42802, 1, 62}, -+ {42873, 1, 4}, {42877, 92, 1}, {42878, 1, 10}, -+ {42891, 0, 1}, {42893, 84, 1}, {42896, 1, 4}, -+ {42902, 1, 20}, {42922, 78, 1}, {42923, 74, 1}, -+ {42924, 76, 1}, {42925, 80, 1}, {42928, 88, 1}, -+ {42929, 82, 1}, {42930, 86, 1}, {42931, 66, 1}, -+ {42932, 1, 4}, {43888, 90, 80}, {65313, 14, 26}, ++ {1329, 24, 38}, {4256, 70, 38}, {4295, 70, 1}, ++ {4301, 70, 1}, {5112, 184, 6}, {7296, 122, 1}, ++ {7297, 124, 1}, {7298, 126, 1}, {7299, 130, 2}, ++ {7301, 128, 1}, {7302, 132, 1}, {7303, 134, 1}, ++ {7304, 96, 1}, {7680, 1, 150}, {7835, 166, 1}, ++ {7838, 116, 1}, {7840, 1, 96}, {7944, 184, 8}, ++ {7960, 184, 6}, {7976, 184, 8}, {7992, 184, 8}, ++ {8008, 184, 6}, {8025, 185, 8}, {8040, 184, 8}, ++ {8072, 184, 8}, {8088, 184, 8}, {8104, 184, 8}, ++ {8120, 184, 2}, {8122, 160, 2}, {8124, 182, 1}, ++ {8126, 120, 1}, {8136, 158, 4}, {8140, 182, 1}, ++ {8152, 184, 2}, {8154, 154, 2}, {8168, 184, 2}, ++ {8170, 152, 2}, {8172, 186, 1}, {8184, 146, 2}, ++ {8186, 148, 2}, {8188, 182, 1}, {8486, 118, 1}, ++ {8490, 112, 1}, {8491, 114, 1}, {8498, 12, 1}, ++ {8544, 8, 16}, {8579, 0, 1}, {9398, 10, 26}, ++ {11264, 24, 47}, {11360, 0, 1}, {11362, 108, 1}, ++ {11363, 136, 1}, {11364, 110, 1}, {11367, 1, 6}, ++ {11373, 104, 1}, {11374, 106, 1}, {11375, 100, 1}, ++ {11376, 102, 1}, {11378, 0, 1}, {11381, 0, 1}, ++ {11390, 98, 2}, {11392, 1, 100}, {11499, 1, 4}, ++ {11506, 0, 1}, {42560, 1, 46}, {42624, 1, 28}, ++ {42786, 1, 14}, {42802, 1, 62}, {42873, 1, 4}, ++ {42877, 94, 1}, {42878, 1, 10}, {42891, 0, 1}, ++ {42893, 86, 1}, {42896, 1, 4}, {42902, 1, 20}, ++ {42922, 80, 1}, {42923, 76, 1}, {42924, 78, 1}, ++ {42925, 82, 1}, {42926, 80, 1}, {42928, 90, 1}, ++ {42929, 84, 1}, {42930, 88, 1}, {42931, 68, 1}, ++ {42932, 1, 4}, {43888, 92, 80}, {65313, 14, 26}, }; static const unsigned short aiOff[] = { 1, 2, 8, 15, 16, 26, 28, 32, - 37, 38, 40, 48, 63, 64, 69, 71, - 79, 80, 116, 202, 203, 205, 206, 207, - 209, 210, 211, 213, 214, 217, 218, 219, +- 37, 38, 40, 48, 63, 64, 69, 71, +- 79, 80, 116, 202, 203, 205, 206, 207, +- 209, 210, 211, 213, 214, 217, 218, 219, - 775, 7264, 10792, 10795, 23228, 23256, 30204, 54721, -+ 775, 928, 7264, 10792, 10795, 23217, 23221, 23228, -+ 23231, 23254, 23256, 23275, 23278, 26672, 30204, 54721, - 54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, - 57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, - 65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, -@@ -185051,6 +185685,12 @@ static int sqlite3Fts5UnicodeFold(int c, +- 54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, +- 57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, +- 65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, +- 65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, +- 65514, 65521, 65527, 65528, 65529, ++ 34, 37, 38, 40, 48, 63, 64, 69, ++ 71, 79, 80, 116, 202, 203, 205, 206, ++ 207, 209, 210, 211, 213, 214, 217, 218, ++ 219, 775, 928, 7264, 10792, 10795, 23217, 23221, ++ 23228, 23231, 23254, 23256, 23275, 23278, 26672, 30204, ++ 35267, 54721, 54753, 54754, 54756, 54787, 54793, 54809, ++ 57153, 57274, 57921, 58019, 58363, 59314, 59315, 59324, ++ 59325, 59326, 59332, 59356, 61722, 65268, 65341, 65373, ++ 65406, 65408, 65410, 65415, 65424, 65436, 65439, 65450, ++ 65462, 65472, 65476, 65478, 65480, 65482, 65488, 65506, ++ 65511, 65514, 65521, 65527, 65528, 65529, + }; + + int ret = c; +@@ -201103,6 +201923,18 @@ static int sqlite3Fts5UnicodeFold(int c, else if( c>=66560 && c<66600 ){ ret = c + 40; } ++ else if( c>=66736 && c<66772 ){ ++ ret = c + 40; ++ } + else if( c>=68736 && c<68787 ){ + ret = c + 64; + } + else if( c>=71840 && c<71872 ){ + ret = c + 32; ++ } ++ else if( c>=125184 && c<125218 ){ ++ ret = c + 34; + } return ret; } -@@ -185574,12 +186214,12 @@ static int fts5VocabInitVtab( +@@ -201629,12 +202461,12 @@ static int fts5VocabInitVtab( *pzErr = sqlite3_mprintf("wrong number of vtable arguments"); rc = SQLITE_ERROR; }else{ @@ -20951,7 +30216,7 @@ int eType = 0; rc = fts5VocabTableType(zType, pzErr, &eType); -@@ -185725,7 +186365,7 @@ static int fts5VocabOpenMethod( +@@ -201793,7 +202625,7 @@ static int fts5VocabOpenMethod( } if( rc==SQLITE_OK ){ @@ -20960,19 +30225,311 @@ pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte); } ---- origsrc/sqlite-autoconf-3100000/sqlite3.h 2016-01-06 13:03:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/sqlite3.h 2016-01-06 17:04:46.843051000 +0100 -@@ -112,7 +112,7 @@ extern "C" { +--- origsrc/sqlite-autoconf-3180000/sqlite3.h 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/sqlite3.h 2017-04-19 16:20:02.077946400 +0200 +@@ -108,7 +108,7 @@ extern "C" { + ** be held constant and Z will be incremented or else Y will be incremented + ** and Z will be reset to zero. + ** +-** Since [version 3.6.18] ([dateof:3.6.18]), ++** Since [version 3.6.18] ([dateof:3.6.18]), + ** SQLite source code has been stored in the + ** Fossil configuration management + ** system. ^The SQLITE_SOURCE_ID macro evaluates to +@@ -122,7 +122,7 @@ extern "C" { ** [sqlite_version()] and [sqlite_source_id()]. */ - #define SQLITE_VERSION "3.10.0" --#define SQLITE_VERSION_NUMBER 3010000 -+#define SQLITE_VERSION_NUMBER 3009000 - #define SQLITE_SOURCE_ID "2016-01-06 11:01:07 fd0a50f0797d154fefff724624f00548b5320566" + #define SQLITE_VERSION "3.18.0" +-#define SQLITE_VERSION_NUMBER 3018000 ++#define SQLITE_VERSION_NUMBER 3016000 + #define SQLITE_SOURCE_ID "2017-03-28 18:48:43 424a0d380332858ee55bdebc4af3789f74e70a2b3ba1cf29d84b9b4bcf3e2e37" /* -@@ -1422,81 +1422,6 @@ SQLITE_API int SQLITE_CDECL sqlite3_conf - SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...); +@@ -149,8 +149,8 @@ extern "C" { + ** function is provided for use in DLLs since DLL users usually do not have + ** direct access to string constants within the DLL. ^The + ** sqlite3_libversion_number() function returns an integer equal to +-** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns +-** a pointer to a string constant whose value is the same as the ++** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns ++** a pointer to a string constant whose value is the same as the + ** [SQLITE_SOURCE_ID] C preprocessor macro. + ** + ** See also: [sqlite_version()] and [sqlite_source_id()]. +@@ -163,20 +163,20 @@ SQLITE_API int sqlite3_libversion_number + /* + ** CAPI3REF: Run-Time Library Compilation Options Diagnostics + ** +-** ^The sqlite3_compileoption_used() function returns 0 or 1 +-** indicating whether the specified option was defined at +-** compile time. ^The SQLITE_ prefix may be omitted from the +-** option name passed to sqlite3_compileoption_used(). ++** ^The sqlite3_compileoption_used() function returns 0 or 1 ++** indicating whether the specified option was defined at ++** compile time. ^The SQLITE_ prefix may be omitted from the ++** option name passed to sqlite3_compileoption_used(). + ** + ** ^The sqlite3_compileoption_get() function allows iterating + ** over the list of options that were defined at compile time by + ** returning the N-th compile time option string. ^If N is out of range, +-** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ +-** prefix is omitted from any strings returned by ++** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ ++** prefix is omitted from any strings returned by + ** sqlite3_compileoption_get(). + ** + ** ^Support for the diagnostic functions sqlite3_compileoption_used() +-** and sqlite3_compileoption_get() may be omitted by specifying the ++** and sqlite3_compileoption_get() may be omitted by specifying the + ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. + ** + ** See also: SQL functions [sqlite_compileoption_used()] and +@@ -197,7 +197,7 @@ SQLITE_API const char *sqlite3_compileop + ** SQLite can be compiled with or without mutexes. When + ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes + ** are enabled and SQLite is threadsafe. When the +-** [SQLITE_THREADSAFE] macro is 0, ++** [SQLITE_THREADSAFE] macro is 0, + ** the mutexes are omitted. Without the mutexes, it is not safe + ** to use SQLite concurrently from more than one thread. + ** +@@ -254,14 +254,14 @@ typedef struct sqlite3 sqlite3; + ** + ** ^The sqlite3_int64 and sqlite_int64 types can store integer values + ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The +-** sqlite3_uint64 and sqlite_uint64 types can store integer values ++** sqlite3_uint64 and sqlite_uint64 types can store integer values + ** between 0 and +18446744073709551615 inclusive. + */ + #ifdef SQLITE_INT64_TYPE + typedef SQLITE_INT64_TYPE sqlite_int64; + # ifdef SQLITE_UINT64_TYPE + typedef SQLITE_UINT64_TYPE sqlite_uint64; +-# else ++# else + typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; + # endif + #elif defined(_MSC_VER) || defined(__BORLANDC__) +@@ -304,7 +304,7 @@ typedef sqlite_uint64 sqlite3_uint64; + ** destructors are called is arbitrary. + ** + ** Applications should [sqlite3_finalize | finalize] all [prepared statements], +-** [sqlite3_blob_close | close] all [BLOB handles], and ++** [sqlite3_blob_close | close] all [BLOB handles], and + ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated + ** with the [sqlite3] object prior to attempting to close the object. ^If + ** sqlite3_close_v2() is called on a [database connection] that still has +@@ -341,7 +341,7 @@ typedef int (*sqlite3_callback)(void*,in + ** The sqlite3_exec() interface is a convenience wrapper around + ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], + ** that allows an application to run multiple statements of SQL +-** without having to use a lot of C code. ++** without having to use a lot of C code. + ** + ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, + ** semicolon-separate SQL statements passed into its 2nd argument, +@@ -381,7 +381,7 @@ typedef int (*sqlite3_callback)(void*,in + ** from [sqlite3_column_name()]. + ** + ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer +-** to an empty string, or a pointer that contains only whitespace and/or ++** to an empty string, or a pointer that contains only whitespace and/or + ** SQL comments, then no SQL statements are evaluated and the database + ** is not changed. + ** +@@ -642,7 +642,7 @@ SQLITE_API int sqlite3_exec( + /* + ** CAPI3REF: OS Interface Open File Handle + ** +-** An [sqlite3_file] object represents an open file in the ++** An [sqlite3_file] object represents an open file in the + ** [sqlite3_vfs | OS interface layer]. Individual OS interface + ** implementations will + ** want to subclass this object by appending additional fields +@@ -664,7 +664,7 @@ struct sqlite3_file { + ** This object defines the methods used to perform various operations + ** against the open file represented by the [sqlite3_file] object. + ** +-** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element ++** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element + ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method + ** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The + ** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] +@@ -804,7 +804,7 @@ struct sqlite3_io_methods { + **
  • [[SQLITE_FCNTL_CHUNK_SIZE]] + ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS + ** extends and truncates the database file in chunks of a size specified +-** by the user. The fourth argument to [sqlite3_file_control()] should ++** by the user. The fourth argument to [sqlite3_file_control()] should + ** point to an integer (type int) containing the new chunk-size to use + ** for the nominated database. Allocating database file space in large + ** chunks (say 1MB at a time), may reduce file-system fragmentation and +@@ -827,24 +827,24 @@ struct sqlite3_io_methods { + **
  • [[SQLITE_FCNTL_SYNC]] + ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and + ** sent to the VFS immediately before the xSync method is invoked on a +-** database file descriptor. Or, if the xSync method is not invoked +-** because the user has configured SQLite with +-** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place ++** database file descriptor. Or, if the xSync method is not invoked ++** because the user has configured SQLite with ++** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place + ** of the xSync method. In most cases, the pointer argument passed with + ** this file-control is NULL. However, if the database file is being synced + ** as part of a multi-database commit, the argument points to a nul-terminated +-** string containing the transactions master-journal file name. VFSes that +-** do not need this signal should silently ignore this opcode. Applications +-** should not call [sqlite3_file_control()] with this opcode as doing so may +-** disrupt the operation of the specialized VFSes that do require it. ++** string containing the transactions master-journal file name. VFSes that ++** do not need this signal should silently ignore this opcode. Applications ++** should not call [sqlite3_file_control()] with this opcode as doing so may ++** disrupt the operation of the specialized VFSes that do require it. + ** + **
  • [[SQLITE_FCNTL_COMMIT_PHASETWO]] + ** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite + ** and sent to the VFS after a transaction has been committed immediately + ** but before the database is unlocked. VFSes that do not need this signal + ** should silently ignore this opcode. Applications should not call +-** [sqlite3_file_control()] with this opcode as doing so may disrupt the +-** operation of the specialized VFSes that do require it. ++** [sqlite3_file_control()] with this opcode as doing so may disrupt the ++** operation of the specialized VFSes that do require it. + ** + **
  • [[SQLITE_FCNTL_WIN32_AV_RETRY]] + ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic +@@ -891,13 +891,13 @@ struct sqlite3_io_methods { + **
  • [[SQLITE_FCNTL_OVERWRITE]] + ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening + ** a write transaction to indicate that, unless it is rolled back for some +-** reason, the entire database file will be overwritten by the current ++** reason, the entire database file will be overwritten by the current + ** transaction. This is used by VACUUM operations. + ** + **
  • [[SQLITE_FCNTL_VFSNAME]] + ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of + ** all [VFSes] in the VFS stack. The names are of all VFS shims and the +-** final bottom-level VFS are written into memory obtained from ++** final bottom-level VFS are written into memory obtained from + ** [sqlite3_malloc()] and the result is stored in the char* variable + ** that the fourth parameter of [sqlite3_file_control()] points to. + ** The caller is responsible for freeing the memory when done. As with +@@ -916,7 +916,7 @@ struct sqlite3_io_methods { + ** upper-most shim only. + ** + **
  • [[SQLITE_FCNTL_PRAGMA]] +-** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] ++** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] + ** file control is sent to the open [sqlite3_file] object corresponding + ** to the database file to which the pragma statement refers. ^The argument + ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of +@@ -927,7 +927,7 @@ struct sqlite3_io_methods { + ** of the char** argument point to a string obtained from [sqlite3_mprintf()] + ** or the equivalent and that string will become the result of the pragma or + ** the error message if the pragma fails. ^If the +-** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal ++** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal + ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] + ** file control returns [SQLITE_OK], then the parser assumes that the + ** VFS has handled the PRAGMA itself and the parser generates a no-op +@@ -967,7 +967,7 @@ struct sqlite3_io_methods { + ** The argument is a pointer to a value of type sqlite3_int64 that + ** is an advisory maximum number of bytes in the file to memory map. The + ** pointer is overwritten with the old value. The limit is not changed if +-** the value originally pointed to is negative, and so the current limit ++** the value originally pointed to is negative, and so the current limit + ** can be queried by passing in a pointer to a negative number. This + ** file-control is used internally to implement [PRAGMA mmap_size]. + ** +@@ -1011,7 +1011,7 @@ struct sqlite3_io_methods { + **
  • [[SQLITE_FCNTL_RBU]] + ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by + ** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for +-** this opcode. ++** this opcode. + ** + */ + #define SQLITE_FCNTL_LOCKSTATE 1 +@@ -1120,14 +1120,14 @@ typedef struct sqlite3_api_routines sqli + ** the [sqlite3_file] can safely store a pointer to the + ** filename if it needs to remember the filename for some reason. + ** If the zFilename parameter to xOpen is a NULL pointer then xOpen +-** must invent its own temporary name for the file. ^Whenever the ++** must invent its own temporary name for the file. ^Whenever the + ** xFilename parameter is NULL it will also be the case that the + ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. + ** + ** The flags argument to xOpen() includes all bits set in + ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] + ** or [sqlite3_open16()] is used, then flags includes at least +-** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. ++** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. + ** If xOpen() opens a file read-only then it sets *pOutFlags to + ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. + ** +@@ -1169,10 +1169,10 @@ typedef struct sqlite3_api_routines sqli + ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction + ** with the [SQLITE_OPEN_CREATE] flag, which are both directly + ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() +-** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the ++** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the + ** SQLITE_OPEN_CREATE, is used to indicate that file should always + ** be created, and that it is an error if it already exists. +-** It is not used to indicate the file should be opened ++** It is not used to indicate the file should be opened + ** for exclusive access. + ** + ** ^At least szOsFile bytes of memory are allocated by SQLite +@@ -1210,16 +1210,16 @@ typedef struct sqlite3_api_routines sqli + ** method returns a Julian Day Number for the current date and time as + ** a floating point value. + ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian +-** Day Number multiplied by 86400000 (the number of milliseconds in +-** a 24-hour day). ++** Day Number multiplied by 86400000 (the number of milliseconds in ++** a 24-hour day). + ** ^SQLite will use the xCurrentTimeInt64() method to get the current +-** date and time if that method is available (if iVersion is 2 or ++** date and time if that method is available (if iVersion is 2 or + ** greater and the function pointer is not NULL) and will fall back + ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. + ** + ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces + ** are not used by the SQLite core. These optional interfaces are provided +-** by some VFSes to facilitate testing of the VFS code. By overriding ++** by some VFSes to facilitate testing of the VFS code. By overriding + ** system calls with functions under its control, a test program can + ** simulate faults and error conditions that would otherwise be difficult + ** or impossible to induce. The set of system calls that can be overridden +@@ -1266,7 +1266,7 @@ struct sqlite3_vfs { + /* + ** The methods above are in versions 1 through 3 of the sqlite_vfs object. + ** New fields may be appended in future versions. The iVersion +- ** value will increment whenever this happens. ++ ** value will increment whenever this happens. + */ + }; + +@@ -1310,7 +1310,7 @@ struct sqlite3_vfs { + ** + ** + ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as +-** was given on the corresponding lock. ++** was given on the corresponding lock. + ** + ** The xShmLock method can transition between unlocked and SHARED or + ** between unlocked and EXCLUSIVE. It cannot transition between SHARED +@@ -1455,7 +1455,7 @@ SQLITE_API int sqlite3_config(int, ...); + ** [database connection] (specified in the first argument). + ** + ** The second argument to sqlite3_db_config(D,V,...) is the +-** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code ++** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code + ** that indicates what aspect of the [database connection] is being configured. + ** Subsequent arguments vary depending on the configuration verb. + ** +@@ -1465,81 +1465,6 @@ SQLITE_API int sqlite3_config(int, ...); + SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); /* -** CAPI3REF: Memory Allocation Routines @@ -21053,7 +30610,16 @@ ** CAPI3REF: Configuration Options ** KEYWORDS: {configuration option} ** -@@ -1552,24 +1477,6 @@ struct sqlite3_mem_methods { +@@ -1561,7 +1486,7 @@ struct sqlite3_mem_methods { + ** by a single thread. ^If SQLite is compiled with + ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then + ** it is not possible to change the [threading mode] from its default +-** value of Single-thread and so [sqlite3_config()] will return ++** value of Single-thread and so [sqlite3_config()] will return + ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD + ** configuration option.
  • + ** +@@ -1595,24 +1520,6 @@ struct sqlite3_mem_methods { ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_SERIALIZED configuration option. ** @@ -21078,65 +30644,848 @@ ** [[SQLITE_CONFIG_MEMSTATUS]]
    SQLITE_CONFIG_MEMSTATUS
    **
    ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, ** interpreted as a boolean, which enables or disables the collection of -@@ -3569,7 +3476,7 @@ typedef struct sqlite3_context sqlite3_c +@@ -1642,7 +1549,7 @@ struct sqlite3_mem_methods { + ** ^SQLite will never request a scratch buffer that is more than 6 + ** times the database page size. + ** ^If SQLite needs needs additional +-** scratch memory beyond what is provided by this configuration option, then ++** scratch memory beyond what is provided by this configuration option, then + ** [sqlite3_malloc()] will be used to obtain the memory needed.

    + ** ^When the application provides any amount of scratch memory using + ** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large +@@ -1654,7 +1561,7 @@ struct sqlite3_mem_methods { + ** [[SQLITE_CONFIG_PAGECACHE]]

    SQLITE_CONFIG_PAGECACHE
    + **
    ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool + ** that SQLite can use for the database page cache with the default page +-** cache implementation. ++** cache implementation. + ** This configuration option is a no-op if an application-define page + ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]. + ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to +@@ -1682,7 +1589,7 @@ struct sqlite3_mem_methods { + ** additional cache line.
    + ** + ** [[SQLITE_CONFIG_HEAP]]
    SQLITE_CONFIG_HEAP
    +-**
    ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer ++**
    ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer + ** that SQLite will use for all of its dynamic memory allocation needs + ** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and + ** [SQLITE_CONFIG_PAGECACHE]. +@@ -1738,7 +1645,7 @@ struct sqlite3_mem_methods { + ** configuration on individual connections.)^
    + ** + ** [[SQLITE_CONFIG_PCACHE2]]
    SQLITE_CONFIG_PCACHE2
    +-**
    ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is ++**
    ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is + ** a pointer to an [sqlite3_pcache_methods2] object. This object specifies + ** the interface to a custom page cache implementation.)^ + ** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.
    +@@ -1752,7 +1659,7 @@ struct sqlite3_mem_methods { + **
    The SQLITE_CONFIG_LOG option is used to configure the SQLite + ** global [error log]. + ** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a +-** function with a call signature of void(*)(void*,int,const char*), ++** function with a call signature of void(*)(void*,int,const char*), + ** and a pointer to void. ^If the function pointer is not NULL, it is + ** invoked by [sqlite3_log()] to process each logging event. ^If the + ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. +@@ -1861,7 +1768,7 @@ struct sqlite3_mem_methods { + ** [[SQLITE_CONFIG_STMTJRNL_SPILL]] + **
    SQLITE_CONFIG_STMTJRNL_SPILL + **
    ^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which +-** becomes the [statement journal] spill-to-disk threshold. ++** becomes the [statement journal] spill-to-disk threshold. + ** [Statement journals] are held in memory until their size (in bytes) + ** exceeds this threshold, at which point they are written to disk. + ** Or if the threshold is -1, statement journals are always held +@@ -1884,7 +1791,7 @@ struct sqlite3_mem_methods { + #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ + #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ + #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ +-/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ ++/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ + #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ + #define SQLITE_CONFIG_PCACHE 14 /* no-op */ + #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ +@@ -1915,7 +1822,7 @@ struct sqlite3_mem_methods { + ** + **
    + **
    SQLITE_DBCONFIG_LOOKASIDE
    +-**
    ^This option takes three additional arguments that determine the ++**
    ^This option takes three additional arguments that determine the + ** [lookaside memory allocator] configuration for the [database connection]. + ** ^The first argument (the third parameter to [sqlite3_db_config()] is a + ** pointer to a memory buffer to use for lookaside memory. +@@ -1933,7 +1840,7 @@ struct sqlite3_mem_methods { + ** when the "current value" returned by + ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. + ** Any attempt to change the lookaside memory configuration when lookaside +-** memory is in use leaves the configuration unchanged and returns ++** memory is in use leaves the configuration unchanged and returns + ** [SQLITE_BUSY].)^
    + ** + **
    SQLITE_DBCONFIG_ENABLE_FKEY
    +@@ -1996,9 +1903,9 @@ struct sqlite3_mem_methods { + **
    + ** + **
    SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
    +-**
    Usually, when a database in wal mode is closed or detached from a +-** database handle, SQLite checks if this will mean that there are now no +-** connections at all to the database. If so, it performs a checkpoint ++**
    Usually, when a database in wal mode is closed or detached from a ++** database handle, SQLite checks if this will mean that there are now no ++** connections at all to the database. If so, it performs a checkpoint + ** operation before closing the connection. This option may be used to + ** override this behaviour. The first parameter passed to this operation + ** is an integer - non-zero to disable checkpoints-on-close, or zero (the +@@ -2043,8 +1950,8 @@ SQLITE_API int sqlite3_extended_result_c + ** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of + ** the most recent successful [INSERT] into a rowid table or [virtual table] + ** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not +-** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred +-** on the database connection D, then sqlite3_last_insert_rowid(D) returns ++** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred ++** on the database connection D, then sqlite3_last_insert_rowid(D) returns + ** zero. + ** + ** As well as being set automatically as rows are inserted into database +@@ -2054,15 +1961,15 @@ SQLITE_API int sqlite3_extended_result_c + ** Some virtual table implementations may INSERT rows into rowid tables as + ** part of committing a transaction (e.g. to flush data accumulated in memory + ** to disk). In this case subsequent calls to this function return the rowid +-** associated with these internal INSERT operations, which leads to ++** associated with these internal INSERT operations, which leads to + ** unintuitive results. Virtual table implementations that do write to rowid +-** tables in this way can avoid this problem by restoring the original +-** rowid value using [sqlite3_set_last_insert_rowid()] before returning ++** tables in this way can avoid this problem by restoring the original ++** rowid value using [sqlite3_set_last_insert_rowid()] before returning + ** control to the user. + ** +-** ^(If an [INSERT] occurs within a trigger then this routine will +-** return the [rowid] of the inserted row as long as the trigger is +-** running. Once the trigger program ends, the value returned ++** ^(If an [INSERT] occurs within a trigger then this routine will ++** return the [rowid] of the inserted row as long as the trigger is ++** running. Once the trigger program ends, the value returned + ** by this routine reverts to what it was before the trigger was fired.)^ + ** + ** ^An [INSERT] that fails due to a constraint violation is not a +@@ -2095,7 +2002,7 @@ SQLITE_API sqlite3_int64 sqlite3_last_in + ** METHOD: sqlite3 + ** + ** The sqlite3_set_last_insert_rowid(D, R) method allows the application to +-** set the value returned by calling sqlite3_last_insert_rowid(D) to R ++** set the value returned by calling sqlite3_last_insert_rowid(D) to R + ** without inserting a row into the database. + */ + SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); +@@ -2111,37 +2018,37 @@ SQLITE_API void sqlite3_set_last_insert_ + ** returned by this function. + ** + ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are +-** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], ++** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], + ** [foreign key actions] or [REPLACE] constraint resolution are not counted. +-** +-** Changes to a view that are intercepted by +-** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value +-** returned by sqlite3_changes() immediately after an INSERT, UPDATE or +-** DELETE statement run on a view is always zero. Only changes made to real ++** ++** Changes to a view that are intercepted by ++** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value ++** returned by sqlite3_changes() immediately after an INSERT, UPDATE or ++** DELETE statement run on a view is always zero. Only changes made to real + ** tables are counted. + ** + ** Things are more complicated if the sqlite3_changes() function is + ** executed while a trigger program is running. This may happen if the + ** program uses the [changes() SQL function], or if some other callback + ** function invokes sqlite3_changes() directly. Essentially: +-** ++** + **
      + **
    • ^(Before entering a trigger program the value returned by +-** sqlite3_changes() function is saved. After the trigger program ++** sqlite3_changes() function is saved. After the trigger program + ** has finished, the original value is restored.)^ +-** +-**
    • ^(Within a trigger program each INSERT, UPDATE and DELETE +-** statement sets the value returned by sqlite3_changes() +-** upon completion as normal. Of course, this value will not include +-** any changes performed by sub-triggers, as the sqlite3_changes() ++** ++**
    • ^(Within a trigger program each INSERT, UPDATE and DELETE ++** statement sets the value returned by sqlite3_changes() ++** upon completion as normal. Of course, this value will not include ++** any changes performed by sub-triggers, as the sqlite3_changes() + ** value will be saved and restored after each sub-trigger has run.)^ + **
    +-** ++** + ** ^This means that if the changes() SQL function (or similar) is used +-** by the first INSERT, UPDATE or DELETE statement within a trigger, it ++** by the first INSERT, UPDATE or DELETE statement within a trigger, it + ** returns the value as set when the calling statement began executing. +-** ^If it is used by the second or subsequent such statement within a trigger +-** program, the value returned reflects the number of rows modified by the ++** ^If it is used by the second or subsequent such statement within a trigger ++** program, the value returned reflects the number of rows modified by the + ** previous INSERT, UPDATE or DELETE statement within the same trigger. + ** + ** See also the [sqlite3_total_changes()] interface, the +@@ -2151,7 +2058,9 @@ SQLITE_API void sqlite3_set_last_insert_ + ** while [sqlite3_changes()] is running then the value returned + ** is unpredictable and not meaningful. + */ +-SQLITE_API int sqlite3_changes(sqlite3*); ++SQLITE_API sqlite3_uint64 sqlite3_changes(sqlite3*); ++#define sqlite3_changes(db) ((int)(sqlite3_changes)(db)) ++#define sqlite3_changes64(db) ((sqlite3_changes)(db)) + + /* + ** CAPI3REF: Total Number Of Rows Modified +@@ -2162,12 +2071,12 @@ SQLITE_API int sqlite3_changes(sqlite3*) + ** since the database connection was opened, including those executed as + ** part of trigger programs. ^Executing any other type of SQL statement + ** does not affect the value returned by sqlite3_total_changes(). +-** ++** + ** ^Changes made as part of [foreign key actions] are included in the + ** count, but those made as part of REPLACE constraint resolution are +-** not. ^Changes to a view that are intercepted by INSTEAD OF triggers ++** not. ^Changes to a view that are intercepted by INSTEAD OF triggers + ** are not counted. +-** ++** + ** See also the [sqlite3_changes()] interface, the + ** [count_changes pragma], and the [total_changes() SQL function]. + ** +@@ -2175,7 +2084,9 @@ SQLITE_API int sqlite3_changes(sqlite3*) + ** while [sqlite3_total_changes()] is running then the value + ** returned is unpredictable and not meaningful. + */ +-SQLITE_API int sqlite3_total_changes(sqlite3*); ++SQLITE_API sqlite3_uint64 sqlite3_total_changes(sqlite3*); ++#define sqlite3_total_changes(db) ((int)(sqlite3_total_changes)(db)) ++#define sqlite3_total_changes64(db) ((sqlite3_total_changes)(db)) + + /* + ** CAPI3REF: Interrupt A Long-Running Query +@@ -2203,7 +2114,7 @@ SQLITE_API int sqlite3_total_changes(sql + ** + ** ^The sqlite3_interrupt(D) call is in effect until all currently running + ** SQL statements on [database connection] D complete. ^Any new SQL statements +-** that are started after the sqlite3_interrupt() call and before the ++** that are started after the sqlite3_interrupt() call and before the + ** running statements reaches zero are interrupted as if they had been + ** running prior to the sqlite3_interrupt() call. ^New SQL statements + ** that are started after the running statement count reaches zero are +@@ -2238,7 +2149,7 @@ SQLITE_API void sqlite3_interrupt(sqlite + ** ^These routines do not parse the SQL statements thus + ** will not detect syntactically incorrect SQL. + ** +-** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior ++** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior + ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked + ** automatically by sqlite3_complete16(). If that initialization fails, + ** then the return value from sqlite3_complete16() will be non-zero +@@ -2283,7 +2194,7 @@ SQLITE_API int sqlite3_complete16(const + ** The presence of a busy handler does not guarantee that it will be invoked + ** when there is lock contention. ^If SQLite determines that invoking the busy + ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] +-** to the application instead of invoking the ++** to the application instead of invoking the + ** busy handler. + ** Consider a scenario where one process is holding a read lock that + ** it is trying to promote to a reserved lock and +@@ -2308,7 +2219,7 @@ SQLITE_API int sqlite3_complete16(const + ** database connection that invoked the busy handler. In other words, + ** the busy handler is not reentrant. Any such actions + ** result in undefined behavior. +-** ++** + ** A busy handler must not close the database connection + ** or [prepared statement] that invoked the busy handler. + */ +@@ -2697,7 +2608,7 @@ SQLITE_API void sqlite3_randomness(int N + ** requested is ok. ^When the callback returns [SQLITE_DENY], the + ** [sqlite3_prepare_v2()] or equivalent call that triggered the + ** authorizer will fail with an error message explaining that +-** access is denied. ++** access is denied. + ** + ** ^The first parameter to the authorizer callback is a copy of the third + ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter +@@ -2744,7 +2655,7 @@ SQLITE_API void sqlite3_randomness(int N + ** database connections for the meaning of "modify" in this paragraph. + ** + ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the +-** statement might be re-prepared during [sqlite3_step()] due to a ++** statement might be re-prepared during [sqlite3_step()] due to a + ** schema change. Hence, the application should ensure that the + ** correct authorizer callback remains in place during the [sqlite3_step()]. + ** +@@ -2892,7 +2803,7 @@ SQLITE_API SQLITE_DEPRECATED void *sqlit + ** execution of the prepared statement, such as at the start of each + ** trigger subprogram. ^The P argument is a pointer to the + ** [prepared statement]. ^The X argument is a pointer to a string which +-** is the unexpanded SQL text of the prepared statement or an SQL comment ++** is the unexpanded SQL text of the prepared statement or an SQL comment + ** that indicates the invocation of a trigger. ^The callback can compute + ** the same text that would have been returned by the legacy [sqlite3_trace()] + ** interface by using the X argument when X begins with "--" and invoking +@@ -2908,7 +2819,7 @@ SQLITE_API SQLITE_DEPRECATED void *sqlit + ** + ** [[SQLITE_TRACE_ROW]]
    SQLITE_TRACE_ROW
    + **
    ^An SQLITE_TRACE_ROW callback is invoked whenever a prepared +-** statement generates a single row of result. ++** statement generates a single row of result. + ** ^The P argument is a pointer to the [prepared statement] and the + ** X argument is unused. + ** +@@ -2935,10 +2846,10 @@ SQLITE_API SQLITE_DEPRECATED void *sqlit + ** M argument should be the bitwise OR-ed combination of + ** zero or more [SQLITE_TRACE] constants. + ** +-** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides ++** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides + ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). + ** +-** ^The X callback is invoked whenever any of the events identified by ++** ^The X callback is invoked whenever any of the events identified by + ** mask M occur. ^The integer return value from the callback is currently + ** ignored, though this may change in future releases. Callback + ** implementations should return zero to ensure future compatibility. +@@ -2970,8 +2881,8 @@ SQLITE_API int sqlite3_trace_v2( + ** database connection D. An example use for this + ** interface is to keep a GUI updated during a large query. + ** +-** ^The parameter P is passed through as the only parameter to the +-** callback function X. ^The parameter N is the approximate number of ++** ^The parameter P is passed through as the only parameter to the ++** callback function X. ^The parameter N is the approximate number of + ** [virtual machine instructions] that are evaluated between successive + ** invocations of the callback X. ^If N is less than one then the progress + ** handler is disabled. +@@ -2998,7 +2909,7 @@ SQLITE_API void sqlite3_progress_handler + ** CAPI3REF: Opening A New Database Connection + ** CONSTRUCTOR: sqlite3 + ** +-** ^These routines open an SQLite database file as specified by the ++** ^These routines open an SQLite database file as specified by the + ** filename argument. ^The filename argument is interpreted as UTF-8 for + ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte + ** order for sqlite3_open16(). ^(A [database connection] handle is usually +@@ -3023,7 +2934,7 @@ SQLITE_API void sqlite3_progress_handler + ** except that it accepts two additional parameters for additional control + ** over the new database connection. ^(The flags parameter to + ** sqlite3_open_v2() can take one of +-** the following three values, optionally combined with the ++** the following three values, optionally combined with the + ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], + ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ + ** +@@ -3091,17 +3002,17 @@ SQLITE_API void sqlite3_progress_handler + ** information. + ** + ** URI filenames are parsed according to RFC 3986. ^If the URI contains an +-** authority, then it must be either an empty string or the string +-** "localhost". ^If the authority is not an empty string or "localhost", an +-** error is returned to the caller. ^The fragment component of a URI, if ++** authority, then it must be either an empty string or the string ++** "localhost". ^If the authority is not an empty string or "localhost", an ++** error is returned to the caller. ^The fragment component of a URI, if + ** present, is ignored. + ** + ** ^SQLite uses the path component of the URI as the name of the disk file +-** which contains the database. ^If the path begins with a '/' character, +-** then it is interpreted as an absolute path. ^If the path does not begin ++** which contains the database. ^If the path begins with a '/' character, ++** then it is interpreted as an absolute path. ^If the path does not begin + ** with a '/' (meaning that the authority section is omitted from the URI) +-** then the path is interpreted as a relative path. +-** ^(On windows, the first component of an absolute path ++** then the path is interpreted as a relative path. ++** ^(On windows, the first component of an absolute path + ** is a drive specification (e.g. "C:").)^ + ** + ** [[core URI query parameters]] +@@ -3121,13 +3032,13 @@ SQLITE_API void sqlite3_progress_handler + ** + **
  • mode: ^(The mode parameter may be set to either "ro", "rw", + ** "rwc", or "memory". Attempting to set it to any other value is +-** an error)^. +-** ^If "ro" is specified, then the database is opened for read-only +-** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the +-** third argument to sqlite3_open_v2(). ^If the mode option is set to +-** "rw", then the database is opened for read-write (but not create) +-** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had +-** been set. ^Value "rwc" is equivalent to setting both ++** an error)^. ++** ^If "ro" is specified, then the database is opened for read-only ++** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the ++** third argument to sqlite3_open_v2(). ^If the mode option is set to ++** "rw", then the database is opened for read-write (but not create) ++** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had ++** been set. ^Value "rwc" is equivalent to setting both + ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is + ** set to "memory" then a pure [in-memory database] that never reads + ** or writes from disk is used. ^It is an error to specify a value for +@@ -3137,7 +3048,7 @@ SQLITE_API void sqlite3_progress_handler + **
  • cache: ^The cache parameter may be set to either "shared" or + ** "private". ^Setting it to "shared" is equivalent to setting the + ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to +-** sqlite3_open_v2(). ^Setting the cache parameter to "private" is ++** sqlite3_open_v2(). ^Setting the cache parameter to "private" is + ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. + ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in + ** a URI filename, its value overrides any behavior requested by setting +@@ -3163,7 +3074,7 @@ SQLITE_API void sqlite3_progress_handler + ** property on a database file that does in fact change can result + ** in incorrect query results and/or [SQLITE_CORRUPT] errors. + ** See also: [SQLITE_IOCAP_IMMUTABLE]. +-** ++** + ** + ** + ** ^Specifying an unknown parameter in the query component of a URI is not an +@@ -3175,36 +3086,36 @@ SQLITE_API void sqlite3_progress_handler + ** + **
  • + **
    URI filenames Results +-**
    file:data.db ++**
    file:data.db + ** Open the file "data.db" in the current directory. + **
    file:/home/fred/data.db
    +-** file:///home/fred/data.db
    +-** file://localhost/home/fred/data.db
    ++** file:///home/fred/data.db
    ++** file://localhost/home/fred/data.db
    + ** Open the database file "/home/fred/data.db". +-**
    file://darkstar/home/fred/data.db ++**
    file://darkstar/home/fred/data.db + ** An error. "darkstar" is not a recognized authority. +-**
    ++**
    + ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db + ** Windows only: Open the file "data.db" on fred's desktop on drive +-** C:. Note that the %20 escaping in this example is not strictly ++** C:. Note that the %20 escaping in this example is not strictly + ** necessary - space characters can be used literally + ** in URI filenames. +-**
    file:data.db?mode=ro&cache=private ++**
    file:data.db?mode=ro&cache=private + ** Open file "data.db" in the current directory for read-only access. + ** Regardless of whether or not shared-cache mode is enabled by + ** default, use a private cache. + **
    file:/home/fred/data.db?vfs=unix-dotfile + ** Open file "/home/fred/data.db". Use the special VFS "unix-dotfile" + ** that uses dot-files in place of posix advisory locking. +-**
    file:data.db?mode=readonly ++**
    file:data.db?mode=readonly + ** An error. "readonly" is not a valid option for the "mode" parameter. + **
    + ** + ** ^URI hexadecimal escape sequences (%HH) are supported within the path and + ** query components of a URI. A hexadecimal escape sequence consists of a +-** percent sign - "%" - followed by exactly two hexadecimal digits ++** percent sign - "%" - followed by exactly two hexadecimal digits + ** specifying an octet value. ^Before the path or query components of a +-** URI filename are interpreted, they are encoded using UTF-8 and all ++** URI filename are interpreted, they are encoded using UTF-8 and all + ** hexadecimal escape sequences replaced by a single byte containing the + ** corresponding octet. If this process generates an invalid UTF-8 encoding, + ** the results are undefined. +@@ -3240,15 +3151,15 @@ SQLITE_API int sqlite3_open_v2( + ** CAPI3REF: Obtain Values For URI Parameters + ** + ** These are utility routines, useful to VFS implementations, that check +-** to see if a database file was a URI that contained a specific query ++** to see if a database file was a URI that contained a specific query + ** parameter, and if so obtains the value of that query parameter. + ** +-** If F is the database filename pointer passed into the xOpen() method of +-** a VFS implementation when the flags parameter to xOpen() has one or ++** If F is the database filename pointer passed into the xOpen() method of ++** a VFS implementation when the flags parameter to xOpen() has one or + ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and + ** P is the name of the query parameter, then + ** sqlite3_uri_parameter(F,P) returns the value of the P +-** parameter if it exists or a NULL pointer if P does not appear as a ++** parameter if it exists or a NULL pointer if P does not appear as a + ** query parameter on F. If P is a query parameter of F + ** has no explicit value, then sqlite3_uri_parameter(F,P) returns + ** a pointer to an empty string. +@@ -3257,7 +3168,7 @@ SQLITE_API int sqlite3_open_v2( + ** parameter and returns true (1) or false (0) according to the value + ** of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the + ** value of query parameter P is one of "yes", "true", or "on" in any +-** case or if the value begins with a non-zero number. The ++** case or if the value begins with a non-zero number. The + ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of + ** query parameter P is one of "no", "false", or "off" in any case or + ** if the value begins with a numeric zero. If P is not a query +@@ -3268,7 +3179,7 @@ SQLITE_API int sqlite3_open_v2( + ** 64-bit signed integer and returns that integer, or D if P does not + ** exist. If the value of P is something other than an integer, then + ** zero is returned. +-** ++** + ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and + ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and + ** is not a database file pathname pointer that SQLite passed into the xOpen +@@ -3284,14 +3195,14 @@ SQLITE_API sqlite3_int64 sqlite3_uri_int + ** CAPI3REF: Error Codes And Messages + ** METHOD: sqlite3 + ** +-** ^If the most recent sqlite3_* API call associated with ++** ^If the most recent sqlite3_* API call associated with + ** [database connection] D failed, then the sqlite3_errcode(D) interface + ** returns the numeric [result code] or [extended result code] for that + ** API call. + ** If the most recent API call was successful, + ** then the return value from sqlite3_errcode() is undefined. + ** ^The sqlite3_extended_errcode() +-** interface is the same except that it always returns the ++** interface is the same except that it always returns the + ** [extended result code] even when extended result codes are + ** disabled. + ** +@@ -3335,7 +3246,7 @@ SQLITE_API const char *sqlite3_errstr(in + ** has been compiled into binary form and is ready to be evaluated. + ** + ** Think of each SQL statement as a separate computer program. The +-** original SQL text is source code. A prepared statement object ++** original SQL text is source code. A prepared statement object + ** is the compiled object code. All SQL must be converted into a + ** prepared statement before it can be run. + ** +@@ -3365,7 +3276,7 @@ typedef struct sqlite3_stmt sqlite3_stmt + ** new limit for that construct.)^ + ** + ** ^If the new limit is a negative number, the limit is unchanged. +-** ^(For each limit category SQLITE_LIMIT_NAME there is a ++** ^(For each limit category SQLITE_LIMIT_NAME there is a + ** [limits | hard upper bound] + ** set at compile-time by a C preprocessor macro called + ** [limits | SQLITE_MAX_NAME]. +@@ -3373,7 +3284,7 @@ typedef struct sqlite3_stmt sqlite3_stmt + ** ^Attempts to increase a limit above its hard upper bound are + ** silently truncated to the hard upper bound. + ** +-** ^Regardless of whether or not the limit was changed, the ++** ^Regardless of whether or not the limit was changed, the + ** [sqlite3_limit()] interface returns the prior value of the limit. + ** ^Hence, to find the current value of a limit without changing it, + ** simply invoke this interface with the third parameter set to -1. +@@ -3534,12 +3445,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, i + ** + ** + **
  • +-** ^If the specific value bound to [parameter | host parameter] in the ++** ^If the specific value bound to [parameter | host parameter] in the + ** WHERE clause might influence the choice of query plan for a statement, +-** then the statement will be automatically recompiled, as if there had been ++** then the statement will be automatically recompiled, as if there had been + ** a schema change, on the first [sqlite3_step()] call following any change +-** to the [sqlite3_bind_text | bindings] of that [parameter]. +-** ^The specific value of WHERE-clause [parameter] might influence the ++** to the [sqlite3_bind_text | bindings] of that [parameter]. ++** ^The specific value of WHERE-clause [parameter] might influence the + ** choice of query plan if the parameter is the left-hand side of a [LIKE] + ** or [GLOB] operator or if the parameter is compared to an indexed column + ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. +@@ -3618,8 +3529,8 @@ SQLITE_API char *sqlite3_expanded_sql(sq + ** the content of the database file. + ** + ** Note that [application-defined SQL functions] or +-** [virtual tables] might change the database indirectly as a side effect. +-** ^(For example, if an application defines a function "eval()" that ++** [virtual tables] might change the database indirectly as a side effect. ++** ^(For example, if an application defines a function "eval()" that + ** calls [sqlite3_exec()], then the following SQL statement would + ** change the database file through side-effects: + ** +@@ -3633,10 +3544,10 @@ SQLITE_API char *sqlite3_expanded_sql(sq + ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], + ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, + ** since the statements themselves do not actually modify the database but +-** rather they control the timing of when other statements modify the ++** rather they control the timing of when other statements modify the + ** database. ^The [ATTACH] and [DETACH] statements also cause + ** sqlite3_stmt_readonly() to return true since, while those statements +-** change the configuration of a database connection, they do not make ++** change the configuration of a database connection, they do not make + ** changes to the content of the database files on disk. + ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since + ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and +@@ -3650,18 +3561,18 @@ SQLITE_API int sqlite3_stmt_readonly(sql + ** METHOD: sqlite3_stmt + ** + ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the +-** [prepared statement] S has been stepped at least once using ++** [prepared statement] S has been stepped at least once using + ** [sqlite3_step(S)] but has neither run to completion (returned + ** [SQLITE_DONE] from [sqlite3_step(S)]) nor + ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) +-** interface returns false if S is a NULL pointer. If S is not a ++** interface returns false if S is a NULL pointer. If S is not a + ** NULL pointer and is not a pointer to a valid [prepared statement] + ** object, then the behavior is undefined and probably undesirable. + ** + ** This interface can be used in combination [sqlite3_next_stmt()] +-** to locate all prepared statements associated with a database ++** to locate all prepared statements associated with a database + ** connection that are in need of being reset. This can be used, +-** for example, in diagnostic routines to search for prepared ++** for example, in diagnostic routines to search for prepared + ** statements that are holding a transaction open. + */ + SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); +@@ -3680,7 +3591,7 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3 + ** will accept either a protected or an unprotected sqlite3_value. + ** Every interface that accepts sqlite3_value arguments specifies + ** whether or not it requires a protected sqlite3_value. The +-** [sqlite3_value_dup()] interface can be used to construct a new ++** [sqlite3_value_dup()] interface can be used to construct a new + ** protected sqlite3_value from an unprotected sqlite3_value. + ** + ** The terms "protected" and "unprotected" refer to whether or not +@@ -3688,7 +3599,7 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3 + ** sqlite3_value object but no mutex is held for an unprotected + ** sqlite3_value object. If SQLite is compiled to be single-threaded + ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) +-** or if SQLite is run in one of reduced mutex modes ++** or if SQLite is run in one of reduced mutex modes + ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] + ** then there is no distinction between protected and unprotected + ** sqlite3_value objects and they can be used interchangeably. However, +@@ -3705,7 +3616,7 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3 + ** The [sqlite3_value_blob | sqlite3_value_type()] family of + ** interfaces require protected sqlite3_value objects. + */ +-typedef struct Mem sqlite3_value; ++typedef struct sqlite3_value sqlite3_value; + + /* + ** CAPI3REF: SQL Function Context Object +@@ -3775,7 +3686,7 @@ typedef struct sqlite3_context sqlite3_c + ** or sqlite3_bind_text16() or sqlite3_bind_text64() then + ** that parameter must be the byte offset + ** where the NUL terminator would occur assuming the string were NUL +-** terminated. If any NUL characters occur at byte offsets less than ++** terminated. If any NUL characters occur at byte offsets less than + ** the value of the fourth parameter then the resulting string value will + ** contain embedded NULs. The result of expressions involving strings + ** with embedded NULs is undefined. +@@ -3828,7 +3739,7 @@ typedef struct sqlite3_context sqlite3_c ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ --SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); -+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, unsigned int n, void(*)(void*)); - SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, +-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); ++SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, unsigned int n, void(*)(void*)); + SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, void(*)(void*)); - SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double); -@@ -4078,8 +3985,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_da + SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); +@@ -3924,7 +3835,7 @@ SQLITE_API int sqlite3_clear_bindings(sq + ** METHOD: sqlite3_stmt + ** + ** ^Return the number of columns in the result set returned by the +-** [prepared statement]. ^If this routine returns 0, that means the ++** [prepared statement]. ^If this routine returns 0, that means the + ** [prepared statement] returns no data (for example an [UPDATE]). + ** ^However, just because this routine returns a positive number does not + ** mean that one or more rows of data will be returned. ^A SELECT statement +@@ -4108,7 +4019,7 @@ SQLITE_API const void *sqlite3_column_de + ** For all versions of SQLite up to and including 3.6.23.1, a call to + ** [sqlite3_reset()] was required after sqlite3_step() returned anything + ** other than [SQLITE_ROW] before any subsequent invocation of +-** sqlite3_step(). Failure to reset the prepared statement using ++** sqlite3_step(). Failure to reset the prepared statement using + ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from + ** sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1], + ** sqlite3_step() began +@@ -4239,7 +4150,7 @@ SQLITE_API int sqlite3_data_count(sqlite + ** the number of bytes in that string. + ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. + ** +-** ^The values returned by [sqlite3_column_bytes()] and ++** ^The values returned by [sqlite3_column_bytes()] and + ** [sqlite3_column_bytes16()] do not include the zero terminators at the end + ** of the string. ^For clarity: the values returned by + ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of +@@ -4342,8 +4253,8 @@ SQLITE_API int sqlite3_data_count(sqlite ** [SQLITE_NOMEM].)^ */ - SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol); --SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol); --SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol); - SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol); - SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol); - SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol); -@@ -4251,6 +4158,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr + SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); +-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); +-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); ++SQLITE_API unsigned int sqlite3_column_bytes(sqlite3_stmt*, int iCol); ++SQLITE_API unsigned int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); + SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); + SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); + SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); +@@ -4430,7 +4341,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stm + ** ^The second parameter is the name of the SQL function to be created or + ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 + ** representation, exclusive of the zero-terminator. ^Note that the name +-** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. ++** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. + ** ^Any attempt to create a function with a longer name + ** will result in [SQLITE_MISUSE] being returned. + ** +@@ -4445,7 +4356,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stm + ** ^The fourth parameter, eTextRep, specifies what + ** [SQLITE_UTF8 | text encoding] this SQL function prefers for + ** its parameters. The application should set this parameter to +-** [SQLITE_UTF16LE] if the function implementation invokes ++** [SQLITE_UTF16LE] if the function implementation invokes + ** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the + ** implementation invokes [sqlite3_value_text16be()] on an input, or + ** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8] +@@ -4476,13 +4387,13 @@ SQLITE_API int sqlite3_reset(sqlite3_stm + ** callbacks. + ** + ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, +-** then it is destructor for the application data pointer. ++** then it is destructor for the application data pointer. + ** The destructor is invoked when the function is deleted, either by being + ** overloaded or when the database connection closes.)^ + ** ^The destructor is also invoked if the call to + ** sqlite3_create_function_v2() fails. + ** ^When the destructor callback of the tenth parameter is invoked, it +-** is passed a single argument which is a copy of the application data ++** is passed a single argument which is a copy of the application data + ** pointer which was the fifth parameter to sqlite3_create_function_v2(). + ** + ** ^It is permitted to register multiple implementations of the same +@@ -4493,7 +4404,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stm + ** nArg parameter is a better match than a function implementation with + ** a negative nArg. ^A function where the preferred text encoding + ** matches the database encoding is a better +-** match than a function where the encoding is different. ++** match than a function where the encoding is different. + ** ^A function where the encoding difference is between UTF16le and UTF16be + ** is a closer match than a function where the encoding difference is + ** between UTF8 and UTF16. +@@ -4515,6 +4426,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 SQLITE_STDCALL sqlite3_create_function16( + SQLITE_API int sqlite3_create_function16( sqlite3 *db, const void *zFunctionName, -@@ -4306,7 +4215,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr +@@ -4553,7 +4466,7 @@ SQLITE_API int sqlite3_create_function_v + /* + ** CAPI3REF: Function Flags + ** +-** These constants may be ORed together with the ++** These constants may be ORed together with the + ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument + ** to [sqlite3_create_function()], [sqlite3_create_function16()], or + ** [sqlite3_create_function_v2()]. +@@ -4565,12 +4478,12 @@ SQLITE_API int sqlite3_create_function_v + ** DEPRECATED + ** + ** These functions are [deprecated]. In order to maintain +-** backwards compatibility with older code, these functions continue ++** backwards compatibility with older code, these functions continue + ** to be supported. However, new applications should avoid ** the use of these functions. To encourage programmers to avoid ** these functions, we will not explain what they do. */ -#ifndef SQLITE_OMIT_DEPRECATED +#if 0 - SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*); - SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*); - SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); -@@ -4363,8 +4272,8 @@ SQLITE_API SQLITE_DEPRECATED int SQLITE_ + SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); + SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); + SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); +@@ -4586,7 +4499,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3 + ** + ** The C-language implementation of SQL functions and aggregates uses + ** this set of interface routines to access the parameter values on +-** the function or aggregate. ++** the function or aggregate. + ** + ** The xFunc (for scalar functions) or xStep (for aggregates) parameters + ** to [sqlite3_create_function()] and [sqlite3_create_function16()] +@@ -4627,8 +4540,8 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3 ** the SQL function that supplied the [sqlite3_value*] parameters. */ - SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*); --SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*); --SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*); -+SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*); - SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*); - SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*); - SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*); -@@ -4668,7 +4577,7 @@ typedef void (*sqlite3_destructor_type)( + SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); +-SQLITE_API int sqlite3_value_bytes(sqlite3_value*); +-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); ++SQLITE_API unsigned int sqlite3_value_bytes(sqlite3_value*); ++SQLITE_API unsigned int sqlite3_value_bytes16(sqlite3_value*); + SQLITE_API double sqlite3_value_double(sqlite3_value*); + SQLITE_API int sqlite3_value_int(sqlite3_value*); + SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); +@@ -4679,7 +4592,7 @@ SQLITE_API void sqlite3_value_free(sqlit + ** Implementations of aggregate SQL functions use this + ** routine to allocate memory for storing their state. + ** +-** ^The first time the sqlite3_aggregate_context(C,N) routine is called ++** ^The first time the sqlite3_aggregate_context(C,N) routine is called + ** for a particular aggregate function, SQLite + ** allocates N of memory, zeroes out that memory, and returns a pointer + ** to the new memory. ^On second and subsequent calls to +@@ -4692,7 +4605,7 @@ SQLITE_API void sqlite3_value_free(sqlit + ** In those cases, sqlite3_aggregate_context() might be called for the + ** first time from within xFinal().)^ + ** +-** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer ++** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer + ** when first called if N is less than or equal to zero or if a memory + ** allocate error occurs. + ** +@@ -4701,10 +4614,10 @@ SQLITE_API void sqlite3_value_free(sqlit + ** value of N in subsequent call to sqlite3_aggregate_context() within + ** the same aggregate function instance will not resize the memory + ** allocation.)^ Within the xFinal callback, it is customary to set +-** N=0 in calls to sqlite3_aggregate_context(C,N) so that no ++** N=0 in calls to sqlite3_aggregate_context(C,N) so that no + ** pointless memory allocations occur. + ** +-** ^SQLite automatically frees the memory allocated by ++** ^SQLite automatically frees the memory allocated by + ** sqlite3_aggregate_context() when the aggregate query concludes. + ** + ** The first parameter must be a copy of the +@@ -4754,7 +4667,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_h + ** some circumstances the associated metadata may be preserved. An example + ** of where this might be useful is in a regular-expression matching + ** function. The compiled version of the regular expression can be stored as +-** metadata associated with the pattern string. ++** metadata associated with the pattern string. + ** Then as long as the pattern string remains the same, + ** the compiled regular expression can be reused on multiple + ** invocations of the same function. +@@ -4779,10 +4692,10 @@ SQLITE_API sqlite3 *sqlite3_context_db_h + ** SQL statement)^, or + **
  • ^(when sqlite3_set_auxdata() is invoked again on the same + ** parameter)^, or +-**
  • ^(during the original sqlite3_set_auxdata() call when a memory ++**
  • ^(during the original sqlite3_set_auxdata() call when a memory + ** allocation error occurs.)^ + ** +-** Note the last bullet in particular. The destructor X in ++** Note the last bullet in particular. The destructor X in + ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the + ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() + ** should be called near the end of the function implementation and the +@@ -4933,7 +4846,7 @@ typedef void (*sqlite3_destructor_type)( ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ --SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); -+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, unsigned int, void(*)(void*)); - SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*, +-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); ++SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, unsigned int, void(*)(void*)); + SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*, sqlite3_uint64,void(*)(void*)); - SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double); -@@ -4692,6 +4601,19 @@ SQLITE_API int SQLITE_STDCALL sqlite3_re + SQLITE_API void sqlite3_result_double(sqlite3_context*, double); +@@ -4957,12 +4870,25 @@ SQLITE_API int sqlite3_result_zeroblob64 /* @@ -21156,24 +31505,296 @@ ** CAPI3REF: Setting The Subtype Of An SQL Function ** METHOD: sqlite3_context ** -@@ -4792,6 +4714,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr + ** The sqlite3_result_subtype(C,T) function causes the subtype of +-** the result from the [application-defined SQL function] with +-** [sqlite3_context] C to be the value T. Only the lower 8 bits ++** the result from the [application-defined SQL function] with ++** [sqlite3_context] C to be the value T. Only the lower 8 bits + ** of the subtype T are preserved in current versions of SQLite; + ** higher order bits are discarded. + ** The number of subtype bytes preserved by SQLite might increase +@@ -5009,7 +4935,7 @@ SQLITE_API void sqlite3_result_subtype(s + ** deleted. ^When all collating functions having the same name are deleted, + ** that collation is no longer usable. + ** +-** ^The collating function callback is invoked with a copy of the pArg ++** ^The collating function callback is invoked with a copy of the pArg + ** application data pointer and with two strings in the encoding specified + ** by the eTextRep argument. The collating function must return an + ** integer that is negative, zero, or positive +@@ -5039,36 +4965,38 @@ SQLITE_API void sqlite3_result_subtype(s + ** calls to the collation creation functions or when the + ** [database connection] is closed using [sqlite3_close()]. + ** +-** ^The xDestroy callback is not called if the ++** ^The xDestroy callback is not called if the + ** sqlite3_create_collation_v2() function fails. Applications that invoke +-** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should ++** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should + ** check the return code and dispose of the application data pointer + ** themselves rather than expecting SQLite to deal with it for them. +-** This is different from every other SQLite interface. The inconsistency +-** is unfortunate but cannot be changed without breaking backwards ++** This is different from every other SQLite interface. The inconsistency ++** is unfortunate but cannot be changed without breaking backwards + ** compatibility. + ** + ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. + */ + SQLITE_API int sqlite3_create_collation( +- sqlite3*, +- const char *zName, +- int eTextRep, ++ sqlite3*, ++ const char *zName, ++ int eTextRep, 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 SQLITE_STDCALL sqlite3_create_collation_v2( - sqlite3*, - const char *zName, -@@ -5329,6 +5253,7 @@ SQLITE_API sqlite3_int64 SQLITE_STDCALL + SQLITE_API int sqlite3_create_collation_v2( +- sqlite3*, +- const char *zName, +- int eTextRep, ++ sqlite3*, ++ const char *zName, ++ int eTextRep, + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*), + void(*xDestroy)(void*) + ); + SQLITE_API int sqlite3_create_collation16( +- sqlite3*, ++ sqlite3*, + const void *zName, +- int eTextRep, ++ int eTextRep, + void *pArg, + int(*xCompare)(void*,int,const void*,int,const void*) + ); +@@ -5101,12 +5029,12 @@ SQLITE_API int sqlite3_create_collation1 + ** [sqlite3_create_collation_v2()]. */ - SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N); + SQLITE_API int sqlite3_collation_needed( +- sqlite3*, +- void*, ++ sqlite3*, ++ void*, + void(*)(void*,sqlite3*,int eTextRep,const char*) + ); + SQLITE_API int sqlite3_collation_needed16( +- sqlite3*, ++ sqlite3*, + void*, + void(*)(void*,sqlite3*,int eTextRep,const void*) + ); +@@ -5148,7 +5076,7 @@ SQLITE_API int sqlite3_rekey_v2( + ); + + /* +-** Specify the activation key for a SEE database. Unless ++** Specify the activation key for a SEE database. Unless + ** activated, none of the SEE routines will work. + */ + SQLITE_API void sqlite3_activate_see( +@@ -5158,7 +5086,7 @@ SQLITE_API void sqlite3_activate_see( + + #ifdef SQLITE_ENABLE_CEROD + /* +-** Specify the activation key for a CEROD database. Unless ++** Specify the activation key for a CEROD database. Unless + ** activated, none of the CEROD routines will work. + */ + SQLITE_API void sqlite3_activate_cerod( +@@ -5214,7 +5142,7 @@ SQLITE_API int sqlite3_sleep(int); + ** ^The [temp_store_directory pragma] may modify this variable and cause + ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, + ** the [temp_store_directory pragma] always assumes that any string +-** that this variable points to is held in memory obtained from ++** that this variable points to is held in memory obtained from + ** [sqlite3_malloc] and the pragma may attempt to free that memory + ** using [sqlite3_free]. + ** Hence, if this variable is modified directly, either it should be +@@ -5271,7 +5199,7 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_t + ** ^The [data_store_directory pragma] may modify this variable and cause + ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, + ** the [data_store_directory pragma] always assumes that any string +-** that this variable points to is held in memory obtained from ++** that this variable points to is held in memory obtained from + ** [sqlite3_malloc] and the pragma may attempt to free that memory + ** using [sqlite3_free]. + ** Hence, if this variable is modified directly, either it should be +@@ -5460,7 +5388,7 @@ SQLITE_API void *sqlite3_rollback_hook(s + ** and [sqlite3_preupdate_hook()] interfaces. + */ + SQLITE_API void *sqlite3_update_hook( +- sqlite3*, ++ sqlite3*, + void(*)(void *,int ,char const *,char const *,sqlite3_int64), + void* + ); +@@ -5474,7 +5402,7 @@ SQLITE_API void *sqlite3_update_hook( + ** and disabled if the argument is false.)^ + ** + ** ^Cache sharing is enabled and disabled for an entire process. +-** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). ++** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). + ** In prior versions of SQLite, + ** sharing was enabled or disabled for each thread separately. + ** +@@ -5491,8 +5419,8 @@ SQLITE_API void *sqlite3_update_hook( + ** cache setting should set it explicitly. + ** + ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 +-** and will always return SQLITE_MISUSE. On those systems, +-** shared cache mode should be enabled per-database connection via ++** and will always return SQLITE_MISUSE. On those systems, ++** shared cache mode should be enabled per-database connection via + ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. + ** + ** This interface is threadsafe on processors where writing a +@@ -5542,7 +5470,7 @@ SQLITE_API int sqlite3_db_release_memory + ** as heap memory usages approaches the limit. + ** ^The soft heap limit is "soft" because even though SQLite strives to stay + ** below the limit, it will exceed the limit rather than generate +-** an [SQLITE_NOMEM] error. In other words, the soft heap limit ++** an [SQLITE_NOMEM] error. In other words, the soft heap limit + ** is advisory only. + ** + ** ^The return value from sqlite3_soft_heap_limit64() is the size of +@@ -5569,7 +5497,7 @@ SQLITE_API int sqlite3_db_release_memory + ** from the heap. + ** )^ + ** +-** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), ++** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), + ** the soft heap limit is enforced + ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] + ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], +@@ -5596,6 +5524,7 @@ SQLITE_API sqlite3_int64 sqlite3_soft_he + */ + SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); +#define sqlite3_soft_heap_limit(N) sqlite3_soft_heap_limit64(N) /* ** CAPI3REF: Extract Metadata About A Column Of A Table -@@ -5781,6 +5706,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_cr +@@ -5645,7 +5574,7 @@ SQLITE_API SQLITE_DEPRECATED void sqlite + ** + ** ^If the specified table is actually a view, an [error code] is returned. + ** +-** ^If the specified column is "rowid", "oid" or "_rowid_" and the table ++** ^If the specified column is "rowid", "oid" or "_rowid_" and the table + ** is not a [WITHOUT ROWID] table and an + ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output + ** parameters are set for the explicitly declared column. ^(If there is no +@@ -5711,7 +5640,7 @@ SQLITE_API int sqlite3_table_column_meta + ** prior to calling this API, + ** otherwise an error will be returned. + ** +-** Security warning: It is recommended that the ++** Security warning: It is recommended that the + ** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this + ** interface. The use of the [sqlite3_enable_load_extension()] interface + ** should be avoided. This will keep the SQL function [load_extension()] +@@ -5798,7 +5727,7 @@ SQLITE_API int sqlite3_auto_extension(vo + ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the + ** initialization routine X that was registered using a prior call to + ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] +-** routine returns 1 if initialization routine X was successfully ++** routine returns 1 if initialization routine X was successfully + ** unregistered and it returns 0 if X was not on the list of initialization + ** routines. + */ +@@ -5833,8 +5762,8 @@ typedef struct sqlite3_module sqlite3_mo + ** CAPI3REF: Virtual Table Object + ** KEYWORDS: sqlite3_module {virtual table module} + ** +-** This structure, sometimes called a "virtual table module", +-** defines the implementation of a [virtual tables]. ++** This structure, sometimes called a "virtual table module", ++** defines the implementation of a [virtual tables]. + ** This structure consists mostly of methods for the module. + ** + ** ^A virtual table module is created by filling in a persistent +@@ -5873,7 +5802,7 @@ struct sqlite3_module { + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), + void **ppArg); + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); +- /* The methods above are in version 1 of the sqlite_module object. Those ++ /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ + int (*xSavepoint)(sqlite3_vtab *pVTab, int); + int (*xRelease)(sqlite3_vtab *pVTab, int); +@@ -5920,7 +5849,7 @@ struct sqlite3_module { + ** required by SQLite. If the table has at least 64 columns and any column + ** to the right of the first 63 is required, then bit 63 of colUsed is also + ** set. In other words, column iCol may be required if the expression +-** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to ++** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to + ** non-zero. + ** + ** The [xBestIndex] method must fill aConstraintUsage[] with information +@@ -5941,17 +5870,17 @@ struct sqlite3_module { + ** + ** ^The estimatedCost value is an estimate of the cost of a particular + ** strategy. A cost of N indicates that the cost of the strategy is similar +-** to a linear scan of an SQLite table with N rows. A cost of log(N) ++** to a linear scan of an SQLite table with N rows. A cost of log(N) + ** indicates that the expense of the operation is similar to that of a + ** binary search on a unique indexed field of an SQLite table with N rows. + ** + ** ^The estimatedRows value is an estimate of the number of rows that + ** will be returned by the strategy. + ** +-** The xBestIndex method may optionally populate the idxFlags field with a ++** The xBestIndex method may optionally populate the idxFlags field with a + ** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - + ** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite +-** assumes that the strategy may visit at most one row. ++** assumes that the strategy may visit at most one row. + ** + ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then + ** SQLite also assumes that if a call to the xUpdate() method is made as +@@ -5964,14 +5893,14 @@ struct sqlite3_module { + ** the xUpdate method are automatically rolled back by SQLite. + ** + ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info +-** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). ++** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). + ** If a virtual table extension is +-** used with an SQLite version earlier than 3.8.2, the results of attempting +-** to read or write the estimatedRows field are undefined (but are likely ++** used with an SQLite version earlier than 3.8.2, the results of attempting ++** to read or write the estimatedRows field are undefined (but are likely + ** to included crashing the application). The estimatedRows field should + ** therefore only be used if [sqlite3_libversion_number()] returns a + ** value greater than or equal to 3008002. Similarly, the idxFlags field +-** was added for [version 3.9.0] ([dateof:3.9.0]). ++** was added for [version 3.9.0] ([dateof:3.9.0]). + ** It may therefore only be used if + ** sqlite3_libversion_number() returns a value greater than or equal to + ** 3009000. +@@ -5996,7 +5925,7 @@ struct sqlite3_index_info { + unsigned char omit; /* Do not code a test for this constraint */ + } *aConstraintUsage; + int idxNum; /* Number used to identify the index */ +- char *idxStr; /* String, possibly obtained from sqlite3_malloc */ ++ const char *idxStr; /* String, possibly obtained from sqlite3_malloc */ + int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ + int orderByConsumed; /* True if output is already ordered */ + double estimatedCost; /* Estimated cost of using this index */ +@@ -6041,7 +5970,7 @@ struct sqlite3_index_info { + ** preexisting [virtual table] for the module. + ** + ** ^The module name is registered on the [database connection] specified +-** by the first parameter. ^The name of the module is given by the ++** by the first parameter. ^The name of the module is given by the + ** second parameter. ^The third parameter is a pointer to + ** the implementation of the [virtual table module]. ^The fourth + ** parameter is an arbitrary client data pointer that is passed through +@@ -6070,6 +5999,8 @@ SQLITE_API int sqlite3_create_module_v2( void *pClientData, /* Client data for xCreate/xConnect */ void(*xDestroy)(void*) /* Module destructor function */ ); @@ -21182,16 +31803,2134 @@ /* ** CAPI3REF: Virtual Table Instance Object -@@ -7543,6 +7470,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_wa +@@ -6133,7 +6064,7 @@ SQLITE_API int sqlite3_declare_vtab(sqli + ** METHOD: sqlite3 + ** + ** ^(Virtual tables can provide alternative implementations of functions +-** using the [xFindFunction] method of the [virtual table module]. ++** using the [xFindFunction] method of the [virtual table module]. + ** But global versions of those functions + ** must exist in order to be overloaded.)^ + ** +@@ -6184,7 +6115,7 @@ typedef struct sqlite3_blob sqlite3_blob + ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; + ** )^ + ** +-** ^(Parameter zDb is not the filename that contains the database, but ++** ^(Parameter zDb is not the filename that contains the database, but + ** rather the symbolic name of the database. For attached databases, this is + ** the name that appears after the AS keyword in the [ATTACH] statement. + ** For the main database file, the database name is "main". For TEMP +@@ -6197,28 +6128,28 @@ typedef struct sqlite3_blob sqlite3_blob + ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored + ** in *ppBlob. Otherwise an [error code] is returned and, unless the error + ** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided +-** the API is not misused, it is always safe to call [sqlite3_blob_close()] ++** the API is not misused, it is always safe to call [sqlite3_blob_close()] + ** on *ppBlob after this function it returns. + ** + ** This function fails with SQLITE_ERROR if any of the following are true: + **
      +-**
    • ^(Database zDb does not exist)^, +-**
    • ^(Table zTable does not exist within database zDb)^, +-**
    • ^(Table zTable is a WITHOUT ROWID table)^, ++**
    • ^(Database zDb does not exist)^, ++**
    • ^(Table zTable does not exist within database zDb)^, ++**
    • ^(Table zTable is a WITHOUT ROWID table)^, + **
    • ^(Column zColumn does not exist)^, + **
    • ^(Row iRow is not present in the table)^, + **
    • ^(The specified column of row iRow contains a value that is not + ** a TEXT or BLOB value)^, +-**
    • ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE ++**
    • ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE + ** constraint and the blob is being opened for read/write access)^, +-**
    • ^([foreign key constraints | Foreign key constraints] are enabled, ++**
    • ^([foreign key constraints | Foreign key constraints] are enabled, + ** column zColumn is part of a [child key] definition and the blob is + ** being opened for read/write access)^. + **
    + ** +-** ^Unless it returns SQLITE_MISUSE, this function sets the +-** [database connection] error code and message accessible via +-** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. ++** ^Unless it returns SQLITE_MISUSE, this function sets the ++** [database connection] error code and message accessible via ++** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. + ** + ** A BLOB referenced by sqlite3_blob_open() may be read using the + ** [sqlite3_blob_read()] interface and modified by using +@@ -6244,7 +6175,7 @@ typedef struct sqlite3_blob sqlite3_blob + ** blob. + ** + ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces +-** and the built-in [zeroblob] SQL function may be used to create a ++** and the built-in [zeroblob] SQL function may be used to create a + ** zero-filled blob to read or write using the incremental-blob interface. + ** + ** To avoid a resource leak, every open [BLOB handle] should eventually +@@ -6294,7 +6225,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlit + ** DESTRUCTOR: sqlite3_blob + ** + ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed +-** unconditionally. Even if this routine returns an error code, the ++** unconditionally. Even if this routine returns an error code, the + ** handle is still closed.)^ + ** + ** ^If the blob handle being closed was opened for read-write access, and if +@@ -6304,10 +6235,10 @@ SQLITE_API int sqlite3_blob_reopen(sqlit + ** code is returned and the transaction rolled back. + ** + ** Calling this function with an argument that is not a NULL pointer or an +-** open blob handle results in undefined behaviour. ^Calling this routine +-** with a null pointer (such as would be returned by a failed call to ++** open blob handle results in undefined behaviour. ^Calling this routine ++** with a null pointer (such as would be returned by a failed call to + ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function +-** is passed a valid open blob handle, the values returned by the ++** is passed a valid open blob handle, the values returned by the + ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning. + */ + SQLITE_API int sqlite3_blob_close(sqlite3_blob *); +@@ -6316,7 +6247,7 @@ SQLITE_API int sqlite3_blob_close(sqlite + ** CAPI3REF: Return The Size Of An Open BLOB + ** METHOD: sqlite3_blob + ** +-** ^Returns the size in bytes of the BLOB accessible via the ++** ^Returns the size in bytes of the BLOB accessible via the + ** successfully opened [BLOB handle] in its only argument. ^The + ** incremental blob I/O routines can only read or overwriting existing + ** blob content; they cannot change the size of a blob. +@@ -6367,9 +6298,9 @@ SQLITE_API int sqlite3_blob_read(sqlite3 + ** + ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. + ** Otherwise, an [error code] or an [extended error code] is returned.)^ +-** ^Unless SQLITE_MISUSE is returned, this function sets the +-** [database connection] error code and message accessible via +-** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. ++** ^Unless SQLITE_MISUSE is returned, this function sets the ++** [database connection] error code and message accessible via ++** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. + ** + ** ^If the [BLOB handle] passed as the first argument was not opened for + ** writing (the flags parameter to [sqlite3_blob_open()] was zero), +@@ -6378,9 +6309,9 @@ SQLITE_API int sqlite3_blob_read(sqlite3 + ** This function may only modify the contents of the BLOB; it is + ** not possible to increase the size of a BLOB using this API. + ** ^If offset iOffset is less than N bytes from the end of the BLOB, +-** [SQLITE_ERROR] is returned and no data is written. The size of the +-** BLOB (and hence the maximum value of N+iOffset) can be determined +-** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less ++** [SQLITE_ERROR] is returned and no data is written. The size of the ++** BLOB (and hence the maximum value of N+iOffset) can be determined ++** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less + ** than zero [SQLITE_ERROR] is returned and no data is written. + ** + ** ^An attempt to write to an expired [BLOB handle] fails with an +@@ -6532,7 +6463,7 @@ SQLITE_API int sqlite3_vfs_unregister(sq + ** ^(Some systems (for example, Windows 95) do not support the operation + ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() + ** will always return SQLITE_BUSY. The SQLite core only ever uses +-** sqlite3_mutex_try() as an optimization so this is acceptable ++** sqlite3_mutex_try() as an optimization so this is acceptable + ** behavior.)^ + ** + ** ^The sqlite3_mutex_leave() routine exits a mutex that was +@@ -6695,7 +6626,7 @@ SQLITE_API int sqlite3_mutex_notheld(sql + ** CAPI3REF: Retrieve the mutex for a database connection + ** METHOD: sqlite3 + ** +-** ^This interface returns a pointer the [sqlite3_mutex] object that ++** ^This interface returns a pointer the [sqlite3_mutex] object that + ** serializes access to the [database connection] given in the argument + ** when the [threading mode] is Serialized. + ** ^If the [threading mode] is Single-thread or Multi-thread then this +@@ -6850,7 +6781,7 @@ SQLITE_API int sqlite3_status64( + **
    This parameter records the largest memory allocation request + ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their + ** internal equivalents). Only the value returned in the +-** *pHighwater parameter to [sqlite3_status()] is of interest. ++** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
    )^ + ** + ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
    SQLITE_STATUS_MALLOC_COUNT
    +@@ -6859,11 +6790,11 @@ SQLITE_API int sqlite3_status64( + ** + ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
    SQLITE_STATUS_PAGECACHE_USED
    + **
    This parameter returns the number of pages used out of the +-** [pagecache memory allocator] that was configured using ++** [pagecache memory allocator] that was configured using + ** [SQLITE_CONFIG_PAGECACHE]. The + ** value returned is in pages, not in bytes.
    )^ + ** +-** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] ++** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] + ** ^(
    SQLITE_STATUS_PAGECACHE_OVERFLOW
    + **
    This parameter returns the number of bytes of page cache + ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] +@@ -6876,7 +6807,7 @@ SQLITE_API int sqlite3_status64( + ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
    SQLITE_STATUS_PAGECACHE_SIZE
    + **
    This parameter records the largest memory allocation request + ** handed to [pagecache memory allocator]. Only the value returned in the +-** *pHighwater parameter to [sqlite3_status()] is of interest. ++** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
    )^ + ** + ** [[SQLITE_STATUS_SCRATCH_USED]] ^(
    SQLITE_STATUS_SCRATCH_USED
    +@@ -6900,11 +6831,11 @@ SQLITE_API int sqlite3_status64( + ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
    SQLITE_STATUS_SCRATCH_SIZE
    + **
    This parameter records the largest memory allocation request + ** handed to [scratch memory allocator]. Only the value returned in the +-** *pHighwater parameter to [sqlite3_status()] is of interest. ++** *pHighwater parameter to [sqlite3_status()] is of interest. + ** The value written into the *pCurrent parameter is undefined.
    )^ + ** + ** [[SQLITE_STATUS_PARSER_STACK]] ^(
    SQLITE_STATUS_PARSER_STACK
    +-**
    The *pHighwater parameter records the deepest parser stack. ++**
    The *pHighwater parameter records the deepest parser stack. + ** The *pCurrent value is undefined. The *pHighwater value is only + ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
    )^ + ** +@@ -6926,12 +6857,12 @@ SQLITE_API int sqlite3_status64( + ** CAPI3REF: Database Connection Status + ** METHOD: sqlite3 + ** +-** ^This interface is used to retrieve runtime status information ++** ^This interface is used to retrieve runtime status information + ** about a single [database connection]. ^The first argument is the + ** database connection object to be interrogated. ^The second argument + ** is an integer constant, taken from the set of + ** [SQLITE_DBSTATUS options], that +-** determines the parameter to interrogate. The set of ++** determines the parameter to interrogate. The set of + ** [SQLITE_DBSTATUS options] is likely + ** to grow in future releases of SQLite. + ** +@@ -6966,7 +6897,7 @@ SQLITE_API int sqlite3_db_status(sqlite3 + ** checked out.)^ + ** + ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
    SQLITE_DBSTATUS_LOOKASIDE_HIT
    +-**
    This parameter returns the number malloc attempts that were ++**
    This parameter returns the number malloc attempts that were + ** satisfied using lookaside memory. Only the high-water value is meaningful; + ** the current value is always zero.)^ + ** +@@ -6991,7 +6922,7 @@ SQLITE_API int sqlite3_db_status(sqlite3 + ** memory used by all pager caches associated with the database connection.)^ + ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. + ** +-** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] ++** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] + ** ^(
    SQLITE_DBSTATUS_CACHE_USED_SHARED
    + **
    This parameter is similar to DBSTATUS_CACHE_USED, except that if a + ** pager cache is shared between two or more connections the bytes of heap +@@ -7006,7 +6937,7 @@ SQLITE_API int sqlite3_db_status(sqlite3 + ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
    SQLITE_DBSTATUS_SCHEMA_USED
    + **
    This parameter returns the approximate number of bytes of heap + ** memory used to store the schema for all databases associated +-** with the connection - main, temp, and any [ATTACH]-ed databases.)^ ++** with the connection - main, temp, and any [ATTACH]-ed databases.)^ + ** ^The full amount of memory used by the schemas is reported, even if the + ** schema memory is shared with other database connections due to + ** [shared cache mode] being enabled. +@@ -7021,13 +6952,13 @@ SQLITE_API int sqlite3_db_status(sqlite3 + ** + ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(
    SQLITE_DBSTATUS_CACHE_HIT
    + **
    This parameter returns the number of pager cache hits that have +-** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT ++** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT + ** is always 0. + **
    + ** + ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(
    SQLITE_DBSTATUS_CACHE_MISS
    + **
    This parameter returns the number of pager cache misses that have +-** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS ++** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS + ** is always 0. + **
    + ** +@@ -7075,7 +7006,7 @@ SQLITE_API int sqlite3_db_status(sqlite3 + ** statements. For example, if the number of table steps greatly exceeds + ** the number of table searches or result rows, that would tend to indicate + ** that the prepared statement is using a full table scan rather than +-** an index. ++** an index. + ** + ** ^(This interface is used to retrieve and reset counter values from + ** a [prepared statement]. The first argument is the prepared statement +@@ -7102,7 +7033,7 @@ SQLITE_API int sqlite3_stmt_status(sqlit + ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
    SQLITE_STMTSTATUS_FULLSCAN_STEP
    + **
    ^This is the number of times that SQLite has stepped forward in + ** a table as part of a full table scan. Large numbers for this counter +-** may indicate opportunities for performance improvement through ++** may indicate opportunities for performance improvement through + ** careful use of indices.
    + ** + ** [[SQLITE_STMTSTATUS_SORT]]
    SQLITE_STMTSTATUS_SORT
    +@@ -7120,7 +7051,7 @@ SQLITE_API int sqlite3_stmt_status(sqlit + ** [[SQLITE_STMTSTATUS_VM_STEP]]
    SQLITE_STMTSTATUS_VM_STEP
    + **
    ^This is the number of virtual machine operations executed + ** by the prepared statement if that number is less than or equal +-** to 2147483647. The number of virtual machine operations can be ++** to 2147483647. The number of virtual machine operations can be + ** used as a proxy for the total work done by the prepared statement. + ** If the number of virtual machine operations exceeds 2147483647 + ** then the value returned by this statement status code is undefined. +@@ -7166,15 +7097,15 @@ struct sqlite3_pcache_page { + ** KEYWORDS: {page cache} + ** + ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can +-** register an alternative page cache implementation by passing in an ++** register an alternative page cache implementation by passing in an + ** instance of the sqlite3_pcache_methods2 structure.)^ +-** In many applications, most of the heap memory allocated by ++** In many applications, most of the heap memory allocated by + ** SQLite is used for the page cache. +-** By implementing a ++** By implementing a + ** custom page cache using this API, an application can better control +-** the amount of memory consumed by SQLite, the way in which +-** that memory is allocated and released, and the policies used to +-** determine exactly which parts of a database file are cached and for ++** the amount of memory consumed by SQLite, the way in which ++** that memory is allocated and released, and the policies used to ++** determine exactly which parts of a database file are cached and for + ** how long. + ** + ** The alternative page cache mechanism is an +@@ -7187,19 +7118,19 @@ struct sqlite3_pcache_page { + ** [sqlite3_config()] returns.)^ + ** + ** [[the xInit() page cache method]] +-** ^(The xInit() method is called once for each effective ++** ^(The xInit() method is called once for each effective + ** call to [sqlite3_initialize()])^ + ** (usually only once during the lifetime of the process). ^(The xInit() + ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ +-** The intent of the xInit() method is to set up global data structures +-** required by the custom page cache implementation. +-** ^(If the xInit() method is NULL, then the ++** The intent of the xInit() method is to set up global data structures ++** required by the custom page cache implementation. ++** ^(If the xInit() method is NULL, then the + ** built-in default page cache is used instead of the application defined + ** page cache.)^ + ** + ** [[the xShutdown() page cache method]] + ** ^The xShutdown() method is called by [sqlite3_shutdown()]. +-** It can be used to clean up ++** It can be used to clean up + ** any outstanding resources before process shutdown, if required. + ** ^The xShutdown() method may be NULL. + ** +@@ -7218,7 +7149,7 @@ struct sqlite3_pcache_page { + ** though this is not guaranteed. ^The + ** first parameter, szPage, is the size in bytes of the pages that must + ** be allocated by the cache. ^szPage will always a power of two. ^The +-** second parameter szExtra is a number of bytes of extra storage ++** second parameter szExtra is a number of bytes of extra storage + ** associated with each page cache entry. ^The szExtra parameter will + ** a number less than 250. SQLite will use the + ** extra szExtra bytes on each page to store metadata about the underlying +@@ -7231,7 +7162,7 @@ struct sqlite3_pcache_page { + ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will + ** never invoke xUnpin() except to deliberately delete a page. + ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to +-** false will always have the "discard" flag set to true. ++** false will always have the "discard" flag set to true. + ** ^Hence, a cache created with bPurgeable false will + ** never contain any unpinned pages. + ** +@@ -7246,12 +7177,12 @@ struct sqlite3_pcache_page { + ** [[the xPagecount() page cache methods]] + ** The xPagecount() method must return the number of pages currently + ** stored in the cache, both pinned and unpinned. +-** ++** + ** [[the xFetch() page cache methods]] +-** The xFetch() method locates a page in the cache and returns a pointer to ++** The xFetch() method locates a page in the cache and returns a pointer to + ** an sqlite3_pcache_page object associated with that page, or a NULL pointer. + ** The pBuf element of the returned sqlite3_pcache_page object will be a +-** pointer to a buffer of szPage bytes used to store the content of a ++** pointer to a buffer of szPage bytes used to store the content of a + ** single database page. The pExtra element of sqlite3_pcache_page will be + ** a pointer to the szExtra bytes of extra storage that SQLite has requested + ** for each entry in the page cache. +@@ -7290,8 +7221,8 @@ struct sqlite3_pcache_page { + ** page cache implementation. ^The page cache implementation + ** may choose to evict unpinned pages at any time. + ** +-** The cache must not perform any reference counting. A single +-** call to xUnpin() unpins the page regardless of the number of prior calls ++** The cache must not perform any reference counting. A single ++** call to xUnpin() unpins the page regardless of the number of prior calls + ** to xFetch(). + ** + ** [[the xRekey() page cache methods]] +@@ -7331,7 +7262,7 @@ struct sqlite3_pcache_methods2 { + int (*xPagecount)(sqlite3_pcache*); + sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); +- void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, ++ void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, + unsigned oldKey, unsigned newKey); + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (*xDestroy)(sqlite3_pcache*); +@@ -7376,7 +7307,7 @@ typedef struct sqlite3_backup sqlite3_ba + ** + ** The backup API copies the content of one database into another. + ** It is useful either for creating backups of databases or +-** for copying in-memory databases to or from persistent files. ++** for copying in-memory databases to or from persistent files. + ** + ** See Also: [Using the SQLite Online Backup API] + ** +@@ -7387,36 +7318,36 @@ typedef struct sqlite3_backup sqlite3_ba + ** ^Thus, the backup may be performed on a live source database without + ** preventing other database connections from + ** reading or writing to the source database while the backup is underway. +-** +-** ^(To perform a backup operation: ++** ++** ^(To perform a backup operation: + **
      + **
    1. sqlite3_backup_init() is called once to initialize the +-** backup, +-**
    2. sqlite3_backup_step() is called one or more times to transfer ++** backup, ++**
    3. sqlite3_backup_step() is called one or more times to transfer + ** the data between the two databases, and finally +-**
    4. sqlite3_backup_finish() is called to release all resources +-** associated with the backup operation. ++**
    5. sqlite3_backup_finish() is called to release all resources ++** associated with the backup operation. + **
    )^ + ** There should be exactly one call to sqlite3_backup_finish() for each + ** successful call to sqlite3_backup_init(). + ** + ** [[sqlite3_backup_init()]] sqlite3_backup_init() + ** +-** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the +-** [database connection] associated with the destination database ++** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the ++** [database connection] associated with the destination database + ** and the database name, respectively. + ** ^The database name is "main" for the main database, "temp" for the + ** temporary database, or the name specified after the AS keyword in + ** an [ATTACH] statement for an attached database. +-** ^The S and M arguments passed to ++** ^The S and M arguments passed to + ** sqlite3_backup_init(D,N,S,M) identify the [database connection] + ** and database name of the source database, respectively. + ** ^The source and destination [database connections] (parameters S and D) + ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with + ** an error. + ** +-** ^A call to sqlite3_backup_init() will fail, returning NULL, if +-** there is already a read or read-write transaction open on the ++** ^A call to sqlite3_backup_init() will fail, returning NULL, if ++** there is already a read or read-write transaction open on the + ** destination database. + ** + ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is +@@ -7428,14 +7359,14 @@ typedef struct sqlite3_backup sqlite3_ba + ** ^A successful call to sqlite3_backup_init() returns a pointer to an + ** [sqlite3_backup] object. + ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and +-** sqlite3_backup_finish() functions to perform the specified backup ++** sqlite3_backup_finish() functions to perform the specified backup + ** operation. + ** + ** [[sqlite3_backup_step()]] sqlite3_backup_step() + ** +-** ^Function sqlite3_backup_step(B,N) will copy up to N pages between ++** ^Function sqlite3_backup_step(B,N) will copy up to N pages between + ** the source and destination databases specified by [sqlite3_backup] object B. +-** ^If N is negative, all remaining source pages are copied. ++** ^If N is negative, all remaining source pages are copied. + ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there + ** are still more pages to be copied, then the function returns [SQLITE_OK]. + ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages +@@ -7457,8 +7388,8 @@ typedef struct sqlite3_backup sqlite3_ba + ** + ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then + ** the [sqlite3_busy_handler | busy-handler function] +-** is invoked (if one is specified). ^If the +-** busy-handler returns non-zero before the lock is available, then ++** is invoked (if one is specified). ^If the ++** busy-handler returns non-zero before the lock is available, then + ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to + ** sqlite3_backup_step() can be retried later. ^If the source + ** [database connection] +@@ -7466,15 +7397,15 @@ typedef struct sqlite3_backup sqlite3_ba + ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this + ** case the call to sqlite3_backup_step() can be retried later on. ^(If + ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or +-** [SQLITE_READONLY] is returned, then +-** there is no point in retrying the call to sqlite3_backup_step(). These +-** errors are considered fatal.)^ The application must accept +-** that the backup operation has failed and pass the backup operation handle ++** [SQLITE_READONLY] is returned, then ++** there is no point in retrying the call to sqlite3_backup_step(). These ++** errors are considered fatal.)^ The application must accept ++** that the backup operation has failed and pass the backup operation handle + ** to the sqlite3_backup_finish() to release associated resources. + ** + ** ^The first call to sqlite3_backup_step() obtains an exclusive lock +-** on the destination file. ^The exclusive lock is not released until either +-** sqlite3_backup_finish() is called or the backup operation is complete ++** on the destination file. ^The exclusive lock is not released until either ++** sqlite3_backup_finish() is called or the backup operation is complete + ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to + ** sqlite3_backup_step() obtains a [shared lock] on the source database that + ** lasts for the duration of the sqlite3_backup_step() call. +@@ -7483,18 +7414,18 @@ typedef struct sqlite3_backup sqlite3_ba + ** through the backup process. ^If the source database is modified by an + ** external process or via a database connection other than the one being + ** used by the backup operation, then the backup will be automatically +-** restarted by the next call to sqlite3_backup_step(). ^If the source ++** restarted by the next call to sqlite3_backup_step(). ^If the source + ** database is modified by the using the same database connection as is used + ** by the backup operation, then the backup database is automatically + ** updated at the same time. + ** + ** [[sqlite3_backup_finish()]] sqlite3_backup_finish() + ** +-** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the ++** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the + ** application wishes to abandon the backup operation, the application + ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). + ** ^The sqlite3_backup_finish() interfaces releases all +-** resources associated with the [sqlite3_backup] object. ++** resources associated with the [sqlite3_backup] object. + ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any + ** active write-transaction on the destination database is rolled back. + ** The [sqlite3_backup] object is invalid +@@ -7534,8 +7465,8 @@ typedef struct sqlite3_backup sqlite3_ba + ** connections, then the source database connection may be used concurrently + ** from within other threads. + ** +-** However, the application must guarantee that the destination +-** [database connection] is not passed to any other API (by any thread) after ++** However, the application must guarantee that the destination ++** [database connection] is not passed to any other API (by any thread) after + ** sqlite3_backup_init() is called and before the corresponding call to + ** sqlite3_backup_finish(). SQLite does not currently check to see + ** if the application incorrectly accesses the destination [database connection] +@@ -7546,11 +7477,11 @@ typedef struct sqlite3_backup sqlite3_ba + ** If running in [shared cache mode], the application must + ** guarantee that the shared cache used by the destination database + ** is not accessed while the backup is running. In practice this means +-** that the application must guarantee that the disk file being ++** that the application must guarantee that the disk file being + ** backed up to is not accessed by any connection within the process, + ** not just the specific connection that was passed to sqlite3_backup_init(). + ** +-** The [sqlite3_backup] object itself is partially threadsafe. Multiple ++** The [sqlite3_backup] object itself is partially threadsafe. Multiple + ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). + ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() + ** APIs are not strictly speaking threadsafe. If they are invoked at the +@@ -7575,8 +7506,8 @@ SQLITE_API int sqlite3_backup_pagecount( + ** ^When running in shared-cache mode, a database operation may fail with + ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or + ** individual tables within the shared-cache cannot be obtained. See +-** [SQLite Shared-Cache Mode] for a description of shared-cache locking. +-** ^This API may be used to register a callback that SQLite will invoke ++** [SQLite Shared-Cache Mode] for a description of shared-cache locking. ++** ^This API may be used to register a callback that SQLite will invoke + ** when the connection currently holding the required lock relinquishes it. + ** ^This API is only available if the library was compiled with the + ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. +@@ -7584,14 +7515,14 @@ SQLITE_API int sqlite3_backup_pagecount( + ** See Also: [Using the SQLite Unlock Notification Feature]. + ** + ** ^Shared-cache locks are released when a database connection concludes +-** its current transaction, either by committing it or rolling it back. ++** its current transaction, either by committing it or rolling it back. + ** + ** ^When a connection (known as the blocked connection) fails to obtain a + ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the + ** identity of the database connection (the blocking connection) that +-** has locked the required resource is stored internally. ^After an ++** has locked the required resource is stored internally. ^After an + ** application receives an SQLITE_LOCKED error, it may call the +-** sqlite3_unlock_notify() method with the blocked connection handle as ++** sqlite3_unlock_notify() method with the blocked connection handle as + ** the first argument to register for a callback that will be invoked + ** when the blocking connections current transaction is concluded. ^The + ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] +@@ -7605,15 +7536,15 @@ SQLITE_API int sqlite3_backup_pagecount( + ** + ** ^If the blocked connection is attempting to obtain a write-lock on a + ** shared-cache table, and more than one other connection currently holds +-** a read-lock on the same table, then SQLite arbitrarily selects one of ++** a read-lock on the same table, then SQLite arbitrarily selects one of + ** the other connections to use as the blocking connection. + ** +-** ^(There may be at most one unlock-notify callback registered by a ++** ^(There may be at most one unlock-notify callback registered by a + ** blocked connection. If sqlite3_unlock_notify() is called when the + ** blocked connection already has a registered unlock-notify callback, + ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is + ** called with a NULL pointer as its second argument, then any existing +-** unlock-notify callback is canceled. ^The blocked connections ++** unlock-notify callback is canceled. ^The blocked connections + ** unlock-notify callback may also be canceled by closing the blocked + ** connection using [sqlite3_close()]. + ** +@@ -7626,7 +7557,7 @@ SQLITE_API int sqlite3_backup_pagecount( + ** + ** Callback Invocation Details + ** +-** When an unlock-notify callback is registered, the application provides a ++** When an unlock-notify callback is registered, the application provides a + ** single void* pointer that is passed to the callback when it is invoked. + ** However, the signature of the callback function allows SQLite to pass + ** it an array of void* context pointers. The first argument passed to +@@ -7639,12 +7570,12 @@ SQLITE_API int sqlite3_backup_pagecount( + ** same callback function, then instead of invoking the callback function + ** multiple times, it is invoked once with the set of void* context pointers + ** specified by the blocked connections bundled together into an array. +-** This gives the application an opportunity to prioritize any actions ++** This gives the application an opportunity to prioritize any actions + ** related to the set of unblocked database connections. + ** + ** Deadlock Detection + ** +-** Assuming that after registering for an unlock-notify callback a ++** Assuming that after registering for an unlock-notify callback a + ** database waits for the callback to be issued before taking any further + ** action (a reasonable assumption), then using this API may cause the + ** application to deadlock. For example, if connection X is waiting for +@@ -7667,7 +7598,7 @@ SQLITE_API int sqlite3_backup_pagecount( + ** + ** The "DROP TABLE" Exception + ** +-** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost ++** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost + ** always appropriate to call sqlite3_unlock_notify(). There is however, + ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, + ** SQLite checks if there are any currently executing SELECT statements +@@ -7680,7 +7611,7 @@ SQLITE_API int sqlite3_backup_pagecount( + ** One way around this problem is to check the extended error code returned + ** by an sqlite3_step() call. ^(If there is a blocking connection, then the + ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in +-** the special "DROP TABLE/INDEX" case, the extended error code is just ++** the special "DROP TABLE/INDEX" case, the extended error code is just + ** SQLITE_LOCKED.)^ + */ + SQLITE_API int sqlite3_unlock_notify( +@@ -7771,8 +7702,8 @@ SQLITE_API void sqlite3_log(int iErrCode + ** ^The [sqlite3_wal_hook()] function is used to register a callback that + ** is invoked each time data is committed to a database in wal mode. + ** +-** ^(The callback is invoked by SQLite after the commit has taken place and +-** the associated write-lock on the database released)^, so the implementation ++** ^(The callback is invoked by SQLite after the commit has taken place and ++** the associated write-lock on the database released)^, so the implementation + ** may read, write or [checkpoint] the database as required. + ** + ** ^The first parameter passed to the callback function when it is invoked +@@ -7791,7 +7722,7 @@ SQLITE_API void sqlite3_log(int iErrCode + ** that does not correspond to any valid SQLite error code, the results + ** are undefined. + ** +-** A single database handle may have at most a single write-ahead log callback ++** A single database handle may have at most a single write-ahead log callback + ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any + ** previously registered write-ahead log callback. ^Note that the + ** [sqlite3_wal_autocheckpoint()] interface and the +@@ -7799,7 +7730,7 @@ SQLITE_API void sqlite3_log(int iErrCode + ** overwrite any prior [sqlite3_wal_hook()] settings. + */ + SQLITE_API void *sqlite3_wal_hook( +- sqlite3*, ++ sqlite3*, + int(*)(void *,sqlite3*,const char*,int), + void* + ); +@@ -7812,7 +7743,7 @@ SQLITE_API void *sqlite3_wal_hook( + ** [sqlite3_wal_hook()] that causes any database on [database connection] D + ** to automatically [checkpoint] + ** after committing a transaction if there are N or +-** more frames in the [write-ahead log] file. ^Passing zero or ++** more frames in the [write-ahead log] file. ^Passing zero or + ** a negative value as the nFrame parameter disables automatic + ** checkpoints entirely. + ** +@@ -7842,7 +7773,7 @@ SQLITE_API int sqlite3_wal_autocheckpoin + ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to + ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^ + ** +-** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the ++** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the + ** [write-ahead log] for database X on [database connection] D to be + ** transferred into the database file and for the write-ahead log to + ** be reset. See the [checkpointing] documentation for addition +@@ -7856,6 +7787,8 @@ SQLITE_API int sqlite3_wal_autocheckpoin ** complication) of [sqlite3_wal_checkpoint_v2()]. */ - SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); + SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); +/* A macro is more efficient than a wrapped call */ +#define sqlite3_wal_checkpoint(a,b) sqlite3_wal_checkpoint_v2(a,b,SQLITE_CHECKPOINT_PASSIVE,0,0); /* ** CAPI3REF: Checkpoint a database -@@ -8589,7 +8518,7 @@ struct fts5_api { +@@ -7868,10 +7801,10 @@ SQLITE_API int sqlite3_wal_checkpoint(sq + ** + **
    + **
    SQLITE_CHECKPOINT_PASSIVE
    +-** ^Checkpoint as many frames as possible without waiting for any database +-** readers or writers to finish, then sync the database file if all frames ++** ^Checkpoint as many frames as possible without waiting for any database ++** readers or writers to finish, then sync the database file if all frames + ** in the log were checkpointed. ^The [busy-handler callback] +-** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode. ++** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode. + ** ^On the other hand, passive mode might leave the checkpoint unfinished + ** if there are concurrent readers or writers. + ** +@@ -7885,9 +7818,9 @@ SQLITE_API int sqlite3_wal_checkpoint(sq + ** + **
    SQLITE_CHECKPOINT_RESTART
    + ** ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition +-** that after checkpointing the log file it blocks (calls the ++** that after checkpointing the log file it blocks (calls the + ** [busy-handler callback]) +-** until all readers are reading from the database file only. ^This ensures ++** until all readers are reading from the database file only. ^This ensures + ** that the next writer will restart the log file from the beginning. + ** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new + ** database writer attempts while it is pending, but does not impede readers. +@@ -7909,31 +7842,31 @@ SQLITE_API int sqlite3_wal_checkpoint(sq + ** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero. + ** + ** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If +-** any other process is running a checkpoint operation at the same time, the +-** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a ++** any other process is running a checkpoint operation at the same time, the ++** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a + ** busy-handler configured, it will not be invoked in this case. + ** +-** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the ++** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the + ** exclusive "writer" lock on the database file. ^If the writer lock cannot be + ** obtained immediately, and a busy-handler is configured, it is invoked and + ** the writer lock retried until either the busy-handler returns 0 or the lock + ** is successfully obtained. ^The busy-handler is also invoked while waiting for + ** database readers as described above. ^If the busy-handler returns 0 before + ** the writer lock is obtained or while waiting for database readers, the +-** checkpoint operation proceeds from that point in the same way as +-** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible ++** checkpoint operation proceeds from that point in the same way as ++** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible + ** without blocking any further. ^SQLITE_BUSY is returned in this case. + ** + ** ^If parameter zDb is NULL or points to a zero length string, then the +-** specified operation is attempted on all WAL databases [attached] to ++** specified operation is attempted on all WAL databases [attached] to + ** [database connection] db. In this case the +-** values written to output parameters *pnLog and *pnCkpt are undefined. ^If +-** an SQLITE_BUSY error is encountered when processing one or more of the +-** attached WAL databases, the operation is still attempted on any remaining +-** attached databases and SQLITE_BUSY is returned at the end. ^If any other +-** error occurs while processing an attached database, processing is abandoned +-** and the error code is returned to the caller immediately. ^If no error +-** (SQLITE_BUSY or otherwise) is encountered while processing the attached ++** values written to output parameters *pnLog and *pnCkpt are undefined. ^If ++** an SQLITE_BUSY error is encountered when processing one or more of the ++** attached WAL databases, the operation is still attempted on any remaining ++** attached databases and SQLITE_BUSY is returned at the end. ^If any other ++** error occurs while processing an attached database, processing is abandoned ++** and the error code is returned to the caller immediately. ^If no error ++** (SQLITE_BUSY or otherwise) is encountered while processing the attached + ** databases, SQLITE_OK is returned. + ** + ** ^If database zDb is the name of an attached database that is not in WAL +@@ -8009,20 +7942,20 @@ SQLITE_API int sqlite3_vtab_config(sqlit + ** If X is non-zero, then the virtual table implementation guarantees + ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before + ** any modifications to internal or persistent data structures have been made. +-** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite ++** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite + ** is able to roll back a statement or database transaction, and abandon +-** or continue processing the current SQL statement as appropriate. ++** or continue processing the current SQL statement as appropriate. + ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns + ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode + ** had been ABORT. + ** + ** Virtual table implementations that are required to handle OR REPLACE +-** must do so within the [xUpdate] method. If a call to the +-** [sqlite3_vtab_on_conflict()] function indicates that the current ON +-** CONFLICT policy is REPLACE, the virtual table implementation should ++** must do so within the [xUpdate] method. If a call to the ++** [sqlite3_vtab_on_conflict()] function indicates that the current ON ++** CONFLICT policy is REPLACE, the virtual table implementation should + ** silently replace the appropriate rows within the xUpdate callback and + ** return SQLITE_OK. Or, if this is not possible, it may return +-** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT ++** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT + ** constraint handling. + **
    + */ +@@ -8148,7 +8081,7 @@ SQLITE_API int sqlite3_stmt_scanstatus( + int idx, /* Index of loop to report on */ + int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */ + void *pOut /* Result written here */ +-); ++); + + /* + ** CAPI3REF: Zero Scan-Status Counters +@@ -8166,15 +8099,15 @@ SQLITE_API void sqlite3_stmt_scanstatus_ + ** + ** ^If a write-transaction is open on [database connection] D when the + ** [sqlite3_db_cacheflush(D)] interface invoked, any dirty +-** pages in the pager-cache that are not currently in use are written out ++** pages in the pager-cache that are not currently in use are written out + ** to disk. A dirty page may be in use if a database cursor created by an + ** active SQL statement is reading from it, or if it is page 1 of a database + ** file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)] + ** interface flushes caches for all schemas - "main", "temp", and + ** any [attached] databases. + ** +-** ^If this function needs to obtain extra database locks before dirty pages +-** can be flushed to disk, it does so. ^If those locks cannot be obtained ++** ^If this function needs to obtain extra database locks before dirty pages ++** can be flushed to disk, it does so. ^If those locks cannot be obtained + ** immediately and there is a busy-handler callback configured, it is invoked + ** in the usual manner. ^If the required lock still cannot be obtained, then + ** the database is skipped and an attempt made to flush any dirty pages +@@ -8221,16 +8154,16 @@ SQLITE_API int sqlite3_db_cacheflush(sql + ** kind of update operation that is about to occur. + ** ^(The fourth parameter to the preupdate callback is the name of the + ** database within the database connection that is being modified. This +-** will be "main" for the main database or "temp" for TEMP tables or ++** will be "main" for the main database or "temp" for TEMP tables or + ** the name given after the AS keyword in the [ATTACH] statement for attached + ** databases.)^ + ** ^The fifth parameter to the preupdate callback is the name of the + ** table that is being modified. + ** + ** For an UPDATE or DELETE operation on a [rowid table], the sixth +-** parameter passed to the preupdate callback is the initial [rowid] of the ++** parameter passed to the preupdate callback is the initial [rowid] of the + ** row being modified or deleted. For an INSERT operation on a rowid table, +-** or any operation on a WITHOUT ROWID table, the value of the sixth ++** or any operation on a WITHOUT ROWID table, the value of the sixth + ** parameter is undefined. For an INSERT or UPDATE on a rowid table the + ** seventh parameter is the final rowid value of the row being inserted + ** or updated. The value of the seventh parameter passed to the callback +@@ -8269,7 +8202,7 @@ SQLITE_API int sqlite3_db_cacheflush(sql + ** + ** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate + ** callback was invoked as a result of a direct insert, update, or delete +-** operation; or 1 for inserts, updates, or deletes invoked by top-level ++** operation; or 1 for inserts, updates, or deletes invoked by top-level + ** triggers; or 2 for changes resulting from triggers called by top-level + ** triggers; and so forth. + ** +@@ -8303,7 +8236,7 @@ SQLITE_API int sqlite3_preupdate_new(sql + ** The return value is OS-dependent. For example, on unix systems, after + ** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be + ** called to get back the underlying "errno" that caused the problem, such +-** as ENOSPC, EAUTH, EISDIR, and so forth. ++** as ENOSPC, EAUTH, EISDIR, and so forth. + */ + SQLITE_API int sqlite3_system_errno(sqlite3*); + +@@ -8330,7 +8263,7 @@ SQLITE_API int sqlite3_system_errno(sqli + ** + ** The constructor for this object is [sqlite3_snapshot_get()]. The + ** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer +-** to an historical snapshot (if possible). The destructor for ++** to an historical snapshot (if possible). The destructor for + ** sqlite3_snapshot objects is [sqlite3_snapshot_free()]. + */ + typedef struct sqlite3_snapshot { +@@ -8347,12 +8280,12 @@ typedef struct sqlite3_snapshot { + ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly + ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK. + ** If there is not already a read-transaction open on schema S when +-** this function is called, one is opened automatically. ++** this function is called, one is opened automatically. + ** + ** The following must be true for this function to succeed. If any of + ** the following statements are false when sqlite3_snapshot_get() is + ** called, SQLITE_ERROR is returned. The final value of *P is undefined +-** in this case. ++** in this case. + ** + **
      + **
    • The database handle must be in [autocommit mode]. +@@ -8364,13 +8297,13 @@ typedef struct sqlite3_snapshot { + ** + **
    • One or more transactions must have been written to the current wal + ** file since it was created on disk (by any connection). This means +-** that a snapshot cannot be taken on a wal mode database with no wal ++** that a snapshot cannot be taken on a wal mode database with no wal + ** file immediately after it is first opened. At least one transaction + ** must be written to it first. + **
    + ** + ** This function may also return SQLITE_NOMEM. If it is called with the +-** database handle in autocommit mode but fails for some other reason, ++** database handle in autocommit mode but fails for some other reason, + ** whether or not a read transaction is opened on schema S is undefined. + ** + ** The [sqlite3_snapshot] object returned from a successful call to +@@ -8410,7 +8343,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlit + ** database connection D does not know that the database file for + ** schema S is in [WAL mode]. A database connection might not know + ** that the database file is in [WAL mode] if there has been no prior +-** I/O on that database connection, or if the database entered [WAL mode] ++** I/O on that database connection, or if the database entered [WAL mode] + ** after the most recent I/O on the database connection.)^ + ** (Hint: Run "[PRAGMA application_id]" against a newly opened + ** database connection in order to make it ready to use snapshots.) +@@ -8442,17 +8375,17 @@ SQLITE_API SQLITE_EXPERIMENTAL void sqli + ** EXPERIMENTAL + ** + ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages +-** of two valid snapshot handles. ++** of two valid snapshot handles. + ** +-** If the two snapshot handles are not associated with the same database +-** file, the result of the comparison is undefined. ++** If the two snapshot handles are not associated with the same database ++** file, the result of the comparison is undefined. + ** + ** Additionally, the result of the comparison is only valid if both of the + ** snapshot handles were obtained by calling sqlite3_snapshot_get() since the + ** last time the wal file was deleted. The wal file is deleted when the + ** database is changed back to rollback mode or when the number of database +-** clients drops to zero. If either snapshot handle was obtained before the +-** wal file was last deleted, the value returned by this function ++** clients drops to zero. If either snapshot handle was obtained before the ++** wal file was last deleted, the value returned by this function + ** is undefined. + ** + ** Otherwise, this API returns a negative value if P1 refers to an older +@@ -8560,7 +8493,7 @@ struct sqlite3_rtree_geometry { + }; + + /* +-** Register a 2nd-generation geometry callback named zScore that can be ++** Register a 2nd-generation geometry callback named zScore that can be + ** used as part of an R-Tree geometry query as follows: + ** + ** SELECT ... FROM WHERE MATCH $zQueryFunc(... params ...) +@@ -8575,7 +8508,7 @@ SQLITE_API int sqlite3_rtree_query_callb + + + /* +-** A pointer to a structure of the following type is passed as the ++** A pointer to a structure of the following type is passed as the + ** argument to scored geometry callback registered using + ** sqlite3_rtree_query_callback(). + ** +@@ -8663,7 +8596,7 @@ typedef struct sqlite3_changeset_iter sq + ** is not possible for an application to register a pre-update hook on a + ** database handle that has one or more session objects attached. Nor is + ** it possible to create a session object attached to a database handle for +-** which a pre-update hook is already defined. The results of attempting ++** which a pre-update hook is already defined. The results of attempting + ** either of these things are undefined. + ** + ** The session object will be used to create changesets for tables in +@@ -8680,13 +8613,13 @@ SQLITE_API int sqlite3session_create( + /* + ** CAPI3REF: Delete A Session Object + ** +-** Delete a session object previously allocated using ++** Delete a session object previously allocated using + ** [sqlite3session_create()]. Once a session object has been deleted, the + ** results of attempting to use pSession with any other session module + ** function are undefined. + ** + ** Session objects must be deleted before the database handle to which they +-** are attached is closed. Refer to the documentation for ++** are attached is closed. Refer to the documentation for + ** [sqlite3session_create()] for details. + */ + SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); +@@ -8703,10 +8636,10 @@ SQLITE_API void sqlite3session_delete(sq + ** the eventual changesets. + ** + ** Passing zero to this function disables the session. Passing a value +-** greater than zero enables it. Passing a value less than zero is a ++** greater than zero enables it. Passing a value less than zero is a + ** no-op, and may be used to query the current state of the session. + ** +-** The return value indicates the final state of the session object: 0 if ++** The return value indicates the final state of the session object: 0 if + ** the session is disabled, or 1 if it is enabled. + */ + SQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable); +@@ -8720,7 +8653,7 @@ SQLITE_API int sqlite3session_enable(sql + **
      + **
    • The session object "indirect" flag is set when the change is + ** made, or +-**
    • The change is made by an SQL trigger or foreign key action ++**
    • The change is made by an SQL trigger or foreign key action + ** instead of directly as a result of a users SQL statement. + **
    + ** +@@ -8732,10 +8665,10 @@ SQLITE_API int sqlite3session_enable(sql + ** flag. If the second argument passed to this function is zero, then the + ** indirect flag is cleared. If it is greater than zero, the indirect flag + ** is set. Passing a value less than zero does not modify the current value +-** of the indirect flag, and may be used to query the current state of the ++** of the indirect flag, and may be used to query the current state of the + ** indirect flag for the specified session object. + ** +-** The return value indicates the final state of the indirect flag: 0 if ++** The return value indicates the final state of the indirect flag: 0 if + ** it is clear, or 1 if it is set. + */ + SQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); +@@ -8744,20 +8677,20 @@ SQLITE_API int sqlite3session_indirect(s + ** CAPI3REF: Attach A Table To A Session Object + ** + ** If argument zTab is not NULL, then it is the name of a table to attach +-** to the session object passed as the first argument. All subsequent changes +-** made to the table while the session object is enabled will be recorded. See ++** to the session object passed as the first argument. All subsequent changes ++** made to the table while the session object is enabled will be recorded. See + ** documentation for [sqlite3session_changeset()] for further details. + ** + ** Or, if argument zTab is NULL, then changes are recorded for all tables +-** in the database. If additional tables are added to the database (by +-** executing "CREATE TABLE" statements) after this call is made, changes for ++** in the database. If additional tables are added to the database (by ++** executing "CREATE TABLE" statements) after this call is made, changes for + ** the new tables are also recorded. + ** + ** Changes can only be recorded for tables that have a PRIMARY KEY explicitly +-** defined as part of their CREATE TABLE statement. It does not matter if the ++** defined as part of their CREATE TABLE statement. It does not matter if the + ** PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias) or not. The PRIMARY + ** KEY may consist of a single column, or may be a composite key. +-** ++** + ** It is not an error if the named table does not exist in the database. Nor + ** is it an error if the named table does not have a PRIMARY KEY. However, + ** no changes will be recorded in either of these scenarios. +@@ -8765,7 +8698,7 @@ SQLITE_API int sqlite3session_indirect(s + ** Changes are not recorded for individual rows that have NULL values stored + ** in one or more of their PRIMARY KEY columns. + ** +-** SQLITE_OK is returned if the call completes without error. Or, if an error ++** SQLITE_OK is returned if the call completes without error. Or, if an error + ** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned. + */ + SQLITE_API int sqlite3session_attach( +@@ -8776,10 +8709,10 @@ SQLITE_API int sqlite3session_attach( + /* + ** CAPI3REF: Set a table filter on a Session Object. + ** +-** The second argument (xFilter) is the "filter callback". For changes to rows ++** The second argument (xFilter) is the "filter callback". For changes to rows + ** in tables that are not attached to the Session object, the filter is called +-** to determine whether changes to the table's rows should be tracked or not. +-** If xFilter returns 0, changes is not tracked. Note that once a table is ++** to determine whether changes to the table's rows should be tracked or not. ++** If xFilter returns 0, changes is not tracked. Note that once a table is + ** attached, xFilter will not be called again. + */ + SQLITE_API void sqlite3session_table_filter( +@@ -8794,9 +8727,9 @@ SQLITE_API void sqlite3session_table_fil + /* + ** CAPI3REF: Generate A Changeset From A Session Object + ** +-** Obtain a changeset containing changes to the tables attached to the +-** session object passed as the first argument. If successful, +-** set *ppChangeset to point to a buffer containing the changeset ++** Obtain a changeset containing changes to the tables attached to the ++** session object passed as the first argument. If successful, ++** set *ppChangeset to point to a buffer containing the changeset + ** and *pnChangeset to the size of the changeset in bytes before returning + ** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to + ** zero and return an SQLite error code. +@@ -8811,7 +8744,7 @@ SQLITE_API void sqlite3session_table_fil + ** modifies the values of primary key columns. If such a change is made, it + ** is represented in a changeset as a DELETE followed by an INSERT. + ** +-** Changes are not recorded for rows that have NULL values stored in one or ++** Changes are not recorded for rows that have NULL values stored in one or + ** more of their PRIMARY KEY columns. If such a row is inserted or deleted, + ** no corresponding change is present in the changesets returned by this + ** function. If an existing row with one or more NULL values stored in +@@ -8864,14 +8797,14 @@ SQLITE_API void sqlite3session_table_fil + **
      + **
    • For each record generated by an insert, the database is queried + ** for a row with a matching primary key. If one is found, an INSERT +-** change is added to the changeset. If no such row is found, no change ++** change is added to the changeset. If no such row is found, no change + ** is added to the changeset. + ** +-**
    • For each record generated by an update or delete, the database is ++**
    • For each record generated by an update or delete, the database is + ** queried for a row with a matching primary key. If such a row is + ** found and one or more of the non-primary key fields have been +-** modified from their original values, an UPDATE change is added to +-** the changeset. Or, if no such row is found in the table, a DELETE ++** modified from their original values, an UPDATE change is added to ++** the changeset. Or, if no such row is found in the table, a DELETE + ** change is added to the changeset. If there is a row with a matching + ** primary key in the database, but all fields contain their original + ** values, no change is added to the changeset. +@@ -8879,7 +8812,7 @@ SQLITE_API void sqlite3session_table_fil + ** + ** This means, amongst other things, that if a row is inserted and then later + ** deleted while a session object is active, neither the insert nor the delete +-** will be present in the changeset. Or if a row is deleted and then later a ++** will be present in the changeset. Or if a row is deleted and then later a + ** row with the same primary key values inserted while a session object is + ** active, the resulting changeset will contain an UPDATE change instead of + ** a DELETE and an INSERT. +@@ -8888,10 +8821,10 @@ SQLITE_API void sqlite3session_table_fil + ** it does not accumulate records when rows are inserted, updated or deleted. + ** This may appear to have some counter-intuitive effects if a single row + ** is written to more than once during a session. For example, if a row +-** is inserted while a session object is enabled, then later deleted while ++** is inserted while a session object is enabled, then later deleted while + ** the same session object is disabled, no INSERT record will appear in the + ** changeset, even though the delete took place while the session was disabled. +-** Or, if one field of a row is updated while a session is disabled, and ++** Or, if one field of a row is updated while a session is disabled, and + ** another field of the same row is updated while the session is enabled, the + ** resulting changeset will contain an UPDATE change that updates both fields. + */ +@@ -8902,7 +8835,7 @@ SQLITE_API int sqlite3session_changeset( + ); + + /* +-** CAPI3REF: Load The Difference Between Tables Into A Session ++** CAPI3REF: Load The Difference Between Tables Into A Session + ** + ** If it is not already attached to the session object passed as the first + ** argument, this function attaches table zTbl in the same manner as the +@@ -8911,7 +8844,7 @@ SQLITE_API int sqlite3session_changeset( + ** an error). + ** + ** Argument zFromDb must be the name of a database ("main", "temp" etc.) +-** attached to the same database handle as the session object that contains ++** attached to the same database handle as the session object that contains + ** a table compatible with the table attached to the session by this function. + ** A table is considered compatible if it: + ** +@@ -8927,25 +8860,25 @@ SQLITE_API int sqlite3session_changeset( + ** APIs, tables without PRIMARY KEYs are simply ignored. + ** + ** This function adds a set of changes to the session object that could be +-** used to update the table in database zFrom (call this the "from-table") +-** so that its content is the same as the table attached to the session ++** used to update the table in database zFrom (call this the "from-table") ++** so that its content is the same as the table attached to the session + ** object (call this the "to-table"). Specifically: + ** + **
        +-**
      • For each row (primary key) that exists in the to-table but not in ++**
      • For each row (primary key) that exists in the to-table but not in + ** the from-table, an INSERT record is added to the session object. + ** +-**
      • For each row (primary key) that exists in the to-table but not in ++**
      • For each row (primary key) that exists in the to-table but not in + ** the from-table, a DELETE record is added to the session object. + ** +-**
      • For each row (primary key) that exists in both tables, but features ++**
      • For each row (primary key) that exists in both tables, but features + ** different non-PK values in each, an UPDATE record is added to the +-** session. ++** session. + **
      + ** + ** To clarify, if this function is called and then a changeset constructed +-** using [sqlite3session_changeset()], then after applying that changeset to +-** database zFrom the contents of the two compatible tables would be ++** using [sqlite3session_changeset()], then after applying that changeset to ++** database zFrom the contents of the two compatible tables would be + ** identical. + ** + ** It an error if database zFrom does not exist or does not contain the +@@ -8953,7 +8886,7 @@ SQLITE_API int sqlite3session_changeset( + ** + ** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite + ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg +-** may be set to point to a buffer containing an English language error ++** may be set to point to a buffer containing an English language error + ** message. It is the responsibility of the caller to free this buffer using + ** sqlite3_free(). + */ +@@ -8971,19 +8904,19 @@ SQLITE_API int sqlite3session_diff( + ** The differences between a patchset and a changeset are that: + ** + **
        +-**
      • DELETE records consist of the primary key fields only. The ++**
      • DELETE records consist of the primary key fields only. The + ** original values of other fields are omitted. +-**
      • The original values of any modified fields are omitted from ++**
      • The original values of any modified fields are omitted from + ** UPDATE records. + **
      + ** +-** A patchset blob may be used with up to date versions of all +-** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), ++** A patchset blob may be used with up to date versions of all ++** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), + ** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly, + ** attempting to use a patchset blob with old versions of the +-** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. ++** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. + ** +-** Because the non-primary key "old.*" fields are omitted, no ++** Because the non-primary key "old.*" fields are omitted, no + ** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset + ** is passed to the sqlite3changeset_apply() API. Other conflict types work + ** in the same way as for changesets. +@@ -9002,29 +8935,29 @@ SQLITE_API int sqlite3session_patchset( + /* + ** CAPI3REF: Test if a changeset has recorded any changes. + ** +-** Return non-zero if no changes to attached tables have been recorded by +-** the session object passed as the first argument. Otherwise, if one or ++** Return non-zero if no changes to attached tables have been recorded by ++** the session object passed as the first argument. Otherwise, if one or + ** more changes have been recorded, return zero. + ** + ** Even if this function returns zero, it is possible that calling + ** [sqlite3session_changeset()] on the session handle may still return a +-** changeset that contains no changes. This can happen when a row in +-** an attached table is modified and then later on the original values ++** changeset that contains no changes. This can happen when a row in ++** an attached table is modified and then later on the original values + ** are restored. However, if this function returns non-zero, then it is +-** guaranteed that a call to sqlite3session_changeset() will return a ++** guaranteed that a call to sqlite3session_changeset() will return a + ** changeset containing zero changes. + */ + SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); + + /* +-** CAPI3REF: Create An Iterator To Traverse A Changeset ++** CAPI3REF: Create An Iterator To Traverse A Changeset + ** + ** Create an iterator used to iterate through the contents of a changeset. + ** If successful, *pp is set to point to the iterator handle and SQLITE_OK + ** is returned. Otherwise, if an error occurs, *pp is set to zero and an + ** SQLite error code is returned. + ** +-** The following functions can be used to advance and query a changeset ++** The following functions can be used to advance and query a changeset + ** iterator created by this function: + ** + **
        +@@ -9041,12 +8974,12 @@ SQLITE_API int sqlite3session_isempty(sq + ** + ** Assuming the changeset blob was created by one of the + ** [sqlite3session_changeset()], [sqlite3changeset_concat()] or +-** [sqlite3changeset_invert()] functions, all changes within the changeset +-** that apply to a single table are grouped together. This means that when +-** an application iterates through a changeset using an iterator created by +-** this function, all changes that relate to a single table are visited +-** consecutively. There is no chance that the iterator will visit a change +-** the applies to table X, then one for table Y, and then later on visit ++** [sqlite3changeset_invert()] functions, all changes within the changeset ++** that apply to a single table are grouped together. This means that when ++** an application iterates through a changeset using an iterator created by ++** this function, all changes that relate to a single table are visited ++** consecutively. There is no chance that the iterator will visit a change ++** the applies to table X, then one for table Y, and then later on visit + ** another change for table X. + */ + SQLITE_API int sqlite3changeset_start( +@@ -9070,12 +9003,12 @@ SQLITE_API int sqlite3changeset_start( + ** point to the first change in the changeset. Each subsequent call advances + ** the iterator to point to the next change in the changeset (if any). If + ** no error occurs and the iterator points to a valid change after a call +-** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. ++** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. + ** Otherwise, if all changes in the changeset have already been visited, + ** SQLITE_DONE is returned. + ** +-** If an error occurs, an SQLite error code is returned. Possible error +-** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or ++** If an error occurs, an SQLite error code is returned. Possible error ++** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or + ** SQLITE_NOMEM. + */ + SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter); +@@ -9092,14 +9025,14 @@ SQLITE_API int sqlite3changeset_next(sql + ** If argument pzTab is not NULL, then *pzTab is set to point to a + ** nul-terminated utf-8 encoded string containing the name of the table + ** affected by the current change. The buffer remains valid until either +-** sqlite3changeset_next() is called on the iterator or until the +-** conflict-handler function returns. If pnCol is not NULL, then *pnCol is ++** sqlite3changeset_next() is called on the iterator or until the ++** conflict-handler function returns. If pnCol is not NULL, then *pnCol is + ** set to the number of columns in the table affected by the change. If + ** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change + ** is an indirect change, or false (0) otherwise. See the documentation for + ** [sqlite3session_indirect()] for a description of direct and indirect +-** changes. Finally, if pOp is not NULL, then *pOp is set to one of +-** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the ++** changes. Finally, if pOp is not NULL, then *pOp is set to one of ++** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the + ** type of change that the iterator currently points to. + ** + ** If no error occurs, SQLITE_OK is returned. If an error does occur, an +@@ -9151,7 +9084,7 @@ SQLITE_API int sqlite3changeset_pk( + ** The pIter argument passed to this function may either be an iterator + ** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator + ** created by [sqlite3changeset_start()]. In the latter case, the most recent +-** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. ++** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. + ** Furthermore, it may only be called if the type of change that the iterator + ** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise, + ** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL. +@@ -9161,9 +9094,9 @@ SQLITE_API int sqlite3changeset_pk( + ** [SQLITE_RANGE] is returned and *ppValue is set to NULL. + ** + ** If successful, this function sets *ppValue to point to a protected +-** sqlite3_value object containing the iVal'th value from the vector of ++** sqlite3_value object containing the iVal'th value from the vector of + ** original row values stored as part of the UPDATE or DELETE change and +-** returns SQLITE_OK. The name of the function comes from the fact that this ++** returns SQLITE_OK. The name of the function comes from the fact that this + ** is similar to the "old.*" columns available to update or delete triggers. + ** + ** If some other error occurs (e.g. an OOM condition), an SQLite error code +@@ -9181,7 +9114,7 @@ SQLITE_API int sqlite3changeset_old( + ** The pIter argument passed to this function may either be an iterator + ** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator + ** created by [sqlite3changeset_start()]. In the latter case, the most recent +-** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. ++** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. + ** Furthermore, it may only be called if the type of change that the iterator + ** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise, + ** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL. +@@ -9191,12 +9124,12 @@ SQLITE_API int sqlite3changeset_old( + ** [SQLITE_RANGE] is returned and *ppValue is set to NULL. + ** + ** If successful, this function sets *ppValue to point to a protected +-** sqlite3_value object containing the iVal'th value from the vector of ++** sqlite3_value object containing the iVal'th value from the vector of + ** new row values stored as part of the UPDATE or INSERT change and + ** returns SQLITE_OK. If the change is an UPDATE and does not include +-** a new value for the requested column, *ppValue is set to NULL and +-** SQLITE_OK returned. The name of the function comes from the fact that +-** this is similar to the "new.*" columns available to update or delete ++** a new value for the requested column, *ppValue is set to NULL and ++** SQLITE_OK returned. The name of the function comes from the fact that ++** this is similar to the "new.*" columns available to update or delete + ** triggers. + ** + ** If some other error occurs (e.g. an OOM condition), an SQLite error code +@@ -9222,7 +9155,7 @@ SQLITE_API int sqlite3changeset_new( + ** [SQLITE_RANGE] is returned and *ppValue is set to NULL. + ** + ** If successful, this function sets *ppValue to point to a protected +-** sqlite3_value object containing the iVal'th value from the ++** sqlite3_value object containing the iVal'th value from the + ** "conflicting row" associated with the current conflict-handler callback + ** and returns SQLITE_OK. + ** +@@ -9264,7 +9197,7 @@ SQLITE_API int sqlite3changeset_fk_confl + ** call has no effect. + ** + ** If an error was encountered within a call to an sqlite3changeset_xxx() +-** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an ++** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an + ** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding + ** to that error is returned by this function. Otherwise, SQLITE_OK is + ** returned. This is to allow the following pattern (pseudo-code): +@@ -9275,7 +9208,7 @@ SQLITE_API int sqlite3changeset_fk_confl + ** } + ** rc = sqlite3changeset_finalize(); + ** if( rc!=SQLITE_OK ){ +-** // An error has occurred ++** // An error has occurred + ** } + */ + SQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter); +@@ -9302,7 +9235,7 @@ SQLITE_API int sqlite3changeset_finalize + ** zeroed and an SQLite error code returned. + ** + ** It is the responsibility of the caller to eventually call sqlite3_free() +-** on the *ppOut pointer to free the buffer allocation following a successful ++** on the *ppOut pointer to free the buffer allocation following a successful + ** call to this function. + ** + ** WARNING/TODO: This function currently assumes that the input is a valid +@@ -9316,11 +9249,11 @@ SQLITE_API int sqlite3changeset_invert( + /* + ** CAPI3REF: Concatenate Two Changeset Objects + ** +-** This function is used to concatenate two changesets, A and B, into a ++** This function is used to concatenate two changesets, A and B, into a + ** single changeset. The result is a changeset equivalent to applying +-** changeset A followed by changeset B. ++** changeset A followed by changeset B. + ** +-** This function combines the two input changesets using an ++** This function combines the two input changesets using an + ** sqlite3_changegroup object. Calling it produces similar results as the + ** following code fragment: + ** +@@ -9362,7 +9295,7 @@ typedef struct sqlite3_changegroup sqlit + ** + ** If successful, this function returns SQLITE_OK and populates (*pp) with + ** a pointer to a new sqlite3_changegroup object before returning. The caller +-** should eventually free the returned object using a call to ++** should eventually free the returned object using a call to + ** sqlite3changegroup_delete(). If an error occurs, an SQLite error code + ** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL. + ** +@@ -9374,7 +9307,7 @@ typedef struct sqlite3_changegroup sqlit + **
      • Zero or more changesets (or patchsets) are added to the object + ** by calling sqlite3changegroup_add(). + ** +-**
      • The result of combining all input changesets together is obtained ++**
      • The result of combining all input changesets together is obtained + ** by the application via a call to sqlite3changegroup_output(). + ** + **
      • The object is deleted using a call to sqlite3changegroup_delete(). +@@ -9383,7 +9316,7 @@ typedef struct sqlite3_changegroup sqlit + ** Any number of calls to add() and output() may be made between the calls to + ** new() and delete(), and in any order. + ** +-** As well as the regular sqlite3changegroup_add() and ++** As well as the regular sqlite3changegroup_add() and + ** sqlite3changegroup_output() functions, also available are the streaming + ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). + */ +@@ -9393,7 +9326,7 @@ int sqlite3changegroup_new(sqlite3_chang + ** CAPI3REF: Add A Changeset To A Changegroup + ** + ** Add all changes within the changeset (or patchset) in buffer pData (size +-** nData bytes) to the changegroup. ++** nData bytes) to the changegroup. + ** + ** If the buffer contains a patchset, then all prior calls to this function + ** on the same changegroup object must also have specified patchsets. Or, if +@@ -9420,7 +9353,7 @@ int sqlite3changegroup_new(sqlite3_chang + ** changeset was recorded immediately after the changesets already + ** added to the changegroup. + ** INSERT UPDATE +-** The INSERT change remains in the changegroup. The values in the ++** The INSERT change remains in the changegroup. The values in the + ** INSERT change are modified as if the row was inserted by the + ** existing change and then updated according to the new change. + ** INSERT DELETE +@@ -9431,17 +9364,17 @@ int sqlite3changegroup_new(sqlite3_chang + ** changeset was recorded immediately after the changesets already + ** added to the changegroup. + ** UPDATE UPDATE +-** The existing UPDATE remains within the changegroup. It is amended +-** so that the accompanying values are as if the row was updated once ++** The existing UPDATE remains within the changegroup. It is amended ++** so that the accompanying values are as if the row was updated once + ** by the existing change and then again by the new change. + ** UPDATE DELETE + ** The existing UPDATE is replaced by the new DELETE within the + ** changegroup. + ** DELETE INSERT + ** If one or more of the column values in the row inserted by the +-** new change differ from those in the row deleted by the existing ++** new change differ from those in the row deleted by the existing + ** change, the existing DELETE is replaced by an UPDATE within the +-** changegroup. Otherwise, if the inserted row is exactly the same ++** changegroup. Otherwise, if the inserted row is exactly the same + ** as the deleted row, the existing DELETE is simply discarded. + ** DELETE UPDATE + ** The new change is ignored. This case does not occur if the new +@@ -9485,7 +9418,7 @@ int sqlite3changegroup_add(sqlite3_chang + ** + ** If an error occurs, an SQLite error code is returned and the output + ** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK +-** is returned and the output variables are set to the size of and a ++** is returned and the output variables are set to the size of and a + ** pointer to the output buffer, respectively. In this case it is the + ** responsibility of the caller to eventually free the buffer using a + ** call to sqlite3_free(). +@@ -9513,21 +9446,21 @@ void sqlite3changegroup_delete(sqlite3_c + ** change in the changeset, the filter callback is invoked with + ** the table name as the second argument, and a copy of the context pointer + ** passed as the sixth argument to this function as the first. If the "filter +-** callback" returns zero, then no attempt is made to apply any changes to ++** callback" returns zero, then no attempt is made to apply any changes to + ** the table. Otherwise, if the return value is non-zero or the xFilter + ** argument to this function is NULL, all changes related to the table are + ** attempted. + ** +-** For each table that is not excluded by the filter callback, this function +-** tests that the target database contains a compatible table. A table is ++** For each table that is not excluded by the filter callback, this function ++** tests that the target database contains a compatible table. A table is + ** considered compatible if all of the following are true: + ** + **
          +-**
        • The table has the same name as the name recorded in the ++**
        • The table has the same name as the name recorded in the + ** changeset, and +-**
        • The table has at least as many columns as recorded in the ++**
        • The table has at least as many columns as recorded in the + ** changeset, and +-**
        • The table has primary key columns in the same position as ++**
        • The table has primary key columns in the same position as + ** recorded in the changeset. + **
        + ** +@@ -9536,11 +9469,11 @@ void sqlite3changegroup_delete(sqlite3_c + ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most + ** one such warning is issued for each table in the changeset. + ** +-** For each change for which there is a compatible table, an attempt is made +-** to modify the table contents according to the UPDATE, INSERT or DELETE +-** change. If a change cannot be applied cleanly, the conflict handler +-** function passed as the fifth argument to sqlite3changeset_apply() may be +-** invoked. A description of exactly when the conflict handler is invoked for ++** For each change for which there is a compatible table, an attempt is made ++** to modify the table contents according to the UPDATE, INSERT or DELETE ++** change. If a change cannot be applied cleanly, the conflict handler ++** function passed as the fifth argument to sqlite3changeset_apply() may be ++** invoked. A description of exactly when the conflict handler is invoked for + ** each type of change is below. + ** + ** Unlike the xFilter argument, xConflict may not be passed NULL. The results +@@ -9548,23 +9481,23 @@ void sqlite3changegroup_delete(sqlite3_c + ** argument are undefined. + ** + ** Each time the conflict handler function is invoked, it must return one +-** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or ++** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or + ** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned + ** if the second argument passed to the conflict handler is either + ** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler + ** returns an illegal value, any changes already made are rolled back and +-** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different ++** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different + ** actions are taken by sqlite3changeset_apply() depending on the value + ** returned by each invocation of the conflict-handler function. Refer to +-** the documentation for the three ++** the documentation for the three + ** [SQLITE_CHANGESET_OMIT|available return values] for details. + ** + **
        + **
        DELETE Changes
        +-** For each DELETE change, this function checks if the target database +-** contains a row with the same primary key value (or values) as the +-** original row values stored in the changeset. If it does, and the values +-** stored in all non-primary key columns also match the values stored in ++** For each DELETE change, this function checks if the target database ++** contains a row with the same primary key value (or values) as the ++** original row values stored in the changeset. If it does, and the values ++** stored in all non-primary key columns also match the values stored in + ** the changeset the row is deleted from the target database. + ** + ** If a row with matching primary key values is found, but one or more of +@@ -9593,22 +9526,22 @@ void sqlite3changegroup_delete(sqlite3_c + ** database table, the trailing fields are populated with their default + ** values. + ** +-** If the attempt to insert the row fails because the database already ++** If the attempt to insert the row fails because the database already + ** contains a row with the same primary key values, the conflict handler +-** function is invoked with the second argument set to ++** function is invoked with the second argument set to + ** [SQLITE_CHANGESET_CONFLICT]. + ** + ** If the attempt to insert the row fails because of some other constraint +-** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is ++** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is + ** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT]. +-** This includes the case where the INSERT operation is re-attempted because +-** an earlier call to the conflict handler function returned ++** This includes the case where the INSERT operation is re-attempted because ++** an earlier call to the conflict handler function returned + ** [SQLITE_CHANGESET_REPLACE]. + ** + **
        UPDATE Changes
        +-** For each UPDATE change, this function checks if the target database +-** contains a row with the same primary key value (or values) as the +-** original row values stored in the changeset. If it does, and the values ++** For each UPDATE change, this function checks if the target database ++** contains a row with the same primary key value (or values) as the ++** original row values stored in the changeset. If it does, and the values + ** stored in all modified non-primary key columns also match the values + ** stored in the changeset the row is updated within the target database. + ** +@@ -9624,12 +9557,12 @@ void sqlite3changegroup_delete(sqlite3_c + ** the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND] + ** passed as the second argument. + ** +-** If the UPDATE operation is attempted, but SQLite returns +-** SQLITE_CONSTRAINT, the conflict-handler function is invoked with ++** If the UPDATE operation is attempted, but SQLite returns ++** SQLITE_CONSTRAINT, the conflict-handler function is invoked with + ** [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument. +-** This includes the case where the UPDATE operation is attempted after ++** This includes the case where the UPDATE operation is attempted after + ** an earlier call to the conflict handler function returned +-** [SQLITE_CHANGESET_REPLACE]. ++** [SQLITE_CHANGESET_REPLACE]. + **
        + ** + ** It is safe to execute SQL statements, including those that write to the +@@ -9640,7 +9573,7 @@ void sqlite3changegroup_delete(sqlite3_c + ** All changes made by this function are enclosed in a savepoint transaction. + ** If any other error (aside from a constraint failure when attempting to + ** write to the target database) occurs, then the savepoint transaction is +-** rolled back, restoring the target database to its original state, and an ++** rolled back, restoring the target database to its original state, and an + ** SQLite error code returned. + */ + SQLITE_API int sqlite3changeset_apply( +@@ -9659,7 +9592,7 @@ SQLITE_API int sqlite3changeset_apply( + void *pCtx /* First argument passed to xConflict */ + ); + +-/* ++/* + ** CAPI3REF: Constants Passed To The Conflict Handler + ** + ** Values that may be passed as the second argument to a conflict-handler. +@@ -9668,32 +9601,32 @@ SQLITE_API int sqlite3changeset_apply( + **
        SQLITE_CHANGESET_DATA
        + ** The conflict handler is invoked with CHANGESET_DATA as the second argument + ** when processing a DELETE or UPDATE change if a row with the required +-** PRIMARY KEY fields is present in the database, but one or more other +-** (non primary-key) fields modified by the update do not contain the ++** PRIMARY KEY fields is present in the database, but one or more other ++** (non primary-key) fields modified by the update do not contain the + ** expected "before" values. +-** ++** + ** The conflicting row, in this case, is the database row with the matching + ** primary key. +-** ++** + **
        SQLITE_CHANGESET_NOTFOUND
        + ** The conflict handler is invoked with CHANGESET_NOTFOUND as the second + ** argument when processing a DELETE or UPDATE change if a row with the + ** required PRIMARY KEY fields is not present in the database. +-** ++** + ** There is no conflicting row in this case. The results of invoking the + ** sqlite3changeset_conflict() API are undefined. +-** ++** + **
        SQLITE_CHANGESET_CONFLICT
        + ** CHANGESET_CONFLICT is passed as the second argument to the conflict +-** handler while processing an INSERT change if the operation would result ++** handler while processing an INSERT change if the operation would result + ** in duplicate primary key values. +-** ++** + ** The conflicting row in this case is the database row with the matching + ** primary key. + ** + **
        SQLITE_CHANGESET_FOREIGN_KEY
        + ** If foreign key handling is enabled, and applying a changeset leaves the +-** database in a state containing foreign key violations, the conflict ++** database in a state containing foreign key violations, the conflict + ** handler is invoked with CHANGESET_FOREIGN_KEY as the second argument + ** exactly once before the changeset is committed. If the conflict handler + ** returns CHANGESET_OMIT, the changes, including those that caused the +@@ -9703,12 +9636,12 @@ SQLITE_API int sqlite3changeset_apply( + ** No current or conflicting row information is provided. The only function + ** it is possible to call on the supplied sqlite3_changeset_iter handle + ** is sqlite3changeset_fk_conflicts(). +-** ++** + **
        SQLITE_CHANGESET_CONSTRAINT
        +-** If any other constraint violation occurs while applying a change (i.e. +-** a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is ++** If any other constraint violation occurs while applying a change (i.e. ++** a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is + ** invoked with CHANGESET_CONSTRAINT as the second argument. +-** ++** + ** There is no conflicting row in this case. The results of invoking the + ** sqlite3changeset_conflict() API are undefined. + ** +@@ -9720,7 +9653,7 @@ SQLITE_API int sqlite3changeset_apply( + #define SQLITE_CHANGESET_CONSTRAINT 4 + #define SQLITE_CHANGESET_FOREIGN_KEY 5 + +-/* ++/* + ** CAPI3REF: Constants Returned By The Conflict Handler + ** + ** A conflict handler callback must return one of the following three values. +@@ -9728,13 +9661,13 @@ SQLITE_API int sqlite3changeset_apply( + **
        + **
        SQLITE_CHANGESET_OMIT
        + ** If a conflict handler returns this value no special action is taken. The +-** change that caused the conflict is not applied. The session module ++** change that caused the conflict is not applied. The session module + ** continues to the next change in the changeset. + ** + **
        SQLITE_CHANGESET_REPLACE
        + ** This value may only be returned if the second argument to the conflict + ** handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this +-** is not the case, any changes applied so far are rolled back and the ++** is not the case, any changes applied so far are rolled back and the + ** call to sqlite3changeset_apply() returns SQLITE_MISUSE. + ** + ** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict +@@ -9747,7 +9680,7 @@ SQLITE_API int sqlite3changeset_apply( + ** the original row is restored to the database before continuing. + ** + **
        SQLITE_CHANGESET_ABORT
        +-** If this value is returned, any changes applied so far are rolled back ++** If this value is returned, any changes applied so far are rolled back + ** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. + **
        + */ +@@ -9758,24 +9691,24 @@ SQLITE_API int sqlite3changeset_apply( + /* + ** CAPI3REF: Streaming Versions of API functions. + ** +-** The six streaming API xxx_strm() functions serve similar purposes to the ++** The six streaming API xxx_strm() functions serve similar purposes to the + ** corresponding non-streaming API functions: + ** + ** + ** +-**
        Streaming functionNon-streaming equivalent
        sqlite3changeset_apply_str[sqlite3changeset_apply] +-**
        sqlite3changeset_concat_str[sqlite3changeset_concat] +-**
        sqlite3changeset_invert_str[sqlite3changeset_invert] +-**
        sqlite3changeset_start_str[sqlite3changeset_start] +-**
        sqlite3session_changeset_str[sqlite3session_changeset] +-**
        sqlite3session_patchset_str[sqlite3session_patchset] ++**
        sqlite3changeset_apply_str[sqlite3changeset_apply] ++**
        sqlite3changeset_concat_str[sqlite3changeset_concat] ++**
        sqlite3changeset_invert_str[sqlite3changeset_invert] ++**
        sqlite3changeset_start_str[sqlite3changeset_start] ++**
        sqlite3session_changeset_str[sqlite3session_changeset] ++**
        sqlite3session_patchset_str[sqlite3session_patchset] + **
        + ** + ** Non-streaming functions that accept changesets (or patchsets) as input +-** require that the entire changeset be stored in a single buffer in memory. +-** Similarly, those that return a changeset or patchset do so by returning +-** a pointer to a single large buffer allocated using sqlite3_malloc(). +-** Normally this is convenient. However, if an application running in a ++** require that the entire changeset be stored in a single buffer in memory. ++** Similarly, those that return a changeset or patchset do so by returning ++** a pointer to a single large buffer allocated using sqlite3_malloc(). ++** Normally this is convenient. However, if an application running in a + ** low-memory environment is required to handle very large changesets, the + ** large contiguous memory allocations required can become onerous. + ** +@@ -9797,12 +9730,12 @@ SQLITE_API int sqlite3changeset_apply( + ** + ** + ** Each time the xInput callback is invoked by the sessions module, the first +-** argument passed is a copy of the supplied pIn context pointer. The second +-** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no +-** error occurs the xInput method should copy up to (*pnData) bytes of data +-** into the buffer and set (*pnData) to the actual number of bytes copied +-** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) +-** should be set to zero to indicate this. Or, if an error occurs, an SQLite ++** argument passed is a copy of the supplied pIn context pointer. The second ++** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no ++** error occurs the xInput method should copy up to (*pnData) bytes of data ++** into the buffer and set (*pnData) to the actual number of bytes copied ++** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) ++** should be set to zero to indicate this. Or, if an error occurs, an SQLite + ** error code should be returned. In all cases, if an xInput callback returns + ** an error, all processing is abandoned and the streaming API function + ** returns a copy of the error code to the caller. +@@ -9810,7 +9743,7 @@ SQLITE_API int sqlite3changeset_apply( + ** In the case of sqlite3changeset_start_strm(), the xInput callback may be + ** invoked by the sessions module at any point during the lifetime of the + ** iterator. If such an xInput callback returns an error, the iterator enters +-** an error state, whereby all subsequent calls to iterator functions ++** an error state, whereby all subsequent calls to iterator functions + ** immediately fail with the same error code as returned by xInput. + ** + ** Similarly, streaming API functions that return changesets (or patchsets) +@@ -9840,7 +9773,7 @@ SQLITE_API int sqlite3changeset_apply( + ** is immediately abandoned and the streaming API function returns a copy + ** of the xOutput error code to the application. + ** +-** The sessions module never invokes an xOutput callback with the third ++** The sessions module never invokes an xOutput callback with the third + ** parameter set to a value less than or equal to zero. Other than this, + ** no guarantees are made as to the size of the chunks of data returned. + */ +@@ -9888,12 +9821,12 @@ SQLITE_API int sqlite3session_patchset_s + int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut + ); +-int sqlite3changegroup_add_strm(sqlite3_changegroup*, ++int sqlite3changegroup_add_strm(sqlite3_changegroup*, + int (*xInput)(void *pIn, void *pData, int *pnData), + void *pIn + ); + int sqlite3changegroup_output_strm(sqlite3_changegroup*, +- int (*xOutput)(void *pOut, const void *pData, int nData), ++ int (*xOutput)(void *pOut, const void *pData, int nData), + void *pOut + ); + +@@ -9921,7 +9854,7 @@ int sqlite3changegroup_output_strm(sqlit + ** + ****************************************************************************** + ** +-** Interfaces to extend FTS5. Using the interfaces defined in this file, ++** Interfaces to extend FTS5. Using the interfaces defined in this file, + ** FTS5 may be extended with: + ** + ** * custom tokenizers, and +@@ -9965,19 +9898,19 @@ struct Fts5PhraseIter { + ** EXTENSION API FUNCTIONS + ** + ** xUserData(pFts): +-** Return a copy of the context pointer the extension function was ++** Return a copy of the context pointer the extension function was + ** registered with. + ** + ** xColumnTotalSize(pFts, iCol, pnToken): + ** If parameter iCol is less than zero, set output variable *pnToken + ** to the total number of tokens in the FTS5 table. Or, if iCol is + ** non-negative but less than the number of columns in the table, return +-** the total number of tokens in column iCol, considering all rows in ++** the total number of tokens in column iCol, considering all rows in + ** the FTS5 table. + ** + ** If parameter iCol is greater than or equal to the number of columns + ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. +-** an OOM condition or IO error), an appropriate SQLite error code is ++** an OOM condition or IO error), an appropriate SQLite error code is + ** returned. + ** + ** xColumnCount(pFts): +@@ -9991,7 +9924,7 @@ struct Fts5PhraseIter { + ** + ** If parameter iCol is greater than or equal to the number of columns + ** in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. +-** an OOM condition or IO error), an appropriate SQLite error code is ++** an OOM condition or IO error), an appropriate SQLite error code is + ** returned. + ** + ** This function may be quite inefficient if used with an FTS5 table +@@ -10018,8 +9951,8 @@ struct Fts5PhraseIter { + ** an error code (i.e. SQLITE_NOMEM) if an error occurs. + ** + ** This API can be quite slow if used with an FTS5 table created with the +-** "detail=none" or "detail=column" option. If the FTS5 table is created +-** with either "detail=none" or "detail=column" and "content=" option ++** "detail=none" or "detail=column" option. If the FTS5 table is created ++** with either "detail=none" or "detail=column" and "content=" option + ** (i.e. if it is a contentless table), then this API always returns 0. + ** + ** xInst: +@@ -10034,11 +9967,11 @@ struct Fts5PhraseIter { + ** with the offsets=0 option specified. In this case *piOff is always + ** set to -1. + ** +-** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) ++** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) + ** if an error occurs. + ** + ** This API can be quite slow if used with an FTS5 table created with the +-** "detail=none" or "detail=column" option. ++** "detail=none" or "detail=column" option. + ** + ** xRowid: + ** Returns the rowid of the current row. +@@ -10054,11 +9987,11 @@ struct Fts5PhraseIter { + ** + ** with $p set to a phrase equivalent to the phrase iPhrase of the + ** current query is executed. Any column filter that applies to +-** phrase iPhrase of the current query is included in $p. For each +-** row visited, the callback function passed as the fourth argument +-** is invoked. The context and API objects passed to the callback ++** phrase iPhrase of the current query is included in $p. For each ++** row visited, the callback function passed as the fourth argument ++** is invoked. The context and API objects passed to the callback + ** function may be used to access the properties of each matched row. +-** Invoking Api.xUserData() returns a copy of the pointer passed as ++** Invoking Api.xUserData() returns a copy of the pointer passed as + ** the third argument to pUserData. + ** + ** If the callback function returns any value other than SQLITE_OK, the +@@ -10073,14 +10006,14 @@ struct Fts5PhraseIter { + ** + ** xSetAuxdata(pFts5, pAux, xDelete) + ** +-** Save the pointer passed as the second argument as the extension functions ++** Save the pointer passed as the second argument as the extension functions + ** "auxiliary data". The pointer may then be retrieved by the current or any + ** future invocation of the same fts5 extension function made as part of + ** of the same MATCH query using the xGetAuxdata() API. + ** + ** Each extension function is allocated a single auxiliary data slot for +-** each FTS query (MATCH expression). If the extension function is invoked +-** more than once for a single FTS query, then all invocations share a ++** each FTS query (MATCH expression). If the extension function is invoked ++** more than once for a single FTS query, then all invocations share a + ** single auxiliary data context. + ** + ** If there is already an auxiliary data pointer when this function is +@@ -10099,7 +10032,7 @@ struct Fts5PhraseIter { + ** + ** xGetAuxdata(pFts5, bClear) + ** +-** Returns the current auxiliary data pointer for the fts5 extension ++** Returns the current auxiliary data pointer for the fts5 extension + ** function. See the xSetAuxdata() method for details. + ** + ** If the bClear argument is non-zero, then the auxiliary data is cleared +@@ -10119,7 +10052,7 @@ struct Fts5PhraseIter { + ** method, to iterate through all instances of a single query phrase within + ** the current row. This is the same information as is accessible via the + ** xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient +-** to use, this API may be faster under some circumstances. To iterate ++** to use, this API may be faster under some circumstances. To iterate + ** through instances of phrase iPhrase, use the following code: + ** + ** Fts5PhraseIter iter; +@@ -10137,8 +10070,8 @@ struct Fts5PhraseIter { + ** xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below). + ** + ** This API can be quite slow if used with an FTS5 table created with the +-** "detail=none" or "detail=column" option. If the FTS5 table is created +-** with either "detail=none" or "detail=column" and "content=" option ++** "detail=none" or "detail=column" option. If the FTS5 table is created ++** with either "detail=none" or "detail=column" and "content=" option + ** (i.e. if it is a contentless table), then this API always iterates + ** through an empty set (all calls to xPhraseFirst() set iCol to -1). + ** +@@ -10162,16 +10095,16 @@ struct Fts5PhraseIter { + ** } + ** + ** This API can be quite slow if used with an FTS5 table created with the +-** "detail=none" option. If the FTS5 table is created with either +-** "detail=none" "content=" option (i.e. if it is a contentless table), +-** then this API always iterates through an empty set (all calls to ++** "detail=none" option. If the FTS5 table is created with either ++** "detail=none" "content=" option (i.e. if it is a contentless table), ++** then this API always iterates through an empty set (all calls to + ** xPhraseFirstColumn() set iCol to -1). + ** + ** The information accessed using this API and its companion + ** xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext + ** (or xInst/xInstCount). The chief advantage of this API is that it is + ** significantly more efficient than those alternatives when used with +-** "detail=column" tables. ++** "detail=column" tables. + ** + ** xPhraseNextColumn() + ** See xPhraseFirstColumn above. +@@ -10185,7 +10118,7 @@ struct Fts5ExtensionApi { + int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow); + int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken); + +- int (*xTokenize)(Fts5Context*, ++ int (*xTokenize)(Fts5Context*, + const char *pText, int nText, /* Text to tokenize */ + void *pCtx, /* Context passed to xToken() */ + int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ +@@ -10214,15 +10147,15 @@ struct Fts5ExtensionApi { + void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); + }; + +-/* ++/* + ** CUSTOM AUXILIARY FUNCTIONS + *************************************************************************/ + + /************************************************************************* + ** CUSTOM TOKENIZERS + ** +-** Applications may also register custom tokenizer types. A tokenizer +-** is registered by providing fts5 with a populated instance of the ++** Applications may also register custom tokenizer types. A tokenizer ++** is registered by providing fts5 with a populated instance of the + ** following structure. All structure methods must be defined, setting + ** any member of the fts5_tokenizer struct to NULL leads to undefined + ** behaviour. The structure methods are expected to function as follows: +@@ -10233,16 +10166,16 @@ struct Fts5ExtensionApi { + ** + ** The first argument passed to this function is a copy of the (void*) + ** pointer provided by the application when the fts5_tokenizer object +-** was registered with FTS5 (the third argument to xCreateTokenizer()). ++** was registered with FTS5 (the third argument to xCreateTokenizer()). + ** The second and third arguments are an array of nul-terminated strings + ** containing the tokenizer arguments, if any, specified following the + ** tokenizer name as part of the CREATE VIRTUAL TABLE statement used + ** to create the FTS5 table. + ** +-** The final argument is an output variable. If successful, (*ppOut) ++** The final argument is an output variable. If successful, (*ppOut) + ** should be set to point to the new tokenizer handle and SQLITE_OK + ** returned. If an error occurs, some value other than SQLITE_OK should +-** be returned. In this case, fts5 assumes that the final value of *ppOut ++** be returned. In this case, fts5 assumes that the final value of *ppOut + ** is undefined. + ** + ** xDelete: +@@ -10251,7 +10184,7 @@ struct Fts5ExtensionApi { + ** be invoked exactly once for each successful call to xCreate(). + ** + ** xTokenize: +-** This function is expected to tokenize the nText byte string indicated ++** This function is expected to tokenize the nText byte string indicated + ** by argument pText. pText may or may not be nul-terminated. The first + ** argument passed to this function is a pointer to an Fts5Tokenizer object + ** returned by an earlier call to xCreate(). +@@ -10265,8 +10198,8 @@ struct Fts5ExtensionApi { + ** determine the set of tokens to add to (or delete from) the + ** FTS index. + ** +-**
      • FTS5_TOKENIZE_QUERY - A MATCH query is being executed +-** against the FTS index. The tokenizer is being called to tokenize ++**
      • FTS5_TOKENIZE_QUERY - A MATCH query is being executed ++** against the FTS index. The tokenizer is being called to tokenize + ** a bareword or quoted string specified as part of the query. + ** + **
      • (FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX) - Same as +@@ -10274,10 +10207,10 @@ struct Fts5ExtensionApi { + ** followed by a "*" character, indicating that the last token + ** returned by the tokenizer will be treated as a token prefix. + ** +-**
      • FTS5_TOKENIZE_AUX - The tokenizer is being invoked to ++**
      • FTS5_TOKENIZE_AUX - The tokenizer is being invoked to + ** satisfy an fts5_api.xTokenize() request made by an auxiliary + ** function. Or an fts5_api.xColumnSize() request made by the same +-** on a columnsize=0 database. ++** on a columnsize=0 database. + **
      + ** + ** For each token in the input string, the supplied callback xToken() must +@@ -10289,10 +10222,10 @@ struct Fts5ExtensionApi { + ** which the token is derived within the input. + ** + ** The second argument passed to the xToken() callback ("tflags") should +-** normally be set to 0. The exception is if the tokenizer supports ++** normally be set to 0. The exception is if the tokenizer supports + ** synonyms. In this case see the discussion below for details. + ** +-** FTS5 assumes the xToken() callback is invoked for each token in the ++** FTS5 assumes the xToken() callback is invoked for each token in the + ** order that they occur within the input text. + ** + ** If an xToken() callback returns any value other than SQLITE_OK, then +@@ -10306,7 +10239,7 @@ struct Fts5ExtensionApi { + ** SYNONYM SUPPORT + ** + ** Custom tokenizers may also support synonyms. Consider a case in which a +-** user wishes to query for a phrase such as "first place". Using the ++** user wishes to query for a phrase such as "first place". Using the + ** built-in tokenizers, the FTS5 query 'first + place' will match instances + ** of "first place" within the document set, but not alternative forms + ** such as "1st place". In some applications, it would be better to match +@@ -10315,7 +10248,7 @@ struct Fts5ExtensionApi { + ** + ** There are several ways to approach this in FTS5: + ** +-**
      1. By mapping all synonyms to a single token. In this case, the ++**
        1. By mapping all synonyms to a single token. In this case, the + ** In the above example, this means that the tokenizer returns the + ** same token for inputs "first" and "1st". Say that token is in + ** fact "first", so that when the user inserts the document "I won +@@ -10325,7 +10258,7 @@ struct Fts5ExtensionApi { + ** as expected. + ** + **
        2. By adding multiple synonyms for a single term to the FTS index. +-** In this case, when tokenizing query text, the tokenizer may ++** In this case, when tokenizing query text, the tokenizer may + ** provide multiple synonyms for a single term within the document. + ** FTS5 then queries the index for each synonym individually. For + ** example, faced with the query: +@@ -10334,26 +10267,26 @@ struct Fts5ExtensionApi { + ** ... MATCH 'first place' + ** + ** the tokenizer offers both "1st" and "first" as synonyms for the +-** first token in the MATCH query and FTS5 effectively runs a query ++** first token in the MATCH query and FTS5 effectively runs a query + ** similar to: + ** + ** + ** ... MATCH '(first OR 1st) place' + ** + ** except that, for the purposes of auxiliary functions, the query +-** still appears to contain just two phrases - "(first OR 1st)" ++** still appears to contain just two phrases - "(first OR 1st)" + ** being treated as a single phrase. + ** + **
        3. By adding multiple synonyms for a single term to the FTS index. + ** Using this method, when tokenizing document text, the tokenizer +-** provides multiple synonyms for each token. So that when a ++** provides multiple synonyms for each token. So that when a + ** document such as "I won first place" is tokenized, entries are + ** added to the FTS index for "i", "won", "first", "1st" and + ** "place". + ** + ** This way, even if the tokenizer does not provide synonyms + ** when tokenizing query text (it should not - to do would be +-** inefficient), it doesn't matter if the user queries for ++** inefficient), it doesn't matter if the user queries for + ** 'first + place' or '1st + place', as there are entires in the + ** FTS index corresponding to both forms of the first token. + **
        +@@ -10374,11 +10307,11 @@ struct Fts5ExtensionApi { + ** + ** It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time + ** xToken() is called. Multiple synonyms may be specified for a single token +-** by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. ++** by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. + ** There is no limit to the number of synonyms that may be provided for a + ** single token. + ** +-** In many cases, method (1) above is the best approach. It does not add ++** In many cases, method (1) above is the best approach. It does not add + ** extra data to the FTS index or require FTS5 to query for multiple terms, + ** so it is efficient in terms of disk space and query speed. However, it + ** does not support prefix queries very well. If, as suggested above, the +@@ -10390,18 +10323,18 @@ struct Fts5ExtensionApi { + ** will not match documents that contain the token "1st" (as the tokenizer + ** will probably not map "1s" to any prefix of "first"). + ** +-** For full prefix support, method (3) may be preferred. In this case, ++** For full prefix support, method (3) may be preferred. In this case, + ** because the index contains entries for both "first" and "1st", prefix + ** queries such as 'fi*' or '1s*' will match correctly. However, because + ** extra entries are added to the FTS index, this method uses more space + ** within the database. + ** + ** Method (2) offers a midpoint between (1) and (3). Using this method, +-** a query such as '1s*' will match documents that contain the literal ++** a query such as '1s*' will match documents that contain the literal + ** token "1st", but not "first" (assuming the tokenizer is not able to + ** provide synonyms for prefixes). However, a non-prefix query like '1st' + ** will match against "1st" and "first". This method does not require +-** extra disk space, as no extra entries are added to the FTS index. ++** extra disk space, as no extra entries are added to the FTS index. + ** On the other hand, it may require more CPU cycles to run MATCH queries, + ** as separate queries of the FTS index are required for each synonym. + ** +@@ -10415,10 +10348,10 @@ typedef struct fts5_tokenizer fts5_token + struct fts5_tokenizer { + int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); + void (*xDelete)(Fts5Tokenizer*); +- int (*xTokenize)(Fts5Tokenizer*, ++ int (*xTokenize)(Fts5Tokenizer*, + void *pCtx, + int flags, /* Mask of FTS5_TOKENIZE_* flags */ +- const char *pText, int nText, ++ const char *pText, int nText, + int (*xToken)( + void *pCtx, /* Copy of 2nd argument to xTokenize() */ + int tflags, /* Mask of FTS5_TOKEN_* flags */ +@@ -10456,7 +10389,7 @@ struct fts5_api { fts5_api *pApi, const char *zName, void *pContext, @@ -21200,9 +33939,9 @@ void (*xDestroy)(void*) ); ---- origsrc/sqlite-autoconf-3100000/sqlite3ext.h 2016-01-06 13:03:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/sqlite3ext.h 2016-01-06 16:18:40.965851800 +0100 -@@ -34,7 +34,7 @@ typedef struct sqlite3_api_routines sqli +--- origsrc/sqlite-autoconf-3180000/sqlite3ext.h 2017-03-30 16:26:48.000000000 +0200 ++++ src/sqlite-autoconf-3180000/sqlite3ext.h 2017-04-19 16:20:02.088947500 +0200 +@@ -32,7 +32,7 @@ struct sqlite3_api_routines { void * (*aggregate_context)(sqlite3_context*,int nBytes); int (*aggregate_count)(sqlite3_context*); @@ -21211,7 +33950,7 @@ int (*bind_double)(sqlite3_stmt*,int,double); int (*bind_int)(sqlite3_stmt*,int,int); int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); -@@ -42,7 +42,7 @@ struct sqlite3_api_routines { +@@ -40,20 +40,20 @@ struct sqlite3_api_routines { int (*bind_parameter_count)(sqlite3_stmt*); int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); const char * (*bind_parameter_name)(sqlite3_stmt*,int); @@ -21220,7 +33959,12 @@ int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); -@@ -54,8 +54,8 @@ struct sqlite3_api_routines { + int (*busy_timeout)(sqlite3*,int ms); +- int (*changes)(sqlite3*); ++ sqlite_uint64 (*changes)(sqlite3*); + int (*close)(sqlite3*); + int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, + int eTextRep,const char*)); int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, int eTextRep,const void*)); const void * (*column_blob)(sqlite3_stmt*,int iCol); @@ -21231,7 +33975,7 @@ int (*column_count)(sqlite3_stmt*pStmt); const char * (*column_database_name)(sqlite3_stmt*,int); const void * (*column_database_name16)(sqlite3_stmt*,int); -@@ -120,7 +120,7 @@ struct sqlite3_api_routines { +@@ -118,7 +118,7 @@ struct sqlite3_api_routines { void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); void *(*realloc)(void*,int); int (*reset)(sqlite3_stmt*pStmt); @@ -21240,7 +33984,15 @@ void (*result_double)(sqlite3_context*,double); void (*result_error)(sqlite3_context*,const char*,int); void (*result_error16)(sqlite3_context*,const void*,int); -@@ -148,8 +148,8 @@ struct sqlite3_api_routines { +@@ -139,15 +139,15 @@ struct sqlite3_api_routines { + int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, + char const**,char const**,int*,int*,int*); + void (*thread_cleanup)(void); +- int (*total_changes)(sqlite3*); ++ sqlite_uint64 (*total_changes)(sqlite3*); + void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); + int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); + void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, sqlite_int64),void*); void * (*user_data)(sqlite3_context*); const void * (*value_blob)(sqlite3_value*); @@ -21251,7 +34003,7 @@ double (*value_double)(sqlite3_value*); int (*value_int)(sqlite3_value*); sqlite_int64 (*value_int64)(sqlite3_value*); -@@ -294,10 +294,9 @@ struct sqlite3_api_routines { +@@ -309,10 +309,9 @@ typedef int (*sqlite3_loadext_entry)( */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) #define sqlite3_aggregate_context sqlite3_api->aggregate_context @@ -21264,7 +34016,7 @@ #define sqlite3_bind_double sqlite3_api->bind_double #define sqlite3_bind_int sqlite3_api->bind_int #define sqlite3_bind_int64 sqlite3_api->bind_int64 -@@ -305,8 +304,12 @@ struct sqlite3_api_routines { +@@ -320,12 +319,19 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name @@ -21277,7 +34029,15 @@ #define sqlite3_bind_value sqlite3_api->bind_value #define sqlite3_busy_handler sqlite3_api->busy_handler #define sqlite3_busy_timeout sqlite3_api->busy_timeout -@@ -338,11 +341,14 @@ struct sqlite3_api_routines { +-#define sqlite3_changes sqlite3_api->changes ++#undef sqlite3_changes ++#define sqlite3_changes (int)sqlite3_api->changes ++#undef sqlite3_changes64 ++#define sqlite3_changes64 sqlite3_api->changes + #define sqlite3_close sqlite3_api->close + #define sqlite3_collation_needed sqlite3_api->collation_needed + #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 +@@ -353,11 +359,14 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_commit_hook sqlite3_api->commit_hook #define sqlite3_complete sqlite3_api->complete #define sqlite3_complete16 sqlite3_api->complete16 @@ -21295,7 +34055,7 @@ #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 #define sqlite3_data_count sqlite3_api->data_count #define sqlite3_db_handle sqlite3_api->db_handle -@@ -352,23 +358,19 @@ struct sqlite3_api_routines { +@@ -367,23 +376,19 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_errmsg sqlite3_api->errmsg #define sqlite3_errmsg16 sqlite3_api->errmsg16 #define sqlite3_exec sqlite3_api->exec @@ -21321,7 +34081,7 @@ #define sqlite3_mprintf sqlite3_api->mprintf #define sqlite3_open sqlite3_api->open #define sqlite3_open16 sqlite3_api->open16 -@@ -378,19 +380,31 @@ struct sqlite3_api_routines { +@@ -393,19 +398,31 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 #define sqlite3_profile sqlite3_api->profile #define sqlite3_progress_handler sqlite3_api->progress_handler @@ -21353,12 +34113,16 @@ #define sqlite3_result_value sqlite3_api->result_value #define sqlite3_rollback_hook sqlite3_api->rollback_hook #define sqlite3_set_authorizer sqlite3_api->set_authorizer -@@ -398,12 +412,8 @@ struct sqlite3_api_routines { +@@ -413,12 +430,11 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_snprintf sqlite3_api->snprintf #define sqlite3_step sqlite3_api->step #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata -#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup - #define sqlite3_total_changes sqlite3_api->total_changes +-#define sqlite3_total_changes sqlite3_api->total_changes ++#undef sqlite3_total_changes ++#define sqlite3_total_changes (int)sqlite3_api->total_changes ++#undef sqlite3_total_changes64 ++#define sqlite3_total_changes64 sqlite3_api->total_changes #define sqlite3_trace sqlite3_api->trace -#ifndef SQLITE_OMIT_DEPRECATED -#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings @@ -21366,7 +34130,7 @@ #define sqlite3_update_hook sqlite3_api->update_hook #define sqlite3_user_data sqlite3_api->user_data #define sqlite3_value_blob sqlite3_api->value_blob -@@ -444,12 +454,13 @@ struct sqlite3_api_routines { +@@ -459,12 +475,13 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig #define sqlite3_sleep sqlite3_api->sleep @@ -21381,7 +34145,7 @@ #define sqlite3_result_error_code sqlite3_api->result_error_code #define sqlite3_test_control sqlite3_api->test_control #define sqlite3_randomness sqlite3_api->randomness -@@ -478,7 +489,8 @@ struct sqlite3_api_routines { +@@ -493,7 +510,8 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_strnicmp sqlite3_api->strnicmp #define sqlite3_unlock_notify sqlite3_api->unlock_notify #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint @@ -21391,8 +34155,8 @@ #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-3100000/sqlite3rbu.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/sqlite3rbu.c 2016-01-06 16:34:23.119740000 +0100 +--- origsrc/sqlite-autoconf-3180000/sqlite3rbu.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/sqlite3rbu.c 2017-04-19 16:20:02.119950600 +0200 @@ -0,0 +1,4059 @@ +/* +** 2014 August 30 @@ -25453,8 +38217,8 @@ +/**************************************************************************/ + +#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */ ---- origsrc/sqlite-autoconf-3100000/sqlite3rbu.h 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/sqlite3rbu.h 2016-01-06 16:41:00.737482400 +0100 +--- origsrc/sqlite-autoconf-3180000/sqlite3rbu.h 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/sqlite3rbu.h 2017-04-19 16:20:02.132951900 +0200 @@ -0,0 +1,461 @@ +/* +** 2014 August 30 @@ -25917,8 +38681,8 @@ +#endif + +#endif /* _SQLITE3RBU_H */ ---- origsrc/sqlite-autoconf-3100000/tea/configure.ac 2016-01-06 13:03:05.000000000 +0100 -+++ src/sqlite-autoconf-3100000/tea/configure.ac 2016-01-06 16:20:37.977544500 +0100 +--- origsrc/sqlite-autoconf-3180000/tea/configure.ac 2017-03-30 16:26:52.000000000 +0200 ++++ src/sqlite-autoconf-3180000/tea/configure.ac 2017-04-19 16:20:02.143953000 +0200 @@ -6,7 +6,7 @@ dnl to configure the system for the loca # RCS: @(#) $Id: configure.in,v 1.43 2005/07/26 19:17:05 mdejong Exp $ @@ -25928,7 +38692,7 @@ # need to modify this file are marked by the string __CHANGE__ #----------------------------------------------------------------------- -@@ -75,10 +75,21 @@ TEA_ADD_SOURCES([tclsqlite3.c]) +@@ -75,9 +75,22 @@ TEA_ADD_SOURCES([tclsqlite3.c]) TEA_ADD_HEADERS([]) TEA_ADD_INCLUDES([-I\"`\${CYGPATH} \${srcdir}/generic`\"]) TEA_ADD_LIBS([]) @@ -25937,12 +38701,13 @@ +TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS3_PARENTHESIS=1]) +TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS4=1]) +TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS5=1]) ++TEA_ADD_CFLAGS([-DSQLITE_ENABLE_COLUMN_METADATA=1]) +TEA_ADD_CFLAGS([-DSQLITE_ENABLE_JSON1=1]) TEA_ADD_CFLAGS([-DSQLITE_3_SUFFIX_ONLY=1]) TEA_ADD_CFLAGS([-DSQLITE_ENABLE_RTREE=1]) +TEA_ADD_CFLAGS([-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1]) ++TEA_ADD_CFLAGS([-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1]) +TEA_ADD_CFLAGS([-DSQLITE_OMIT_BUILTIN_TEST=1]) - TEA_ADD_CFLAGS([-DSQLITE_OMIT_DEPRECATED=1]) +TEA_ADD_CFLAGS([-DSQLITE_OMIT_LOOKASIDE=1]) +TEA_ADD_CFLAGS([-DSQLITE_SECURE_DELETE=1]) +TEA_ADD_CFLAGS([-DSQLITE_SOUNDEX=1]) @@ -25951,32 +38716,43 @@ TEA_ADD_STUB_SOURCES([]) TEA_ADD_TCL_SOURCES([]) -@@ -168,8 +179,9 @@ AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stu +@@ -167,8 +180,9 @@ AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stu #-------------------------------------------------------------------- # #AC_CHECK_FUNC(fdatasync, , AC_DEFINE(fdatasync, fsync)) +AC_CHECK_HEADERS([malloc.h]) # Check for library functions that SQLite can optionally use. -AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r]) -+AC_CHECK_FUNCS([fdatasync usleep strchrnul localtime_r gmtime_r localtime_s malloc_usable_size utime flock]) ++AC_CHECK_FUNCS([fdatasync usleep strchrnul localtime_r gmtime_r localtime_s malloc_usable_size utime flock readlink lstat pread pread64 pwrite pwrite64 rand_s]) AC_FUNC_STRERROR_R ---- origsrc/sqlite-autoconf-3100000/tea/generic/tclsqlite3.c 2016-01-06 13:03:05.000000000 +0100 -+++ src/sqlite-autoconf-3100000/tea/generic/tclsqlite3.c 2016-01-06 16:25:56.782779100 +0100 -@@ -67,13 +67,17 @@ +--- origsrc/sqlite-autoconf-3180000/tea/generic/tclsqlite3.c 2017-03-30 16:26:52.000000000 +0200 ++++ src/sqlite-autoconf-3180000/tea/generic/tclsqlite3.c 2017-04-19 16:20:02.156954300 +0200 +@@ -1,7 +1,7 @@ + #ifdef USE_SYSTEM_SQLITE + # include + #else +-#include "sqlite3.c" ++#include "../compat/sqlite3/sqlite3.c" + #endif + /* + ** 2001 September 15 +@@ -73,6 +73,26 @@ + # define GETPID (int)GetCurrentProcessId #endif - /* -- * Windows needs to know which symbols to export. Unix does not. -- * BUILD_sqlite should be undefined for Unix. ++#ifndef CONST ++# define CONST const ++#endif ++#ifndef EXTERN ++# define EXTERN DLLEXPORT ++#endif ++ ++/* + * If we are not sure the platform is 32-bit, always use sqlite3_????64() + * in stead of sqlite3_????() for certain functions, in order to prevent overflow. - */ --#ifdef BUILD_sqlite --#undef TCL_STORAGE_CLASS --#define TCL_STORAGE_CLASS DLLEXPORT --#endif /* BUILD_sqlite */ ++ */ +#if !defined(i386) && !defined(__i386__) && !defined(_M_IX86) && \ + !defined(_M_ARM) && !defined(__arm__) && !defined(__x86) && \ + (!defined(__SIZEOF_POINTER__) || (__SIZEOF_POINTER__ != 4)) @@ -25985,10 +38761,11 @@ +# define sqlite3_bind_text(pStmt, i, zData, nData, xDel) sqlite3_bind_text64(pStmt, i, zData, nData, xDel, SQLITE_UTF8) +# define sqlite3_result_text(pCtx, z, n, xDel) sqlite3_result_text64(pCtx, z, n, xDel, SQLITE_UTF8) +#endif - - #define NUM_PREPARED_STMTS 10 - #define MAX_PREPARED_STMTS 100 -@@ -182,6 +186,10 @@ static int strlen30(const char *z){ ++ + /* + * Windows needs to know which symbols to export. Unix does not. + * BUILD_sqlite should be undefined for Unix. +@@ -192,6 +212,10 @@ static int strlen30(const char *z){ return 0x3fffffff & (int)(z2 - z); } @@ -25999,16 +38776,7 @@ #ifndef SQLITE_OMIT_INCRBLOB /* -@@ -269,7 +277,7 @@ static int incrblobInput( - */ - static int incrblobOutput( - ClientData instanceData, -- CONST char *buf, -+ const char *buf, - int toWrite, - int *errorCodePtr - ){ -@@ -542,10 +550,16 @@ static void DbDeleteCmd(void *db){ +@@ -568,10 +592,16 @@ static void SQLITE_TCLAPI DbDeleteCmd(vo static int DbBusyHandler(void *cd, int nTries){ SqliteDb *pDb = (SqliteDb*)cd; int rc; @@ -26028,7 +38796,138 @@ if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){ return 0; } -@@ -866,8 +880,8 @@ static void tclSqlFunc(sqlite3_context * +@@ -587,7 +617,7 @@ static int DbProgressHandler(void *cd){ + int rc; + + assert( pDb->zProgress ); +- rc = Tcl_Eval(pDb->interp, pDb->zProgress); ++ rc = Tcl_EvalEx(pDb->interp, pDb->zProgress, -1, 0); + if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){ + return 1; + } +@@ -595,22 +625,27 @@ static int DbProgressHandler(void *cd){ + } + #endif + +-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \ +- !defined(SQLITE_OMIT_DEPRECATED) ++#ifndef SQLITE_OMIT_TRACE + /* + ** This routine is called by the SQLite trace handler whenever a new + ** block of SQL is executed. The TCL script in pDb->zTrace is executed. + */ +-static void DbTraceHandler(void *cd, const char *zSql){ ++static int DbTraceHandler( ++ unsigned type, /* One of the SQLITE_TRACE_* event types. */ ++ void *cd, /* The original context data pointer. */ ++ void *pd, /* Primary event data, depends on event type. */ ++ void *xd /* Extra event data, depends on event type. */ ++){ + SqliteDb *pDb = (SqliteDb*)cd; + Tcl_DString str; + + Tcl_DStringInit(&str); + Tcl_DStringAppend(&str, pDb->zTrace, -1); +- Tcl_DStringAppendElement(&str, zSql); +- Tcl_Eval(pDb->interp, Tcl_DStringValue(&str)); ++ Tcl_DStringAppendElement(&str, (char *)xd); ++ Tcl_EvalEx(pDb->interp, Tcl_DStringValue(&str), -1, 0); + Tcl_DStringFree(&str); + Tcl_ResetResult(pDb->interp); ++ return TCL_OK; + } + #endif + +@@ -638,7 +673,7 @@ static int DbTraceV2Handler( + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, +- Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); ++ Tcl_NewWideIntObj((Tcl_WideInt)(size_t)pStmt)); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewStringObj(zSql, -1)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); +@@ -648,12 +683,12 @@ static int DbTraceV2Handler( + } + case SQLITE_TRACE_PROFILE: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; +- sqlite3_int64 ns = (sqlite3_int64)xd; ++ size_t ns = (size_t)xd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, +- Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); ++ Tcl_NewWideIntObj((Tcl_WideInt)(size_t)pStmt)); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)ns)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); +@@ -667,7 +702,7 @@ static int DbTraceV2Handler( + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, +- Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); ++ Tcl_NewWideIntObj((Tcl_WideInt)(size_t)pStmt)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); +@@ -679,7 +714,7 @@ static int DbTraceV2Handler( + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, +- Tcl_NewWideIntObj((Tcl_WideInt)db)); ++ Tcl_NewWideIntObj((Tcl_WideInt)(size_t)db)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); +@@ -690,25 +725,31 @@ static int DbTraceV2Handler( + } + #endif + +-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \ +- !defined(SQLITE_OMIT_DEPRECATED) ++#ifndef SQLITE_OMIT_TRACE + /* + ** This routine is called by the SQLite profile handler after a statement + ** SQL has executed. The TCL script in pDb->zProfile is evaluated. + */ +-static void DbProfileHandler(void *cd, const char *zSql, sqlite_uint64 tm){ ++static int DbProfileHandler( ++ unsigned type, /* One of the SQLITE_TRACE_* event types. */ ++ void *cd, /* The original context data pointer. */ ++ void *pd, /* Primary event data, depends on event type. */ ++ void *xd /* Extra event data, depends on event type. */ ++){ + SqliteDb *pDb = (SqliteDb*)cd; + Tcl_DString str; + char zTm[100]; ++ sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + +- sqlite3_snprintf(sizeof(zTm)-1, zTm, "%lld", tm); ++ sqlite3_snprintf(sizeof(zTm)-1, zTm, "%lld", (Tcl_WideInt)(size_t)xd); + Tcl_DStringInit(&str); + Tcl_DStringAppend(&str, pDb->zProfile, -1); +- Tcl_DStringAppendElement(&str, zSql); ++ Tcl_DStringAppendElement(&str, sqlite3_sql(pStmt)); + Tcl_DStringAppendElement(&str, zTm); +- Tcl_Eval(pDb->interp, Tcl_DStringValue(&str)); ++ Tcl_EvalEx(pDb->interp, Tcl_DStringValue(&str), -1, 0); + Tcl_DStringFree(&str); + Tcl_ResetResult(pDb->interp); ++ return SQLITE_OK; + } + #endif + +@@ -722,7 +763,7 @@ static int DbCommitHandler(void *cd){ + SqliteDb *pDb = (SqliteDb*)cd; + int rc; + +- rc = Tcl_Eval(pDb->interp, pDb->zCommit); ++ rc = Tcl_EvalEx(pDb->interp, pDb->zCommit, -1, 0); + if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){ + return 1; + } +@@ -1010,8 +1051,8 @@ static void tclSqlFunc(sqlite3_context * Tcl_GetWideIntFromObj(0, pVar, &v); sqlite3_result_int64(context, v); }else{ @@ -26039,7 +38938,16 @@ } } } -@@ -960,6 +974,7 @@ static int auth_callback( +@@ -1088,7 +1129,7 @@ static int auth_callback( + #ifdef SQLITE_USER_AUTHENTICATION + Tcl_DStringAppendElement(&str, zArg5 ? zArg5 : ""); + #endif +- rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str)); ++ rc = Tcl_EvalEx(pDb->interp, Tcl_DStringValue(&str), -1, TCL_EVAL_GLOBAL); + Tcl_DStringFree(&str); + zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : "SQLITE_DENY"; + if( strcmp(zReply,"SQLITE_OK")==0 ){ +@@ -1104,6 +1145,7 @@ static int auth_callback( } #endif /* SQLITE_OMIT_AUTHORIZATION */ @@ -26047,7 +38955,7 @@ /* ** This routine reads a line of text from FILE in, stores ** the text in memory obtained from malloc() and returns a pointer -@@ -1004,6 +1019,7 @@ static char *local_getline(char *zPrompt +@@ -1148,6 +1190,7 @@ static char *local_getline(char *zPrompt zLine = realloc( zLine, n+1 ); return zLine; } @@ -26055,7 +38963,7 @@ /* -@@ -1219,8 +1235,8 @@ static int dbPrepareAndBind( +@@ -1363,8 +1406,8 @@ static int dbPrepareAndBind( Tcl_GetWideIntFromObj(interp, pVar, &v); sqlite3_bind_int64(pStmt, i, v); }else{ @@ -26066,18 +38974,18 @@ Tcl_IncrRefCount(pVar); pPreStmt->apParm[iParm++] = pVar; } -@@ -1918,8 +1934,8 @@ static int DbObjCmd(void *cd, Tcl_Interp +@@ -2111,8 +2154,8 @@ static int SQLITE_TCLAPI DbObjCmd( pCollate->zScript = (char*)&pCollate[1]; pDb->pCollate = pCollate; memcpy(pCollate->zScript, zScript, nScript+1); -- if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, +- if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, - pCollate, tclSqlCollate) ){ -+ if( sqlite3_create_collation_v2(pDb->db, zName, SQLITE_UTF8, ++ 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; } -@@ -2036,9 +2052,10 @@ static int DbObjCmd(void *cd, Tcl_Interp +@@ -2229,9 +2272,10 @@ static int SQLITE_TCLAPI DbObjCmd( char *zLine; /* A single line of input from the file */ char **azCol; /* zLine[] broken up into columns */ const char *zCommit; /* How to commit changes */ @@ -26089,7 +38997,7 @@ Tcl_Obj *pResult; /* interp result */ const char *zSep; -@@ -2096,7 +2113,7 @@ static int DbObjCmd(void *cd, Tcl_Interp +@@ -2289,7 +2333,7 @@ static int SQLITE_TCLAPI DbObjCmd( if( nCol==0 ) { return TCL_ERROR; } @@ -26098,7 +39006,7 @@ if( zSql==0 ) { Tcl_AppendResult(interp, "Error: can't malloc()", (char*)0); return TCL_ERROR; -@@ -2111,29 +2128,30 @@ static int DbObjCmd(void *cd, Tcl_Interp +@@ -2304,29 +2348,30 @@ static int SQLITE_TCLAPI DbObjCmd( zSql[j++] = ')'; zSql[j] = 0; rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0); @@ -26112,7 +39020,7 @@ - in = fopen(zFile, "rb"); + in = Tcl_OpenFileChannel(interp, zFile, "r", 0666); if( in==0 ){ -- Tcl_AppendResult(interp, "Error: cannot open file: ", zFile, NULL); +- Tcl_AppendResult(interp, "Error: cannot open file: ", zFile, (char*)0); sqlite3_finalize(pStmt); return TCL_ERROR; } @@ -26135,19 +39043,33 @@ azCol[0] = zLine; for(i=0, z=zLine; *z; z++){ if( *z==zSep[0] && strncmp(z, zSep, nSep)==0 ){ -@@ -2161,25 +2179,27 @@ static int DbObjCmd(void *cd, Tcl_Interp +@@ -2341,38 +2386,38 @@ static int SQLITE_TCLAPI DbObjCmd( + if( i+1!=nCol ){ + char *zErr; + int nErr = strlen30(zFile) + 200; +- zErr = malloc(nErr); ++ zErr = sqlite3_malloc(nErr); + if( zErr ){ + sqlite3_snprintf(nErr, zErr, + "Error: %s line %d: expected %d columns of data but found %d", + zFile, lineno, nCol, i+1); + Tcl_AppendResult(interp, zErr, (char*)0); +- free(zErr); ++ sqlite3_free(zErr); + } + zCommit = "ROLLBACK"; + break; } for(i=0; i0 && strcmp(azCol[i], zNull)==0) -- || strlen30(azCol[i])==0 -+ || len==0 +- if( (nNull>0 && strcmp(azCol[i], zNull)==0) +- || strlen30(azCol[i])==0 ++ if( (azCol[i][0]==0) || (nNull>0 && strcmp(azCol[i], zNull)==0) ){ sqlite3_bind_null(pStmt, i+1); }else{ - sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC); -+ sqlite3_bind_text(pStmt, i+1, azCol[i], len, SQLITE_STATIC); ++ sqlite3_bind_text(pStmt, i+1, azCol[i], strlen30(azCol[i]), SQLITE_STATIC); } } sqlite3_step(pStmt); @@ -26168,25 +39090,7 @@ sqlite3_finalize(pStmt); (void)sqlite3_exec(pDb->db, zCommit, 0, 0, 0); -@@ -2346,7 +2366,7 @@ static int DbObjCmd(void *cd, Tcl_Interp - int n = strlen30(z); - if( n>2 && strncmp(z, "-argcount",n)==0 ){ - if( i==(objc-2) ){ -- Tcl_AppendResult(interp, "option requires an argument: ", z, 0); -+ Tcl_AppendResult(interp, "option requires an argument: ", z, (char*)0); - return TCL_ERROR; - } - if( Tcl_GetIntFromObj(interp, objv[i+1], &nArg) ) return TCL_ERROR; -@@ -2361,7 +2381,7 @@ static int DbObjCmd(void *cd, Tcl_Interp - flags |= SQLITE_DETERMINISTIC; - }else{ - Tcl_AppendResult(interp, "bad option \"", z, -- "\": must be -argcount or -deterministic", 0 -+ "\": must be -argcount or -deterministic", (char*)0 - ); - return TCL_ERROR; - } -@@ -2377,8 +2397,8 @@ static int DbObjCmd(void *cd, Tcl_Interp +@@ -2572,8 +2617,8 @@ static int SQLITE_TCLAPI DbObjCmd( pFunc->pScript = pScript; Tcl_IncrRefCount(pScript); pFunc->useEvalObjv = safeToUseEvalObjv(interp, pScript); @@ -26197,7 +39101,52 @@ if( rc!=SQLITE_OK ){ rc = TCL_ERROR; Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); -@@ -3104,9 +3124,21 @@ static int DbMain(void *cd, Tcl_Interp * +@@ -2754,13 +2799,12 @@ static int SQLITE_TCLAPI DbObjCmd( + }else{ + pDb->zProfile = 0; + } +-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \ +- !defined(SQLITE_OMIT_DEPRECATED) ++#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) + if( pDb->zProfile ){ + pDb->interp = interp; +- sqlite3_profile(pDb->db, DbProfileHandler, pDb); ++ sqlite3_trace_v2(pDb->db, SQLITE_TRACE_PROFILE, DbProfileHandler, pDb); + }else{ +- sqlite3_profile(pDb->db, 0, 0); ++ sqlite3_trace_v2(pDb->db, 0, 0, 0); + } + #endif + } +@@ -2942,13 +2986,12 @@ static int SQLITE_TCLAPI DbObjCmd( + }else{ + pDb->zTrace = 0; + } +-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \ +- !defined(SQLITE_OMIT_DEPRECATED) ++#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) + if( pDb->zTrace ){ + pDb->interp = interp; +- sqlite3_trace(pDb->db, DbTraceHandler, pDb); ++ sqlite3_trace_v2(pDb->db, SQLITE_TRACE_STMT, DbTraceHandler, pDb); + }else{ +- sqlite3_trace(pDb->db, 0, 0); ++ sqlite3_trace_v2(pDb->db, 0, 0, 0); + } + #endif + } +@@ -3410,6 +3453,10 @@ static int SQLITE_TCLAPI DbMain( + } + zErrMsg = 0; + p = (SqliteDb*)Tcl_Alloc( sizeof(*p) ); ++ if( p==0 ){ ++ Tcl_SetResult(interp, (char *)"malloc failed", TCL_STATIC); ++ return TCL_ERROR; ++ } + memset(p, 0, sizeof(*p)); + zFile = Tcl_GetStringFromObj(objv[2], 0); + zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename); +@@ -3452,9 +3499,21 @@ static int SQLITE_TCLAPI DbMain( ** Provide a dummy Tcl_InitStubs if we are using this as a static ** library. */ @@ -26220,57 +39169,35 @@ #endif /* -@@ -3127,9 +3159,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. +@@ -3478,7 +3537,10 @@ static int SQLITE_TCLAPI DbMain( + ** The EXTERN 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) ? TCL_OK : TCL_ERROR; + EXTERN int Sqlite3_Init(Tcl_Interp *interp){ +- int rc = Tcl_InitStubs(interp, "8.4", 0) ? TCL_OK : TCL_ERROR; ++ int rc = Tcl_InitStubs(interp, "8.5-", 0) ? TCL_OK : TCL_ERROR; ++ if( rc!=TCL_OK ){ ++ rc = Tcl_InitStubs(interp, "8.4", 0) ? TCL_OK : TCL_ERROR; ++ } if( rc==TCL_OK ){ Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0); -@@ -3143,9 +3175,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 -@@ -3471,7 +3503,7 @@ static int md5_cmd(void*cd, Tcl_Interp * - return TCL_ERROR; - } - MD5Init(&ctx); -- MD5Update(&ctx, (unsigned char*)argv[1], (unsigned)strlen(argv[1])); -+ MD5Update(&ctx, (unsigned char*)argv[1], (unsigned)strlen30(argv[1])); - MD5Final(digest, &ctx); - converter = (void(*)(unsigned char*,char*))cd; - converter(digest, zBuf); -@@ -3484,7 +3516,7 @@ static int md5_cmd(void*cd, Tcl_Interp * - ** name of the file. - */ - static int md5file_cmd(void*cd, Tcl_Interp*interp, int argc, const char **argv){ + #ifndef SQLITE_3_SUFFIX_ONLY +@@ -3846,7 +3908,7 @@ static int SQLITE_TCLAPI md5file_cmd( + int argc, + const char **argv + ){ - FILE *in; + Tcl_Channel in; MD5Context ctx; void (*converter)(unsigned char*, char*); unsigned char digest[16]; -@@ -3495,20 +3527,18 @@ static int md5file_cmd(void*cd, Tcl_Inte +@@ -3857,20 +3919,18 @@ static int SQLITE_TCLAPI md5file_cmd( " FILENAME\"", (char*)0); return TCL_ERROR; } - in = fopen(argv[1],"rb"); + in = Tcl_OpenFileChannel(interp,argv[1],"rb",0666); if( in==0 ){ -- Tcl_AppendResult(interp,"unable to open file \"", argv[1], +- Tcl_AppendResult(interp,"unable to open file \"", argv[1], - "\" for reading", (char*)0); return TCL_ERROR; } @@ -26287,52 +39214,25 @@ MD5Final(digest, &ctx); converter = (void(*)(unsigned char*,char*))cd; converter(digest, zBuf); -@@ -3550,7 +3580,7 @@ static void md5step(sqlite3_context *con +@@ -3912,7 +3972,7 @@ static void md5step(sqlite3_context *con for(i=0; imxPathname; + return sqlite3_vfs_register(&vlog_vfs.base, 1); +} ---- origsrc/sqlite-autoconf-3100000/vtshim.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/vtshim.c 2016-01-06 16:30:42.521122400 +0100 -@@ -0,0 +1,561 @@ +--- origsrc/sqlite-autoconf-3180000/vfsstat.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/vfsstat.c 2017-04-19 16:20:02.210959700 +0200 +@@ -0,0 +1,833 @@ ++/* ++** 2016-05-27 ++** ++** 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 file contains the implementation of an SQLite vfs shim that ++** tracks I/O. Access to the accumulated status counts is provided using ++** an eponymous virtual table. ++*/ ++#include ++SQLITE_EXTENSION_INIT1 ++ ++/* ++** This module contains code for a wrapper VFS that cause stats for ++** most VFS calls to be recorded. ++** ++** To use this module, first compile it as a loadable extension. See ++** https://www.sqlite.org/loadext.html#build for compilations instructions. ++** ++** After compliing, load this extension, then open database connections to be ++** measured. Query usages status using the vfsstat virtual table: ++** ++** SELECT * FROM vfsstat; ++** ++** Reset counters using UPDATE statements against vfsstat: ++** ++** UPDATE vfsstat SET count=0; ++** ++** EXAMPLE SCRIPT: ++** ++** .load ./vfsstat ++** .open test.db ++** DROP TABLE IF EXISTS t1; ++** CREATE TABLE t1(x,y); ++** INSERT INTO t1 VALUES(123, randomblob(5000)); ++** CREATE INDEX t1x ON t1(x); ++** DROP TABLE t1; ++** VACUUM; ++** SELECT * FROM vfsstat WHERE count>0; ++** ++** LIMITATIONS: ++** ++** This module increments counters without using mutex protection. So if ++** two or more threads try to use this module at the same time, race conditions ++** may occur which mess up the counts. This is harmless, other than giving ++** incorrect statistics. ++*/ ++#include ++#include ++#include ++ ++/* ++** File types ++*/ ++#define VFSSTAT_MAIN 0 /* Main database file */ ++#define VFSSTAT_JOURNAL 1 /* Rollback journal */ ++#define VFSSTAT_WAL 2 /* Write-ahead log file */ ++#define VFSSTAT_MASTERJRNL 3 /* Master journal */ ++#define VFSSTAT_SUBJRNL 4 /* Subjournal */ ++#define VFSSTAT_TEMPDB 5 /* TEMP database */ ++#define VFSSTAT_TEMPJRNL 6 /* Journal for TEMP database */ ++#define VFSSTAT_TRANSIENT 7 /* Transient database */ ++#define VFSSTAT_ANY 8 /* Unspecified file type */ ++#define VFSSTAT_nFile 9 /* This many file types */ ++ ++/* Names of the file types. These are allowed values for the ++** first column of the vfsstat virtual table. ++*/ ++static const char *azFile[] = { ++ "database", "journal", "wal", "master-journal", "sub-journal", ++ "temp-database", "temp-journal", "transient-db", "*" ++}; ++ ++/* ++** Stat types ++*/ ++#define VFSSTAT_BYTESIN 0 /* Bytes read in */ ++#define VFSSTAT_BYTESOUT 1 /* Bytes written out */ ++#define VFSSTAT_READ 2 /* Read requests */ ++#define VFSSTAT_WRITE 3 /* Write requests */ ++#define VFSSTAT_SYNC 4 /* Syncs */ ++#define VFSSTAT_OPEN 5 /* File opens */ ++#define VFSSTAT_LOCK 6 /* Lock requests */ ++#define VFSSTAT_ACCESS 0 /* xAccess calls. filetype==ANY only */ ++#define VFSSTAT_DELETE 1 /* xDelete calls. filetype==ANY only */ ++#define VFSSTAT_FULLPATH 2 /* xFullPathname calls. ANY only */ ++#define VFSSTAT_RANDOM 3 /* xRandomness calls. ANY only */ ++#define VFSSTAT_SLEEP 4 /* xSleep calls. ANY only */ ++#define VFSSTAT_CURTIME 5 /* xCurrentTime calls. ANY only */ ++#define VFSSTAT_nStat 7 /* This many stat types */ ++ ++ ++/* Names for the second column of the vfsstat virtual table for all ++** cases except when the first column is "*" or VFSSTAT_ANY. */ ++static const char *azStat[] = { ++ "bytes-in", "bytes-out", "read", "write", "sync", "open", "lock", ++}; ++static const char *azStatAny[] = { ++ "access", "delete", "fullpathname", "randomness", "sleep", "currenttimestamp", ++ "not-used" ++}; ++ ++/* Total number of counters */ ++#define VFSSTAT_MXCNT (VFSSTAT_nStat*VFSSTAT_nFile) ++ ++/* ++** Performance stats are collected in an instance of the following ++** global array. ++*/ ++static sqlite3_uint64 aVfsCnt[VFSSTAT_MXCNT]; ++ ++/* ++** Access to a specific counter ++*/ ++#define STATCNT(filetype,stat) (aVfsCnt[(filetype)*VFSSTAT_nStat+(stat)]) ++ ++/* ++** Forward declaration of objects used by this utility ++*/ ++typedef struct VStatVfs VStatVfs; ++typedef struct VStatFile VStatFile; ++ ++/* An instance of the VFS */ ++struct VStatVfs { ++ sqlite3_vfs base; /* VFS methods */ ++ sqlite3_vfs *pVfs; /* Parent VFS */ ++}; ++ ++/* An open file */ ++struct VStatFile { ++ sqlite3_file base; /* IO methods */ ++ sqlite3_file *pReal; /* Underlying file handle */ ++ unsigned char eFiletype; /* What type of file is this */ ++}; ++ ++#define REALVFS(p) (((VStatVfs*)(p))->pVfs) ++ ++/* ++** Methods for VStatFile ++*/ ++static int vstatClose(sqlite3_file*); ++static int vstatRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); ++static int vstatWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst); ++static int vstatTruncate(sqlite3_file*, sqlite3_int64 size); ++static int vstatSync(sqlite3_file*, int flags); ++static int vstatFileSize(sqlite3_file*, sqlite3_int64 *pSize); ++static int vstatLock(sqlite3_file*, int); ++static int vstatUnlock(sqlite3_file*, int); ++static int vstatCheckReservedLock(sqlite3_file*, int *pResOut); ++static int vstatFileControl(sqlite3_file*, int op, void *pArg); ++static int vstatSectorSize(sqlite3_file*); ++static int vstatDeviceCharacteristics(sqlite3_file*); ++static int vstatShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**); ++static int vstatShmLock(sqlite3_file*, int offset, int n, int flags); ++static void vstatShmBarrier(sqlite3_file*); ++static int vstatShmUnmap(sqlite3_file*, int deleteFlag); ++static int vstatFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); ++static int vstatUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p); ++ ++/* ++** Methods for VStatVfs ++*/ ++static int vstatOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *); ++static int vstatDelete(sqlite3_vfs*, const char *zName, int syncDir); ++static int vstatAccess(sqlite3_vfs*, const char *zName, int flags, int *); ++static int vstatFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut); ++static void *vstatDlOpen(sqlite3_vfs*, const char *zFilename); ++static void vstatDlError(sqlite3_vfs*, int nByte, char *zErrMsg); ++static void (*vstatDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void); ++static void vstatDlClose(sqlite3_vfs*, void*); ++static int vstatRandomness(sqlite3_vfs*, int nByte, char *zOut); ++static int vstatSleep(sqlite3_vfs*, int microseconds); ++static int vstatCurrentTime(sqlite3_vfs*, double*); ++static int vstatGetLastError(sqlite3_vfs*, int, char *); ++static int vstatCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); ++ ++static VStatVfs vstat_vfs = { ++ { ++ 2, /* iVersion */ ++ 0, /* szOsFile (set by register_vstat()) */ ++ 1024, /* mxPathname */ ++ 0, /* pNext */ ++ "vfslog", /* zName */ ++ 0, /* pAppData */ ++ vstatOpen, /* xOpen */ ++ vstatDelete, /* xDelete */ ++ vstatAccess, /* xAccess */ ++ vstatFullPathname, /* xFullPathname */ ++ vstatDlOpen, /* xDlOpen */ ++ vstatDlError, /* xDlError */ ++ vstatDlSym, /* xDlSym */ ++ vstatDlClose, /* xDlClose */ ++ vstatRandomness, /* xRandomness */ ++ vstatSleep, /* xSleep */ ++ vstatCurrentTime, /* xCurrentTime */ ++ vstatGetLastError, /* xGetLastError */ ++ vstatCurrentTimeInt64 /* xCurrentTimeInt64 */ ++ }, ++ 0 ++}; ++ ++static const sqlite3_io_methods vstat_io_methods = { ++ 3, /* iVersion */ ++ vstatClose, /* xClose */ ++ vstatRead, /* xRead */ ++ vstatWrite, /* xWrite */ ++ vstatTruncate, /* xTruncate */ ++ vstatSync, /* xSync */ ++ vstatFileSize, /* xFileSize */ ++ vstatLock, /* xLock */ ++ vstatUnlock, /* xUnlock */ ++ vstatCheckReservedLock, /* xCheckReservedLock */ ++ vstatFileControl, /* xFileControl */ ++ vstatSectorSize, /* xSectorSize */ ++ vstatDeviceCharacteristics, /* xDeviceCharacteristics */ ++ vstatShmMap, /* xShmMap */ ++ vstatShmLock, /* xShmLock */ ++ vstatShmBarrier, /* xShmBarrier */ ++ vstatShmUnmap, /* xShmUnmap */ ++ vstatFetch, /* xFetch */ ++ vstatUnfetch /* xUnfetch */ ++}; ++ ++ ++ ++/* ++** Close an vstat-file. ++*/ ++static int vstatClose(sqlite3_file *pFile){ ++ VStatFile *p = (VStatFile *)pFile; ++ int rc = SQLITE_OK; ++ ++ if( p->pReal->pMethods ){ ++ rc = p->pReal->pMethods->xClose(p->pReal); ++ } ++ return rc; ++} ++ ++ ++/* ++** Read data from an vstat-file. ++*/ ++static int vstatRead( ++ sqlite3_file *pFile, ++ void *zBuf, ++ int iAmt, ++ sqlite_int64 iOfst ++){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ ++ rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst); ++ STATCNT(p->eFiletype,VFSSTAT_READ)++; ++ if( rc==SQLITE_OK ){ ++ STATCNT(p->eFiletype,VFSSTAT_BYTESIN) += iAmt; ++ } ++ return rc; ++} ++ ++/* ++** Write data to an vstat-file. ++*/ ++static int vstatWrite( ++ sqlite3_file *pFile, ++ const void *z, ++ int iAmt, ++ sqlite_int64 iOfst ++){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ ++ rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst); ++ STATCNT(p->eFiletype,VFSSTAT_WRITE)++; ++ if( rc==SQLITE_OK ){ ++ STATCNT(p->eFiletype,VFSSTAT_BYTESOUT) += iAmt; ++ } ++ return rc; ++} ++ ++/* ++** Truncate an vstat-file. ++*/ ++static int vstatTruncate(sqlite3_file *pFile, sqlite_int64 size){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xTruncate(p->pReal, size); ++ return rc; ++} ++ ++/* ++** Sync an vstat-file. ++*/ ++static int vstatSync(sqlite3_file *pFile, int flags){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xSync(p->pReal, flags); ++ STATCNT(p->eFiletype,VFSSTAT_SYNC)++; ++ return rc; ++} ++ ++/* ++** Return the current file-size of an vstat-file. ++*/ ++static int vstatFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xFileSize(p->pReal, pSize); ++ return rc; ++} ++ ++/* ++** Lock an vstat-file. ++*/ ++static int vstatLock(sqlite3_file *pFile, int eLock){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xLock(p->pReal, eLock); ++ STATCNT(p->eFiletype,VFSSTAT_LOCK)++; ++ return rc; ++} ++ ++/* ++** Unlock an vstat-file. ++*/ ++static int vstatUnlock(sqlite3_file *pFile, int eLock){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xUnlock(p->pReal, eLock); ++ STATCNT(p->eFiletype,VFSSTAT_LOCK)++; ++ return rc; ++} ++ ++/* ++** Check if another file-handle holds a RESERVED lock on an vstat-file. ++*/ ++static int vstatCheckReservedLock(sqlite3_file *pFile, int *pResOut){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut); ++ STATCNT(p->eFiletype,VFSSTAT_LOCK)++; ++ return rc; ++} ++ ++/* ++** File control method. For custom operations on an vstat-file. ++*/ ++static int vstatFileControl(sqlite3_file *pFile, int op, void *pArg){ ++ VStatFile *p = (VStatFile *)pFile; ++ int rc; ++ rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg); ++ if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){ ++ *(char**)pArg = sqlite3_mprintf("vstat/%z", *(char**)pArg); ++ } ++ return rc; ++} ++ ++/* ++** Return the sector-size in bytes for an vstat-file. ++*/ ++static int vstatSectorSize(sqlite3_file *pFile){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xSectorSize(p->pReal); ++ return rc; ++} ++ ++/* ++** Return the device characteristic flags supported by an vstat-file. ++*/ ++static int vstatDeviceCharacteristics(sqlite3_file *pFile){ ++ int rc; ++ VStatFile *p = (VStatFile *)pFile; ++ rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal); ++ return rc; ++} ++ ++/* Create a shared memory file mapping */ ++static int vstatShmMap( ++ sqlite3_file *pFile, ++ int iPg, ++ int pgsz, ++ int bExtend, ++ void volatile **pp ++){ ++ VStatFile *p = (VStatFile *)pFile; ++ return p->pReal->pMethods->xShmMap(p->pReal, iPg, pgsz, bExtend, pp); ++} ++ ++/* Perform locking on a shared-memory segment */ ++static int vstatShmLock(sqlite3_file *pFile, int offset, int n, int flags){ ++ VStatFile *p = (VStatFile *)pFile; ++ return p->pReal->pMethods->xShmLock(p->pReal, offset, n, flags); ++} ++ ++/* Memory barrier operation on shared memory */ ++static void vstatShmBarrier(sqlite3_file *pFile){ ++ VStatFile *p = (VStatFile *)pFile; ++ p->pReal->pMethods->xShmBarrier(p->pReal); ++} ++ ++/* Unmap a shared memory segment */ ++static int vstatShmUnmap(sqlite3_file *pFile, int deleteFlag){ ++ VStatFile *p = (VStatFile *)pFile; ++ return p->pReal->pMethods->xShmUnmap(p->pReal, deleteFlag); ++} ++ ++/* Fetch a page of a memory-mapped file */ ++static int vstatFetch( ++ sqlite3_file *pFile, ++ sqlite3_int64 iOfst, ++ int iAmt, ++ void **pp ++){ ++ VStatFile *p = (VStatFile *)pFile; ++ return p->pReal->pMethods->xFetch(p->pReal, iOfst, iAmt, pp); ++} ++ ++/* Release a memory-mapped page */ ++static int vstatUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ ++ VStatFile *p = (VStatFile *)pFile; ++ return p->pReal->pMethods->xUnfetch(p->pReal, iOfst, pPage); ++} ++ ++/* ++** Open an vstat file handle. ++*/ ++static int vstatOpen( ++ sqlite3_vfs *pVfs, ++ const char *zName, ++ sqlite3_file *pFile, ++ int flags, ++ int *pOutFlags ++){ ++ int rc; ++ VStatFile *p = (VStatFile*)pFile; ++ ++ p->pReal = (sqlite3_file*)&p[1]; ++ rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags); ++ if( flags & SQLITE_OPEN_MAIN_DB ){ ++ p->eFiletype = VFSSTAT_MAIN; ++ }else if( flags & SQLITE_OPEN_MAIN_JOURNAL ){ ++ p->eFiletype = VFSSTAT_JOURNAL; ++ }else if( flags & SQLITE_OPEN_WAL ){ ++ p->eFiletype = VFSSTAT_WAL; ++ }else if( flags & SQLITE_OPEN_MASTER_JOURNAL ){ ++ p->eFiletype = VFSSTAT_MASTERJRNL; ++ }else if( flags & SQLITE_OPEN_SUBJOURNAL ){ ++ p->eFiletype = VFSSTAT_SUBJRNL; ++ }else if( flags & SQLITE_OPEN_TEMP_DB ){ ++ p->eFiletype = VFSSTAT_TEMPDB; ++ }else if( flags & SQLITE_OPEN_TEMP_JOURNAL ){ ++ p->eFiletype = VFSSTAT_TEMPJRNL; ++ }else{ ++ p->eFiletype = VFSSTAT_TRANSIENT; ++ } ++ STATCNT(p->eFiletype,VFSSTAT_OPEN)++; ++ pFile->pMethods = rc ? 0 : &vstat_io_methods; ++ return rc; ++} ++ ++/* ++** Delete the file located at zPath. If the dirSync argument is true, ++** ensure the file-system modifications are synced to disk before ++** returning. ++*/ ++static int vstatDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ ++ int rc; ++ rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync); ++ STATCNT(VFSSTAT_ANY,VFSSTAT_DELETE)++; ++ return rc; ++} ++ ++/* ++** Test for access permissions. Return true if the requested permission ++** is available, or false otherwise. ++*/ ++static int vstatAccess( ++ sqlite3_vfs *pVfs, ++ const char *zPath, ++ int flags, ++ int *pResOut ++){ ++ int rc; ++ rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut); ++ STATCNT(VFSSTAT_ANY,VFSSTAT_ACCESS)++; ++ return rc; ++} ++ ++/* ++** Populate buffer zOut with the full canonical pathname corresponding ++** to the pathname in zPath. zOut is guaranteed to point to a buffer ++** of at least (INST_MAX_PATHNAME+1) bytes. ++*/ ++static int vstatFullPathname( ++ sqlite3_vfs *pVfs, ++ const char *zPath, ++ int nOut, ++ char *zOut ++){ ++ STATCNT(VFSSTAT_ANY,VFSSTAT_FULLPATH)++; ++ return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut); ++} ++ ++/* ++** Open the dynamic library located at zPath and return a handle. ++*/ ++static void *vstatDlOpen(sqlite3_vfs *pVfs, const char *zPath){ ++ return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath); ++} ++ ++/* ++** Populate the buffer zErrMsg (size nByte bytes) with a human readable ++** utf-8 string describing the most recent error encountered associated ++** with dynamic libraries. ++*/ ++static void vstatDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){ ++ REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg); ++} ++ ++/* ++** Return a pointer to the symbol zSymbol in the dynamic library pHandle. ++*/ ++static void (*vstatDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){ ++ return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym); ++} ++ ++/* ++** Close the dynamic library handle pHandle. ++*/ ++static void vstatDlClose(sqlite3_vfs *pVfs, void *pHandle){ ++ REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle); ++} ++ ++/* ++** Populate the buffer pointed to by zBufOut with nByte bytes of ++** random data. ++*/ ++static int vstatRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ ++ STATCNT(VFSSTAT_ANY,VFSSTAT_RANDOM)++; ++ return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut); ++} ++ ++/* ++** Sleep for nMicro microseconds. Return the number of microseconds ++** actually slept. ++*/ ++static int vstatSleep(sqlite3_vfs *pVfs, int nMicro){ ++ STATCNT(VFSSTAT_ANY,VFSSTAT_SLEEP)++; ++ return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro); ++} ++ ++/* ++** Return the current time as a Julian Day number in *pTimeOut. ++*/ ++static int vstatCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ ++ STATCNT(VFSSTAT_ANY,VFSSTAT_CURTIME)++; ++ return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut); ++} ++ ++static int vstatGetLastError(sqlite3_vfs *pVfs, int a, char *b){ ++ return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b); ++} ++static int vstatCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){ ++ STATCNT(VFSSTAT_ANY,VFSSTAT_CURTIME)++; ++ return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p); ++} ++ ++/* ++** A virtual table for accessing the stats collected by this VFS shim ++*/ ++static int vstattabConnect(sqlite3*, void*, int, const char*const*, ++ sqlite3_vtab**,char**); ++static int vstattabBestIndex(sqlite3_vtab*,sqlite3_index_info*); ++static int vstattabDisconnect(sqlite3_vtab*); ++static int vstattabOpen(sqlite3_vtab*, sqlite3_vtab_cursor**); ++static int vstattabClose(sqlite3_vtab_cursor*); ++static int vstattabFilter(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, ++ int argc, sqlite3_value **argv); ++static int vstattabNext(sqlite3_vtab_cursor*); ++static int vstattabEof(sqlite3_vtab_cursor*); ++static int vstattabColumn(sqlite3_vtab_cursor*,sqlite3_context*,int); ++static int vstattabRowid(sqlite3_vtab_cursor*,sqlite3_int64*); ++static int vstattabUpdate(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*); ++ ++/* A cursor for the vfsstat virtual table */ ++typedef struct VfsStatCursor { ++ sqlite3_vtab_cursor base; /* Base class. Must be first */ ++ int i; /* Pointing to this aVfsCnt[] value */ ++} VfsStatCursor; ++ ++ ++static int vstattabConnect( ++ sqlite3 *db, ++ void *pAux, ++ int argc, const char *const*argv, ++ sqlite3_vtab **ppVtab, ++ char **pzErr ++){ ++ sqlite3_vtab *pNew; ++ int rc; ++ ++/* Column numbers */ ++#define VSTAT_COLUMN_FILE 0 ++#define VSTAT_COLUMN_STAT 1 ++#define VSTAT_COLUMN_COUNT 2 ++ ++ rc = sqlite3_declare_vtab(db,"CREATE TABLE x(file,stat,count)"); ++ if( rc==SQLITE_OK ){ ++ pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); ++ if( pNew==0 ) return SQLITE_NOMEM; ++ memset(pNew, 0, sizeof(*pNew)); ++ } ++ return rc; ++} ++ ++/* ++** This method is the destructor for vstat table object. ++*/ ++static int vstattabDisconnect(sqlite3_vtab *pVtab){ ++ sqlite3_free(pVtab); ++ return SQLITE_OK; ++} ++ ++/* ++** Constructor for a new vstat table cursor object. ++*/ ++static int vstattabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ ++ VfsStatCursor *pCur; ++ pCur = sqlite3_malloc( sizeof(*pCur) ); ++ if( pCur==0 ) return SQLITE_NOMEM; ++ memset(pCur, 0, sizeof(*pCur)); ++ *ppCursor = &pCur->base; ++ return SQLITE_OK; ++} ++ ++ ++/* ++** Destructor for a VfsStatCursor. ++*/ ++static int vstattabClose(sqlite3_vtab_cursor *cur){ ++ sqlite3_free(cur); ++ return SQLITE_OK; ++} ++ ++ ++/* ++** Advance a VfsStatCursor to its next row of output. ++*/ ++static int vstattabNext(sqlite3_vtab_cursor *cur){ ++ ((VfsStatCursor*)cur)->i++; ++ return SQLITE_OK; ++} ++ ++/* ++** Return values of columns for the row at which the VfsStatCursor ++** is currently pointing. ++*/ ++static int vstattabColumn( ++ sqlite3_vtab_cursor *cur, /* The cursor */ ++ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ ++ int i /* Which column to return */ ++){ ++ VfsStatCursor *pCur = (VfsStatCursor*)cur; ++ switch( i ){ ++ case VSTAT_COLUMN_FILE: { ++ sqlite3_result_text(ctx, azFile[pCur->i/VFSSTAT_nStat], -1, SQLITE_STATIC); ++ break; ++ } ++ case VSTAT_COLUMN_STAT: { ++ const char **az; ++ az = (pCur->i/VFSSTAT_nStat)==VFSSTAT_ANY ? azStatAny : azStat; ++ sqlite3_result_text(ctx, az[pCur->i%VFSSTAT_nStat], -1, SQLITE_STATIC); ++ break; ++ } ++ case VSTAT_COLUMN_COUNT: { ++ sqlite3_result_int64(ctx, aVfsCnt[pCur->i]); ++ break; ++ } ++ } ++ return SQLITE_OK; ++} ++ ++/* ++** Return the rowid for the current row. ++*/ ++static int vstattabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ ++ VfsStatCursor *pCur = (VfsStatCursor*)cur; ++ *pRowid = pCur->i; ++ return SQLITE_OK; ++} ++ ++/* ++** Return TRUE if the cursor has been moved off of the last ++** row of output. ++*/ ++static int vstattabEof(sqlite3_vtab_cursor *cur){ ++ VfsStatCursor *pCur = (VfsStatCursor*)cur; ++ return pCur->i >= VFSSTAT_MXCNT; ++} ++ ++/* ++** Only a full table scan is supported. So xFilter simply rewinds to ++** the beginning. ++*/ ++static int vstattabFilter( ++ sqlite3_vtab_cursor *pVtabCursor, ++ int idxNum, const char *idxStr, ++ int argc, sqlite3_value **argv ++){ ++ VfsStatCursor *pCur = (VfsStatCursor*)pVtabCursor; ++ pCur->i = 0; ++ return SQLITE_OK; ++} ++ ++/* ++** Only a forwards full table scan is supported. xBestIndex is a no-op. ++*/ ++static int vstattabBestIndex( ++ sqlite3_vtab *tab, ++ sqlite3_index_info *pIdxInfo ++){ ++ return SQLITE_OK; ++} ++ ++/* ++** Any VSTAT_COLUMN_COUNT can be changed to a positive integer. ++** No deletions or insertions are allowed. No changes to other ++** columns are allowed. ++*/ ++static int vstattabUpdate( ++ sqlite3_vtab *tab, ++ int argc, sqlite3_value **argv, ++ sqlite3_int64 *pRowid ++){ ++ sqlite3_int64 iRowid, x; ++ if( argc==1 ) return SQLITE_ERROR; ++ if( sqlite3_value_type(argv[0])!=SQLITE_INTEGER ) return SQLITE_ERROR; ++ iRowid = sqlite3_value_int64(argv[0]); ++ if( iRowid!=sqlite3_value_int64(argv[1]) ) return SQLITE_ERROR; ++ if( iRowid<0 || iRowid>=VFSSTAT_MXCNT ) return SQLITE_ERROR; ++ if( sqlite3_value_type(argv[VSTAT_COLUMN_COUNT+2])!=SQLITE_INTEGER ){ ++ return SQLITE_ERROR; ++ } ++ x = sqlite3_value_int64(argv[VSTAT_COLUMN_COUNT+2]); ++ if( x<0 ) return SQLITE_ERROR; ++ aVfsCnt[iRowid] = x; ++ return SQLITE_OK; ++} ++ ++static const sqlite3_module VfsStatModule = { ++ 0, /* iVersion */ ++ 0, /* xCreate */ ++ vstattabConnect, /* xConnect */ ++ vstattabBestIndex, /* xBestIndex */ ++ vstattabDisconnect, /* xDisconnect */ ++ 0, /* xDestroy */ ++ vstattabOpen, /* xOpen - open a cursor */ ++ vstattabClose, /* xClose - close a cursor */ ++ vstattabFilter, /* xFilter - configure scan constraints */ ++ vstattabNext, /* xNext - advance a cursor */ ++ vstattabEof, /* xEof - check for end of scan */ ++ vstattabColumn, /* xColumn - read data */ ++ vstattabRowid, /* xRowid - read data */ ++ vstattabUpdate, /* xUpdate */ ++ 0, /* xBegin */ ++ 0, /* xSync */ ++ 0, /* xCommit */ ++ 0, /* xRollback */ ++ 0, /* xFindMethod */ ++ 0, /* xRename */ ++}; ++ ++/* ++** This routine is an sqlite3_auto_extension() callback, invoked to register ++** the vfsstat virtual table for all new database connections. ++*/ ++static int vstatRegister( ++ sqlite3 *db, ++ const char **pzErrMsg, ++ const struct sqlite3_api_routines *pThunk ++){ ++ return sqlite3_create_module(db, "vfsstat", &VfsStatModule, 0); ++} ++ ++#ifdef _WIN32 ++__declspec(dllexport) ++#endif ++/* ++** This routine is called when the extension is loaded. ++** ++** Register the new VFS. Make arrangement to register the virtual table ++** for each new database connection. ++*/ ++int sqlite3_vfsstat_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ vstat_vfs.pVfs = sqlite3_vfs_find(0); ++ vstat_vfs.base.szOsFile = sizeof(VStatFile) + vstat_vfs.pVfs->szOsFile; ++ rc = sqlite3_vfs_register(&vstat_vfs.base, 1); ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_auto_extension((void(*)(void))vstatRegister); ++ } ++ if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY; ++ return rc; ++} ++#if !defined(_WIN32) && !defined(SQLITE_TEST) ++int sqlite3_extension_init( ++ sqlite3 *db, ++ char **pzErrMsg, ++ const sqlite3_api_routines *pApi ++){ ++ int rc = SQLITE_OK; ++ SQLITE_EXTENSION_INIT2(pApi); ++ vstat_vfs.pVfs = sqlite3_vfs_find(0); ++ vstat_vfs.base.szOsFile = sizeof(VStatFile) + vstat_vfs.pVfs->szOsFile; ++ rc = sqlite3_vfs_register(&vstat_vfs.base, 1); ++ if( rc==SQLITE_OK ){ ++ rc = sqlite3_auto_extension((void(*)(void))vstatRegister); ++ } ++ return rc; ++} ++#endif +--- origsrc/sqlite-autoconf-3180000/vtshim.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/vtshim.c 2017-04-19 16:20:02.221960800 +0200 +@@ -0,0 +1,563 @@ +/* +** 2013-06-12 +** @@ -27971,6 +41712,7 @@ + if( rc ){ + sqlite3_free(pNew); + *ppVtab = 0; ++ return rc; + } + pNew->pAux = pAux; + pNew->ppPrev = &pAux->pAllVtab; @@ -28009,6 +41751,7 @@ + if( rc ){ + sqlite3_free(pNew); + *ppVtab = 0; ++ return rc; + } + pNew->pAux = pAux; + pNew->ppPrev = &pAux->pAllVtab; @@ -28435,8 +42178,8 @@ + return SQLITE_OK; +} +#endif ---- origsrc/sqlite-autoconf-3100000/wholenumber.c 1970-01-01 01:00:00.000000000 +0100 -+++ src/sqlite-autoconf-3100000/wholenumber.c 2016-01-06 16:30:42.523122500 +0100 +--- origsrc/sqlite-autoconf-3180000/wholenumber.c 1970-01-01 01:00:00.000000000 +0100 ++++ src/sqlite-autoconf-3180000/wholenumber.c 2017-04-19 16:20:02.231961800 +0200 @@ -0,0 +1,288 @@ +/* +** 2011 April 02 diff --git a/sqlite/sqlite3-cygwin-msys.patch b/sqlite/sqlite3-cygwin-msys.patch deleted file mode 100644 index 8d468a9d..00000000 --- a/sqlite/sqlite3-cygwin-msys.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -Naur sqlite-autoconf-3100000-orig/sqlite3.c sqlite-autoconf-3100000/sqlite3.c ---- sqlite-autoconf-3100000-orig/sqlite3.c 2014-11-08 20:34:01.593800000 +0300 -+++ sqlite-autoconf-3100000/sqlite3.c 2014-11-08 20:37:42.146600000 +0300 -@@ -100964,7 +100964,9 @@ - sqlite3_free(zAltFile); - #if defined(_WIN32) || defined(__CYGWIN__) - if( handle==0 ){ --# if defined(__CYGWIN__) -+# if defined(__MSYS__) -+ zAltFile = sqlite3_mprintf("msys-sqlite3%s-0.%s", zFile, azEnding); -+# elif defined(__CYGWIN__) - zAltFile = sqlite3_mprintf("cygsqlite3%s-0.%s", zFile, azEnding); - # else /* how about Msys/Msys-2 ??? */ - zAltFile = sqlite3_mprintf("sqlite3%s.%s", zFile, azEnding);