sqlite3: import sqlite3 3.35.5

Merge commit '0511e356f5e2106928ee352ee974d1470c860a9a' into new_merge

Changes at https://www.sqlite.org/releaselog/3_35_5.html.

MFC after:      1 month
This commit is contained in:
Cy Schubert 2021-05-06 18:01:44 -07:00
commit ce9de47260
9 changed files with 7733 additions and 4882 deletions

View File

@ -303,6 +303,9 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
!ENDIF !ENDIF
# Always enable math functions on Windows
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MATH_FUNCTIONS
# Should the rbu extension be enabled? If so, add compilation options # Should the rbu extension be enabled? If so, add compilation options
# to enable it. # to enable it.
# #

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for sqlite 3.34.1. # Generated by GNU Autoconf 2.69 for sqlite 3.35.5.
# #
# Report bugs to <http://www.sqlite.org>. # Report bugs to <http://www.sqlite.org>.
# #
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='sqlite' PACKAGE_NAME='sqlite'
PACKAGE_TARNAME='sqlite' PACKAGE_TARNAME='sqlite'
PACKAGE_VERSION='3.34.1' PACKAGE_VERSION='3.35.5'
PACKAGE_STRING='sqlite 3.34.1' PACKAGE_STRING='sqlite 3.35.5'
PACKAGE_BUGREPORT='http://www.sqlite.org' PACKAGE_BUGREPORT='http://www.sqlite.org'
PACKAGE_URL='' PACKAGE_URL=''
@ -772,6 +772,7 @@ enable_editline
enable_readline enable_readline
enable_threadsafe enable_threadsafe
enable_dynamic_extensions enable_dynamic_extensions
enable_math
enable_fts4 enable_fts4
enable_fts3 enable_fts3
enable_fts5 enable_fts5
@ -1341,7 +1342,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures sqlite 3.34.1 to adapt to many kinds of systems. \`configure' configures sqlite 3.35.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1412,7 +1413,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of sqlite 3.34.1:";; short | recursive ) echo "Configuration of sqlite 3.35.5:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1437,6 +1438,7 @@ Optional Features:
--enable-threadsafe build a thread-safe library [default=yes] --enable-threadsafe build a thread-safe library [default=yes]
--enable-dynamic-extensions --enable-dynamic-extensions
support loadable extensions [default=yes] support loadable extensions [default=yes]
--enable-math SQL math functions [default=yes]
--enable-fts4 include fts4 support [default=yes] --enable-fts4 include fts4 support [default=yes]
--enable-fts3 include fts3 support [default=no] --enable-fts3 include fts3 support [default=no]
--enable-fts5 include fts5 support [default=yes] --enable-fts5 include fts5 support [default=yes]
@ -1537,7 +1539,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
sqlite configure 3.34.1 sqlite configure 3.35.5
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1952,7 +1954,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by sqlite $as_me 3.34.1, which was It was created by sqlite $as_me 3.35.5, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2818,7 +2820,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='sqlite' PACKAGE='sqlite'
VERSION='3.34.1' VERSION='3.35.5'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -13335,7 +13337,9 @@ else
enable_threadsafe=yes enable_threadsafe=yes
fi fi
if test x"$enable_threadsafe" != "xno"; then if test x"$enable_threadsafe" == "xno"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_THREADSAFE=0"
else
BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1" BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5
$as_echo_n "checking for library containing pthread_create... " >&6; } $as_echo_n "checking for library containing pthread_create... " >&6; }
@ -13528,6 +13532,84 @@ $as_echo_n "checking for whether to support dynamic extensions... " >&6; }
$as_echo "$enable_dynamic_extensions" >&6; } $as_echo "$enable_dynamic_extensions" >&6; }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# --enable-math
#
# Check whether --enable-math was given.
if test "${enable_math+set}" = set; then :
enableval=$enable_math;
else
enable_math=yes
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SQL math functions" >&5
$as_echo_n "checking SQL math functions... " >&6; }
if test x"$enable_math" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_MATH_FUNCTIONS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ceil" >&5
$as_echo_n "checking for library containing ceil... " >&6; }
if ${ac_cv_search_ceil+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char ceil ();
int
main ()
{
return ceil ();
;
return 0;
}
_ACEOF
for ac_lib in '' m; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_ceil=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_ceil+:} false; then :
break
fi
done
if ${ac_cv_search_ceil+:} false; then :
else
ac_cv_search_ceil=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ceil" >&5
$as_echo "$ac_cv_search_ceil" >&6; }
ac_res=$ac_cv_search_ceil
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi
#-----------------------------------------------------------------------
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# --enable-fts4 # --enable-fts4
# #
@ -13538,8 +13620,15 @@ else
enable_fts4=yes enable_fts4=yes
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking FTS4 extension" >&5
$as_echo_n "checking FTS4 extension... " >&6; }
if test x"$enable_fts4" = "xyes"; then if test x"$enable_fts4" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -13551,8 +13640,15 @@ if test "${enable_fts3+set}" = set; then :
enableval=$enable_fts3; enableval=$enable_fts3;
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking FTS3 extension" >&5
$as_echo_n "checking FTS3 extension... " >&6; }
if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -13566,7 +13662,11 @@ else
enable_fts5=yes enable_fts5=yes
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking FTS5 extension" >&5
$as_echo_n "checking FTS5 extension... " >&6; }
if test x"$enable_fts5" = "xyes"; then if test x"$enable_fts5" = "xyes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing log" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing log" >&5
$as_echo_n "checking for library containing log... " >&6; } $as_echo_n "checking for library containing log... " >&6; }
if ${ac_cv_search_log+:} false; then : if ${ac_cv_search_log+:} false; then :
@ -13624,6 +13724,9 @@ if test "$ac_res" != no; then :
fi fi
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -13637,8 +13740,15 @@ else
enable_json1=yes enable_json1=yes
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking JSON functions" >&5
$as_echo_n "checking JSON functions... " >&6; }
if test x"$enable_json1" = "xyes"; then if test x"$enable_json1" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_JSON1" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_JSON1"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -13652,8 +13762,15 @@ else
enable_rtree=yes enable_rtree=yes
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking RTREE extension" >&5
$as_echo_n "checking RTREE extension... " >&6; }
if test x"$enable_rtree" = "xyes"; then if test x"$enable_rtree" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -13665,8 +13782,15 @@ if test "${enable_session+set}" = set; then :
enableval=$enable_session; enableval=$enable_session;
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Session extension" >&5
$as_echo_n "checking Session extension... " >&6; }
if test x"$enable_session" = "xyes"; then if test x"$enable_session" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
$as_echo "enabled" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
$as_echo "disabled" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -13678,9 +13802,16 @@ if test "${enable_debug+set}" = set; then :
enableval=$enable_debug; enableval=$enable_debug;
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Build type" >&5
$as_echo_n "checking Build type... " >&6; }
if test x"$enable_debug" = "xyes"; then if test x"$enable_debug" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE"
CFLAGS="-g -O0" CFLAGS="-g -O0"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: debug" >&5
$as_echo "debug" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: release" >&5
$as_echo "release" >&6; }
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -14438,7 +14569,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by sqlite $as_me 3.34.1, which was This file was extended by sqlite $as_me 3.35.5, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -14495,7 +14626,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
sqlite config.status 3.34.1 sqlite config.status 3.35.5
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -10,7 +10,7 @@
# #
AC_PREREQ(2.61) AC_PREREQ(2.61)
AC_INIT(sqlite, 3.34.1, http://www.sqlite.org) AC_INIT(sqlite, 3.35.5, http://www.sqlite.org)
AC_CONFIG_SRCDIR([sqlite3.c]) AC_CONFIG_SRCDIR([sqlite3.c])
AC_CONFIG_AUX_DIR([.]) AC_CONFIG_AUX_DIR([.])
@ -87,7 +87,9 @@ AC_SUBST(READLINE_LIBS)
AC_ARG_ENABLE(threadsafe, [AS_HELP_STRING( 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]) [], [enable_threadsafe=yes])
if test x"$enable_threadsafe" != "xno"; then if test x"$enable_threadsafe" == "xno"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_THREADSAFE=0"
else
BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1" BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1"
AC_SEARCH_LIBS(pthread_create, pthread) AC_SEARCH_LIBS(pthread_create, pthread)
AC_SEARCH_LIBS(pthread_mutexattr_init, pthread) AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
@ -109,14 +111,34 @@ AC_MSG_CHECKING([for whether to support dynamic extensions])
AC_MSG_RESULT($enable_dynamic_extensions) AC_MSG_RESULT($enable_dynamic_extensions)
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# --enable-math
#
AC_ARG_ENABLE(math, [AS_HELP_STRING(
[--enable-math], [SQL math functions [default=yes]])],
[], [enable_math=yes])
AC_MSG_CHECKING([SQL math functions])
if test x"$enable_math" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_MATH_FUNCTIONS"
AC_MSG_RESULT([enabled])
AC_SEARCH_LIBS(ceil, m)
else
AC_MSG_RESULT([disabled])
fi
#-----------------------------------------------------------------------
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# --enable-fts4 # --enable-fts4
# #
AC_ARG_ENABLE(fts4, [AS_HELP_STRING( AC_ARG_ENABLE(fts4, [AS_HELP_STRING(
[--enable-fts4], [include fts4 support [default=yes]])], [--enable-fts4], [include fts4 support [default=yes]])],
[], [enable_fts4=yes]) [], [enable_fts4=yes])
AC_MSG_CHECKING([FTS4 extension])
if test x"$enable_fts4" = "xyes"; then if test x"$enable_fts4" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4"
AC_MSG_RESULT([enabled])
else
AC_MSG_RESULT([disabled])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -126,8 +148,12 @@ fi
AC_ARG_ENABLE(fts3, [AS_HELP_STRING( AC_ARG_ENABLE(fts3, [AS_HELP_STRING(
[--enable-fts3], [include fts3 support [default=no]])], [--enable-fts3], [include fts3 support [default=no]])],
[], []) [], [])
AC_MSG_CHECKING([FTS3 extension])
if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3"
AC_MSG_RESULT([enabled])
else
AC_MSG_RESULT([disabled])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -137,9 +163,13 @@ fi
AC_ARG_ENABLE(fts5, [AS_HELP_STRING( AC_ARG_ENABLE(fts5, [AS_HELP_STRING(
[--enable-fts5], [include fts5 support [default=yes]])], [--enable-fts5], [include fts5 support [default=yes]])],
[], [enable_fts5=yes]) [], [enable_fts5=yes])
AC_MSG_CHECKING([FTS5 extension])
if test x"$enable_fts5" = "xyes"; then if test x"$enable_fts5" = "xyes"; then
AC_MSG_RESULT([enabled])
AC_SEARCH_LIBS(log, m) AC_SEARCH_LIBS(log, m)
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5"
else
AC_MSG_RESULT([disabled])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -149,8 +179,12 @@ fi
AC_ARG_ENABLE(json1, [AS_HELP_STRING( AC_ARG_ENABLE(json1, [AS_HELP_STRING(
[--enable-json1], [include json1 support [default=yes]])], [--enable-json1], [include json1 support [default=yes]])],
[],[enable_json1=yes]) [],[enable_json1=yes])
AC_MSG_CHECKING([JSON functions])
if test x"$enable_json1" = "xyes"; then if test x"$enable_json1" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_JSON1" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_JSON1"
AC_MSG_RESULT([enabled])
else
AC_MSG_RESULT([disabled])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -160,8 +194,12 @@ fi
AC_ARG_ENABLE(rtree, [AS_HELP_STRING( AC_ARG_ENABLE(rtree, [AS_HELP_STRING(
[--enable-rtree], [include rtree support [default=yes]])], [--enable-rtree], [include rtree support [default=yes]])],
[], [enable_rtree=yes]) [], [enable_rtree=yes])
AC_MSG_CHECKING([RTREE extension])
if test x"$enable_rtree" = "xyes"; then if test x"$enable_rtree" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY"
AC_MSG_RESULT([enabled])
else
AC_MSG_RESULT([disabled])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -171,8 +209,12 @@ fi
AC_ARG_ENABLE(session, [AS_HELP_STRING( AC_ARG_ENABLE(session, [AS_HELP_STRING(
[--enable-session], [enable the session extension [default=no]])], [--enable-session], [enable the session extension [default=no]])],
[], []) [], [])
AC_MSG_CHECKING([Session extension])
if test x"$enable_session" = "xyes"; then if test x"$enable_session" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
AC_MSG_RESULT([enabled])
else
AC_MSG_RESULT([disabled])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -182,9 +224,13 @@ fi
AC_ARG_ENABLE(debug, [AS_HELP_STRING( AC_ARG_ENABLE(debug, [AS_HELP_STRING(
[--enable-debug], [build with debugging features enabled [default=no]])], [--enable-debug], [build with debugging features enabled [default=no]])],
[], []) [], [])
AC_MSG_CHECKING([Build type])
if test x"$enable_debug" = "xyes"; then if test x"$enable_debug" = "xyes"; then
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE" BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE"
CFLAGS="-g -O0" CFLAGS="-g -O0"
AC_MSG_RESULT([debug])
else
AC_MSG_RESULT([release])
fi fi
#----------------------------------------------------------------------- #-----------------------------------------------------------------------

View File

@ -1424,7 +1424,10 @@ SQLITE_EXTENSION_INIT1
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#ifndef SQLITE_AMALGAMATION
/* typedef sqlite3_uint64 u64; */ /* typedef sqlite3_uint64 u64; */
#endif /* SQLITE_AMALGAMATION */
/****************************************************************************** /******************************************************************************
** The Hash Engine ** The Hash Engine
@ -3637,24 +3640,23 @@ int sqlite3_completion_init(
** appended onto the end of some other file, such as an executable. ** appended onto the end of some other file, such as an executable.
** **
** A special record must appear at the end of the file that identifies the ** A special record must appear at the end of the file that identifies the
** file as an appended database and provides an offset to page 1. For ** file as an appended database and provides the offset to the first page
** best performance page 1 should be located at a disk page boundary, though ** of the exposed content. (Or, it is the length of the content prefix.)
** that is not required. ** For best performance page 1 should be located at a disk page boundary,
** though that is not required.
** **
** When opening a database using this VFS, the connection might treat ** When opening a database using this VFS, the connection might treat
** the file as an ordinary SQLite database, or it might treat is as a ** the file as an ordinary SQLite database, or it might treat it as a
** database appended onto some other file. Here are the rules: ** database appended onto some other file. The decision is made by
** applying the following rules in order:
** **
** (1) When opening a new empty file, that file is treated as an ordinary ** (1) An empty file is an ordinary database.
** database.
** **
** (2) When opening a file that begins with the standard SQLite prefix ** (2) If the file ends with the appendvfs trailer string
** string "SQLite format 3", that file is treated as an ordinary ** "Start-Of-SQLite3-NNNNNNNN" that file is an appended database.
** database.
** **
** (3) When opening a file that ends with the appendvfs trailer string ** (3) If the file begins with the standard SQLite prefix string
** "Start-Of-SQLite3-NNNNNNNN" that file is treated as an appended ** "SQLite format 3", that file is an ordinary database.
** database.
** **
** (4) If none of the above apply and the SQLITE_OPEN_CREATE flag is ** (4) If none of the above apply and the SQLITE_OPEN_CREATE flag is
** set, then a new database is appended to the already existing file. ** set, then a new database is appended to the already existing file.
@ -3662,13 +3664,13 @@ int sqlite3_completion_init(
** (5) Otherwise, SQLITE_CANTOPEN is returned. ** (5) Otherwise, SQLITE_CANTOPEN is returned.
** **
** To avoid unnecessary complications with the PENDING_BYTE, the size of ** To avoid unnecessary complications with the PENDING_BYTE, the size of
** the file containing the database is limited to 1GB. This VFS will refuse ** the file containing the database is limited to 1GiB. (1073741824 bytes)
** to read or write past the 1GB mark. This restriction might be lifted in ** This VFS will not read or write past the 1GiB mark. This restriction
** future versions. For now, if you need a large database, then keep the ** might be lifted in future versions. For now, if you need a larger
** database in a separate file. ** database, then keep it in a separate file.
** **
** If the file being opened is not an appended database, then this shim is ** If the file being opened is a plain database (not an appended one), then
** a pass-through into the default underlying VFS. ** this shim is a pass-through into the default underlying VFS. (rule 3)
**/ **/
/* #include "sqlite3ext.h" */ /* #include "sqlite3ext.h" */
SQLITE_EXTENSION_INIT1 SQLITE_EXTENSION_INIT1
@ -3681,17 +3683,27 @@ SQLITE_EXTENSION_INIT1
** 123456789 123456789 12345 ** 123456789 123456789 12345
** **
** The NNNNNNNN represents a 64-bit big-endian unsigned integer which is ** The NNNNNNNN represents a 64-bit big-endian unsigned integer which is
** the offset to page 1. ** the offset to page 1, and also the length of the prefix content.
*/ */
#define APND_MARK_PREFIX "Start-Of-SQLite3-" #define APND_MARK_PREFIX "Start-Of-SQLite3-"
#define APND_MARK_PREFIX_SZ 17 #define APND_MARK_PREFIX_SZ 17
#define APND_MARK_SIZE 25 #define APND_MARK_FOS_SZ 8
#define APND_MARK_SIZE (APND_MARK_PREFIX_SZ+APND_MARK_FOS_SZ)
/* /*
** Maximum size of the combined prefix + database + append-mark. This ** Maximum size of the combined prefix + database + append-mark. This
** must be less than 0x40000000 to avoid locking issues on Windows. ** must be less than 0x40000000 to avoid locking issues on Windows.
*/ */
#define APND_MAX_SIZE (65536*15259) #define APND_MAX_SIZE (0x40000000)
/*
** Try to align the database to an even multiple of APND_ROUNDUP bytes.
*/
#ifndef APND_ROUNDUP
#define APND_ROUNDUP 4096
#endif
#define APND_ALIGN_MASK ((sqlite3_int64)(APND_ROUNDUP-1))
#define APND_START_ROUNDUP(fsz) (((fsz)+APND_ALIGN_MASK) & ~APND_ALIGN_MASK)
/* /*
** Forward declaration of objects used by this utility ** Forward declaration of objects used by this utility
@ -3705,11 +3717,45 @@ typedef struct ApndFile ApndFile;
#define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData))
#define ORIGFILE(p) ((sqlite3_file*)(((ApndFile*)(p))+1)) #define ORIGFILE(p) ((sqlite3_file*)(((ApndFile*)(p))+1))
/* An open file */ /* An open appendvfs file
**
** An instance of this structure describes the appended database file.
** A separate sqlite3_file object is always appended. The appended
** sqlite3_file object (which can be accessed using ORIGFILE()) describes
** the entire file, including the prefix, the database, and the
** append-mark.
**
** The structure of an AppendVFS database is like this:
**
** +-------------+---------+----------+-------------+
** | prefix-file | padding | database | append-mark |
** +-------------+---------+----------+-------------+
** ^ ^
** | |
** iPgOne iMark
**
**
** "prefix file" - file onto which the database has been appended.
** "padding" - zero or more bytes inserted so that "database"
** starts on an APND_ROUNDUP boundary
** "database" - The SQLite database file
** "append-mark" - The 25-byte "Start-Of-SQLite3-NNNNNNNN" that indicates
** the offset from the start of prefix-file to the start
** of "database".
**
** The size of the database is iMark - iPgOne.
**
** The NNNNNNNN in the "Start-Of-SQLite3-NNNNNNNN" suffix is the value
** of iPgOne stored as a big-ending 64-bit integer.
**
** iMark will be the size of the underlying file minus 25 (APND_MARKSIZE).
** Or, iMark is -1 to indicate that it has not yet been written.
*/
struct ApndFile { struct ApndFile {
sqlite3_file base; /* IO methods */ sqlite3_file base; /* Subclass. MUST BE FIRST! */
sqlite3_int64 iPgOne; /* File offset to page 1 */ sqlite3_int64 iPgOne; /* Offset to the start of the database */
sqlite3_int64 iMark; /* Start of the append-mark */ sqlite3_int64 iMark; /* Offset of the append mark. -1 if unwritten */
/* Always followed by another sqlite3_file that describes the whole file */
}; };
/* /*
@ -3801,8 +3847,6 @@ static const sqlite3_io_methods apnd_io_methods = {
apndUnfetch /* xUnfetch */ apndUnfetch /* xUnfetch */
}; };
/* /*
** Close an apnd-file. ** Close an apnd-file.
*/ */
@ -3820,22 +3864,37 @@ static int apndRead(
int iAmt, int iAmt,
sqlite_int64 iOfst sqlite_int64 iOfst
){ ){
ApndFile *p = (ApndFile *)pFile; ApndFile *paf = (ApndFile *)pFile;
pFile = ORIGFILE(pFile); pFile = ORIGFILE(pFile);
return pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst+p->iPgOne); return pFile->pMethods->xRead(pFile, zBuf, iAmt, paf->iPgOne+iOfst);
} }
/* /*
** Add the append-mark onto the end of the file. ** Add the append-mark onto what should become the end of the file.
* If and only if this succeeds, internal ApndFile.iMark is updated.
* Parameter iWriteEnd is the appendvfs-relative offset of the new mark.
*/ */
static int apndWriteMark(ApndFile *p, sqlite3_file *pFile){ static int apndWriteMark(
int i; ApndFile *paf,
sqlite3_file *pFile,
sqlite_int64 iWriteEnd
){
sqlite_int64 iPgOne = paf->iPgOne;
unsigned char a[APND_MARK_SIZE]; unsigned char a[APND_MARK_SIZE];
int i = APND_MARK_FOS_SZ;
int rc;
assert(pFile == ORIGFILE(paf));
memcpy(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ); memcpy(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ);
for(i=0; i<8; i++){ while( --i >= 0 ){
a[APND_MARK_PREFIX_SZ+i] = (p->iPgOne >> (56 - i*8)) & 0xff; a[APND_MARK_PREFIX_SZ+i] = (unsigned char)(iPgOne & 0xff);
iPgOne >>= 8;
} }
return pFile->pMethods->xWrite(pFile, a, APND_MARK_SIZE, p->iMark); iWriteEnd += paf->iPgOne;
if( SQLITE_OK==(rc = pFile->pMethods->xWrite
(pFile, a, APND_MARK_SIZE, iWriteEnd)) ){
paf->iMark = iWriteEnd;
}
return rc;
} }
/* /*
@ -3847,38 +3906,28 @@ static int apndWrite(
int iAmt, int iAmt,
sqlite_int64 iOfst sqlite_int64 iOfst
){ ){
int rc; ApndFile *paf = (ApndFile *)pFile;
ApndFile *p = (ApndFile *)pFile; sqlite_int64 iWriteEnd = iOfst + iAmt;
if( iWriteEnd>=APND_MAX_SIZE ) return SQLITE_FULL;
pFile = ORIGFILE(pFile); pFile = ORIGFILE(pFile);
if( iOfst+iAmt>=APND_MAX_SIZE ) return SQLITE_FULL; /* If append-mark is absent or will be overwritten, write it. */
rc = pFile->pMethods->xWrite(pFile, zBuf, iAmt, iOfst+p->iPgOne); if( paf->iMark < 0 || paf->iPgOne + iWriteEnd > paf->iMark ){
if( rc==SQLITE_OK && iOfst + iAmt + p->iPgOne > p->iMark ){ int rc = apndWriteMark(paf, pFile, iWriteEnd);
sqlite3_int64 sz = 0; if( SQLITE_OK!=rc ) return rc;
rc = pFile->pMethods->xFileSize(pFile, &sz);
if( rc==SQLITE_OK ){
p->iMark = sz - APND_MARK_SIZE;
if( iOfst + iAmt + p->iPgOne > p->iMark ){
p->iMark = p->iPgOne + iOfst + iAmt;
rc = apndWriteMark(p, pFile);
}
}
} }
return rc; return pFile->pMethods->xWrite(pFile, zBuf, iAmt, paf->iPgOne+iOfst);
} }
/* /*
** Truncate an apnd-file. ** Truncate an apnd-file.
*/ */
static int apndTruncate(sqlite3_file *pFile, sqlite_int64 size){ static int apndTruncate(sqlite3_file *pFile, sqlite_int64 size){
int rc; ApndFile *paf = (ApndFile *)pFile;
ApndFile *p = (ApndFile *)pFile;
pFile = ORIGFILE(pFile); pFile = ORIGFILE(pFile);
rc = pFile->pMethods->xTruncate(pFile, size+p->iPgOne+APND_MARK_SIZE); /* The append mark goes out first so truncate failure does not lose it. */
if( rc==SQLITE_OK ){ if( SQLITE_OK!=apndWriteMark(paf, pFile, size) ) return SQLITE_IOERR;
p->iMark = p->iPgOne+size; /* Truncate underlying file just past append mark */
rc = apndWriteMark(p, pFile); return pFile->pMethods->xTruncate(pFile, paf->iMark+APND_MARK_SIZE);
}
return rc;
} }
/* /*
@ -3891,16 +3940,12 @@ static int apndSync(sqlite3_file *pFile, int flags){
/* /*
** Return the current file-size of an apnd-file. ** Return the current file-size of an apnd-file.
** If the append mark is not yet there, the file-size is 0.
*/ */
static int apndFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ static int apndFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
ApndFile *p = (ApndFile *)pFile; ApndFile *paf = (ApndFile *)pFile;
int rc; *pSize = ( paf->iMark >= 0 )? (paf->iMark - paf->iPgOne) : 0;
pFile = ORIGFILE(p); return SQLITE_OK;
rc = pFile->pMethods->xFileSize(pFile, pSize);
if( rc==SQLITE_OK && p->iPgOne ){
*pSize -= p->iPgOne + APND_MARK_SIZE;
}
return rc;
} }
/* /*
@ -3931,12 +3976,13 @@ static int apndCheckReservedLock(sqlite3_file *pFile, int *pResOut){
** File control method. For custom operations on an apnd-file. ** File control method. For custom operations on an apnd-file.
*/ */
static int apndFileControl(sqlite3_file *pFile, int op, void *pArg){ static int apndFileControl(sqlite3_file *pFile, int op, void *pArg){
ApndFile *p = (ApndFile *)pFile; ApndFile *paf = (ApndFile *)pFile;
int rc; int rc;
pFile = ORIGFILE(pFile); pFile = ORIGFILE(pFile);
if( op==SQLITE_FCNTL_SIZE_HINT ) *(sqlite3_int64*)pArg += paf->iPgOne;
rc = pFile->pMethods->xFileControl(pFile, op, pArg); rc = pFile->pMethods->xFileControl(pFile, op, pArg);
if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){ if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){
*(char**)pArg = sqlite3_mprintf("apnd(%lld)/%z", p->iPgOne, *(char**)pArg); *(char**)pArg = sqlite3_mprintf("apnd(%lld)/%z", paf->iPgOne,*(char**)pArg);
} }
return rc; return rc;
} }
@ -3995,6 +4041,9 @@ static int apndFetch(
void **pp void **pp
){ ){
ApndFile *p = (ApndFile *)pFile; ApndFile *p = (ApndFile *)pFile;
if( p->iMark < 0 || iOfst+iAmt > p->iMark ){
return SQLITE_IOERR; /* Cannot read what is not yet there. */
}
pFile = ORIGFILE(pFile); pFile = ORIGFILE(pFile);
return pFile->pMethods->xFetch(pFile, iOfst+p->iPgOne, iAmt, pp); return pFile->pMethods->xFetch(pFile, iOfst+p->iPgOne, iAmt, pp);
} }
@ -4006,95 +4055,153 @@ static int apndUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){
return pFile->pMethods->xUnfetch(pFile, iOfst+p->iPgOne, pPage); return pFile->pMethods->xUnfetch(pFile, iOfst+p->iPgOne, pPage);
} }
/*
** Check to see if the file is an ordinary SQLite database file.
*/
static int apndIsOrdinaryDatabaseFile(sqlite3_int64 sz, sqlite3_file *pFile){
int rc;
char zHdr[16];
static const char aSqliteHdr[] = "SQLite format 3";
if( sz<512 ) return 0;
rc = pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), 0);
if( rc ) return 0;
return memcmp(zHdr, aSqliteHdr, sizeof(zHdr))==0;
}
/* /*
** Try to read the append-mark off the end of a file. Return the ** Try to read the append-mark off the end of a file. Return the
** start of the appended database if the append-mark is present. If ** start of the appended database if the append-mark is present.
** there is no append-mark, return -1; ** If there is no valid append-mark, return -1;
**
** An append-mark is only valid if the NNNNNNNN start-of-database offset
** indicates that the appended database contains at least one page. The
** start-of-database value must be a multiple of 512.
*/ */
static sqlite3_int64 apndReadMark(sqlite3_int64 sz, sqlite3_file *pFile){ static sqlite3_int64 apndReadMark(sqlite3_int64 sz, sqlite3_file *pFile){
int rc, i; int rc, i;
sqlite3_int64 iMark; sqlite3_int64 iMark;
int msbs = 8 * (APND_MARK_FOS_SZ-1);
unsigned char a[APND_MARK_SIZE]; unsigned char a[APND_MARK_SIZE];
if( sz<=APND_MARK_SIZE ) return -1; if( APND_MARK_SIZE!=(sz & 0x1ff) ) return -1;
rc = pFile->pMethods->xRead(pFile, a, APND_MARK_SIZE, sz-APND_MARK_SIZE); rc = pFile->pMethods->xRead(pFile, a, APND_MARK_SIZE, sz-APND_MARK_SIZE);
if( rc ) return -1; if( rc ) return -1;
if( memcmp(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ)!=0 ) return -1; if( memcmp(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ)!=0 ) return -1;
iMark = ((sqlite3_int64)(a[APND_MARK_PREFIX_SZ]&0x7f))<<56; iMark = ((sqlite3_int64)(a[APND_MARK_PREFIX_SZ] & 0x7f)) << msbs;
for(i=1; i<8; i++){ for(i=1; i<8; i++){
iMark += (sqlite3_int64)a[APND_MARK_PREFIX_SZ+i]<<(56-8*i); msbs -= 8;
iMark |= (sqlite3_int64)a[APND_MARK_PREFIX_SZ+i]<<msbs;
} }
if( iMark > (sz - APND_MARK_SIZE - 512) ) return -1;
if( iMark & 0x1ff ) return -1;
return iMark; return iMark;
} }
static const char apvfsSqliteHdr[] = "SQLite format 3";
/*
** Check to see if the file is an appendvfs SQLite database file.
** Return true iff it is such. Parameter sz is the file's size.
*/
static int apndIsAppendvfsDatabase(sqlite3_int64 sz, sqlite3_file *pFile){
int rc;
char zHdr[16];
sqlite3_int64 iMark = apndReadMark(sz, pFile);
if( iMark>=0 ){
/* If file has the correct end-marker, the expected odd size, and the
** SQLite DB type marker where the end-marker puts it, then it
** is an appendvfs database.
*/
rc = pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), iMark);
if( SQLITE_OK==rc
&& memcmp(zHdr, apvfsSqliteHdr, sizeof(zHdr))==0
&& (sz & 0x1ff) == APND_MARK_SIZE
&& sz>=512+APND_MARK_SIZE
){
return 1; /* It's an appendvfs database */
}
}
return 0;
}
/*
** Check to see if the file is an ordinary SQLite database file.
** Return true iff so. Parameter sz is the file's size.
*/
static int apndIsOrdinaryDatabaseFile(sqlite3_int64 sz, sqlite3_file *pFile){
char zHdr[16];
if( apndIsAppendvfsDatabase(sz, pFile) /* rule 2 */
|| (sz & 0x1ff) != 0
|| SQLITE_OK!=pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), 0)
|| memcmp(zHdr, apvfsSqliteHdr, sizeof(zHdr))!=0
){
return 0;
}else{
return 1;
}
}
/* /*
** Open an apnd file handle. ** Open an apnd file handle.
*/ */
static int apndOpen( static int apndOpen(
sqlite3_vfs *pVfs, sqlite3_vfs *pApndVfs,
const char *zName, const char *zName,
sqlite3_file *pFile, sqlite3_file *pFile,
int flags, int flags,
int *pOutFlags int *pOutFlags
){ ){
ApndFile *p; ApndFile *pApndFile = (ApndFile*)pFile;
sqlite3_file *pSubFile; sqlite3_file *pBaseFile = ORIGFILE(pFile);
sqlite3_vfs *pSubVfs; sqlite3_vfs *pBaseVfs = ORIGVFS(pApndVfs);
int rc; int rc;
sqlite3_int64 sz; sqlite3_int64 sz = 0;
pSubVfs = ORIGVFS(pVfs);
if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){
return pSubVfs->xOpen(pSubVfs, zName, pFile, flags, pOutFlags); /* The appendvfs is not to be used for transient or temporary databases.
** Just use the base VFS open to initialize the given file object and
** open the underlying file. (Appendvfs is then unused for this file.)
*/
return pBaseVfs->xOpen(pBaseVfs, zName, pFile, flags, pOutFlags);
} }
p = (ApndFile*)pFile; memset(pApndFile, 0, sizeof(ApndFile));
memset(p, 0, sizeof(*p));
pSubFile = ORIGFILE(pFile);
pFile->pMethods = &apnd_io_methods; pFile->pMethods = &apnd_io_methods;
rc = pSubVfs->xOpen(pSubVfs, zName, pSubFile, flags, pOutFlags); pApndFile->iMark = -1; /* Append mark not yet written */
if( rc ) goto apnd_open_done;
rc = pSubFile->pMethods->xFileSize(pSubFile, &sz); rc = pBaseVfs->xOpen(pBaseVfs, zName, pBaseFile, flags, pOutFlags);
if( rc ){ if( rc==SQLITE_OK ){
pSubFile->pMethods->xClose(pSubFile); rc = pBaseFile->pMethods->xFileSize(pBaseFile, &sz);
goto apnd_open_done;
} }
if( apndIsOrdinaryDatabaseFile(sz, pSubFile) ){ if( rc ){
memmove(pFile, pSubFile, pSubVfs->szOsFile); pBaseFile->pMethods->xClose(pBaseFile);
pFile->pMethods = 0;
return rc;
}
if( apndIsOrdinaryDatabaseFile(sz, pBaseFile) ){
/* The file being opened appears to be just an ordinary DB. Copy
** the base dispatch-table so this instance mimics the base VFS.
*/
memmove(pApndFile, pBaseFile, pBaseVfs->szOsFile);
return SQLITE_OK; return SQLITE_OK;
} }
p->iMark = 0; pApndFile->iPgOne = apndReadMark(sz, pFile);
p->iPgOne = apndReadMark(sz, pFile); if( pApndFile->iPgOne>=0 ){
if( p->iPgOne>0 ){ pApndFile->iMark = sz - APND_MARK_SIZE; /* Append mark found */
return SQLITE_OK; return SQLITE_OK;
} }
if( (flags & SQLITE_OPEN_CREATE)==0 ){ if( (flags & SQLITE_OPEN_CREATE)==0 ){
pSubFile->pMethods->xClose(pSubFile); pBaseFile->pMethods->xClose(pBaseFile);
rc = SQLITE_CANTOPEN; rc = SQLITE_CANTOPEN;
pFile->pMethods = 0;
}else{
/* Round newly added appendvfs location to #define'd page boundary.
** Note that nothing has yet been written to the underlying file.
** The append mark will be written along with first content write.
** Until then, paf->iMark value indicates it is not yet written.
*/
pApndFile->iPgOne = APND_START_ROUNDUP(sz);
} }
p->iPgOne = (sz+0xfff) & ~(sqlite3_int64)0xfff;
apnd_open_done:
if( rc ) pFile->pMethods = 0;
return rc; return rc;
} }
/*
** Delete an apnd file.
** For an appendvfs, this could mean delete the appendvfs portion,
** leaving the appendee as it was before it gained an appendvfs.
** For now, this code deletes the underlying file too.
*/
static int apndDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
return ORIGVFS(pVfs)->xDelete(ORIGVFS(pVfs), zPath, dirSync);
}
/* /*
** All other VFS methods are pass-thrus. ** All other VFS methods are pass-thrus.
*/ */
static int apndDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
return ORIGVFS(pVfs)->xDelete(ORIGVFS(pVfs), zPath, dirSync);
}
static int apndAccess( static int apndAccess(
sqlite3_vfs *pVfs, sqlite3_vfs *pVfs,
const char *zPath, const char *zPath,
@ -5201,6 +5308,14 @@ static void ieee754func(
int isNeg = 0; int isNeg = 0;
m = sqlite3_value_int64(argv[0]); m = sqlite3_value_int64(argv[0]);
e = sqlite3_value_int64(argv[1]); e = sqlite3_value_int64(argv[1]);
/* Limit the range of e. Ticket 22dea1cfdb9151e4 2021-03-02 */
if( e>10000 ){
e = 10000;
}else if( e<-10000 ){
e = -10000;
}
if( m<0 ){ if( m<0 ){
isNeg = 1; isNeg = 1;
m = -m; m = -m;
@ -5565,7 +5680,8 @@ static int seriesEof(sqlite3_vtab_cursor *cur){
** 4: step=VALUE ** 4: step=VALUE
** **
** Also, if bit 8 is set, that means that the series should be output ** Also, if bit 8 is set, that means that the series should be output
** in descending order rather than in ascending order. ** in descending order rather than in ascending order. If bit 16 is
** set, then output must appear in ascending order.
** **
** This routine should initialize the cursor and position it so that it ** This routine should initialize the cursor and position it so that it
** is pointing at the first row, or pointing off the end of the table ** is pointing at the first row, or pointing off the end of the table
@ -5591,7 +5707,12 @@ static int seriesFilter(
} }
if( idxNum & 4 ){ if( idxNum & 4 ){
pCur->iStep = sqlite3_value_int64(argv[i++]); pCur->iStep = sqlite3_value_int64(argv[i++]);
if( pCur->iStep<1 ) pCur->iStep = 1; if( pCur->iStep==0 ){
pCur->iStep = 1;
}else if( pCur->iStep<0 ){
pCur->iStep = -pCur->iStep;
if( (idxNum & 16)==0 ) idxNum |= 8;
}
}else{ }else{
pCur->iStep = 1; pCur->iStep = 1;
} }
@ -5685,7 +5806,11 @@ static int seriesBestIndex(
pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0)); pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0));
pIdxInfo->estimatedRows = 1000; pIdxInfo->estimatedRows = 1000;
if( pIdxInfo->nOrderBy==1 ){ if( pIdxInfo->nOrderBy==1 ){
if( pIdxInfo->aOrderBy[0].desc ) idxNum |= 8; if( pIdxInfo->aOrderBy[0].desc ){
idxNum |= 8;
}else{
idxNum |= 16;
}
pIdxInfo->orderByConsumed = 1; pIdxInfo->orderByConsumed = 1;
} }
}else{ }else{
@ -8936,7 +9061,7 @@ static int idxGetTableInfo(
char *pCsr = 0; char *pCsr = 0;
int nPk = 0; int nPk = 0;
rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_info=%Q", zTab); rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){ while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1); const char *zCol = (const char*)sqlite3_column_text(p1, 1);
nByte += 1 + STRLEN(zCol); nByte += 1 + STRLEN(zCol);
@ -11116,12 +11241,12 @@ struct ShellState {
u8 autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ u8 autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
u8 autoEQPtest; /* autoEQP is in test mode */ u8 autoEQPtest; /* autoEQP is in test mode */
u8 autoEQPtrace; /* autoEQP is in trace mode */ u8 autoEQPtrace; /* autoEQP is in trace mode */
u8 statsOn; /* True to display memory stats before each finalize */
u8 scanstatsOn; /* True to display scan stats before each finalize */ u8 scanstatsOn; /* True to display scan stats before each finalize */
u8 openMode; /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */ u8 openMode; /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */
u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */ u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */
u8 nEqpLevel; /* Depth of the EQP output graph */ u8 nEqpLevel; /* Depth of the EQP output graph */
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */ u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
unsigned statsOn; /* True to display memory stats before each finalize */
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */ unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
int outCount; /* Revert to stdout when reaching zero */ int outCount; /* Revert to stdout when reaching zero */
int cnt; /* Number of records displayed so far */ int cnt; /* Number of records displayed so far */
@ -12058,6 +12183,7 @@ static int shell_callback(
if( azArg==0 ) break; if( azArg==0 ) break;
for(i=0; i<nArg; i++){ for(i=0; i<nArg; i++){
int w = aExplainWidth[i]; int w = aExplainWidth[i];
if( i==nArg-1 ) w = 0;
if( azArg[i] && strlenChar(azArg[i])>w ){ if( azArg[i] && strlenChar(azArg[i])>w ){
w = strlenChar(azArg[i]); w = strlenChar(azArg[i]);
} }
@ -12622,7 +12748,7 @@ static int display_stats(
if( pArg==0 || pArg->out==0 ) return 0; if( pArg==0 || pArg->out==0 ) return 0;
out = pArg->out; out = pArg->out;
if( pArg->pStmt && (pArg->statsOn & 2) ){ if( pArg->pStmt && pArg->statsOn==2 ){
int nCol, i, x; int nCol, i, x;
sqlite3_stmt *pStmt = pArg->pStmt; sqlite3_stmt *pStmt = pArg->pStmt;
char z[100]; char z[100];
@ -12646,6 +12772,14 @@ static int display_stats(
} }
} }
if( pArg->statsOn==3 ){
if( pArg->pStmt ){
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
raw_printf(pArg->out, "VM-steps: %d\n", iCur);
}
return 0;
}
displayStatLine(pArg, "Memory Used:", displayStatLine(pArg, "Memory Used:",
"%lld (max %lld) bytes", SQLITE_STATUS_MEMORY_USED, bReset); "%lld (max %lld) bytes", SQLITE_STATUS_MEMORY_USED, bReset);
displayStatLine(pArg, "Number of Outstanding Allocations:", displayStatLine(pArg, "Number of Outstanding Allocations:",
@ -12912,31 +13046,18 @@ static void explain_data_delete(ShellState *p){
/* /*
** Disable and restore .wheretrace and .selecttrace settings. ** Disable and restore .wheretrace and .selecttrace settings.
*/ */
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE) static unsigned int savedSelectTrace;
extern unsigned int sqlite3_unsupported_selecttrace; static unsigned int savedWhereTrace;
static int savedSelectTrace;
#endif
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
extern int sqlite3WhereTrace;
static int savedWhereTrace;
#endif
static void disable_debug_trace_modes(void){ static void disable_debug_trace_modes(void){
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE) unsigned int zero = 0;
savedSelectTrace = sqlite3_unsupported_selecttrace; sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 0, &savedSelectTrace);
sqlite3_unsupported_selecttrace = 0; sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 1, &zero);
#endif sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 2, &savedWhereTrace);
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE) sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 3, &zero);
savedWhereTrace = sqlite3WhereTrace;
sqlite3WhereTrace = 0;
#endif
} }
static void restore_debug_trace_modes(void){ static void restore_debug_trace_modes(void){
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE) sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 1, &savedSelectTrace);
sqlite3_unsupported_selecttrace = savedSelectTrace; sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 3, &savedWhereTrace);
#endif
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
sqlite3WhereTrace = savedWhereTrace;
#endif
} }
/* Create the TEMP table used to store parameter bindings */ /* Create the TEMP table used to store parameter bindings */
@ -13098,6 +13219,7 @@ static void exec_prepared_stmt_columnar(
if( rc!=SQLITE_ROW ) return; if( rc!=SQLITE_ROW ) return;
nColumn = sqlite3_column_count(pStmt); nColumn = sqlite3_column_count(pStmt);
nAlloc = nColumn*4; nAlloc = nColumn*4;
if( nAlloc<=0 ) nAlloc = 1;
azData = sqlite3_malloc64( nAlloc*sizeof(char*) ); azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
if( azData==0 ) shell_out_of_memory(); if( azData==0 ) shell_out_of_memory();
for(i=0; i<nColumn; i++){ for(i=0; i<nColumn; i++){
@ -13137,6 +13259,7 @@ static void exec_prepared_stmt_columnar(
if( n>p->actualWidth[j] ) p->actualWidth[j] = n; if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
} }
if( seenInterrupt ) goto columnar_end; if( seenInterrupt ) goto columnar_end;
if( nColumn==0 ) goto columnar_end;
switch( p->cMode ){ switch( p->cMode ){
case MODE_Column: { case MODE_Column: {
colSep = " "; colSep = " ";
@ -13926,13 +14049,13 @@ static const char *(azHelp[]) = {
".databases List names and files of attached databases", ".databases List names and files of attached databases",
".dbconfig ?op? ?val? List or change sqlite3_db_config() options", ".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
".dbinfo ?DB? Show status information about the database", ".dbinfo ?DB? Show status information about the database",
".dump ?TABLE? Render database content as SQL", ".dump ?OBJECTS? Render database content as SQL",
" Options:", " Options:",
" --data-only Output only INSERT statements", " --data-only Output only INSERT statements",
" --newlines Allow unescaped newline characters in output", " --newlines Allow unescaped newline characters in output",
" --nosys Omit system tables (ex: \"sqlite_stat1\")", " --nosys Omit system tables (ex: \"sqlite_stat1\")",
" --preserve-rowids Include ROWID values in the output", " --preserve-rowids Include ROWID values in the output",
" TABLE is a LIKE pattern for the tables to dump", " OBJECTS is a LIKE pattern for tables, indexes, triggers or views to dump",
" Additional LIKE patterns can be given in subsequent arguments", " Additional LIKE patterns can be given in subsequent arguments",
".echo on|off Turn command echo on or off", ".echo on|off Turn command echo on or off",
".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN", ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
@ -14091,7 +14214,11 @@ static const char *(azHelp[]) = {
".shell CMD ARGS... Run CMD ARGS... in a system shell", ".shell CMD ARGS... Run CMD ARGS... in a system shell",
#endif #endif
".show Show the current values for various settings", ".show Show the current values for various settings",
".stats ?on|off? Show stats or turn stats on or off", ".stats ?ARG? Show stats or turn stats on or off",
" off Turn off automatic stat display",
" on Turn on automatic stat display",
" stmt Show statement stats",
" vmstep Show the virtual machine step count only",
#ifndef SQLITE_NOHAVE_SYSTEM #ifndef SQLITE_NOHAVE_SYSTEM
".system CMD ARGS... Run CMD ARGS... in a system shell", ".system CMD ARGS... Run CMD ARGS... in a system shell",
#endif #endif
@ -17907,16 +18034,17 @@ static int do_meta_command(char *zLine, ShellState *p){
int ctrlCode; /* Integer code for that option */ int ctrlCode; /* Integer code for that option */
const char *zUsage; /* Usage notes */ const char *zUsage; /* Usage notes */
} aCtrl[] = { } aCtrl[] = {
{ "size_limit", SQLITE_FCNTL_SIZE_LIMIT, "[LIMIT]" },
{ "chunk_size", SQLITE_FCNTL_CHUNK_SIZE, "SIZE" }, { "chunk_size", SQLITE_FCNTL_CHUNK_SIZE, "SIZE" },
/* { "win32_av_retry", SQLITE_FCNTL_WIN32_AV_RETRY, "COUNT DELAY" },*/ { "data_version", SQLITE_FCNTL_DATA_VERSION, "" },
{ "persist_wal", SQLITE_FCNTL_PERSIST_WAL, "[BOOLEAN]" },
{ "psow", SQLITE_FCNTL_POWERSAFE_OVERWRITE, "[BOOLEAN]" },
/* { "pragma", SQLITE_FCNTL_PRAGMA, "NAME ARG" },*/
{ "tempfilename", SQLITE_FCNTL_TEMPFILENAME, "" },
{ "has_moved", SQLITE_FCNTL_HAS_MOVED, "" }, { "has_moved", SQLITE_FCNTL_HAS_MOVED, "" },
{ "lock_timeout", SQLITE_FCNTL_LOCK_TIMEOUT, "MILLISEC" }, { "lock_timeout", SQLITE_FCNTL_LOCK_TIMEOUT, "MILLISEC" },
{ "persist_wal", SQLITE_FCNTL_PERSIST_WAL, "[BOOLEAN]" },
/* { "pragma", SQLITE_FCNTL_PRAGMA, "NAME ARG" },*/
{ "psow", SQLITE_FCNTL_POWERSAFE_OVERWRITE, "[BOOLEAN]" },
{ "reserve_bytes", SQLITE_FCNTL_RESERVE_BYTES, "[N]" }, { "reserve_bytes", SQLITE_FCNTL_RESERVE_BYTES, "[N]" },
{ "size_limit", SQLITE_FCNTL_SIZE_LIMIT, "[LIMIT]" },
{ "tempfilename", SQLITE_FCNTL_TEMPFILENAME, "" },
/* { "win32_av_retry", SQLITE_FCNTL_WIN32_AV_RETRY, "COUNT DELAY" },*/
}; };
int filectrl = -1; int filectrl = -1;
int iCtrl = -1; int iCtrl = -1;
@ -18003,6 +18131,7 @@ static int do_meta_command(char *zLine, ShellState *p){
isOk = 1; isOk = 1;
break; break;
} }
case SQLITE_FCNTL_DATA_VERSION:
case SQLITE_FCNTL_HAS_MOVED: { case SQLITE_FCNTL_HAS_MOVED: {
int x; int x;
if( nArg!=2 ) break; if( nArg!=2 ) break;
@ -18711,9 +18840,9 @@ static int do_meta_command(char *zLine, ShellState *p){
#endif /* SQLITE_DEBUG */ #endif /* SQLITE_DEBUG */
if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){ if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
char *zNewFilename; /* Name of the database file to open */ char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */ int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */ int newFlag = 0; /* True to delete file before opening */
/* Close the existing database */ /* Close the existing database */
session_close_all(p); session_close_all(p);
close_db(p->db); close_db(p->db);
@ -18725,7 +18854,7 @@ static int do_meta_command(char *zLine, ShellState *p){
p->openFlags = 0; p->openFlags = 0;
p->szMax = 0; p->szMax = 0;
/* Check for command-line arguments */ /* Check for command-line arguments */
for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){ for(iName=1; iName<nArg; iName++){
const char *z = azArg[iName]; const char *z = azArg[iName];
if( optionMatch(z,"new") ){ if( optionMatch(z,"new") ){
newFlag = 1; newFlag = 1;
@ -18751,10 +18880,15 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(stderr, "unknown option: %s\n", z); utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1; rc = 1;
goto meta_command_exit; goto meta_command_exit;
}else if( zNewFilename ){
utf8_printf(stderr, "extra argument: \"%s\"\n", z);
rc = 1;
goto meta_command_exit;
}else{
zNewFilename = sqlite3_mprintf("%s", z);
} }
} }
/* If a filename is specified, try to open it first */ /* If a filename is specified, try to open it first */
zNewFilename = nArg>iName ? sqlite3_mprintf("%s", azArg[iName]) : 0;
if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){ if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
if( newFlag ) shellDeleteFile(zNewFilename); if( newFlag ) shellDeleteFile(zNewFilename);
p->zDbFilename = zNewFilename; p->zDbFilename = zNewFilename;
@ -18777,7 +18911,7 @@ static int do_meta_command(char *zLine, ShellState *p){
&& (strncmp(azArg[0], "output", n)==0||strncmp(azArg[0], "once", n)==0)) && (strncmp(azArg[0], "output", n)==0||strncmp(azArg[0], "once", n)==0))
|| (c=='e' && n==5 && strcmp(azArg[0],"excel")==0) || (c=='e' && n==5 && strcmp(azArg[0],"excel")==0)
){ ){
const char *zFile = 0; char *zFile = 0;
int bTxtMode = 0; int bTxtMode = 0;
int i; int i;
int eMode = 0; int eMode = 0;
@ -18807,17 +18941,22 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = 1; rc = 1;
goto meta_command_exit; goto meta_command_exit;
} }
}else if( zFile==0 ){ }else if( zFile==0 && eMode!='e' && eMode!='x' ){
zFile = z; zFile = sqlite3_mprintf("%s", z);
if( zFile[0]=='|' ){
while( i+1<nArg ) zFile = sqlite3_mprintf("%z %s", zFile, azArg[++i]);
break;
}
}else{ }else{
utf8_printf(p->out,"ERROR: extra parameter: \"%s\". Usage:\n", utf8_printf(p->out,"ERROR: extra parameter: \"%s\". Usage:\n",
azArg[i]); azArg[i]);
showHelp(p->out, azArg[0]); showHelp(p->out, azArg[0]);
rc = 1; rc = 1;
sqlite3_free(zFile);
goto meta_command_exit; goto meta_command_exit;
} }
} }
if( zFile==0 ) zFile = "stdout"; if( zFile==0 ) zFile = sqlite3_mprintf("stdout");
if( bOnce ){ if( bOnce ){
p->outCount = 2; p->outCount = 2;
}else{ }else{
@ -18840,7 +18979,8 @@ static int do_meta_command(char *zLine, ShellState *p){
newTempFile(p, "txt"); newTempFile(p, "txt");
bTxtMode = 1; bTxtMode = 1;
} }
zFile = p->zTempFile; sqlite3_free(zFile);
zFile = sqlite3_mprintf("%s", p->zTempFile);
} }
#endif /* SQLITE_NOHAVE_SYSTEM */ #endif /* SQLITE_NOHAVE_SYSTEM */
if( zFile[0]=='|' ){ if( zFile[0]=='|' ){
@ -18872,6 +19012,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile); sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
} }
} }
sqlite3_free(zFile);
}else }else
if( c=='p' && n>=3 && strncmp(azArg[0], "parameter", n)==0 ){ if( c=='p' && n>=3 && strncmp(azArg[0], "parameter", n)==0 ){
@ -19055,6 +19196,11 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit; goto meta_command_exit;
} }
if( azArg[1][0]=='|' ){ if( azArg[1][0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
raw_printf(stderr, "Error: pipes are not supported in this OS\n");
rc = 1;
p->out = stdout;
#else
p->in = popen(azArg[1]+1, "r"); p->in = popen(azArg[1]+1, "r");
if( p->in==0 ){ if( p->in==0 ){
utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]);
@ -19063,6 +19209,7 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = process_input(p); rc = process_input(p);
pclose(p->in); pclose(p->in);
} }
#endif
}else if( notNormalFile(azArg[1]) || (p->in = fopen(azArg[1], "rb"))==0 ){ }else if( notNormalFile(azArg[1]) || (p->in = fopen(azArg[1], "rb"))==0 ){
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1; rc = 1;
@ -19277,11 +19424,10 @@ static int do_meta_command(char *zLine, ShellState *p){
} }
}else }else
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){ if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){
sqlite3_unsupported_selecttrace = nArg>=2 ? (int)integerValue(azArg[1]) : 0xffff; unsigned int x = nArg>=2 ? (unsigned int)integerValue(azArg[1]) : 0xffffffff;
sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 1, &x);
}else }else
#endif
#if defined(SQLITE_ENABLE_SESSION) #if defined(SQLITE_ENABLE_SESSION)
if( c=='s' && strncmp(azArg[0],"session",n)==0 && n>=3 ){ if( c=='s' && strncmp(azArg[0],"session",n)==0 && n>=3 ){
@ -19762,6 +19908,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='s' && strncmp(azArg[0], "show", n)==0 ){ if( c=='s' && strncmp(azArg[0], "show", n)==0 ){
static const char *azBool[] = { "off", "on", "trigger", "full"}; static const char *azBool[] = { "off", "on", "trigger", "full"};
const char *zOut;
int i; int i;
if( nArg!=1 ){ if( nArg!=1 ){
raw_printf(stderr, "Usage: .show\n"); raw_printf(stderr, "Usage: .show\n");
@ -19786,7 +19933,13 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out,"%12.12s: ", "rowseparator"); utf8_printf(p->out,"%12.12s: ", "rowseparator");
output_c_string(p->out, p->rowSeparator); output_c_string(p->out, p->rowSeparator);
raw_printf(p->out, "\n"); raw_printf(p->out, "\n");
utf8_printf(p->out, "%12.12s: %s\n","stats", azBool[p->statsOn!=0]); switch( p->statsOn ){
case 0: zOut = "off"; break;
default: zOut = "on"; break;
case 2: zOut = "stmt"; break;
case 3: zOut = "vmstep"; break;
}
utf8_printf(p->out, "%12.12s: %s\n","stats", zOut);
utf8_printf(p->out, "%12.12s: ", "width"); utf8_printf(p->out, "%12.12s: ", "width");
for (i=0;i<p->nWidth;i++) { for (i=0;i<p->nWidth;i++) {
raw_printf(p->out, "%d ", p->colWidth[i]); raw_printf(p->out, "%d ", p->colWidth[i]);
@ -19798,11 +19951,17 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){ if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){
if( nArg==2 ){ if( nArg==2 ){
p->statsOn = (u8)booleanValue(azArg[1]); if( strcmp(azArg[1],"stmt")==0 ){
p->statsOn = 2;
}else if( strcmp(azArg[1],"vmstep")==0 ){
p->statsOn = 3;
}else{
p->statsOn = (u8)booleanValue(azArg[1]);
}
}else if( nArg==1 ){ }else if( nArg==1 ){
display_stats(p->db, p, 0); display_stats(p->db, p, 0);
}else{ }else{
raw_printf(stderr, "Usage: .stats ?on|off?\n"); raw_printf(stderr, "Usage: .stats ?on|off|stmt|vmstep?\n");
rc = 1; rc = 1;
} }
}else }else
@ -20007,7 +20166,7 @@ static int do_meta_command(char *zLine, ShellState *p){
/* sqlite3_test_control(int, db, int) */ /* sqlite3_test_control(int, db, int) */
case SQLITE_TESTCTRL_OPTIMIZATIONS: case SQLITE_TESTCTRL_OPTIMIZATIONS:
if( nArg==3 ){ if( nArg==3 ){
int opt = (int)strtol(azArg[2], 0, 0); unsigned int opt = (unsigned int)strtol(azArg[2], 0, 0);
rc2 = sqlite3_test_control(testctrl, p->db, opt); rc2 = sqlite3_test_control(testctrl, p->db, opt);
isOk = 3; isOk = 3;
} }
@ -20336,11 +20495,10 @@ static int do_meta_command(char *zLine, ShellState *p){
} }
}else }else
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){ if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){
sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff; unsigned int x = nArg>=2 ? (unsigned int)integerValue(azArg[1]) : 0xffffffff;
sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 3, &x);
}else }else
#endif
if( c=='w' && strncmp(azArg[0], "width", n)==0 ){ if( c=='w' && strncmp(azArg[0], "width", n)==0 ){
int j; int j;
@ -20829,7 +20987,8 @@ static char *cmdline_option_value(int argc, char **argv, int i){
} }
#ifndef SQLITE_SHELL_IS_UTF8 #ifndef SQLITE_SHELL_IS_UTF8
# if (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER) # if (defined(_WIN32) || defined(WIN32)) \
&& (defined(_MSC_VER) || (defined(UNICODE) && defined(__GNUC__)))
# define SQLITE_SHELL_IS_UTF8 (0) # define SQLITE_SHELL_IS_UTF8 (0)
# else # else
# define SQLITE_SHELL_IS_UTF8 (1) # define SQLITE_SHELL_IS_UTF8 (1)

File diff suppressed because it is too large Load Diff

View File

@ -123,9 +123,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.34.1" #define SQLITE_VERSION "3.35.5"
#define SQLITE_VERSION_NUMBER 3034001 #define SQLITE_VERSION_NUMBER 3035005
#define SQLITE_SOURCE_ID "2021-01-20 14:10:07 10e20c0b43500cfb9bbc0eaa061c57514f715d87238f4d835880cd846b9ebd1f" #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -2115,7 +2115,13 @@ struct sqlite3_mem_methods {
** The second parameter is a pointer to an integer into which ** The second parameter is a pointer to an integer into which
** is written 0 or 1 to indicate whether triggers are disabled or enabled ** is written 0 or 1 to indicate whether triggers are disabled or enabled
** following this call. The second parameter may be a NULL pointer, in ** following this call. The second parameter may be a NULL pointer, in
** which case the trigger setting is not reported back. </dd> ** which case the trigger setting is not reported back.
**
** <p>Originally this option disabled all triggers. ^(However, since
** SQLite version 3.35.0, TEMP triggers are still allowed even if
** this option is off. So, in other words, this option now only disables
** triggers in the main database schema or in the schemas of ATTACH-ed
** databases.)^ </dd>
** **
** [[SQLITE_DBCONFIG_ENABLE_VIEW]] ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt> ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
@ -2126,7 +2132,13 @@ struct sqlite3_mem_methods {
** The second parameter is a pointer to an integer into which ** The second parameter is a pointer to an integer into which
** is written 0 or 1 to indicate whether views are disabled or enabled ** is written 0 or 1 to indicate whether views are disabled or enabled
** following this call. The second parameter may be a NULL pointer, in ** following this call. The second parameter may be a NULL pointer, in
** which case the view setting is not reported back. </dd> ** which case the view setting is not reported back.
**
** <p>Originally this option disabled all views. ^(However, since
** SQLite version 3.35.0, TEMP views are still allowed even if
** this option is off. So, in other words, this option now only disables
** views in the main database schema or in the schemas of ATTACH-ed
** databases.)^ </dd>
** **
** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt> ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
@ -3499,6 +3511,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
** that uses dot-files in place of posix advisory locking. ** that uses dot-files in place of posix advisory locking.
** <tr><td> file:data.db?mode=readonly <td> ** <tr><td> file:data.db?mode=readonly <td>
** An error. "readonly" is not a valid option for the "mode" parameter. ** An error. "readonly" is not a valid option for the "mode" parameter.
** Use "ro" instead: "file:data.db?mode=ro".
** </table> ** </table>
** **
** ^URI hexadecimal escape sequences (%HH) are supported within the path and ** ^URI hexadecimal escape sequences (%HH) are supported within the path and
@ -7765,7 +7778,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_PRNG_SEED 28
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
#define SQLITE_TESTCTRL_SEEK_COUNT 30 #define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */ #define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */
/* /*
** CAPI3REF: SQL Keyword Checking ** CAPI3REF: SQL Keyword Checking
@ -10438,6 +10452,14 @@ SQLITE_API int sqlite3session_patchset(
*/ */
SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession);
/*
** CAPI3REF: Query for the amount of heap memory used by a session object.
**
** This API returns the total amount of heap memory in bytes currently
** used by the session object passed as the only argument.
*/
SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession);
/* /*
** CAPI3REF: Create An Iterator To Traverse A Changeset ** CAPI3REF: Create An Iterator To Traverse A Changeset
** CONSTRUCTOR: sqlite3_changeset_iter ** CONSTRUCTOR: sqlite3_changeset_iter
@ -10540,18 +10562,23 @@ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this
** is not the case, this function returns [SQLITE_MISUSE]. ** is not the case, this function returns [SQLITE_MISUSE].
** **
** If argument pzTab is not NULL, then *pzTab is set to point to a ** Arguments pOp, pnCol and pzTab may not be NULL. Upon return, three
** nul-terminated utf-8 encoded string containing the name of the table ** outputs are set through these pointers:
** affected by the current change. The buffer remains valid until either **
** sqlite3changeset_next() is called on the iterator or until the ** *pOp is set to one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE],
** conflict-handler function returns. If pnCol is not NULL, then *pnCol is ** depending on the type of change that the iterator currently points to;
** set to the number of columns in the table affected by the change. If **
** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change ** *pnCol is set to the number of columns in the table affected by the change; and
**
** *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 pbIndirect 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 ** is an indirect change, or false (0) otherwise. See the documentation for
** [sqlite3session_indirect()] for a description of direct and indirect ** [sqlite3session_indirect()] for a description of direct and indirect
** changes. Finally, if pOp is not NULL, then *pOp is set to one of ** changes.
** [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 ** If no error occurs, SQLITE_OK is returned. If an error does occur, an
** SQLite error code is returned. The values of the output variables may not ** SQLite error code is returned. The values of the output variables may not

View File

@ -1,3 +1,3 @@
#ifndef SQLITE_RESOURCE_VERSION #ifndef SQLITE_RESOURCE_VERSION
#define SQLITE_RESOURCE_VERSION 3,34,1 #define SQLITE_RESOURCE_VERSION 3,35,5
#endif #endif

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for sqlite 3.34.1. # Generated by GNU Autoconf 2.69 for sqlite 3.35.5.
# #
# #
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='sqlite' PACKAGE_NAME='sqlite'
PACKAGE_TARNAME='sqlite' PACKAGE_TARNAME='sqlite'
PACKAGE_VERSION='3.34.1' PACKAGE_VERSION='3.35.5'
PACKAGE_STRING='sqlite 3.34.1' PACKAGE_STRING='sqlite 3.35.5'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
PACKAGE_URL='' PACKAGE_URL=''
@ -1303,7 +1303,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures sqlite 3.34.1 to adapt to many kinds of systems. \`configure' configures sqlite 3.35.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1365,7 +1365,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of sqlite 3.34.1:";; short | recursive ) echo "Configuration of sqlite 3.35.5:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1467,7 +1467,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
sqlite configure 3.34.1 sqlite configure 3.35.5
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1878,7 +1878,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by sqlite $as_me 3.34.1, which was It was created by sqlite $as_me 3.35.5, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -9373,7 +9373,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by sqlite $as_me 3.34.1, which was This file was extended by sqlite $as_me 3.35.5, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -9426,7 +9426,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
sqlite config.status 3.34.1 sqlite config.status 3.35.5
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -19,7 +19,7 @@ dnl to configure the system for the local environment.
# so you can encode the package version directly into the source files. # so you can encode the package version directly into the source files.
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
AC_INIT([sqlite], [3.34.1]) AC_INIT([sqlite], [3.35.5])
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars. # Call TEA_INIT as the first TEA_ macro to set up initial vars.