diff -Nru sqlite3-3.33.0/autoconf/tea/win/makefile.vc sqlite3-3.34.0/autoconf/tea/win/makefile.vc --- sqlite3-3.33.0/autoconf/tea/win/makefile.vc 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/autoconf/tea/win/makefile.vc 2020-12-01 16:36:02.000000000 +0000 @@ -153,7 +153,7 @@ # #------------------------------------------------------------------------- -PROJECT = tclsqlite3 +PROJECT = sqlite3 !include "rules.vc" # nmakehelp -V will search the file for tag, skips until a diff -Nru sqlite3-3.33.0/configure sqlite3-3.34.0/configure --- sqlite3-3.33.0/configure 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/configure 2020-12-01 16:36:02.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.33.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.34.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.33.0' -PACKAGE_STRING='sqlite 3.33.0' +PACKAGE_VERSION='3.34.0' +PACKAGE_STRING='sqlite 3.34.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -799,7 +799,6 @@ ALLOWRELEASE SQLITE_THREADSAFE BUILD_CC -VERSION_NUMBER RELEASE VERSION program_prefix @@ -1467,7 +1466,7 @@ # 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. cat <<_ACEOF -\`configure' configures sqlite 3.33.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.34.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1532,7 +1531,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.33.0:";; + short | recursive ) echo "Configuration of sqlite 3.34.0:";; esac cat <<\_ACEOF @@ -1659,7 +1658,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.33.0 +sqlite configure 3.34.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2078,7 +2077,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.33.0, which was +It was created by sqlite $as_me 3.34.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3936,13 +3935,13 @@ else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3939: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3938: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3942: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3941: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3945: output\"" >&5) + (eval echo "\"\$as_me:3944: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5148,7 +5147,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5151 "configure"' > conftest.$ac_ext + echo '#line 5150 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6673,11 +6672,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6676: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6675: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6680: \$? = $ac_status" >&5 + echo "$as_me:6679: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7012,11 +7011,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7015: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7014: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7019: \$? = $ac_status" >&5 + echo "$as_me:7018: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7117,11 +7116,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7120: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7119: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7124: \$? = $ac_status" >&5 + echo "$as_me:7123: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7172,11 +7171,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7175: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7174: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7179: \$? = $ac_status" >&5 + echo "$as_me:7178: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9552,7 +9551,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9555 "configure" +#line 9554 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9648,7 +9647,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9651 "configure" +#line 9650 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10388,12 +10387,6 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: Release set to $RELEASE" >&5 $as_echo "$as_me: Release set to $RELEASE" >&6;} -VERSION_NUMBER=`cat $srcdir/VERSION \ - | sed 's/[^0-9]/ /g' \ - | awk '{printf "%d%03d%03d",$1,$2,$3}'` -{ $as_echo "$as_me:${as_lineno-$LINENO}: Version number set to $VERSION_NUMBER" >&5 -$as_echo "$as_me: Version number set to $VERSION_NUMBER" >&6;} - ######### # Locate a compiler for the build machine. This compiler should @@ -12243,7 +12236,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.33.0, which was +This file was extended by sqlite $as_me 3.34.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12309,7 +12302,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.33.0 +sqlite config.status 3.34.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru sqlite3-3.33.0/configure.ac sqlite3-3.34.0/configure.ac --- sqlite3-3.33.0/configure.ac 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/configure.ac 2020-12-01 16:36:02.000000000 +0000 @@ -155,11 +155,6 @@ RELEASE=`cat $srcdir/VERSION` AC_MSG_NOTICE(Release set to $RELEASE) AC_SUBST(RELEASE) -VERSION_NUMBER=[`cat $srcdir/VERSION \ - | sed 's/[^0-9]/ /g' \ - | awk '{printf "%d%03d%03d",$1,$2,$3}'`] -AC_MSG_NOTICE(Version number set to $VERSION_NUMBER) -AC_SUBST(VERSION_NUMBER) ######### # Locate a compiler for the build machine. This compiler should diff -Nru sqlite3-3.33.0/debian/changelog sqlite3-3.34.0/debian/changelog --- sqlite3-3.33.0/debian/changelog 2020-08-15 14:40:06.000000000 +0000 +++ sqlite3-3.34.0/debian/changelog 2020-12-04 21:11:24.000000000 +0000 @@ -1,3 +1,16 @@ +sqlite3 (3.34.0-1) unstable; urgency=medium + + * New upstream release. + * Update patches to apply clean. + * Update libsqlite3-0 symbols. + * Update debhelper level to 13 . + * Update Standards-Version to 4.5.1 . + + [ Pino Toscano ] + * Don't ship .la files (closes: #968488). + + -- Laszlo Boszormenyi (GCS) Fri, 04 Dec 2020 22:11:24 +0100 + sqlite3 (3.33.0-1) unstable; urgency=medium * New upstream release. diff -Nru sqlite3-3.33.0/debian/control sqlite3-3.34.0/debian/control --- sqlite3-3.33.0/debian/control 2020-05-24 09:47:32.000000000 +0000 +++ sqlite3-3.34.0/debian/control 2020-12-04 21:11:24.000000000 +0000 @@ -2,10 +2,10 @@ Section: devel Priority: optional Maintainer: Laszlo Boszormenyi (GCS) -Build-Depends: debhelper-compat (= 11), autoconf (>= 2.59), libtool (>= 1.5.2), automake, chrpath, lynx, libreadline-dev, tcl8.6-dev +Build-Depends: debhelper-compat (= 13), autoconf (>= 2.59), libtool (>= 1.5.2), automake, chrpath, lynx, libreadline-dev, tcl8.6-dev Build-Conflicts: tcl8.4, tcl8.4-dev, tcl8.5, tcl8.5-dev Homepage: https://www.sqlite.org/ -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Package: lemon Architecture: any diff -Nru sqlite3-3.33.0/debian/libsqlite3-0.symbols sqlite3-3.34.0/debian/libsqlite3-0.symbols --- sqlite3-3.33.0/debian/libsqlite3-0.symbols 2020-08-15 14:40:06.000000000 +0000 +++ sqlite3-3.34.0/debian/libsqlite3-0.symbols 2020-12-04 21:11:24.000000000 +0000 @@ -230,6 +230,7 @@ sqlite3_trace@Base 3.5.9 sqlite3_trace_v2@Base 3.14.0 sqlite3_transfer_bindings@Base 3.5.9 + sqlite3_txn_state@Base 3.34.0 sqlite3_unlock_notify@Base 3.6.12 sqlite3_unsupported_selecttrace@Base 3.33.0 sqlite3_update_hook@Base 3.5.9 diff -Nru sqlite3-3.33.0/debian/libsqlite3-dev.install sqlite3-3.34.0/debian/libsqlite3-dev.install --- sqlite3-3.33.0/debian/libsqlite3-dev.install 2018-06-05 21:47:02.000000000 +0000 +++ sqlite3-3.34.0/debian/libsqlite3-dev.install 2020-12-04 21:11:24.000000000 +0000 @@ -1,5 +1,4 @@ usr/include/*.h usr/lib/*/libsqlite3.a usr/lib/*/libsqlite3.so -usr/lib/*/libsqlite3.la usr/lib/*/pkgconfig/sqlite3.pc diff -Nru sqlite3-3.33.0/debian/patches/02-use-packaged-lempar.c.patch sqlite3-3.34.0/debian/patches/02-use-packaged-lempar.c.patch --- sqlite3-3.33.0/debian/patches/02-use-packaged-lempar.c.patch 2019-12-29 18:49:54.000000000 +0000 +++ sqlite3-3.34.0/debian/patches/02-use-packaged-lempar.c.patch 2020-12-04 21:11:24.000000000 +0000 @@ -1,18 +1,18 @@ Description: use packaged lempar.c Look for lempar.c under the package directory. Author: Laszlo Boszormenyi (GCS) -Last-Update: 2019-12-29 +Last-Update: 2020-12-04 --- ---- sqlite3-3.8.4.3.orig/tool/lemon.c -+++ sqlite3-3.8.4.3/tool/lemon.c -@@ -3540,6 +3540,8 @@ PRIVATE FILE *tplt_open(struct lemon *le +--- a/tool/lemon.c ++++ b/tool/lemon.c +@@ -3668,6 +3668,8 @@ PRIVATE FILE *tplt_open(struct lemon *le tpltname = buf; }else if( access(templatename,004)==0 ){ tpltname = templatename; + }else if( access("/usr/share/lemon/lempar.c",004)==0 ){ + tpltname = "/usr/share/lemon/lempar.c"; }else{ - tpltname = pathsearch(lemp->argv0,templatename,0); + toFree = tpltname = pathsearch(lemp->argv0,templatename,0); } diff -Nru sqlite3-3.33.0/debian/patches/32-fix-readline-path-3.patch sqlite3-3.34.0/debian/patches/32-fix-readline-path-3.patch --- sqlite3-3.33.0/debian/patches/32-fix-readline-path-3.patch 2019-10-05 18:22:43.000000000 +0000 +++ sqlite3-3.34.0/debian/patches/32-fix-readline-path-3.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -Index: sqlite3-3.26.0+fossilbc891ac6b/configure.ac -=================================================================== ---- sqlite3-3.26.0+fossilbc891ac6b.orig/configure.ac -+++ sqlite3-3.26.0+fossilbc891ac6b/configure.ac -@@ -62,7 +62,7 @@ - # - # This variables define the directory that contain header - # files for the readline library. If the compiler is able --# to find on its own, then this can be blank. -+# to find on its own, then this can be blank. - # - # TARGET_EXEEXT - # -@@ -548,12 +548,12 @@ if test x"$with_readline" != xno; then - [with_readline_inc=$withval], - [with_readline_inc="auto"]) - if test "x$with_readline_inc" = xauto; then -- AC_CHECK_HEADER(readline.h, [found="yes"], [ -+ AC_CHECK_HEADER(readline/readline.h, [found="yes"], [ - found="no" - if test "$cross_compiling" != yes; then - for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do -- for subdir in include include/readline; do -- AC_CHECK_FILE($dir/$subdir/readline.h, found=yes) -+ for subdir in include; do -+ AC_CHECK_FILE($dir/$subdir/readline/readline.h, found=yes) - if test "$found" = "yes"; then - TARGET_READLINE_INC="-I$dir/$subdir" - break - diff -Nru sqlite3-3.33.0/debian/patches/series sqlite3-3.34.0/debian/patches/series --- sqlite3-3.33.0/debian/patches/series 2020-06-20 15:04:00.000000000 +0000 +++ sqlite3-3.34.0/debian/patches/series 2020-12-04 21:11:24.000000000 +0000 @@ -5,5 +5,3 @@ 10-665363-disable-malloc-usable-size.patch 31-increase_SQLITE_MAX_DEFAULT_PAGE_SIZE_to_32k.patch 02-use-packaged-lempar.c.patch -32-fix-readline-path-3.patch -#40-CVE-2020-13871.patch diff -Nru sqlite3-3.33.0/debian/rules sqlite3-3.34.0/debian/rules --- sqlite3-3.33.0/debian/rules 2020-06-01 05:23:26.000000000 +0000 +++ sqlite3-3.34.0/debian/rules 2020-12-04 21:11:24.000000000 +0000 @@ -122,7 +122,7 @@ $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/sqlite/ # Remove *.la files per policy 3.9.1.0 - sed -i "/dependency_libs/ s/'.*'/''/" `find $(DESTDIR) -name '*.la'` + rm $(DESTDIR)/usr/lib/*/libsqlite3.la # Create the pkgIndex.tcl file for the Tcl module. This generated file # actually turns out to be relocatable. diff -Nru sqlite3-3.33.0/doc/lemon.html sqlite3-3.34.0/doc/lemon.html --- sqlite3-3.33.0/doc/lemon.html 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/doc/lemon.html 2020-12-01 16:36:02.000000000 +0000 @@ -2,7 +2,8 @@ The Lemon Parser Generator - + +

The Lemon Parser Generator

Lemon is an LALR(1) parser generator for C. @@ -23,11 +24,41 @@

This document is an introduction to the Lemon parser generator.

-

Security Note

+ +

1.0 Table of Contents

+ + + +

2.0 Security Note

The language parser code created by Lemon is very robust and is well-suited for use in internet-facing applications that need to -safely process maliciously crafted inputs. +safely process maliciously crafted inputs.

The "lemon.exe" command-line tool itself works great when given a valid input grammar file and almost always gives helpful @@ -43,56 +74,60 @@

  • The "lemon.exe" command line tool itself → Not so much -

    Theory of Operation

    + +

    3.0 Theory of Operation

    -

    The main goal of Lemon is to translate a context free grammar (CFG) +

    Lemon is computer program that translates a context free grammar (CFG) for a particular language into C code that implements a parser for that language. -The program has two inputs: +The Lemon program has two inputs:

    • The grammar specification.
    • A parser template file.
    -Typically, only the grammar specification is supplied by the programmer. -Lemon comes with a default parser template which works fine for most -applications. But the user is free to substitute a different parser -template if desired.

    +

    Typically, only the grammar specification is supplied by the programmer. +Lemon comes with a default parser template +("lempar.c") +that works fine for most applications. But the user is free to substitute +a different parser template if desired.

    Depending on command-line options, Lemon will generate up to -three output files. +three output files.

      -
    • C code to implement the parser. -
    • A header file defining an integer ID for each terminal symbol. +
    • C code to implement a parser for the input grammar. +
    • A header file defining an integer ID for each terminal symbol + (or "token").
    • An information file that describes the states of the generated parser automaton.
    -By default, all three of these output files are generated. +

    By default, all three of these output files are generated. The header file is suppressed if the "-m" command-line option is used and the report file is omitted when "-q" is selected.

    The grammar specification file uses a ".y" suffix, by convention. In the examples used in this document, we'll assume the name of the grammar file is "gram.y". A typical use of Lemon would be the -following command: +following command:

        lemon gram.y
     
    -This command will generate three output files named "gram.c", +

    This command will generate three output files named "gram.c", "gram.h" and "gram.out". The first is C code to implement the parser. The second is the header file that defines numerical values for all terminal symbols, and the last is the report that explains the states used by the parser automaton.

    -

    Command Line Options

    + +

    3.1 Command Line Options

    The behavior of Lemon can be modified using command-line options. You can obtain a list of the available command-line options together -with a brief explanation of what each does by typing +with a brief explanation of what each does by typing

        lemon "-?"
     
    -As of this writing, the following command-line options are supported: +

    As of this writing, the following command-line options are supported:

    • -b Show only the basis for each parser state in the report file. @@ -134,7 +169,8 @@ Print the Lemon version number.
    -

    The Parser Interface

    + +

    3.2 The Parser Interface

    Lemon doesn't generate a complete, working program. It only generates a few subroutines that implement a parser. This section describes @@ -144,11 +180,11 @@

    Before a program begins using a Lemon-generated parser, the program must first create the parser. -A new parser is created as follows: +A new parser is created as follows:

        void *pParser = ParseAlloc( malloc );
     
    -The ParseAlloc() routine allocates and initializes a new parser and +

    The ParseAlloc() routine allocates and initializes a new parser and returns a pointer to it. The actual data structure used to represent a parser is opaque — its internal structure is not visible or usable by the calling routine. @@ -158,22 +194,22 @@ subroutine used to allocate memory. Typically this means malloc().

    After a program is finished using a parser, it can reclaim all -memory allocated by that parser by calling +memory allocated by that parser by calling

        ParseFree(pParser, free);
     
    -The first argument is the same pointer returned by ParseAlloc(). The +

    The first argument is the same pointer returned by ParseAlloc(). The second argument is a pointer to the function used to release bulk memory back to the system.

    After a parser has been allocated using ParseAlloc(), the programmer must supply the parser with a sequence of tokens (terminal symbols) to be parsed. This is accomplished by calling the following function -once for each token: +once for each token:

        Parse(pParser, hTokenID, sTokenData, pArg);
     
    -The first argument to the Parse() routine is the pointer returned by +

    The first argument to the Parse() routine is the pointer returned by ParseAlloc(). The second argument is a small positive integer that tells the parser the type of the next token in the data stream. @@ -199,7 +235,7 @@ to the action routines without having to use global variables.

    A typical use of a Lemon parser might look something like the -following: +following:

         1 ParseTree *ParseFile(const char *zFilename){
         2    Tokenizer *pTokenizer;
    @@ -220,7 +256,7 @@
        17    return sState.treeRoot;
        18 }
     
    -This example shows a user-written routine that parses a file of +

    This example shows a user-written routine that parses a file of text and returns a pointer to the parse tree. (All error-handling code is omitted from this example to keep it simple.) @@ -232,7 +268,7 @@ some kind of structure that contains details about each token, such as its complete text, what line it occurs on, etc.

    -

    This example also assumes the existence of structure of type +

    This example also assumes the existence of a structure of type ParserState that holds state information about a particular parse. An instance of such a structure is created on line 6 and initialized on line 10. A pointer to this structure is passed into the Parse() @@ -243,7 +279,7 @@ the ParserState structure is left pointing to the root of the parse tree.

    -

    The core of this example as it relates to Lemon is as follows: +

    The core of this example as it relates to Lemon is as follows:

        ParseFile(){
           pParser = ParseAlloc( malloc );
    @@ -254,7 +290,7 @@
           ParseFree(pParser, free );
        }
     
    -Basically, what a program has to do to use a Lemon-generated parser +

    Basically, what a program has to do to use a Lemon-generated parser is first create the parser, then send it lots of tokens obtained by tokenizing an input source. When the end of input is reached, the Parse() routine should be called one last time with a token type @@ -265,21 +301,75 @@

    There is one other interface routine that should be mentioned before we move on. The ParseTrace() function can be used to generate debugging output -from the parser. A prototype for this routine is as follows: +from the parser. A prototype for this routine is as follows:

        ParseTrace(FILE *stream, char *zPrefix);
     
    -After this routine is called, a short (one-line) message is written +

    After this routine is called, a short (one-line) message is written to the designated output stream every time the parser changes states or calls an action routine. Each such message is prefaced using the text given by zPrefix. This debugging output can be turned off by calling ParseTrace() again with a first argument of NULL (0).

    -

    Differences With YACC and BISON

    + +

    3.2.1 Allocating The Parse Object On Stack

    + +

    If all calls to the Parse() interface are made from within +%code directives, then the parse +object can be allocated from the stack rather than from the heap. +These are the steps: + +

      +
    • Declare a local variable of type "yyParser" +
    • Initialize the variable using ParseInit() +
    • Pass a pointer to the variable in calls ot Parse() +
    • Deallocate substructure in the parse variable using ParseFinalize(). +
    + +

    The following code illustrates how this is done: + +

    +   ParseFile(){
    +      yyParser x;
    +      ParseInit( &x );
    +      while( GetNextToken(pTokenizer,&hTokenId, &sToken) ){
    +         Parse(&x, hTokenId, sToken);
    +      }
    +      Parse(&x, 0, sToken);
    +      ParseFinalize( &x );
    +   }
    +
    + + +

    3.2.2 Interface Summary

    + +

    Here is a quick overview of the C-language interface to a +Lemon-generated parser:

    + +
    +void *ParseAlloc( (void*(*malloc)(size_t) );
    +void ParseFree(void *pParser, (void(*free)(void*) );
    +void Parse(void *pParser, int tokenCode, ParseTOKENTYPE token, ...);
    +void ParseTrace(FILE *stream, char *zPrefix);
    +
    + +

    Notes:

    + + + +

    3.3 Differences With YACC and BISON

    Programmers who have previously used the yacc or bison parser generator will notice several important differences between yacc and/or -bison and Lemon. +bison and Lemon.

    • In yacc and bison, the parser calls the tokenizer. In Lemon, the tokenizer calls the parser. @@ -288,7 +378,7 @@
    • Lemon allows multiple parsers to be running simultaneously. Yacc and bison do not.
    -These differences may cause some initial confusion for programmers +

    These differences may cause some initial confusion for programmers with prior yacc and bison experience. But after years of experience using Lemon, I firmly believe that the Lemon way of doing things is better.

    @@ -296,10 +386,39 @@

    Updated as of 2016-02-16: The text above was written in the 1990s. We are told that Bison has lately been enhanced to support the -tokenizer-calls-parser paradigm used by Lemon, and to obviate the +tokenizer-calls-parser paradigm used by Lemon, eliminating the need for global variables.

    -

    Input File Syntax

    + +

    3.4 Building The "lemon" or "lemon.exe" Executable

    + +

    The "lemon" or "lemon.exe" program is built from a single file +of C-code named +"lemon.c". +The Lemon source code is generic C89 code that uses +no unusual or non-standard libraries. Any +reasonable C compiler should suffice to compile the lemon program. +A command-line like the following will usually work:

    + +
    +cc -o lemon lemon.c
    +
    On Windows machines with Visual C++ installed, bring up a +"VS20NN x64 Native Tools Command Prompt" window and enter: + +
    +cl lemon.c
    +
    + +

    Compiling Lemon really is that simple. +Additional compiler options such as +"-O2" or "-g" or "-Wall" can be added if desired, but they are not +necessary.

    + + + +

    4.0 Input File Syntax

    The main purpose of the grammar specification file for Lemon is to define the grammar for the parser. But the input file also @@ -307,13 +426,14 @@ Most of the work in using Lemon is in writing an appropriate grammar file.

    -

    The grammar file for Lemon is, for the most part, free format. +

    The grammar file for Lemon is, for the most part, a free format. It does not have sections or divisions like yacc or bison. Any -declaration can occur at any point in the file. -Lemon ignores whitespace (except where it is needed to separate -tokens), and it honors the same commenting conventions as C and C++.

    +declaration can occur at any point in the file. Lemon ignores +whitespace (except where it is needed to separate tokens), and it +honors the same commenting conventions as C and C++.

    -

    Terminals and Nonterminals

    + +

    4.1 Terminals and Nonterminals

    A terminal symbol (token) is any string of alphanumeric and/or underscore characters @@ -338,7 +458,8 @@ terminal symbols. With Lemon, all symbols, terminals and nonterminals, must have alphanumeric names.

    -

    Grammar Rules

    + +

    4.2 Grammar Rules

    The main component of a Lemon grammar file is a sequence of grammar rules. @@ -351,14 +472,13 @@ first rule is assumed to be the start symbol for the grammar (unless specified otherwise using the %start_symbol directive described below.) -A typical sequence of grammar rules might look something like this: +A typical sequence of grammar rules might look something like this:

       expr ::= expr PLUS expr.
       expr ::= expr TIMES expr.
       expr ::= LPAREN expr RPAREN.
       expr ::= VALUE.
     
    -

    There is one non-terminal in this example, "expr", and five terminal symbols or tokens: "PLUS", "TIMES", "LPAREN", @@ -370,11 +490,10 @@ In Lemon, this action is specified by putting the C code (contained within curly braces {...}) immediately after the period that closes the rule. -For example: +For example:

       expr ::= expr PLUS expr.   { printf("Doing an addition...\n"); }
     
    -

    In order to be useful, grammar actions must normally be linked to their associated grammar rules. @@ -391,18 +510,18 @@

    Lemon avoids the need to count grammar symbols by assigning symbolic names to each symbol in a grammar rule and then using those symbolic names in the action. -In yacc or bison, one would write this: +In yacc or bison, one would write this:

       expr -> expr PLUS expr  { $$ = $1 + $3; };
     
    -But in Lemon, the same rule becomes the following: +

    But in Lemon, the same rule becomes the following:

       expr(A) ::= expr(B) PLUS expr(C).  { A = B+C; }
     
    -In the Lemon rule, any symbol in parentheses after a grammar rule +

    In the Lemon rule, any symbol in parentheses after a grammar rule symbol becomes a place holder for that symbol in the grammar rule. This place holder can then be used in the associated C action to -stand for the value of that symbol.

    +stand for the value of that symbol.

    The Lemon notation for linking a grammar rule with its reduce action is superior to yacc/bison on several counts. @@ -412,11 +531,11 @@ includes a linking symbol in parentheses but that linking symbol is not actually used in the reduce action, then an error message is generated. -For example, the rule +For example, the rule

       expr(A) ::= expr(B) PLUS expr(C).  { A = B; }
     
    -will generate an error because the linking symbol "C" is used +

    will generate an error because the linking symbol "C" is used in the grammar rule but not in the reduce action.

    The Lemon notation for linking grammar rules to reduce actions @@ -424,8 +543,8 @@ allocated by the values of terminals and nonterminals on the right-hand side of a rule.

    - -

    Precedence Rules

    + +

    4.3 Precedence Rules

    Lemon resolves parsing ambiguities in exactly the same way as yacc and bison. A shift-reduce conflict is resolved in favor @@ -443,50 +562,50 @@ mentioned in earlier directives have a lower precedence than terminal symbols mentioned in later directives. For example:

    -

    +
        %left AND.
        %left OR.
        %nonassoc EQ NE GT GE LT LE.
        %left PLUS MINUS.
        %left TIMES DIVIDE MOD.
        %right EXP NOT.
    -

    +

    In the preceding sequence of directives, the AND operator is defined to have the lowest precedence. The OR operator is one precedence level higher. And so forth. Hence, the grammar would -attempt to group the ambiguous expression +attempt to group the ambiguous expression

          a AND b OR c
     
    -like this +

    like this

          a AND (b OR c).
     
    -The associativity (left, right or nonassoc) is used to determine +

    The associativity (left, right or nonassoc) is used to determine the grouping when the precedence is the same. AND is left-associative -in our example, so +in our example, so

          a AND b AND c
     
    -is parsed like this +

    is parsed like this

          (a AND b) AND c.
     
    -The EXP operator is right-associative, though, so +

    The EXP operator is right-associative, though, so

          a EXP b EXP c
     
    -is parsed like this +

    is parsed like this

          a EXP (b EXP c).
     
    -The nonassoc precedence is used for non-associative operators. -So +

    The nonassoc precedence is used for non-associative operators. +So

          a EQ b EQ c
     
    -is an error.

    +

    is an error.

    The precedence of non-terminals is transferred to rules as follows: The precedence of a grammar rule is equal to the precedence of the @@ -497,9 +616,9 @@ symbol in square braces after the period at the end of the rule and before any C-code. For example:

    -

    +
        expr = MINUS expr.  [NOT]
    -

    +

    This rule has a precedence equal to that of the NOT symbol, not the MINUS symbol as would have been the case by default.

    @@ -508,7 +627,7 @@ symbols and individual grammar rules, we can now explain precisely how parsing conflicts are resolved in Lemon. Shift-reduce conflicts are resolved -as follows: +as follows:

    • If either the token to be shifted or the rule to be reduced lacks precedence information, then resolve in favor of the @@ -528,7 +647,7 @@
    • Otherwise, resolve the conflict by doing the shift, and report a parsing conflict.
    -Reduce-reduce conflicts are resolved this way: +

    Reduce-reduce conflicts are resolved this way:

    • If either reduce rule lacks precedence information, then resolve in favor of the @@ -541,7 +660,8 @@ appears first in the grammar, and report a parsing conflict.
    -

    Special Directives

    + +

    4.4 Special Directives

    The input grammar to Lemon consists of grammar rules and special directives. We've described all the grammar rules, so now we'll @@ -553,7 +673,7 @@ directives used to assign precedence to terminals is important, but other than that, the order of directives in Lemon is arbitrary.

    -

    Lemon supports the following special directives: +

    Lemon supports the following special directives:

    -Each of these directives will be described separately in the +

    Each of these directives will be described separately in the following sections:

    - -

    The %code directive

    + +

    4.4.1 The %code directive

    The %code directive is used to specify additional C code that is added to the end of the main output file. This is similar to @@ -599,13 +719,16 @@ a tokenizer or even the "main()" function as part of the output file.

    - -

    The %default_destructor directive

    +

    There can be multiple %code directives. The arguments of +all %code directives are concatenated.

    + + +

    4.4.2 The %default_destructor directive

    The %default_destructor directive specifies a destructor to use for non-terminals that do not have their own destructor specified by a separate %destructor directive. See the documentation -on the %destructor directive below for +on the %destructor directive below for additional information.

    In some grammars, many different non-terminal symbols have the @@ -613,15 +736,15 @@ a convenient way to specify the same destructor for all those non-terminals using a single statement.

    - -

    The %default_type directive

    + +

    4.4.3 The %default_type directive

    The %default_type directive specifies the data type of non-terminal symbols that do not have their own data type defined using a separate %type directive.

    - -

    The %destructor directive

    + +

    4.4.4 The %destructor directive

    The %destructor directive is used to specify a destructor for a non-terminal symbol. @@ -630,24 +753,24 @@

    A non-terminal's destructor is called to dispose of the non-terminal's value whenever the non-terminal is popped from -the stack. This includes all of the following circumstances: +the stack. This includes all of the following circumstances:

    • When a rule reduces and the value of a non-terminal on the right-hand side is not linked to C code.
    • When the stack is popped during error processing.
    • When the ParseFree() function runs.
    -The destructor can do whatever it wants with the value of +

    The destructor can do whatever it wants with the value of the non-terminal, but its design is to deallocate memory or other resources held by that non-terminal.

    -

    Consider an example: +

    Consider an example:

        %type nt {void*}
        %destructor nt { free($$); }
        nt(A) ::= ID NUM.   { A = malloc( 100 ); }
     
    -This example is a bit contrived, but it serves to illustrate how +

    This example is a bit contrived, but it serves to illustrate how destructors work. The example shows a non-terminal named "nt" that holds values of type "void*". When the rule for an "nt" reduces, it sets the value of the non-terminal to @@ -670,18 +793,18 @@ allocated objects when they go out of scope. To do the same using yacc or bison is much more difficult.

    - -

    The %extra_argument directive

    + +

    4.4.5 The %extra_argument directive

    -The %extra_argument directive instructs Lemon to add a 4th parameter +

    The %extra_argument directive instructs Lemon to add a 4th parameter to the parameter list of the Parse() function it generates. Lemon doesn't do anything itself with this extra argument, but it does make the argument available to C-code action routines, destructors, and so forth. For example, if the grammar file contains:

    -

    +
         %extra_argument { MyStruct *pAbc }
    -

    +

    Then the Parse() function generated will have an 4th parameter of type "MyStruct*" and all action routines will have access to @@ -690,30 +813,30 @@

    The %extra_context directive works the same except that it is passed in on the ParseAlloc() or ParseInit() routines instead of -on Parse(). +on Parse().

    - -

    The %extra_context directive

    + +

    4.4.6 The %extra_context directive

    -The %extra_context directive instructs Lemon to add a 2nd parameter -to the parameter list of the ParseAlloc() and ParseInif() functions. Lemon +

    The %extra_context directive instructs Lemon to add a 2nd parameter +to the parameter list of the ParseAlloc() and ParseInit() functions. Lemon doesn't do anything itself with these extra argument, but it does store the value make it available to C-code action routines, destructors, and so forth. For example, if the grammar file contains:

    -

    +
         %extra_context { MyStruct *pAbc }
    -

    +

    Then the ParseAlloc() and ParseInit() functions will have an 2nd parameter of type "MyStruct*" and all action routines will have access to a variable named "pAbc" that is the value of that 2nd parameter.

    The %extra_argument directive works the same except that it -is passed in on the Parse() routine instead of on ParseAlloc()/ParseInit(). +is passed in on the Parse() routine instead of on ParseAlloc()/ParseInit().

    - -

    The %fallback directive

    + +

    4.4.7 The %fallback directive

    The %fallback directive specifies an alternative meaning for one or more tokens. The alternative meaning is tried if the original token @@ -729,7 +852,7 @@ provides a mechanism to tell the parser: "If you are unable to parse this keyword, try treating it as an identifier instead."

    -

    The syntax of %fallback is as follows: +

    The syntax of %fallback is as follows:

    %fallback ID TOKEN... . @@ -742,8 +865,8 @@ arguments are tokens which fall back to the token identified by the first argument.

    - -

    The %if directive and its friends

    + +

    4.4.8 The %if directive and its friends

    The %if, %ifdef, %ifndef, %else, and %endif directives @@ -773,8 +896,8 @@ intended to be a single preprocessor symbol name, not a general expression. Use the "%if" directive for general expressions.

    - -

    The %include directive

    + +

    4.4.9 The %include directive

    The %include directive specifies C code that is included at the top of the generated parser. You can include any text you want — @@ -787,9 +910,9 @@ preprocessor statements at the beginning of the generated parser. For example:

    -

    +
        %include {#include <unistd.h>}
    -

    +

    This might be needed, for example, if some of the C actions in the grammar call functions that are prototyped in unistd.h.

    @@ -797,8 +920,8 @@

    Use the %code directive to add code to the end of the generated parser.

    - -

    The %left directive

    + +

    4.4.10 The %left directive

    The %left directive is used (along with the %right and @@ -809,14 +932,14 @@ given the same left-associative precedence value. Subsequent %left directives have higher precedence. For example:

    -

    +
        %left AND.
        %left OR.
        %nonassoc EQ NE GT GE LT LE.
        %left PLUS MINUS.
        %left TIMES DIVIDE MOD.
        %right EXP NOT.
    -

    +

    Note the period that terminates each %left, %right or %nonassoc @@ -827,30 +950,30 @@ operators. For this reason, it is recommended that you use %left rather than %right whenever possible.

    - -

    The %name directive

    + +

    4.4.11 The %name directive

    By default, the functions generated by Lemon all begin with the five-character string "Parse". You can change this string to something different using the %name directive. For instance:

    -

    +
        %name Abcde
    -

    +

    Putting this directive in the grammar file will cause Lemon to generate -functions named +functions named

    • AbcdeAlloc(),
    • AbcdeFree(),
    • AbcdeTrace(), and
    • Abcde().
    -The %name directive allows you to generate two or more different +

    The %name directive allows you to generate two or more different parsers and link them all into the same executable.

    - -

    The %nonassoc directive

    + +

    4.4.12 The %nonassoc directive

    This directive is used to assign non-associative precedence to one or more terminal symbols. See the section on @@ -858,8 +981,8 @@ or on the %left directive for additional information.

    - -

    The %parse_accept directive

    + +

    4.4.13 The %parse_accept directive

    The %parse_accept directive specifies a block of C code that is executed whenever the parser accepts its input string. To "accept" @@ -868,14 +991,14 @@

    For example:

    -

    +
        %parse_accept {
           printf("parsing complete!\n");
        }
    -

    +
    - -

    The %parse_failure directive

    + +

    4.4.14 The %parse_failure directive

    The %parse_failure directive specifies a block of C code that is executed whenever the parser fails complete. This code is not @@ -883,51 +1006,51 @@ error using is usual error recovery strategy. The routine is only invoked when parsing is unable to continue.

    -

    +
        %parse_failure {
          fprintf(stderr,"Giving up.  Parser is hopelessly lost...\n");
        }
    -

    +
    - -

    The %right directive

    + +

    4.4.15 The %right directive

    This directive is used to assign right-associative precedence to one or more terminal symbols. See the section on precedence rules or on the %left directive for additional information.

    - -

    The %stack_overflow directive

    + +

    4.4.16 The %stack_overflow directive

    The %stack_overflow directive specifies a block of C code that is executed if the parser's internal stack ever overflows. Typically this just prints an error message. After a stack overflow, the parser will be unable to continue and must be reset.

    -

    +
        %stack_overflow {
          fprintf(stderr,"Giving up.  Parser stack overflow\n");
        }
    -

    +

    You can help prevent parser stack overflows by avoiding the use of right recursion and right-precedence operators in your grammar. Use left recursion and and left-precedence operators instead to encourage rules to reduce sooner and keep the stack size down. -For example, do rules like this: +For example, do rules like this:

        list ::= list element.      // left-recursion.  Good!
        list ::= .
     
    -Not like this: +

    Not like this:

        list ::= element list.      // right-recursion.  Bad!
        list ::= .
    -

    + - -

    The %stack_size directive

    + +

    4.4.17 The %stack_size directive

    If stack overflow is a problem and you can't resolve the trouble by using left-recursion, then you might want to increase the size @@ -935,35 +1058,35 @@ after the %stack_size directive and Lemon will generate a parse with a stack of the requested size. The default value is 100.

    -

    +
        %stack_size 2000
    -

    +
    - -

    The %start_symbol directive

    + +

    4.4.18 The %start_symbol directive

    By default, the start symbol for the grammar that Lemon generates is the first non-terminal that appears in the grammar file. But you can choose a different start symbol using the %start_symbol directive.

    -

    +
        %start_symbol  prog
    -

    +
    - -

    The %syntax_error directive

    + +

    4.4.19 The %syntax_error directive

    See Error Processing.

    - -

    The %token_class directive

    + +

    4.4.20 The %token_class directive

    Undocumented. Appears to be related to the MULTITERMINAL concept. Implementation.

    - -

    The %token_destructor directive

    + +

    4.4.21 The %token_destructor directive

    The %destructor directive assigns a destructor to a non-terminal symbol. (See the description of the @@ -971,42 +1094,42 @@ The %token_destructor directive does the same thing for all terminal symbols.

    -

    Unlike non-terminal symbols which may each have a different data type +

    Unlike non-terminal symbols, which may each have a different data type for their values, terminals all use the same data type (defined by the %token_type directive) and so they use a common destructor. Other than that, the token destructor works just like the non-terminal destructors.

    - -

    The %token_prefix directive

    + +

    4.4.22 The %token_prefix directive

    Lemon generates #defines that assign small integer constants to each terminal symbol in the grammar. If desired, Lemon will add a prefix specified by this directive to each of the #defines it generates.

    -

    So if the default output of Lemon looked like this: +

    So if the default output of Lemon looked like this:

         #define AND              1
         #define MINUS            2
         #define OR               3
         #define PLUS             4
     
    -You can insert a statement into the grammar like this: +

    You can insert a statement into the grammar like this:

         %token_prefix    TOKEN_
     
    -to cause Lemon to produce these symbols instead: +

    to cause Lemon to produce these symbols instead:

         #define TOKEN_AND        1
         #define TOKEN_MINUS      2
         #define TOKEN_OR         3
         #define TOKEN_PLUS       4
    -

    + - -

    The %token_type and %type directives

    + +

    4.4.23 The %token_type and %type directives

    These directives are used to specify the data types for values on the parser's stack associated with terminal and non-terminal @@ -1016,9 +1139,9 @@ make the value of a terminal symbol be a pointer to some kind of token structure. Like this:

    -

    +
        %token_type    {Token*}
    -

    +

    If the data type of terminals is not specified, the default value is "void*".

    @@ -1028,9 +1151,9 @@ structure that contains all information about that non-terminal. For example:

    -

    +
        %type   expr  {Expr*}
    -

    +

    Each entry on the parser's stack is actually a union containing instances of all data types for every non-terminal and terminal symbol. @@ -1042,8 +1165,8 @@ entry parser stack will require 100K of heap space. If you are willing and able to pay that price, fine. You just need to know.

    - -

    The %wildcard directive

    + +

    4.4.24 The %wildcard directive

    The %wildcard directive is followed by a single token name and a period. This directive specifies that the identified token should @@ -1053,8 +1176,8 @@ the wildcard token and some other token, the other token is always used. The wildcard token is only matched if there are no alternatives.

    - -

    Error Processing

    + +

    5.0 Error Processing

    After extensive experimentation over several years, it has been discovered that the error recovery strategy used by yacc is about @@ -1077,5 +1200,41 @@ first syntax error, of course, if there are no instances of the "error" non-terminal in your grammar.

    + +

    6.0 History of Lemon

    + +

    Lemon was originally written by Richard Hipp sometime in the late +1980s on a Sun4 Workstation using K&R C. +There was a companion LL(1) parser generator program named "Lime", the +source code to which as been lost.

    + +

    The lemon.c source file was originally many separate files that were +compiled together to generate the "lemon" executable. Sometime in the +1990s, the individual source code files were combined together into +the current single large "lemon.c" source file. You can still see traces +of original filenames in the code.

    + +

    Since 2001, Lemon has been part of the +SQLite project and the source code +to Lemon has been managed as a part of the +SQLite source tree in the following +files:

    + + + + +

    7.0 Copyright

    + +

    All of the source code to Lemon, including the template parser file +"lempar.c" and this documentation file ("lemon.html") are in the public +domain. You can use the code for any purpose and without attribution.

    + +

    The code comes with no warranty. If it breaks, you get to keep both +pieces.

    + diff -Nru sqlite3-3.33.0/doc/vdbesort-memory.md sqlite3-3.34.0/doc/vdbesort-memory.md --- sqlite3-3.33.0/doc/vdbesort-memory.md 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/doc/vdbesort-memory.md 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,49 @@ + +20-11-2020 + +# Memory Allocation In vdbesort.c + +Memory allocation is slightly different depending on: + + * whether or not SQLITE_CONFIG_SMALL_MALLOC is set, and + * whether or not worker threads are enabled. + +## SQLITE_CONFIG_SMALL_MALLOC=0 + +Assuming SQLITE_CONFIG_SMALL_MALLOC is not set, keys passed to the sorter are +added to an in-memory buffer. This buffer is grown using sqlite3Realloc() as +required it reaches the size configured for the main pager cache using "PRAGMA +cache_size". i.e. if the user has executed "PRAGMA main.cache_size = -2048", +then this buffer is allowed to grow up to 2MB in size. + +Once the buffer has grown to its threshold, keys are sorted and written to +a temp file. If worker threads are not enabled, this is the only significant +allocation the sorter module makes. After keys are sorted and flushed out to +the temp file, the buffer is reused to accumulate the next batch of keys. + +If worker threads are available, then the buffer is passed to a worker thread +to sort and flush once it is full, and a new buffer allocated to allow the +main thread to continue to accumulate keys. Buffers are reused once they +have been flushed, so in this case at most (nWorker+1) buffers are allocated +and used, where nWorker is the number of configured worker threads. + +There are no other significant users of heap memory in the sorter module. +Once sorted buffers of keys have been flushed to disk, they are read back +either by mapping the file (via sqlite3_file.xFetch()) or else read back +in one page at a time. + +All buffers are allocated by the main thread. A sorter object is associated +with a single database connection, to which it holds a pointer. + +## SQLITE_CONFIG_SMALL_MALLOC=1 + +This case is similar to the above, except that instead of accumulating +multiple keys in a single large buffer, sqlite3VdbeSorterWrite() stores +keys in a regular heap-memory linked list (one allocation per element). +List elements are freed as they are flushed to disk, either by the main +thread or by a worker thread. + +Each time a key is added the sorter (and an allocation made), +sqlite3HeapNearlyFull() is called. If it returns true, the current +list of keys is flushed to a temporary file, even if it has not yet +reached the size threshold. diff -Nru sqlite3-3.33.0/ext/expert/expert1.test sqlite3-3.34.0/ext/expert/expert1.test --- sqlite3-3.33.0/ext/expert/expert1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/expert/expert1.test 2020-12-01 16:36:02.000000000 +0000 @@ -326,6 +326,47 @@ SCAN TABLE t1 } +do_setup_rec_test $tn.17.1 { + CREATE TABLE example (A INTEGER, B INTEGER, C INTEGER, PRIMARY KEY (A,B)); +} { + SELECT * FROM example WHERE a=? +} { + (no new indexes) + SEARCH TABLE example USING INDEX sqlite_autoindex_example_1 (A=?) +} +do_setup_rec_test $tn.17.2 { + CREATE TABLE example (A INTEGER, B INTEGER, C INTEGER, PRIMARY KEY (A,B)); +} { + SELECT * FROM example WHERE b=? +} { + CREATE INDEX example_idx_00000042 ON example(B); + SEARCH TABLE example USING INDEX example_idx_00000042 (B=?) +} +do_setup_rec_test $tn.17.3 { + CREATE TABLE example (A INTEGER, B INTEGER, C INTEGER, PRIMARY KEY (A,B)); +} { + SELECT * FROM example WHERE a=? AND b=? +} { + (no new indexes) + SEARCH TABLE example USING INDEX sqlite_autoindex_example_1 (A=? AND B=?) +} +do_setup_rec_test $tn.17.4 { + CREATE TABLE example (A INTEGER, B INTEGER, C INTEGER, PRIMARY KEY (A,B)); +} { + SELECT * FROM example WHERE a=? AND b>? +} { + (no new indexes) + SEARCH TABLE example USING INDEX sqlite_autoindex_example_1 (A=? AND B>?) +} +do_setup_rec_test $tn.17.5 { + CREATE TABLE example (A INTEGER, B INTEGER, C INTEGER, PRIMARY KEY (A,B)); +} { + SELECT * FROM example WHERE a>? AND b=? +} { + CREATE INDEX example_idx_0000cb3f ON example(B, A); + SEARCH TABLE example USING INDEX example_idx_0000cb3f (B=? AND A>?) +} + } proc do_candidates_test {tn sql res} { diff -Nru sqlite3-3.33.0/ext/expert/sqlite3expert.c sqlite3-3.34.0/ext/expert/sqlite3expert.c --- sqlite3-3.33.0/ext/expert/sqlite3expert.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/expert/sqlite3expert.c 2020-12-01 16:36:02.000000000 +0000 @@ -685,6 +685,7 @@ IdxTable *pNew = 0; int rc, rc2; char *pCsr = 0; + int nPk = 0; rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_info=%Q", zTab); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){ @@ -695,6 +696,7 @@ ); nByte += 1 + STRLEN(zCol); nCol++; + nPk += (sqlite3_column_int(p1, 5)>0); } rc2 = sqlite3_reset(p1); if( rc==SQLITE_OK ) rc = rc2; @@ -714,7 +716,7 @@ const char *zCol = (const char*)sqlite3_column_text(p1, 1); int nCopy = STRLEN(zCol) + 1; pNew->aCol[nCol].zName = pCsr; - pNew->aCol[nCol].iPk = sqlite3_column_int(p1, 5); + pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1); memcpy(pCsr, zCol, nCopy); pCsr += nCopy; diff -Nru sqlite3-3.33.0/ext/fts3/unicode/mkunicode.tcl sqlite3-3.34.0/ext/fts3/unicode/mkunicode.tcl --- sqlite3-3.33.0/ext/fts3/unicode/mkunicode.tcl 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts3/unicode/mkunicode.tcl 2020-12-01 16:36:02.000000000 +0000 @@ -742,6 +742,7 @@ } iTbl++; } + aAscii[0] = 0; /* 0x00 is never a token character */ } }] } diff -Nru sqlite3-3.33.0/ext/fts5/fts5_aux.c sqlite3-3.34.0/ext/fts5/fts5_aux.c --- sqlite3-3.33.0/ext/fts5/fts5_aux.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_aux.c 2020-12-01 16:36:02.000000000 +0000 @@ -566,7 +566,7 @@ int rc = SQLITE_OK; /* Return code */ Fts5Bm25Data *p; /* Object to return */ - p = pApi->xGetAuxdata(pFts, 0); + p = (Fts5Bm25Data*)pApi->xGetAuxdata(pFts, 0); if( p==0 ){ int nPhrase; /* Number of phrases in query */ sqlite3_int64 nRow = 0; /* Number of rows in table */ @@ -640,7 +640,7 @@ ){ const double k1 = 1.2; /* Constant "k1" from BM25 formula */ const double b = 0.75; /* Constant "b" from BM25 formula */ - int rc = SQLITE_OK; /* Error code */ + int rc; /* Error code */ double score = 0.0; /* SQL function return value */ Fts5Bm25Data *pData; /* Values allocated/calculated once only */ int i; /* Iterator variable */ @@ -672,17 +672,15 @@ D = (double)nTok; } - /* Determine the BM25 score for the current row. */ - for(i=0; rc==SQLITE_OK && inPhrase; i++){ - score += pData->aIDF[i] * ( - ( aFreq[i] * (k1 + 1.0) ) / - ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) ) - ); - } - - /* If no error has occurred, return the calculated score. Otherwise, - ** throw an SQL exception. */ + /* Determine and return the BM25 score for the current row. Or, if an + ** error has occurred, throw an exception. */ if( rc==SQLITE_OK ){ + for(i=0; inPhrase; i++){ + score += pData->aIDF[i] * ( + ( aFreq[i] * (k1 + 1.0) ) / + ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) ) + ); + } sqlite3_result_double(pCtx, -1.0 * score); }else{ sqlite3_result_error_code(pCtx, rc); diff -Nru sqlite3-3.33.0/ext/fts5/fts5_config.c sqlite3-3.34.0/ext/fts5/fts5_config.c --- sqlite3-3.33.0/ext/fts5/fts5_config.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_config.c 2020-12-01 16:36:02.000000000 +0000 @@ -325,7 +325,7 @@ rc = SQLITE_ERROR; }else{ rc = sqlite3Fts5GetTokenizer(pGlobal, - (const char**)azArg, (int)nArg, &pConfig->pTok, &pConfig->pTokApi, + (const char**)azArg, (int)nArg, pConfig, pzErr ); } @@ -397,9 +397,7 @@ */ static int fts5ConfigDefaultTokenizer(Fts5Global *pGlobal, Fts5Config *pConfig){ assert( pConfig->pTok==0 && pConfig->pTokApi==0 ); - return sqlite3Fts5GetTokenizer( - pGlobal, 0, 0, &pConfig->pTok, &pConfig->pTokApi, 0 - ); + return sqlite3Fts5GetTokenizer(pGlobal, 0, 0, pConfig, 0); } /* diff -Nru sqlite3-3.33.0/ext/fts5/fts5_expr.c sqlite3-3.34.0/ext/fts5/fts5_expr.c --- sqlite3-3.33.0/ext/fts5/fts5_expr.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_expr.c 2020-12-01 16:36:02.000000000 +0000 @@ -128,6 +128,7 @@ int nPhrase; /* Size of apPhrase array */ Fts5ExprPhrase **apPhrase; /* Array of all phrases */ Fts5ExprNode *pExpr; /* Result of a successful parse */ + int bPhraseToAnd; /* Convert "a+b" to "a AND b" */ }; void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){ @@ -216,6 +217,7 @@ int sqlite3Fts5ExprNew( Fts5Config *pConfig, /* FTS5 Configuration */ + int bPhraseToAnd, int iCol, const char *zExpr, /* Expression text */ Fts5Expr **ppNew, @@ -231,6 +233,7 @@ *ppNew = 0; *pzErr = 0; memset(&sParse, 0, sizeof(sParse)); + sParse.bPhraseToAnd = bPhraseToAnd; pEngine = sqlite3Fts5ParserAlloc(fts5ParseAlloc); if( pEngine==0 ){ return SQLITE_NOMEM; } sParse.pConfig = pConfig; @@ -273,6 +276,7 @@ pNew->pConfig = pConfig; pNew->apExprPhrase = sParse.apPhrase; pNew->nPhrase = sParse.nPhrase; + pNew->bDesc = 0; sParse.apPhrase = 0; } }else{ @@ -285,6 +289,81 @@ } /* +** This function is only called when using the special 'trigram' tokenizer. +** Argument zText contains the text of a LIKE or GLOB pattern matched +** against column iCol. This function creates and compiles an FTS5 MATCH +** expression that will match a superset of the rows matched by the LIKE or +** GLOB. If successful, SQLITE_OK is returned. Otherwise, an SQLite error +** code. +*/ +int sqlite3Fts5ExprPattern( + Fts5Config *pConfig, int bGlob, int iCol, const char *zText, Fts5Expr **pp +){ + i64 nText = strlen(zText); + char *zExpr = (char*)sqlite3_malloc64(nText*4 + 1); + int rc = SQLITE_OK; + + if( zExpr==0 ){ + rc = SQLITE_NOMEM; + }else{ + char aSpec[3]; + int iOut = 0; + int i = 0; + int iFirst = 0; + + if( bGlob==0 ){ + aSpec[0] = '_'; + aSpec[1] = '%'; + aSpec[2] = 0; + }else{ + aSpec[0] = '*'; + aSpec[1] = '?'; + aSpec[2] = '['; + } + + while( i<=nText ){ + if( i==nText + || zText[i]==aSpec[0] || zText[i]==aSpec[1] || zText[i]==aSpec[2] + ){ + if( i-iFirst>=3 ){ + int jj; + zExpr[iOut++] = '"'; + for(jj=iFirst; jj0 ){ + int bAnd = 0; + if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ + bAnd = 1; + if( pConfig->eDetail==FTS5_DETAIL_NONE ){ + iCol = pConfig->nCol; + } + } + zExpr[iOut] = '\0'; + rc = sqlite3Fts5ExprNew(pConfig, bAnd, iCol, zExpr, pp,pConfig->pzErrmsg); + }else{ + *pp = 0; + } + sqlite3_free(zExpr); + } + + return rc; +} + +/* ** Free the expression node object passed as the only argument. */ void sqlite3Fts5ParseNodeFree(Fts5ExprNode *p){ @@ -1661,6 +1740,20 @@ pParse->pExpr = p; } +static int parseGrowPhraseArray(Fts5Parse *pParse){ + if( (pParse->nPhrase % 8)==0 ){ + sqlite3_int64 nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8); + Fts5ExprPhrase **apNew; + apNew = (Fts5ExprPhrase**)sqlite3_realloc64(pParse->apPhrase, nByte); + if( apNew==0 ){ + pParse->rc = SQLITE_NOMEM; + return SQLITE_NOMEM; + } + pParse->apPhrase = apNew; + } + return SQLITE_OK; +} + /* ** This function is called by the parser to process a string token. The ** string may or may not be quoted. In any case it is tokenized and a @@ -1696,16 +1789,9 @@ }else{ if( pAppend==0 ){ - if( (pParse->nPhrase % 8)==0 ){ - sqlite3_int64 nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8); - Fts5ExprPhrase **apNew; - apNew = (Fts5ExprPhrase**)sqlite3_realloc64(pParse->apPhrase, nByte); - if( apNew==0 ){ - pParse->rc = SQLITE_NOMEM; - fts5ExprPhraseFree(sCtx.pPhrase); - return 0; - } - pParse->apPhrase = apNew; + if( parseGrowPhraseArray(pParse) ){ + fts5ExprPhraseFree(sCtx.pPhrase); + return 0; } pParse->nPhrase++; } @@ -2113,6 +2199,67 @@ } /* +** This function is used when parsing LIKE or GLOB patterns against +** trigram indexes that specify either detail=column or detail=none. +** It converts a phrase: +** +** abc + def + ghi +** +** into an AND tree: +** +** abc AND def AND ghi +*/ +static Fts5ExprNode *fts5ParsePhraseToAnd( + Fts5Parse *pParse, + Fts5ExprNearset *pNear +){ + int nTerm = pNear->apPhrase[0]->nTerm; + int ii; + int nByte; + Fts5ExprNode *pRet; + + assert( pNear->nPhrase==1 ); + assert( pParse->bPhraseToAnd ); + + nByte = sizeof(Fts5ExprNode) + nTerm*sizeof(Fts5ExprNode*); + pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte); + if( pRet ){ + pRet->eType = FTS5_AND; + pRet->nChild = nTerm; + fts5ExprAssignXNext(pRet); + pParse->nPhrase--; + for(ii=0; iirc, sizeof(Fts5ExprPhrase) + ); + if( pPhrase ){ + if( parseGrowPhraseArray(pParse) ){ + fts5ExprPhraseFree(pPhrase); + }else{ + pParse->apPhrase[pParse->nPhrase++] = pPhrase; + pPhrase->nTerm = 1; + pPhrase->aTerm[0].zTerm = sqlite3Fts5Strndup( + &pParse->rc, pNear->apPhrase[0]->aTerm[ii].zTerm, -1 + ); + pRet->apChild[ii] = sqlite3Fts5ParseNode(pParse, FTS5_STRING, + 0, 0, sqlite3Fts5ParseNearset(pParse, 0, pPhrase) + ); + } + } + } + + if( pParse->rc ){ + sqlite3Fts5ParseNodeFree(pRet); + pRet = 0; + }else{ + sqlite3Fts5ParseNearsetFree(pNear); + } + } + + return pRet; +} + +/* ** Allocate and return a new expression object. If anything goes wrong (i.e. ** OOM error), leave an error code in pParse and return NULL. */ @@ -2136,51 +2283,58 @@ if( eType!=FTS5_STRING && pLeft==0 ) return pRight; if( eType!=FTS5_STRING && pRight==0 ) return pLeft; - if( eType==FTS5_NOT ){ - nChild = 2; - }else if( eType==FTS5_AND || eType==FTS5_OR ){ - nChild = 2; - if( pLeft->eType==eType ) nChild += pLeft->nChild-1; - if( pRight->eType==eType ) nChild += pRight->nChild-1; - } - - nByte = sizeof(Fts5ExprNode) + sizeof(Fts5ExprNode*)*(nChild-1); - pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte); - - if( pRet ){ - pRet->eType = eType; - pRet->pNear = pNear; - fts5ExprAssignXNext(pRet); - if( eType==FTS5_STRING ){ - int iPhrase; - for(iPhrase=0; iPhrasenPhrase; iPhrase++){ - pNear->apPhrase[iPhrase]->pNode = pRet; - if( pNear->apPhrase[iPhrase]->nTerm==0 ){ - pRet->xNext = 0; - pRet->eType = FTS5_EOF; + if( eType==FTS5_STRING + && pParse->bPhraseToAnd + && pNear->apPhrase[0]->nTerm>1 + ){ + pRet = fts5ParsePhraseToAnd(pParse, pNear); + }else{ + if( eType==FTS5_NOT ){ + nChild = 2; + }else if( eType==FTS5_AND || eType==FTS5_OR ){ + nChild = 2; + if( pLeft->eType==eType ) nChild += pLeft->nChild-1; + if( pRight->eType==eType ) nChild += pRight->nChild-1; + } + + nByte = sizeof(Fts5ExprNode) + sizeof(Fts5ExprNode*)*(nChild-1); + pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte); + + if( pRet ){ + pRet->eType = eType; + pRet->pNear = pNear; + fts5ExprAssignXNext(pRet); + if( eType==FTS5_STRING ){ + int iPhrase; + for(iPhrase=0; iPhrasenPhrase; iPhrase++){ + pNear->apPhrase[iPhrase]->pNode = pRet; + if( pNear->apPhrase[iPhrase]->nTerm==0 ){ + pRet->xNext = 0; + pRet->eType = FTS5_EOF; + } } - } - if( pParse->pConfig->eDetail!=FTS5_DETAIL_FULL ){ - Fts5ExprPhrase *pPhrase = pNear->apPhrase[0]; - if( pNear->nPhrase!=1 - || pPhrase->nTerm>1 - || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst) - ){ - assert( pParse->rc==SQLITE_OK ); - pParse->rc = SQLITE_ERROR; - assert( pParse->zErr==0 ); - pParse->zErr = sqlite3_mprintf( - "fts5: %s queries are not supported (detail!=full)", - pNear->nPhrase==1 ? "phrase": "NEAR" - ); - sqlite3_free(pRet); - pRet = 0; + if( pParse->pConfig->eDetail!=FTS5_DETAIL_FULL ){ + Fts5ExprPhrase *pPhrase = pNear->apPhrase[0]; + if( pNear->nPhrase!=1 + || pPhrase->nTerm>1 + || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst) + ){ + assert( pParse->rc==SQLITE_OK ); + pParse->rc = SQLITE_ERROR; + assert( pParse->zErr==0 ); + pParse->zErr = sqlite3_mprintf( + "fts5: %s queries are not supported (detail!=full)", + pNear->nPhrase==1 ? "phrase": "NEAR" + ); + sqlite3_free(pRet); + pRet = 0; + } } + }else{ + fts5ExprAddChildren(pRet, pLeft); + fts5ExprAddChildren(pRet, pRight); } - }else{ - fts5ExprAddChildren(pRet, pLeft); - fts5ExprAddChildren(pRet, pRight); } } } @@ -2401,8 +2555,17 @@ int iTerm; if( pNear->pColset ){ - int iCol = pNear->pColset->aiCol[0]; - zRet = fts5PrintfAppend(zRet, "%s : ", pConfig->azCol[iCol]); + int ii; + Fts5Colset *pColset = pNear->pColset; + if( pColset->nCol>1 ) zRet = fts5PrintfAppend(zRet, "{"); + for(ii=0; iinCol; ii++){ + zRet = fts5PrintfAppend(zRet, "%s%s", + pConfig->azCol[pColset->aiCol[ii]], ii==pColset->nCol-1 ? "" : " " + ); + } + if( zRet ){ + zRet = fts5PrintfAppend(zRet, "%s : ", pColset->nCol>1 ? "}" : ""); + } if( zRet==0 ) return 0; } @@ -2525,7 +2688,7 @@ rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr); + rc = sqlite3Fts5ExprNew(pConfig, 0, pConfig->nCol, zExpr, &pExpr, &zErr); } if( rc==SQLITE_OK ){ char *zText; diff -Nru sqlite3-3.33.0/ext/fts5/fts5_hash.c sqlite3-3.34.0/ext/fts5/fts5_hash.c --- sqlite3-3.33.0/ext/fts5/fts5_hash.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_hash.c 2020-12-01 16:36:02.000000000 +0000 @@ -306,7 +306,6 @@ p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); } - nIncr += p->nData; }else{ /* Appending to an existing hash-entry. Check that there is enough @@ -339,8 +338,9 @@ /* If this is a new rowid, append the 4-byte size field for the previous ** entry, and the new rowid for this entry. */ if( iRowid!=p->iRowid ){ + u64 iDiff = (u64)iRowid - (u64)p->iRowid; fts5HashAddPoslistSize(pHash, p, 0); - p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid); + p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iDiff); p->iRowid = iRowid; bNew = 1; p->iSzPoslist = p->nData; diff -Nru sqlite3-3.33.0/ext/fts5/fts5_index.c sqlite3-3.34.0/ext/fts5/fts5_index.c --- sqlite3-3.33.0/ext/fts5/fts5_index.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_index.c 2020-12-01 16:36:02.000000000 +0000 @@ -1754,7 +1754,7 @@ ASSERT_SZLEAF_OK(pIter->pLeaf); while( 1 ){ - i64 iDelta = 0; + u64 iDelta = 0; if( eDetail==FTS5_DETAIL_NONE ){ /* todo */ @@ -1769,7 +1769,7 @@ i += nPos; } if( i>=n ) break; - i += fts5GetVarint(&a[i], (u64*)&iDelta); + i += fts5GetVarint(&a[i], &iDelta); pIter->iRowid += iDelta; /* If necessary, grow the pIter->aRowidOffset[] array. */ @@ -1868,7 +1868,7 @@ if( pIter->iRowidOffset>0 ){ u8 *a = pIter->pLeaf->p; int iOff; - i64 iDelta; + u64 iDelta; pIter->iRowidOffset--; pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset]; @@ -1877,7 +1877,7 @@ if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){ iOff += pIter->nPos; } - fts5GetVarint(&a[iOff], (u64*)&iDelta); + fts5GetVarint(&a[iOff], &iDelta); pIter->iRowid -= iDelta; }else{ fts5SegIterReverseNewPage(p, pIter); @@ -4997,7 +4997,9 @@ ** at most 20 bytes of unexpected space. */ fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid); fts5BufferZero(&tmp); - sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist + 10 + 10); + sqlite3Fts5BufferSize(&p->rc, &tmp, + i1.nPoslist + i2.nPoslist + 10 + 10 + FTS5_DATA_ZERO_PADDING + ); if( p->rc ) break; sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1); @@ -5071,9 +5073,10 @@ } assert_nc( out.n<=(p1->n+p2->n+9) ); - fts5BufferSet(&p->rc, p1, out.n, out.p); + fts5BufferFree(p1); fts5BufferFree(&tmp); - fts5BufferFree(&out); + memset(&out.p[out.n], 0, FTS5_DATA_ZERO_PADDING); + *p1 = out; } } @@ -6059,7 +6062,7 @@ ** error, or some other SQLite error code if another error (e.g. OOM) ** occurs. */ -int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ +int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum){ int eDetail = p->pConfig->eDetail; u64 cksum2 = 0; /* Checksum based on contents of indexes */ Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */ @@ -6120,6 +6123,7 @@ }else{ poslist.n = 0; fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist); + fts5BufferAppendBlob(&p->rc, &poslist, 4, (const u8*)"\0\0\0\0"); while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){ int iCol = FTS5_POS2COLUMN(iPos); int iTokOff = FTS5_POS2OFFSET(iPos); @@ -6130,7 +6134,7 @@ fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3); fts5MultiIterFree(pIter); - if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT; + if( p->rc==SQLITE_OK && bUseCksum && cksum!=cksum2 ) p->rc = FTS5_CORRUPT; fts5StructureRelease(pStruct); #ifdef SQLITE_DEBUG diff -Nru sqlite3-3.33.0/ext/fts5/fts5Int.h sqlite3-3.34.0/ext/fts5/fts5Int.h --- sqlite3-3.33.0/ext/fts5/fts5Int.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5Int.h 2020-12-01 16:36:02.000000000 +0000 @@ -184,6 +184,7 @@ Fts5Tokenizer *pTok; fts5_tokenizer *pTokApi; int bLock; /* True when table is preparing statement */ + int ePattern; /* FTS_PATTERN_XXX constant */ /* Values loaded from the %_config table */ int iCookie; /* Incremented when %_config is modified */ @@ -204,17 +205,19 @@ }; /* Current expected value of %_config table 'version' field */ -#define FTS5_CURRENT_VERSION 4 +#define FTS5_CURRENT_VERSION 4 #define FTS5_CONTENT_NORMAL 0 #define FTS5_CONTENT_NONE 1 #define FTS5_CONTENT_EXTERNAL 2 -#define FTS5_DETAIL_FULL 0 -#define FTS5_DETAIL_NONE 1 -#define FTS5_DETAIL_COLUMNS 2 - - +#define FTS5_DETAIL_FULL 0 +#define FTS5_DETAIL_NONE 1 +#define FTS5_DETAIL_COLUMNS 2 + +#define FTS5_PATTERN_NONE 0 +#define FTS5_PATTERN_LIKE 65 /* matches SQLITE_INDEX_CONSTRAINT_LIKE */ +#define FTS5_PATTERN_GLOB 66 /* matches SQLITE_INDEX_CONSTRAINT_GLOB */ int sqlite3Fts5ConfigParse( Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char** @@ -484,7 +487,7 @@ /* ** Functions called by the storage module as part of integrity-check. */ -int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum); +int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum, int bUseCksum); /* ** Called during virtual module initialization to register UDF @@ -554,8 +557,7 @@ Fts5Global*, const char **azArg, int nArg, - Fts5Tokenizer**, - fts5_tokenizer**, + Fts5Config*, char **pzErr ); @@ -639,7 +641,7 @@ int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); -int sqlite3Fts5StorageIntegrity(Fts5Storage *p); +int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg); int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**); void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*); @@ -684,11 +686,19 @@ /* Parse a MATCH expression. */ int sqlite3Fts5ExprNew( Fts5Config *pConfig, + int bPhraseToAnd, int iCol, /* Column on LHS of MATCH operator */ const char *zExpr, Fts5Expr **ppNew, char **pzErr ); +int sqlite3Fts5ExprPattern( + Fts5Config *pConfig, + int bGlob, + int iCol, + const char *zText, + Fts5Expr **pp +); /* ** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc); @@ -797,6 +807,10 @@ */ int sqlite3Fts5TokenizerInit(fts5_api*); +int sqlite3Fts5TokenizerPattern( + int (*xCreate)(void*, const char**, int, Fts5Tokenizer**), + Fts5Tokenizer *pTok +); /* ** End of interface to code in fts5_tokenizer.c. **************************************************************************/ diff -Nru sqlite3-3.33.0/ext/fts5/fts5_main.c sqlite3-3.34.0/ext/fts5/fts5_main.c --- sqlite3-3.33.0/ext/fts5/fts5_main.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_main.c 2020-12-01 16:36:02.000000000 +0000 @@ -464,6 +464,23 @@ #endif } +static int fts5UsePatternMatch( + Fts5Config *pConfig, + struct sqlite3_index_constraint *p +){ + assert( FTS5_PATTERN_GLOB==SQLITE_INDEX_CONSTRAINT_GLOB ); + assert( FTS5_PATTERN_LIKE==SQLITE_INDEX_CONSTRAINT_LIKE ); + if( pConfig->ePattern==FTS5_PATTERN_GLOB && p->op==FTS5_PATTERN_GLOB ){ + return 1; + } + if( pConfig->ePattern==FTS5_PATTERN_LIKE + && (p->op==FTS5_PATTERN_LIKE || p->op==FTS5_PATTERN_GLOB) + ){ + return 1; + } + return 0; +} + /* ** Implementation of the xBestIndex method for FTS5 tables. Within the ** WHERE constraint, it searches for the following: @@ -493,7 +510,9 @@ ** ** Match against table column: "m" ** Match against rank column: "r" -** Match against other column: "" +** Match against other column: "M" +** LIKE against other column: "L" +** GLOB against other column: "G" ** Equality constraint against the rowid: "=" ** A < or <= against the rowid: "<" ** A > or >= against the rowid: ">" @@ -554,7 +573,7 @@ return SQLITE_ERROR; } - idxStr = (char*)sqlite3_malloc(pInfo->nConstraint * 6 + 1); + idxStr = (char*)sqlite3_malloc(pInfo->nConstraint * 8 + 1); if( idxStr==0 ) return SQLITE_NOMEM; pInfo->idxStr = idxStr; pInfo->needToFreeIdxStr = 1; @@ -578,25 +597,29 @@ if( bSeenRank ) continue; idxStr[iIdxStr++] = 'r'; bSeenRank = 1; - }else{ + }else if( iCol>=0 ){ bSeenMatch = 1; - idxStr[iIdxStr++] = 'm'; - if( iColaConstraintUsage[i].argvIndex = ++iCons; pInfo->aConstraintUsage[i].omit = 1; } - } - else if( p->usable && bSeenEq==0 - && p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol<0 - ){ - idxStr[iIdxStr++] = '='; - bSeenEq = 1; - pInfo->aConstraintUsage[i].argvIndex = ++iCons; + }else if( p->usable ){ + if( iCol>=0 && iColop==FTS5_PATTERN_LIKE || p->op==FTS5_PATTERN_GLOB ); + idxStr[iIdxStr++] = p->op==FTS5_PATTERN_LIKE ? 'L' : 'G'; + sqlite3_snprintf(6, &idxStr[iIdxStr], "%d", iCol); + idxStr += strlen(&idxStr[iIdxStr]); + pInfo->aConstraintUsage[i].argvIndex = ++iCons; + assert( idxStr[iIdxStr]=='\0' ); + }else if( bSeenEq==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol<0 ){ + idxStr[iIdxStr++] = '='; + bSeenEq = 1; + pInfo->aConstraintUsage[i].argvIndex = ++iCons; + } } } @@ -1229,19 +1252,14 @@ case 'r': pRank = apVal[i]; break; - case 'm': { + case 'M': { const char *zText = (const char*)sqlite3_value_text(apVal[i]); if( zText==0 ) zText = ""; - - if( idxStr[iIdxStr]>='0' && idxStr[iIdxStr]<='9' ){ - iCol = 0; - do{ - iCol = iCol*10 + (idxStr[iIdxStr]-'0'); - iIdxStr++; - }while( idxStr[iIdxStr]>='0' && idxStr[iIdxStr]<='9' ); - }else{ - iCol = pConfig->nCol; - } + iCol = 0; + do{ + iCol = iCol*10 + (idxStr[iIdxStr]-'0'); + iIdxStr++; + }while( idxStr[iIdxStr]>='0' && idxStr[iIdxStr]<='9' ); if( zText[0]=='*' ){ /* The user has issued a query of the form "MATCH '*...'". This @@ -1251,7 +1269,7 @@ goto filter_out; }else{ char **pzErr = &pTab->p.base.zErrMsg; - rc = sqlite3Fts5ExprNew(pConfig, iCol, zText, &pExpr, pzErr); + rc = sqlite3Fts5ExprNew(pConfig, 0, iCol, zText, &pExpr, pzErr); if( rc==SQLITE_OK ){ rc = sqlite3Fts5ExprAnd(&pCsr->pExpr, pExpr); pExpr = 0; @@ -1261,6 +1279,25 @@ break; } + case 'L': + case 'G': { + int bGlob = (idxStr[iIdxStr-1]=='G'); + const char *zText = (const char*)sqlite3_value_text(apVal[i]); + iCol = 0; + do{ + iCol = iCol*10 + (idxStr[iIdxStr]-'0'); + iIdxStr++; + }while( idxStr[iIdxStr]>='0' && idxStr[iIdxStr]<='9' ); + if( zText ){ + rc = sqlite3Fts5ExprPattern(pConfig, bGlob, iCol, zText, &pExpr); + } + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5ExprAnd(&pCsr->pExpr, pExpr); + pExpr = 0; + } + if( rc!=SQLITE_OK ) goto filter_out; + break; + } case '=': pRowidEq = apVal[i]; break; @@ -1508,7 +1545,8 @@ int nMerge = sqlite3_value_int(pVal); rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge); }else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){ - rc = sqlite3Fts5StorageIntegrity(pTab->pStorage); + int iArg = sqlite3_value_int(pVal); + rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, iArg); #ifdef SQLITE_DEBUG }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ pConfig->bPrefixIndex = sqlite3_value_int(pVal); @@ -2671,8 +2709,7 @@ Fts5Global *pGlobal, const char **azArg, int nArg, - Fts5Tokenizer **ppTok, - fts5_tokenizer **ppTokApi, + Fts5Config *pConfig, char **pzErr ){ Fts5TokenizerModule *pMod; @@ -2684,16 +2721,22 @@ rc = SQLITE_ERROR; *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); }else{ - rc = pMod->x.xCreate(pMod->pUserData, &azArg[1], (nArg?nArg-1:0), ppTok); - *ppTokApi = &pMod->x; - if( rc!=SQLITE_OK && pzErr ){ - *pzErr = sqlite3_mprintf("error in tokenizer constructor"); + rc = pMod->x.xCreate( + pMod->pUserData, &azArg[1], (nArg?nArg-1:0), &pConfig->pTok + ); + pConfig->pTokApi = &pMod->x; + if( rc!=SQLITE_OK ){ + if( pzErr ) *pzErr = sqlite3_mprintf("error in tokenizer constructor"); + }else{ + pConfig->ePattern = sqlite3Fts5TokenizerPattern( + pMod->x.xCreate, pConfig->pTok + ); } } if( rc!=SQLITE_OK ){ - *ppTokApi = 0; - *ppTok = 0; + pConfig->pTokApi = 0; + pConfig->pTok = 0; } return rc; diff -Nru sqlite3-3.33.0/ext/fts5/fts5_storage.c sqlite3-3.34.0/ext/fts5/fts5_storage.c --- sqlite3-3.33.0/ext/fts5/fts5_storage.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_storage.c 2020-12-01 16:36:02.000000000 +0000 @@ -429,9 +429,16 @@ zText, nText, (void*)&ctx, fts5StorageInsertCallback ); p->aTotalSize[iCol-1] -= (i64)ctx.szCol; + if( p->aTotalSize[iCol-1]<0 ){ + rc = FTS5_CORRUPT; + } } } - p->nTotalRow--; + if( rc==SQLITE_OK && p->nTotalRow<1 ){ + rc = FTS5_CORRUPT; + }else{ + p->nTotalRow--; + } rc2 = sqlite3_reset(pSeek); if( rc==SQLITE_OK ) rc = rc2; @@ -874,13 +881,14 @@ ** some other SQLite error code if an error occurs while attempting to ** determine this. */ -int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ +int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg){ Fts5Config *pConfig = p->pConfig; - int rc; /* Return code */ + int rc = SQLITE_OK; /* Return code */ int *aColSize; /* Array of size pConfig->nCol */ i64 *aTotalSize; /* Array of size pConfig->nCol */ Fts5IntegrityCtx ctx; sqlite3_stmt *pScan; + int bUseCksum; memset(&ctx, 0, sizeof(Fts5IntegrityCtx)); ctx.pConfig = p->pConfig; @@ -889,83 +897,88 @@ aColSize = (int*)&aTotalSize[pConfig->nCol]; memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol); - /* Generate the expected index checksum based on the contents of the - ** %_content table. This block stores the checksum in ctx.cksum. */ - rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0); - if( rc==SQLITE_OK ){ - int rc2; - while( SQLITE_ROW==sqlite3_step(pScan) ){ - int i; - ctx.iRowid = sqlite3_column_int64(pScan, 0); - ctx.szCol = 0; - if( pConfig->bColumnsize ){ - rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize); - } - if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){ - rc = sqlite3Fts5TermsetNew(&ctx.pTermset); - } - for(i=0; rc==SQLITE_OK && inCol; i++){ - if( pConfig->abUnindexed[i] ) continue; - ctx.iCol = i; + bUseCksum = (pConfig->eContent==FTS5_CONTENT_NORMAL + || (pConfig->eContent==FTS5_CONTENT_EXTERNAL && iArg) + ); + if( bUseCksum ){ + /* Generate the expected index checksum based on the contents of the + ** %_content table. This block stores the checksum in ctx.cksum. */ + rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0); + if( rc==SQLITE_OK ){ + int rc2; + while( SQLITE_ROW==sqlite3_step(pScan) ){ + int i; + ctx.iRowid = sqlite3_column_int64(pScan, 0); ctx.szCol = 0; - if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ - rc = sqlite3Fts5TermsetNew(&ctx.pTermset); + if( pConfig->bColumnsize ){ + rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize); } - if( rc==SQLITE_OK ){ - const char *zText = (const char*)sqlite3_column_text(pScan, i+1); - int nText = sqlite3_column_bytes(pScan, i+1); - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - zText, nText, - (void*)&ctx, - fts5StorageIntegrityCallback - ); - } - if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ - rc = FTS5_CORRUPT; + if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){ + rc = sqlite3Fts5TermsetNew(&ctx.pTermset); } - aTotalSize[i] += ctx.szCol; - if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ - sqlite3Fts5TermsetFree(ctx.pTermset); - ctx.pTermset = 0; + for(i=0; rc==SQLITE_OK && inCol; i++){ + if( pConfig->abUnindexed[i] ) continue; + ctx.iCol = i; + ctx.szCol = 0; + if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ + rc = sqlite3Fts5TermsetNew(&ctx.pTermset); + } + if( rc==SQLITE_OK ){ + const char *zText = (const char*)sqlite3_column_text(pScan, i+1); + int nText = sqlite3_column_bytes(pScan, i+1); + rc = sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, + zText, nText, + (void*)&ctx, + fts5StorageIntegrityCallback + ); + } + if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ + rc = FTS5_CORRUPT; + } + aTotalSize[i] += ctx.szCol; + if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ + sqlite3Fts5TermsetFree(ctx.pTermset); + ctx.pTermset = 0; + } } + sqlite3Fts5TermsetFree(ctx.pTermset); + ctx.pTermset = 0; + + if( rc!=SQLITE_OK ) break; } - sqlite3Fts5TermsetFree(ctx.pTermset); - ctx.pTermset = 0; - - if( rc!=SQLITE_OK ) break; + rc2 = sqlite3_reset(pScan); + if( rc==SQLITE_OK ) rc = rc2; } - rc2 = sqlite3_reset(pScan); - if( rc==SQLITE_OK ) rc = rc2; - } - /* Test that the "totals" (sometimes called "averages") record looks Ok */ - if( rc==SQLITE_OK ){ - int i; - rc = fts5StorageLoadTotals(p, 0); - for(i=0; rc==SQLITE_OK && inCol; i++){ - if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT; + /* Test that the "totals" (sometimes called "averages") record looks Ok */ + if( rc==SQLITE_OK ){ + int i; + rc = fts5StorageLoadTotals(p, 0); + for(i=0; rc==SQLITE_OK && inCol; i++){ + if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT; + } } - } - /* Check that the %_docsize and %_content tables contain the expected - ** number of rows. */ - if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ - i64 nRow = 0; - rc = fts5StorageCount(p, "content", &nRow); - if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT; - } - if( rc==SQLITE_OK && pConfig->bColumnsize ){ - i64 nRow = 0; - rc = fts5StorageCount(p, "docsize", &nRow); - if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT; + /* Check that the %_docsize and %_content tables contain the expected + ** number of rows. */ + if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ + i64 nRow = 0; + rc = fts5StorageCount(p, "content", &nRow); + if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT; + } + if( rc==SQLITE_OK && pConfig->bColumnsize ){ + i64 nRow = 0; + rc = fts5StorageCount(p, "docsize", &nRow); + if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT; + } } /* Pass the expected checksum down to the FTS index module. It will ** verify, amongst other things, that it matches the checksum generated by ** inspecting the index itself. */ if( rc==SQLITE_OK ){ - rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum); + rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum, bUseCksum); } sqlite3_free(aTotalSize); diff -Nru sqlite3-3.33.0/ext/fts5/fts5_tokenize.c sqlite3-3.34.0/ext/fts5/fts5_tokenize.c --- sqlite3-3.33.0/ext/fts5/fts5_tokenize.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_tokenize.c 2020-12-01 16:36:02.000000000 +0000 @@ -1258,6 +1258,133 @@ ); } +/************************************************************************** +** Start of trigram implementation. +*/ +typedef struct TrigramTokenizer TrigramTokenizer; +struct TrigramTokenizer { + int bFold; /* True to fold to lower-case */ +}; + +/* +** Free a trigram tokenizer. +*/ +static void fts5TriDelete(Fts5Tokenizer *p){ + sqlite3_free(p); +} + +/* +** Allocate a trigram tokenizer. +*/ +static int fts5TriCreate( + void *pUnused, + const char **azArg, + int nArg, + Fts5Tokenizer **ppOut +){ + int rc = SQLITE_OK; + TrigramTokenizer *pNew = (TrigramTokenizer*)sqlite3_malloc(sizeof(*pNew)); + UNUSED_PARAM(pUnused); + if( pNew==0 ){ + rc = SQLITE_NOMEM; + }else{ + int i; + pNew->bFold = 1; + for(i=0; rc==SQLITE_OK && ibFold = (zArg[0]=='0'); + } + }else{ + rc = SQLITE_ERROR; + } + } + if( rc!=SQLITE_OK ){ + fts5TriDelete((Fts5Tokenizer*)pNew); + pNew = 0; + } + } + *ppOut = (Fts5Tokenizer*)pNew; + return rc; +} + +/* +** Trigram tokenizer tokenize routine. +*/ +static int fts5TriTokenize( + Fts5Tokenizer *pTok, + void *pCtx, + int unusedFlags, + const char *pText, int nText, + int (*xToken)(void*, int, const char*, int, int, int) +){ + TrigramTokenizer *p = (TrigramTokenizer*)pTok; + int rc = SQLITE_OK; + char aBuf[32]; + const unsigned char *zIn = (const unsigned char*)pText; + const unsigned char *zEof = &zIn[nText]; + u32 iCode; + + UNUSED_PARAM(unusedFlags); + while( 1 ){ + char *zOut = aBuf; + int iStart = zIn - (const unsigned char*)pText; + const unsigned char *zNext; + + READ_UTF8(zIn, zEof, iCode); + if( iCode==0 ) break; + zNext = zIn; + if( zInbFold ) iCode = sqlite3Fts5UnicodeFold(iCode, 0); + WRITE_UTF8(zOut, iCode); + READ_UTF8(zIn, zEof, iCode); + if( iCode==0 ) break; + }else{ + break; + } + if( zInbFold ) iCode = sqlite3Fts5UnicodeFold(iCode, 0); + WRITE_UTF8(zOut, iCode); + READ_UTF8(zIn, zEof, iCode); + if( iCode==0 ) break; + if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, 0); + WRITE_UTF8(zOut, iCode); + }else{ + break; + } + rc = xToken(pCtx, 0, aBuf, zOut-aBuf, iStart, iStart + zOut-aBuf); + if( rc!=SQLITE_OK ) break; + zIn = zNext; + } + + return rc; +} + +/* +** Argument xCreate is a pointer to a constructor function for a tokenizer. +** pTok is a tokenizer previously created using the same method. This function +** returns one of FTS5_PATTERN_NONE, FTS5_PATTERN_LIKE or FTS5_PATTERN_GLOB +** indicating the style of pattern matching that the tokenizer can support. +** In practice, this is: +** +** "trigram" tokenizer, case_sensitive=1 - FTS5_PATTERN_GLOB +** "trigram" tokenizer, case_sensitive=0 (the default) - FTS5_PATTERN_LIKE +** all other tokenizers - FTS5_PATTERN_NONE +*/ +int sqlite3Fts5TokenizerPattern( + int (*xCreate)(void*, const char**, int, Fts5Tokenizer**), + Fts5Tokenizer *pTok +){ + if( xCreate==fts5TriCreate ){ + TrigramTokenizer *p = (TrigramTokenizer*)pTok; + return p->bFold ? FTS5_PATTERN_LIKE : FTS5_PATTERN_GLOB; + } + return FTS5_PATTERN_NONE; +} + /* ** Register all built-in tokenizers with FTS5. */ @@ -1269,6 +1396,7 @@ { "unicode61", {fts5UnicodeCreate, fts5UnicodeDelete, fts5UnicodeTokenize}}, { "ascii", {fts5AsciiCreate, fts5AsciiDelete, fts5AsciiTokenize }}, { "porter", {fts5PorterCreate, fts5PorterDelete, fts5PorterTokenize }}, + { "trigram", {fts5TriCreate, fts5TriDelete, fts5TriTokenize}}, }; int rc = SQLITE_OK; /* Return code */ diff -Nru sqlite3-3.33.0/ext/fts5/fts5_unicode2.c sqlite3-3.34.0/ext/fts5/fts5_unicode2.c --- sqlite3-3.33.0/ext/fts5/fts5_unicode2.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/fts5_unicode2.c 2020-12-01 16:36:02.000000000 +0000 @@ -773,4 +773,6 @@ } iTbl++; } + aAscii[0] = 0; /* 0x00 is never a token character */ } + diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5colset.test sqlite3-3.34.0/ext/fts5/test/fts5colset.test --- sqlite3-3.33.0/ext/fts5/test/fts5colset.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5colset.test 2020-12-01 16:36:02.000000000 +0000 @@ -82,5 +82,24 @@ } {1 {unable to use function MATCH in the requested context}} } +#------------------------------------------------------------------------- +# Confirm that the expression parser creates the same expression tree +# for: +# +# {a b} : (abc AND def) +# -{c d} : (abc AND def) +# +# Assuming that the table columns are (a, b, c, d). +# +do_execsql_test 5.1 { + SELECT fts5_expr('abcd AND cdef'); +} {{"abcd" AND "cdef"}} +do_execsql_test 5.2 { + SELECT fts5_expr('{a b} : (abcd AND cdef)', 'a', 'b', 'c', 'd'); +} {{{a b} : "abcd" AND {a b} : "cdef"}} +do_execsql_test 5.3 { + SELECT fts5_expr('-{c d} : (abcd AND cdef)', 'a', 'b', 'c', 'd'); +} {{{a b} : "abcd" AND {a b} : "cdef"}} + finish_test diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5corrupt3.test sqlite3-3.34.0/ext/fts5/test/fts5corrupt3.test --- sqlite3-3.33.0/ext/fts5/test/fts5corrupt3.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5corrupt3.test 2020-12-01 16:36:02.000000000 +0000 @@ -9691,7 +9691,7 @@ do_catchsql_test 65.1 { SELECT ( MATCH (t1,591)) FROM t1 WHERE t1 MATCH 'e*eŸ' -} {1 {database disk image is malformed}} +} {1 {malformed database schema (t2) - invalid rootpage}} #------------------------------------------------------------------------- # @@ -10324,6 +10324,190 @@ SELECT * FROM t1 WHERE a MATCH 'fx*' } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +reset_db +do_test 70.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +.open --hexdb +| size 24576 pagesize 4096 filename sql022250.txt.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........ +| 96: 00 00 00 00 0d 00 00 00 06 0d e2 00 0f c4 0f 6a ...............j +| 112: 0e fc 0e 9d 0e 3d 0d e2 00 00 00 00 00 00 00 00 .....=.......... +| 3552: 00 00 59 06 06 17 21 21 01 7f 74 61 62 6c 65 74 ..Y...!!..tablet +| 3568: 74 74 5f 63 6f 6e 66 69 67 74 74 74 5f 63 6f 6e tt_configttt_con +| 3584: 66 69 67 06 43 52 45 41 54 45 20 54 41 42 4c 45 fig.CREATE TABLE +| 3600: 20 27 74 74 74 5f 63 6f 6e 66 69 67 27 28 6b 20 'ttt_config'(k +| 3616: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 PRIMARY KEY, v) +| 3632: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5e 15 07 WITHOUT ROWID^.. +| 3648: 17 23 23 01 81 03 74 61 62 6c 65 74 74 74 5f 64 .##...tablettt_d +| 3664: 6f 63 73 69 7a 65 74 74 74 5f 64 6f 63 73 69 7a ocsizettt_docsiz +| 3680: 65 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 e.CREATE TABLE ' +| 3696: 74 74 74 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 ttt_docsize'(id +| 3712: 49 4d 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 IMTEGER PRIMARY +| 3728: 4b 45 59 2c 20 73 7a 20 42 4c 4f 20 29 5d 04 07 KEY, sz BLO )].. +| 3744: 17 23 23 01 81 01 74 61 62 6c 65 74 74 74 5f 63 .##...tablettt_c +| 3760: 6f 6e 74 65 6e 74 74 74 74 5f 63 6f 6e 74 65 6e ontentttt_conten +| 3776: 74 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 t.CREATE TABLE ' +| 3792: 74 74 74 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20 ttt_content'(id +| 3808: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 INTEGER PRIMARY +| 3824: 4b 45 59 2c 20 63 30 2c 20 63 31 29 6c 03 07 17 KEY, c0, c1)l... +| 3840: 1b 1b 01 81 2f 74 61 62 6c 65 74 74 74 5f 69 64 ..../tablettt_id +| 3856: 78 74 74 74 5f 69 64 78 03 43 52 45 41 54 45 20 xttt_idx.CREATE +| 3872: 54 41 42 4c 45 20 27 74 74 74 5f 69 64 78 27 28 TABLE 'ttt_idx'( +| 3888: 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67 6e segid, term, pgn +| 3904: 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28 73 o, PRIMARY KEY(s +| 3920: 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49 54 egid, term)) WIT +| 3936: 48 4f 55 54 20 52 4f 57 49 44 58 02 07 17 1d 1d HOUT ROWIDX..... +| 3952: 01 81 03 74 61 62 6c 65 74 74 74 5f 64 61 74 61 ...tablettt_data +| 3968: 74 74 74 5f 64 61 74 61 02 43 52 45 41 54 45 20 ttt_data.CREATE +| 3984: 54 41 42 4c 45 20 27 74 74 74 5f 64 61 74 61 27 TABLE 'ttt_data' +| 4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM +| 4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 ARY KEY, block B +| 4032: 4c 4f 42 29 3a 01 06 17 13 13 08 5f 74 61 62 6c LOB):......_tabl +| 4048: 65 74 74 74 74 74 74 43 52 45 41 54 45 20 56 49 ettttttCREATE VI +| 4064: 52 54 55 41 4c 20 54 41 42 4c 45 20 74 74 74 20 RTUAL TABLE ttt +| 4080: 55 53 49 4e 47 20 66 74 73 35 28 61 2c 20 62 29 USING fts5(a, b) +| page 2 offset 4096 +| 0: 0d 0f 54 00 05 0e 81 00 0f e7 0e 81 0f af 0f 58 ..T............X +| 16: 0e 98 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +| 3712: 00 15 0a 03 00 30 00 00 00 00 01 03 03 00 03 01 .....0.......... +| 3728: 01 01 02 01 01 03 01 01 81 24 8c 80 80 80 80 01 .........$...... +| 3744: 04 00 82 4c 00 00 00 9b 02 30 65 03 1a 02 05 05 ...L.....0e..... +| 3760: 07 05 01 01 04 03 03 08 03 03 01 2e 02 05 05 07 ................ +| 3776: 05 07 05 07 05 01 01 14 03 03 08 03 03 08 03 bf ................ +| 3792: 07 f2 f3 02 01 65 03 1e 03 05 05 04 05 05 01 01 .....e.......... +| 3808: 03 06 04 04 06 04 03 01 36 03 05 05 04 05 05 04 ........6....... +| 3824: 05 15 04 05 05 01 01 03 06 04 04 06 04 04 a1 04 ................ +| 3840: 04 06 04 03 03 01 65 03 14 04 05 07 05 05 01 01 ......e......... +| 3856: 02 09 0a 01 20 04 05 07 05 07 05 07 05 05 01 01 .... ........... +| 3872: 02 0f da 0a 0a 04 01 64 f3 02 0a 01 06 0a 0a 0a .......d........ +| 3888: 05 01 65 03 06 01 01 0a 01 0a 01 01 0a 0a 0a 04 ..e............. +| 3904: 2b 31 21 0b 0f ef 00 14 2a 00 00 00 00 01 02 02 +1!.....*....... +| 3920: 00 02 01 01 01 02 01 01 50 88 80 80 80 80 01 04 ........P....... +| 3936: 00 81 24 00 00 00 47 01 30 65 02 1a 02 05 05 07 ..$...G.0e...... +| 3952: 05 01 01 04 03 03 08 03 03 02 01 65 02 1d f3 05 ...........e.... +| 3968: 05 04 05 05 01 01 04 06 04 04 06 04 03 03 01 65 ...............e +| 3984: 02 14 04 05 07 05 05 01 01 02 08 0a 04 01 65 02 ..............e. +| 4000: 02 0a 05 01 65 02 06 01 01 0a 04 12 14 0f 06 31 ....e..........1 +| 4016: 84 80 80 80 80 01 03 00 68 00 00 00 2b 02 30 65 ........h...+.0e +| 4032: 01 10 02 05 05 01 01 04 03 03 02 01 66 01 12 03 ............f... +| 4048: 05 05 01 01 03 06 04 03 03 01 65 01 0e 04 05 05 ..........e..... +| 4064: 01 01 02 08 04 0d 0e 06 01 03 00 12 04 4c 4c 00 .............LL. +| 4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01 ...$............ +| page 3 offset 8192 +| 0: 0a 2f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ./.............. +| page 4 offset 12288 +| 3344: 00 00 00 00 00 00 00 00 00 00 81 52 04 06 10 81 ...........R.... +| 3360: 5d 81 55 65 20 65 65 20 65 65 65 20 65 20 65 65 ].Ue ee eee e ee +| 3376: 20 65 65 65 20 65 20 65 65 20 65 65 65 65 20 65 eee e ee eeee e +| 3392: 65 20 65 65 65 24 a5 20 65 65 20 65 65 65 20 65 e eee$. ee eee e +| 3408: 24 05 65 20 65 65 65 65 20 65 65 20 65 65 65 20 $.e eeee ee eee +| 3424: 65 20 65 65 20 65 65 65 20 65 20 65 65 20 65 65 e ee eee e ee ee +| 3440: 65 65 20 65 65 20 65 65 65 20 65 20 65 65 10 65 ee ee eee e ee.e +| 3456: 65 65 20 65 20 65 65 20 65 65 65 65 65 65 20 65 ee e ee eeeeee e +| 3472: 65 20 65 20 65 20 65 20 65 65 20 65 65 65 20 65 e e e e ee eee e +| 3488: 1f 20 65 65 66 65 65 20 65 65 20 65 20 65 20 2d . eefee ee e e - +| page 5 offset 16384 +| 4064: 00 00 00 00 05 04 d0 00 10 21 21 05 03 03 00 10 .........!!..... +| 4080: 11 11 05 02 03 00 10 11 10 05 01 03 00 10 09 09 ................ +| page 6 offset 20480 +| 0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04 ........version. +| end sql022250.txt.db +}]} {} + +do_catchsql_test 70.1 { + SELECT snippet(ttt, -1, '', '','','>')FROM ttt('e* NOT ee*e* NOT ee*'); +} {1 {database disk image is malformed}} + +do_catchsql_test 70.2 { + SELECT snippet(ttt, -1, '', '','',13)FROM ttt('e* NOT ee*e* NOT ee*') +} {1 {database disk image is malformed}} + +#------------------------------------------------------------------------- +reset_db +do_test 71.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +.open --hexdb +| size 28672 pagesize 4096 filename sql025294.txt.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 10 00 00 01 00 40 20 20 00 00 00 00 00 00 00 07 .....@ ........ +| 96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d ...............m +| 112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00 .....N.......... +| 3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74 .........1tablet +| 3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45 2t2.CREATE TABLE +| 3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61 t2(x)V.......ta +| 3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63 blet1_configt1_c +| 3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42 onfig.CREATE TAB +| 3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b LE 't1_config'(k +| 3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 PRIMARY KEY, v) +| 3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05 WITHOUT ROWID[. +| 3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64 ..!!...tablet1_d +| 3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65 ocsizet1_docsize +| 3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 .CREATE TABLE 't +| 3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 1_docsize'(id IN +| 3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 TEGER PRIMARY KE +| 3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21 Y, sz BLOB)U...! +| 3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65 !.wtablet1_conte +| 3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45 ntt1_content.CRE +| 3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f ATE TABLE 't1_co +| 3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45 ntent'(id INTEGE +| 3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63 R PRIMARY KEY, c +| 3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 0)i.......-table +| 3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 t1_idxt1_idx.CRE +| 3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 ATE TABLE 't1_id +| 3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 x'(segid, term, +| 3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 pgno, PRIMARY KE +| 3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 Y(segid, term)) +| 3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 WITHOUT ROWIDU.. +| 3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 ......tablet1_da +| 3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 tat1_data.CREATE +| 3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 TABLE 't1_data' +| 4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (id INTEGER PRIM +| 4016: 41 52 58 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 ARX KEY, block B +| 4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c LOB):......ctabl +| 4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54 et1t1CREATE VIRT +| 4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49 UAL TABLE t1 USI +| 4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29 NG fts5(content) +| page 2 offset 4096 +| 0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00 ................ +| 4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80 .............$.. +| 4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61 ......N.....0aba +| 4048: 60 eb 01 02 02 04 01 66 74 02 02 02 04 04 6e 64 `......ft.....nd +| 4064: 6f 6e 03 01 f2 04 1a 07 05 01 03 00 10 03 03 0f on.............. +| 4080: 0a 03 00 24 00 00 00 00 01 01 4b 00 01 01 01 01 ...$......K..... +| page 3 offset 8192 +| 0: 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02 ................ +| page 4 offset 12288 +| 0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00 ................ +| 4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00 .....abandon.... +| 4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b .abaft.....aback +| page 5 offset 16384 +| 0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00 ................ +| 4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03 ................ +| 4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01 ................ +| page 6 offset 20480 +| 0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00 ................ +| 4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04 ........version. +| page 7 offset 24576 +| 0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 00 00 00 00 ................ +| 4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c ..........rebuil +| 4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63 d...+integrity-c +| 4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65 heck....optimize +| end sql025294.txt.db +}]} {} + +do_catchsql_test 71.2 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {1 {database disk image is malformed}} + + sqlite3_fts5_may_be_corrupt 0 finish_test diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5delete.test sqlite3-3.34.0/ext/fts5/test/fts5delete.test --- sqlite3-3.33.0/ext/fts5/test/fts5delete.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5delete.test 2020-12-01 16:36:02.000000000 +0000 @@ -50,4 +50,47 @@ } } {} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + CREATE TABLE test ( + id INTEGER PRIMARY KEY, + name TEXT, + value TEXT + ); + CREATE VIRTUAL TABLE test_idx USING fts5( + name, content=test, content_rowid=id + ); +} + +do_catchsql_test 2.1 { + INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 1, 'quick'); +} {1 {database disk image is malformed}} + +do_catchsql_test 2.2 { + INSERT INTO test_idx(rowid, name) VALUES(123, 'one one one'); + INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one'); + INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one'); +} {1 {database disk image is malformed}} + +do_execsql_test 2.3 { + DROP TABLE test_idx; + CREATE VIRTUAL TABLE test_idx USING fts5( + name, content=test, content_rowid=id + ); + + INSERT INTO test_idx(rowid, name) VALUES(123, 'one one one'); + INSERT INTO test_idx(rowid, name) VALUES(124, 'two two two'); + INSERT INTO test_idx(rowid, name) VALUES(125, 'two two two'); + INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one'); + INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one'); + INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one'); +} + +do_catchsql_test 2.4 { + SELECT rowid FROM test_idx WHERE test_idx MATCH 'two' ORDER BY rank; +} {1 {database disk image is malformed}} + + + finish_test diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5faultD.test sqlite3-3.34.0/ext/fts5/test/fts5faultD.test --- sqlite3-3.33.0/ext/fts5/test/fts5faultD.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5faultD.test 2020-12-01 16:36:02.000000000 +0000 @@ -14,7 +14,7 @@ source [file join [file dirname [info script]] fts5_common.tcl] source $testdir/malloc_common.tcl -set testprefix fts5faultA +set testprefix fts5faultD # If SQLITE_ENABLE_FTS3 is defined, omit this file. ifcapable !fts5 { diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5faultE.test sqlite3-3.34.0/ext/fts5/test/fts5faultE.test --- sqlite3-3.33.0/ext/fts5/test/fts5faultE.test 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5faultE.test 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,71 @@ +# 2016 February 2 +# +# 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 is focused on OOM errors. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +source $testdir/malloc_common.tcl +set testprefix fts5faultE + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +faultsim_save_and_close +do_faultsim_test 1 -prep { + faultsim_restore_and_reopen +} -body { + execsql { CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram) } +} -test { + faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}} +} + +reset_db +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram); +} + +faultsim_save_and_close +do_faultsim_test 2 -prep { + faultsim_restore_and_reopen +} -body { + execsql { + INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL); + SELECT count(*) FROM t1 WHERE x LIKE '%mnop%' AND t1 MATCH 'jkl'; + } +} -test { + faultsim_test_result {0 1} {1 {vtable constructor failed: t1}} +} + +reset_db +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram, detail=none); + INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL); +} + +faultsim_save_and_close +do_faultsim_test 3 -prep { + faultsim_restore_and_reopen +} -body { + execsql { + SELECT count(*) FROM t1 WHERE x LIKE '%mnopqrs%' AND t1 MATCH 'abc' + } +} -test { + faultsim_test_result {0 1} {1 {vtable constructor failed: t1}} +} + + + +finish_test + diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5hash.test sqlite3-3.34.0/ext/fts5/test/fts5hash.test --- sqlite3-3.33.0/ext/fts5/test/fts5hash.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5hash.test 2020-12-01 16:36:02.000000000 +0000 @@ -112,7 +112,7 @@ # Add a small and very large token with the same hash value to an # empty table. At one point this would provoke an asan error. # - do_test 2.0 { + do_test 1.5 { set big [string repeat 12345 40] set hash [sqlite3_fts5_token_hash 1024 $big] while {1} { @@ -128,4 +128,41 @@ } ;# foreach_detail_mode +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE t1 USING fts5(x); + INSERT INTO t1(t1, rank) VALUES('hashsize', 1024); + INSERT INTO t1(t1, rank) VALUES('automerge', 0); + INSERT INTO t1(t1, rank) VALUES('crisismerge', 1000); +} + +do_execsql_test 2.2 { + BEGIN; + INSERT INTO t1 VALUES('abc def ghi'); + SELECT count(*) FROM t1_data; +} {2} + +do_execsql_test 2.3 { + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1024 + ) + INSERT INTO t1 SELECT 'abc def ghi' FROM s; + SELECT (SELECT count(*) FROM t1_data) > 10; +} {1} + +do_execsql_test 2.4 { + COMMIT; + DROP TABLE t1; + CREATE VIRTUAL TABLE t1 USING fts5(x); + INSERT INTO t1(t1, rank) VALUES('hashsize', 1024); + INSERT INTO t1(t1, rank) VALUES('automerge', 0); + INSERT INTO t1(t1, rank) VALUES('crisismerge', 1000); + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1024 + ) + INSERT INTO t1 SELECT 'abc' || i || ' def' || i || ' ghi' || i FROM s; + SELECT (SELECT count(*) FROM t1_data) > 100; +} {1} + finish_test diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5integrity.test sqlite3-3.34.0/ext/fts5/test/fts5integrity.test --- sqlite3-3.33.0/ext/fts5/test/fts5integrity.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5integrity.test 2020-12-01 16:36:02.000000000 +0000 @@ -273,7 +273,6 @@ SELECT quote(x'37'); } {X'37'} -breakpoint do_execsql_test 9.2 { INSERT INTO vt0 VALUES (SUBSTR(x'37', 0)); -- INSERT INTO vt0 VALUES (x'37'); @@ -282,4 +281,40 @@ INSERT INTO vt0(vt0) VALUES('integrity-check'); } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 10.0 { + CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b); + CREATE VIRTUAL TABLE vt0 USING fts5(a, b, content=t1); + INSERT INTO vt0(rowid, a, b) VALUES(1, 'abc', 'def'); +} +do_catchsql_test 10.1 { + INSERT INTO vt0(vt0) VALUES('integrity-check'); +} {0 {}} +do_catchsql_test 10.2 { + INSERT INTO vt0(vt0, rank) VALUES('integrity-check', 0); +} {0 {}} +do_catchsql_test 10.3 { + INSERT INTO vt0(vt0, rank) VALUES('integrity-check', 1); +} {1 {database disk image is malformed}} +do_catchsql_test 10.3 { + INSERT INTO t1 VALUES(1, 'abc', 'def'); + INSERT INTO vt0(vt0, rank) VALUES('integrity-check', 1); +} {0 {}} + +do_execsql_test 10.4 { + CREATE VIRTUAL TABLE vt1 USING fts5(a, b, content=); + INSERT INTO vt1(rowid, a, b) VALUES(1, 'abc', 'def'); +} + +do_catchsql_test 10.5.1 { + INSERT INTO vt0(vt0, rank) VALUES('integrity-check', 0); +} {0 {}} +do_catchsql_test 10.5.2 { + INSERT INTO vt0(vt0, rank) VALUES('integrity-check', 1); +} {0 {}} +do_catchsql_test 10.5.3 { + INSERT INTO vt0(vt0) VALUES('integrity-check'); +} {0 {}} + finish_test diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5plan.test sqlite3-3.34.0/ext/fts5/test/fts5plan.test --- sqlite3-3.33.0/ext/fts5/test/fts5plan.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5plan.test 2020-12-01 16:36:02.000000000 +0000 @@ -31,7 +31,7 @@ } { QUERY PLAN |--SCAN TABLE t1 - `--SCAN TABLE f1 VIRTUAL TABLE INDEX 0:m + `--SCAN TABLE f1 VIRTUAL TABLE INDEX 0:M1 } do_eqp_test 1.2 { @@ -46,7 +46,7 @@ SELECT * FROM f1 WHERE f1 MATCH ? ORDER BY ff } { QUERY PLAN - |--SCAN TABLE f1 VIRTUAL TABLE INDEX 0:m + |--SCAN TABLE f1 VIRTUAL TABLE INDEX 0:M1 `--USE TEMP B-TREE FOR ORDER BY } diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5tok1.test sqlite3-3.34.0/ext/fts5/test/fts5tok1.test --- sqlite3-3.33.0/ext/fts5/test/fts5tok1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5tok1.test 2020-12-01 16:36:02.000000000 +0000 @@ -111,5 +111,40 @@ SELECT * FROM t4; } {1 {SQL logic error}} +#------------------------------------------------------------------------- +# Embedded 0x00 characters. +# +reset_db +do_execsql_test 3.1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(z); + CREATE VIRTUAL TABLE tt USING fts5vocab(t1, 'instance'); + INSERT INTO t1 VALUES('abc' || char(0) || 'def'); + SELECT * FROM tt; +} { abc 1 z 0 def 1 z 1 } +do_execsql_test 3.1.1 { + SELECT hex(z) FROM t1; +} {61626300646566} +do_execsql_test 3.1.2 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {} + +do_execsql_test 3.2.0 { + CREATE VIRTUAL TABLE t2 USING fts5(z, + tokenize="unicode61 categories 'L* N* Co Cc'" + ); + CREATE VIRTUAL TABLE tu USING fts5vocab(t2, 'instance'); + + INSERT INTO t2 VALUES('abc' || char(0) || 'def'); + SELECT * FROM tu; +} { abc 1 z 0 def 1 z 1 } + +do_execsql_test 3.2.1 { + SELECT hex(z) FROM t1; +} {61626300646566} + +do_execsql_test 3.2.2 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {} + finish_test diff -Nru sqlite3-3.33.0/ext/fts5/test/fts5trigram.test sqlite3-3.34.0/ext/fts5/test/fts5trigram.test --- sqlite3-3.33.0/ext/fts5/test/fts5trigram.test 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/test/fts5trigram.test 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,201 @@ +# 2020 September 30 +# +# 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. +# +#************************************************************************* +# +# Tests for the fts5 "trigram" tokenizer. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +ifcapable !fts5 { finish_test ; return } +set ::testprefix fts5trigram + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(y, tokenize=trigram); + INSERT INTO t1 VALUES('abcdefghijklm'); + INSERT INTO t1 VALUES('กรุงเทพมหานคร'); +} + +foreach {tn s res} { + 1 abc "(abc)defghijklm" + 2 defgh "abc(defgh)ijklm" + 3 abcdefghijklm "(abcdefghijklm)" + 4 กรุ "(กรุ)งเทพมหานคร" + 5 งเทพมห "กรุ(งเทพมห)านคร" + 6 กรุงเทพมหานคร "(กรุงเทพมหานคร)" + 7 Abc "(abc)defghijklm" + 8 deFgh "abc(defgh)ijklm" + 9 aBcdefGhijKlm "(abcdefghijklm)" +} { + do_execsql_test 1.1.$tn { + SELECT highlight(t1, 0, '(', ')') FROM t1($s) + } $res +} + +do_execsql_test 1.2.0 { + SELECT fts5_expr('ABCD', 'tokenize=trigram') +} {{"abc" + "bcd"}} + +do_execsql_test 1.2.1 { + SELECT * FROM t1 WHERE y LIKE ? ESCAPE 'a' +} + +foreach {tn like res} { + 1 {%cDef%} 1 + 2 {cDef%} {} + 3 {%f%} 1 + 4 {%f_h%} 1 + 5 {%f_g%} {} + 6 {abc%klm} 1 + 7 {ABCDEFG%} 1 + 8 {%รุงเ%} 2 +} { + do_execsql_test 1.3.$tn { + SELECT rowid FROM t1 WHERE y LIKE $like + } $res +} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t1 USING fts5(y, tokenize="trigram case_sensitive 1"); + INSERT INTO t1 VALUES('abcdefghijklm'); + INSERT INTO t1 VALUES('กรุงเทพมหานคร'); +} + +foreach {tn s res} { + 1 abc "(abc)defghijklm" + 2 defgh "abc(defgh)ijklm" + 3 abcdefghijklm "(abcdefghijklm)" + 4 กรุ "(กรุ)งเทพมหานคร" + 5 งเทพมห "กรุ(งเทพมห)านคร" + 6 กรุงเทพมหานคร "(กรุงเทพมหานคร)" + 7 Abc "" + 8 deFgh "" + 9 aBcdefGhijKlm "" +} { + do_execsql_test 2.1.$tn { + SELECT highlight(t1, 0, '(', ')') FROM t1($s) + } $res +} +foreach {tn like res} { + 1 {%cDef%} 1 + 2 {cDef%} {} + 3 {%f%} 1 + 4 {%f_h%} 1 + 5 {%f_g%} {} + 6 {abc%klm} 1 + 7 {ABCDEFG%} 1 + 8 {%รุงเ%} 2 +} { + do_execsql_test 2.2.$tn { + SELECT rowid FROM t1 WHERE y LIKE $like + } $res +} +foreach {tn like res} { + 1 {*cdef*} 1 + 2 {cdef*} {} + 3 {*f*} 1 + 4 {*f?h*} 1 + 5 {*f?g*} {} + 6 {abc*klm} 1 + 7 {abcdefg*} 1 + 8 {*รุงเ*} 2 + 9 {abc[d]efg*} 1 + 10 {abc[]d]efg*} 1 + 11 {abc[^]d]efg*} {} + 12 {abc[^]XYZ]efg*} 1 +} { + do_execsql_test 2.3.$tn { + SELECT rowid FROM t1 WHERE y GLOB $like + } $res +} + +do_execsql_test 2.3.null.1 { + SELECT rowid FROM t1 WHERE y LIKE NULL +} + +#------------------------------------------------------------------------- +reset_db +do_catchsql_test 3.1 { + CREATE VIRTUAL TABLE ttt USING fts5(c, tokenize="trigram case_sensitive 2"); +} {1 {error in tokenizer constructor}} +do_catchsql_test 3.2 { + CREATE VIRTUAL TABLE ttt USING fts5(c, tokenize="trigram case_sensitive 11"); +} {1 {error in tokenizer constructor}} +do_catchsql_test 3.3 { + CREATE VIRTUAL TABLE ttt USING fts5(c, "tokenize=trigram case_sensitive 1"); +} {0 {}} + +#------------------------------------------------------------------------- +reset_db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE t0 USING fts5(b, tokenize = "trigram"); +} +do_execsql_test 4.1 { + INSERT INTO t0 VALUES (x'000b01'); +} +do_execsql_test 4.2 { + INSERT INTO t0(t0) VALUES('integrity-check'); +} + +#------------------------------------------------------------------------- +reset_db +foreach_detail_mode $::testprefix { + foreach {ci} {0 1} { + reset_db + do_execsql_test 5.cs=$ci.0.1 " + CREATE VIRTUAL TABLE t1 USING fts5( + y, tokenize=\"trigram case_sensitive $ci\", detail=%DETAIL% + ); + " + do_execsql_test 5.cs=$ci.0.2 { + INSERT INTO t1 VALUES('abcdefghijklm'); + INSERT INTO t1 VALUES('กรุงเทพมหานคร'); + } + + foreach {tn like res} { + 1 {%cDef%} 1 + 2 {cDef%} {} + 3 {%f%} 1 + 4 {%f_h%} 1 + 5 {%f_g%} {} + 6 {abc%klm} 1 + 7 {ABCDEFG%} 1 + 8 {%รุงเ%} 2 + } { + do_execsql_test 5.cs=$ci.1.$tn { + SELECT rowid FROM t1 WHERE y LIKE $like + } $res + } + } +} + +do_execsql_test 6.0 { + CREATE VIRTUAL TABLE ci0 USING fts5(x, tokenize="trigram"); + CREATE VIRTUAL TABLE ci1 USING fts5(x, tokenize="trigram case_sensitive 1"); +} + +# LIKE and GLOB both work with case-insensitive tokenizers. Only GLOB works +# with case-sensitive. +do_eqp_test 6.1 { + SELECT * FROM ci0 WHERE x LIKE ? +} {VIRTUAL TABLE INDEX 0:L0} +do_eqp_test 6.2 { + SELECT * FROM ci0 WHERE x GLOB ? +} {VIRTUAL TABLE INDEX 0:G0} +do_eqp_test 6.3 { + SELECT * FROM ci1 WHERE x LIKE ? +} {{SCAN TABLE ci1 VIRTUAL TABLE INDEX 0:}} +do_eqp_test 6.4 { + SELECT * FROM ci1 WHERE x GLOB ? +} {VIRTUAL TABLE INDEX 0:G0} + +finish_test + diff -Nru sqlite3-3.33.0/ext/fts5/tool/fts5txt2db.tcl sqlite3-3.34.0/ext/fts5/tool/fts5txt2db.tcl --- sqlite3-3.33.0/ext/fts5/tool/fts5txt2db.tcl 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/fts5/tool/fts5txt2db.tcl 2020-12-01 16:36:02.000000000 +0000 @@ -12,6 +12,7 @@ cmdline::process ::A $::argv { {fts5 "use fts5 (this is the default)"} {fts4 "use fts4"} + {trigram "Use tokenize=trigram"} {colsize "10 10 10" "list of column sizes"} {tblname "t1" "table name to create"} {detail "full" "Fts5 detail mode to use"} @@ -175,6 +176,7 @@ set sql "CREATE VIRTUAL TABLE IF NOT EXISTS $A(tblname) USING $A(fts) (" append sql [join $cols ,] if {$A(fts)=="fts5"} { append sql ",detail=$A(detail)" } + if {$A(trigram)} { append sql ",tokenize=trigram" } append sql ", prefix='$A(prefix)');" db eval $sql diff -Nru sqlite3-3.33.0/ext/misc/carray.c sqlite3-3.34.0/ext/misc/carray.c --- sqlite3-3.33.0/ext/misc/carray.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/misc/carray.c 2020-12-01 16:36:02.000000000 +0000 @@ -57,20 +57,31 @@ #include #include +/* Allowed values for the mFlags parameter to sqlite3_carray_bind(). +** Must exactly match the definitions in carray.h. +*/ +#define CARRAY_INT32 0 /* Data is 32-bit signed integers */ +#define CARRAY_INT64 1 /* Data is 64-bit signed integers */ +#define CARRAY_DOUBLE 2 /* Data is doubles */ +#define CARRAY_TEXT 3 /* Data is char* */ + #ifndef SQLITE_OMIT_VIRTUALTABLE /* -** Allowed datatypes +** Names of allowed datatypes */ -#define CARRAY_INT32 0 -#define CARRAY_INT64 1 -#define CARRAY_DOUBLE 2 -#define CARRAY_TEXT 3 +static const char *azType[] = { "int32", "int64", "double", "char*" }; /* -** Names of types +** Structure used to hold the sqlite3_carray_bind() information */ -static const char *azType[] = { "int32", "int64", "double", "char*" }; +typedef struct carray_bind carray_bind; +struct carray_bind { + void *aData; /* The data */ + int nData; /* Number of elements */ + int mFlags; /* Control flags */ + void (*xDel)(void*); /* Destructor for aData */ +}; /* carray_cursor is a subclass of sqlite3_vtab_cursor which will @@ -239,28 +250,39 @@ int argc, sqlite3_value **argv ){ carray_cursor *pCur = (carray_cursor *)pVtabCursor; - if( idxNum ){ - pCur->pPtr = sqlite3_value_pointer(argv[0], "carray"); - pCur->iCnt = pCur->pPtr ? sqlite3_value_int64(argv[1]) : 0; - 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; + pCur->pPtr = 0; + pCur->iCnt = 0; + switch( idxNum ){ + case 1: { + carray_bind *pBind = sqlite3_value_pointer(argv[0], "carray-bind"); + if( pBind==0 ) break; + pCur->pPtr = pBind->aData; + pCur->iCnt = pBind->nData; + pCur->eType = pBind->mFlags & 0x03; + break; + } + case 2: + case 3: { + pCur->pPtr = sqlite3_value_pointer(argv[0], "carray"); + pCur->iCnt = pCur->pPtr ? sqlite3_value_int64(argv[1]) : 0; + if( idxNum<3 ){ + pCur->eType = CARRAY_INT32; }else{ - pCur->eType = i; + 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; + } } + break; } - }else{ - pCur->pPtr = 0; - pCur->iCnt = 0; } pCur->iRowid = 1; return SQLITE_OK; @@ -275,9 +297,16 @@ ** 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. +** idxNum is: +** +** 1 If only the pointer= constraint exists. In this case, the +** parameter must be bound using sqlite3_carray_bind(). +** +** 2 if the pointer= and count= constraints exist. +** +** 3 if the ctype= constraint also exists. +** +** idxNum is 0 otherwise and carray becomes an empty table. */ static int carrayBestIndex( sqlite3_vtab *tab, @@ -305,18 +334,21 @@ break; } } - if( ptrIdx>=0 && cntIdx>=0 ){ + if( ptrIdx>=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; + pIdxInfo->idxNum = 1; + if( cntIdx>=0 ){ + pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2; + pIdxInfo->aConstraintUsage[cntIdx].omit = 1; + pIdxInfo->idxNum = 2; + if( ctypeIdx>=0 ){ + pIdxInfo->aConstraintUsage[ctypeIdx].argvIndex = 3; + pIdxInfo->aConstraintUsage[ctypeIdx].omit = 1; + pIdxInfo->idxNum = 3; + } } }else{ pIdxInfo->estimatedCost = (double)2147483647; @@ -354,6 +386,89 @@ }; /* +** Destructor for the carray_bind object +*/ +static void carrayBindDel(void *pPtr){ + carray_bind *p = (carray_bind*)pPtr; + if( p->xDel!=SQLITE_STATIC ){ + p->xDel(p->aData); + } + sqlite3_free(p); +} + +/* +** Invoke this interface in order to bind to the single-argument +** version of CARRAY(). +*/ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_carray_bind( + sqlite3_stmt *pStmt, + int idx, + void *aData, + int nData, + int mFlags, + void (*xDestroy)(void*) +){ + carray_bind *pNew; + int i; + pNew = sqlite3_malloc64(sizeof(*pNew)); + if( pNew==0 ){ + if( xDestroy!=SQLITE_STATIC && xDestroy!=SQLITE_TRANSIENT ){ + xDestroy(aData); + } + return SQLITE_NOMEM; + } + pNew->nData = nData; + pNew->mFlags = mFlags; + if( xDestroy==SQLITE_TRANSIENT ){ + sqlite3_int64 sz = nData; + switch( mFlags & 0x03 ){ + case CARRAY_INT32: sz *= 4; break; + case CARRAY_INT64: sz *= 8; break; + case CARRAY_DOUBLE: sz *= 8; break; + case CARRAY_TEXT: sz *= sizeof(char*); break; + } + if( (mFlags & 0x03)==CARRAY_TEXT ){ + for(i=0; iaData = sqlite3_malloc64( sz ); + if( pNew->aData==0 ){ + sqlite3_free(pNew); + return SQLITE_NOMEM; + } + if( (mFlags & 0x03)==CARRAY_TEXT ){ + char **az = (char**)pNew->aData; + char *z = (char*)&az[nData]; + for(i=0; iaData, aData, sz*nData); + } + pNew->xDel = sqlite3_free; + }else{ + pNew->aData = aData; + pNew->xDel = xDestroy; + } + return sqlite3_bind_pointer(pStmt, idx, pNew, "carray-bind", carrayBindDel); +} + + +/* ** For testing purpose in the TCL test harness, we need a method for ** setting the pointer value. The inttoptr(X) SQL function accomplishes ** this. Tcl script will bind an integer to X and the inttoptr() SQL diff -Nru sqlite3-3.33.0/ext/misc/carray.h sqlite3-3.34.0/ext/misc/carray.h --- sqlite3-3.33.0/ext/misc/carray.h 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/ext/misc/carray.h 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,23 @@ +/* +** Interface definitions for the CARRAY table-valued function +** extension. +*/ + +/* Use this interface to bind an array to the single-argument version +** of CARRAY(). +*/ +int sqlite3_carray_bind( + sqlite3_stmt *pStmt, /* Statement to be bound */ + int i, /* Parameter index */ + void *aData, /* Pointer to array data */ + int nData, /* Number of data elements */ + int mFlags, /* CARRAY flags */ + void (*xDel)(void*) /* Destructgor for aData*/ +); + +/* Allowed values for the mFlags parameter to sqlite3_carray_bind(). +*/ +#define CARRAY_INT32 0 /* Data is 32-bit signed integers */ +#define CARRAY_INT64 1 /* Data is 64-bit signed integers */ +#define CARRAY_DOUBLE 2 /* Data is doubles */ +#define CARRAY_TEXT 3 /* Data is char* */ diff -Nru sqlite3-3.33.0/ext/misc/cksumvfs.c sqlite3-3.34.0/ext/misc/cksumvfs.c --- sqlite3-3.33.0/ext/misc/cksumvfs.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/misc/cksumvfs.c 2020-12-01 16:36:02.000000000 +0000 @@ -54,11 +54,11 @@ ** statically linked against the application, initialize it using ** a single API call as follows: ** -** sqlite3_cksumvfs_init(); +** sqlite3_register_cksumvfs(); ** ** Cksumvfs is a VFS Shim. When loaded, "cksmvfs" becomes the new ** default VFS and it uses the prior default VFS as the next VFS -** down in the stack. This is normally what you want. However, it +** down in the stack. This is normally what you want. However, in ** complex situations where multiple VFS shims are being loaded, ** it might be important to ensure that cksumvfs is loaded in the ** correct order so that it sequences itself into the default VFS @@ -79,7 +79,7 @@ ** the reserve-bytes value to 8 by runing: ** ** int n = 8; -** sqlite3_file_control(db, 0, SQLITE_FCNTL_RESERVED_BYTES, &n); +** sqlite3_file_control(db, 0, SQLITE_FCNTL_RESERVE_BYTES, &n); ** ** If you do this immediately after creating a new database file, ** before anything else has been written into the file, then that @@ -157,6 +157,9 @@ ** value at offset 20 the SQLite database header is exactly 8. If ** the reserved-space value is not 8, this module is a no-op. */ +#if defined(SQLITE_AMALGAMATION) && !defined(SQLITE_CKSUMVFS_STATIC) +# define SQLITE_CKSUMVFS_STATIC +#endif #ifdef SQLITE_CKSUMVFS_STATIC # include "sqlite3.h" #else @@ -176,7 +179,7 @@ /* ** Useful datatype abbreviations */ -#if !defined(SQLITE_CORE) +#if !defined(SQLITE_AMALGAMATION) typedef unsigned char u8; typedef unsigned int u32; #endif @@ -395,7 +398,9 @@ pFile = ORIGFILE(pFile); rc = pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst); if( rc==SQLITE_OK ){ - if( iOfst==0 && iAmt>=100 && memcmp(zBuf,"SQLite format 3",16)==0 ){ + if( iOfst==0 && iAmt>=100 && ( + memcmp(zBuf,"SQLite format 3",16)==0 || memcmp(zBuf,"ZV-",3)==0 + )){ u8 *d = (u8*)zBuf; char hasCorrectReserveSize = (d[20]==8); cksmSetFlags(p, hasCorrectReserveSize); @@ -434,7 +439,9 @@ ){ CksmFile *p = (CksmFile *)pFile; pFile = ORIGFILE(pFile); - if( iOfst==0 && iAmt>=100 && memcmp(zBuf,"SQLite format 3",16)==0 ){ + if( iOfst==0 && iAmt>=100 && ( + memcmp(zBuf,"SQLite format 3",16)==0 || memcmp(zBuf,"ZV-",3)==0 + )){ u8 *d = (u8*)zBuf; char hasCorrectReserveSize = (d[20]==8); cksmSetFlags(p, hasCorrectReserveSize); @@ -604,13 +611,20 @@ return SQLITE_OK; } pFile = ORIGFILE(pFile); - return pFile->pMethods->xFetch(pFile, iOfst, iAmt, pp); + if( pFile->pMethods->iVersion>2 && pFile->pMethods->xFetch ){ + return pFile->pMethods->xFetch(pFile, iOfst, iAmt, pp); + } + *pp = 0; + return SQLITE_OK; } /* Release a memory-mapped page */ static int cksmUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ pFile = ORIGFILE(pFile); - return pFile->pMethods->xUnfetch(pFile, iOfst, pPage); + if( pFile->pMethods->iVersion>2 && pFile->pMethods->xUnfetch ){ + return pFile->pMethods->xUnfetch(pFile, iOfst, pPage); + } + return SQLITE_OK; } /* @@ -763,6 +777,13 @@ (void)NotUsed; return cksmRegisterVfs(); } +int sqlite3_unregister_cksumvfs(void){ + if( sqlite3_vfs_find("cksmvfs") ){ + sqlite3_vfs_unregister(&cksm_vfs); + sqlite3_cancel_auto_extension((void(*)(void))cksmRegisterFunc); + } + return SQLITE_OK; +} #endif /* defined(SQLITE_CKSUMVFS_STATIC */ #if !defined(SQLITE_CKSUMVFS_STATIC) diff -Nru sqlite3-3.33.0/ext/misc/csv.c sqlite3-3.34.0/ext/misc/csv.c --- sqlite3-3.33.0/ext/misc/csv.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/misc/csv.c 2020-12-01 16:36:02.000000000 +0000 @@ -776,7 +776,7 @@ 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); + sqlite3_result_text(ctx, pCur->azVal[i], -1, SQLITE_TRANSIENT); } return SQLITE_OK; } diff -Nru sqlite3-3.33.0/ext/misc/series.c sqlite3-3.34.0/ext/misc/series.c --- sqlite3-3.33.0/ext/misc/series.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/misc/series.c 2020-12-01 16:36:02.000000000 +0000 @@ -106,10 +106,10 @@ */ static int seriesConnect( sqlite3 *db, - void *pAux, - int argc, const char *const*argv, + void *pUnused, + int argcUnused, const char *const*argvUnused, sqlite3_vtab **ppVtab, - char **pzErr + char **pzErrUnused ){ sqlite3_vtab *pNew; int rc; @@ -120,6 +120,10 @@ #define SERIES_COLUMN_STOP 2 #define SERIES_COLUMN_STEP 3 + (void)pUnused; + (void)argcUnused; + (void)argvUnused; + (void)pzErrUnused; rc = sqlite3_declare_vtab(db, "CREATE TABLE x(value,start hidden,stop hidden,step hidden)"); if( rc==SQLITE_OK ){ @@ -142,8 +146,9 @@ /* ** Constructor for a new series_cursor object. */ -static int seriesOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ +static int seriesOpen(sqlite3_vtab *pUnused, sqlite3_vtab_cursor **ppCursor){ series_cursor *pCur; + (void)pUnused; pCur = sqlite3_malloc( sizeof(*pCur) ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(*pCur)); @@ -250,11 +255,12 @@ */ static int seriesFilter( sqlite3_vtab_cursor *pVtabCursor, - int idxNum, const char *idxStr, + int idxNum, const char *idxStrUnused, int argc, sqlite3_value **argv ){ series_cursor *pCur = (series_cursor *)pVtabCursor; int i = 0; + (void)idxStrUnused; if( idxNum & 1 ){ pCur->mnValue = sqlite3_value_int64(argv[i++]); }else{ @@ -311,7 +317,7 @@ ** (8) output in descending order */ static int seriesBestIndex( - sqlite3_vtab *tab, + sqlite3_vtab *tabUnused, sqlite3_index_info *pIdxInfo ){ int i, j; /* Loop over constraints */ @@ -325,6 +331,7 @@ ** are the last three columns in the virtual table. */ assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 ); assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 ); + (void)tabUnused; aIdx[0] = aIdx[1] = aIdx[2] = -1; pConstraint = pIdxInfo->aConstraint; for(i=0; inConstraint; i++, pConstraint++){ @@ -398,6 +405,10 @@ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ + 0, /* xSavepoint */ + 0, /* xRelease */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ diff -Nru sqlite3-3.33.0/ext/misc/zipfile.c sqlite3-3.34.0/ext/misc/zipfile.c --- sqlite3-3.33.0/ext/misc/zipfile.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/misc/zipfile.c 2020-12-01 16:36:02.000000000 +0000 @@ -523,14 +523,16 @@ const u8 *aWrite, int nWrite ){ - size_t n; - fseek(pTab->pWriteFd, (long)pTab->szCurrent, SEEK_SET); - n = fwrite(aWrite, 1, nWrite, pTab->pWriteFd); - if( (int)n!=nWrite ){ - pTab->base.zErrMsg = sqlite3_mprintf("error in fwrite()"); - return SQLITE_ERROR; + if( nWrite>0 ){ + size_t n = nWrite; + fseek(pTab->pWriteFd, (long)pTab->szCurrent, SEEK_SET); + n = fwrite(aWrite, 1, nWrite, pTab->pWriteFd); + if( (int)n!=nWrite ){ + pTab->base.zErrMsg = sqlite3_mprintf("error in fwrite()"); + return SQLITE_ERROR; + } + pTab->szCurrent += nWrite; } - pTab->szCurrent += nWrite; return SQLITE_OK; } diff -Nru sqlite3-3.33.0/ext/rtree/geopoly.c sqlite3-3.34.0/ext/rtree/geopoly.c --- sqlite3-3.33.0/ext/rtree/geopoly.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/rtree/geopoly.c 2020-12-01 16:36:02.000000000 +0000 @@ -1075,7 +1075,7 @@ geopolyAddSegments(p, p1, 1); geopolyAddSegments(p, p2, 2); pThisEvent = geopolySortEventsByX(p->aEvent, p->nEvent); - rX = pThisEvent->x==0.0 ? -1.0 : 0.0; + rX = pThisEvent && pThisEvent->x==0.0 ? -1.0 : 0.0; memset(aOverlap, 0, sizeof(aOverlap)); while( pThisEvent ){ if( pThisEvent->x!=rX ){ diff -Nru sqlite3-3.33.0/ext/rtree/rtree.c sqlite3-3.34.0/ext/rtree/rtree.c --- sqlite3-3.33.0/ext/rtree/rtree.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/rtree/rtree.c 2020-12-01 16:36:02.000000000 +0000 @@ -759,7 +759,7 @@ ** are the leaves, and so on. If the depth as specified on the root node ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. */ - if( pNode && iNode==1 ){ + if( pNode && rc==SQLITE_OK && iNode==1 ){ pRtree->iDepth = readInt16(pNode->zData); if( pRtree->iDepth>RTREE_MAX_DEPTH ){ rc = SQLITE_CORRUPT_VTAB; diff -Nru sqlite3-3.33.0/ext/session/test_session.c sqlite3-3.34.0/ext/session/test_session.c --- sqlite3-3.33.0/ext/session/test_session.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/ext/session/test_session.c 2020-12-01 16:36:02.000000000 +0000 @@ -227,7 +227,7 @@ ){ TestSession *p = (TestSession*)clientData; sqlite3_session *pSession = p->pSession; - struct SessionSubcmd { + static struct SessionSubcmd { const char *zSub; int nArg; const char *zMsg; @@ -1131,7 +1131,7 @@ int objc, Tcl_Obj *CONST objv[] ){ - struct RebaseSubcmd { + static struct RebaseSubcmd { const char *zSub; int nArg; const char *zMsg; @@ -1248,7 +1248,7 @@ int objc, Tcl_Obj *CONST objv[] ){ - struct ConfigOpt { + static struct ConfigOpt { const char *zSub; int op; } aSub[] = { diff -Nru sqlite3-3.33.0/main.mk sqlite3-3.34.0/main.mk --- sqlite3-3.33.0/main.mk 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/main.mk 2020-12-01 16:36:02.000000000 +0000 @@ -361,6 +361,7 @@ TESTSRC += \ $(TOP)/ext/misc/amatch.c \ $(TOP)/ext/misc/carray.c \ + $(TOP)/ext/misc/cksumvfs.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/decimal.c \ @@ -912,6 +913,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DBPAGE_VTAB TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_BYTECODE_VTAB TESTFIXTURE_FLAGS += -DTCLSH_INIT_PROC=sqlite3TestInit +TESTFIXTURE_FLAGS += -DSQLITE_CKSUMVFS_STATIC testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c $(TCCX) $(TCL_FLAGS) $(TESTFIXTURE_FLAGS) \ diff -Nru sqlite3-3.33.0/Makefile.in sqlite3-3.34.0/Makefile.in --- sqlite3-3.33.0/Makefile.in 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/Makefile.in 2020-12-01 16:36:02.000000000 +0000 @@ -441,6 +441,7 @@ $(TOP)/ext/expert/test_expert.c \ $(TOP)/ext/misc/amatch.c \ $(TOP)/ext/misc/carray.c \ + $(TOP)/ext/misc/cksumvfs.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/decimal.c \ @@ -1086,6 +1087,7 @@ $(TOP)/ext/misc/decimal.c \ $(TOP)/ext/misc/fileio.c \ $(TOP)/ext/misc/ieee754.c \ + $(TOP)/ext/misc/series.c \ $(TOP)/ext/misc/shathree.c \ $(TOP)/ext/misc/sqlar.c \ $(TOP)/ext/misc/uint.c \ @@ -1232,6 +1234,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DBPAGE_VTAB TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_BYTECODE_VTAB TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DESERIALIZE +TESTFIXTURE_FLAGS += -DSQLITE_CKSUMVFS_STATIC TESTFIXTURE_SRC0 = $(TESTSRC2) libsqlite3.la TESTFIXTURE_SRC1 = sqlite3.c diff -Nru sqlite3-3.33.0/Makefile.msc sqlite3-3.34.0/Makefile.msc --- sqlite3-3.33.0/Makefile.msc 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/Makefile.msc 2020-12-01 16:36:02.000000000 +0000 @@ -1558,6 +1558,7 @@ $(TOP)\ext\expert\test_expert.c \ $(TOP)\ext\misc\amatch.c \ $(TOP)\ext\misc\carray.c \ + $(TOP)\ext\misc\cksumvfs.c \ $(TOP)\ext\misc\closure.c \ $(TOP)\ext\misc\csv.c \ $(TOP)\ext\misc\decimal.c \ @@ -2208,6 +2209,7 @@ $(TOP)\ext\misc\decimal.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\ieee754.c \ + $(TOP)\ext\misc\series.c \ $(TOP)\ext\misc\shathree.c \ $(TOP)\ext\misc\uint.c \ $(TOP)\ext\expert\sqlite3expert.c \ @@ -2386,6 +2388,7 @@ TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_JSON1=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1 +TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_CKSUMVFS_STATIC=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS) TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) diff -Nru sqlite3-3.33.0/manifest sqlite3-3.34.0/manifest --- sqlite3-3.33.0/manifest 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/manifest 2020-12-01 16:36:02.000000000 +0000 @@ -1,13 +1,13 @@ -C Version\s3.33.0 -D 2020-08-14T13:23:32.827 +C Version\s3.34.0 +D 2020-12-01T16:14:00.051 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 19374a5db06c3199ec1bab71ab74a103d8abf21053c05e9389255dc58083f806 +F Makefile.in 0e88f5d095213a9ccd45c5bbd871c8ead498f886dff4493471fbf48b1f867f9d F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241 -F Makefile.msc 48f5a3fc32672c09ad73795749f6253e406a31526935fbbffd8f021108d54574 +F Makefile.msc dd10dbf63b2f8ac3e2f0542963a21bc69058976ac4355165f212a31c83d17f44 F README.md 1514a365ffca3c138e00c5cc839906108a01011a6b082bad19b09781e3aa498a -F VERSION 5db2ee2cfcc790af73775fa485c13b2e8ccaa5936c6e1f47aedeba7056041ca5 +F VERSION 4027b9aea92d64385570778ebd14388c0b23e92aafda15e7b89c45886c9b920a F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -28,19 +28,20 @@ F autoconf/tea/pkgIndex.tcl.in 3ef61715cf1c7bdcff56947ffadb26bc991ca39d F autoconf/tea/tclconfig/install-sh bdd5e293591621ae60d9824d86a4b1c5f22c3d00 F autoconf/tea/tclconfig/tcl.m4 66ddf0a5d5e4b1d29bff472c0985fd7fa89d0fb5 -F autoconf/tea/win/makefile.vc 71915591c07cd5137711dc40ba3e127deb3f4531b9aad220b724cf5b451362bd +F autoconf/tea/win/makefile.vc a5ff708245260c2794c6aaa0151efe5403d5896566eaf096747be0d9075284e4 F autoconf/tea/win/nmakehlp.c 247538ad8e8c508f33c03ec1fbd67d3a07ef6291 F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure a97f98dfff699495aef66ae3d9c424345778a663f583e0d6e7522670518f87c1 x -F configure.ac 40d01e89cb325c28b33f5957e61fede0bd17da2b5e37d9b223a90c8a318e88d4 +F configure e7df2824b6e60d482d919fb3e7d823faf08467093b096ad47a4fe2eec3f0ba99 x +F configure.ac 73545c21eebcef9398d85c982c7be260f07708256778221b541f83ae8c6f61eb F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd -F doc/lemon.html 1edc0f916e771212792d4d077aedc05168bf13fd65d64d41b2c13e46ac0063a8 +F doc/lemon.html c5d8ba85ac1daef7be8c2d389899480eb62451ff5c09b0c28ff8157bb8770746 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a +F doc/vdbesort-memory.md 4da2639c14cd24a31e0af694b1a8dd37eaf277aff3867e9a8cc14046bc49df56 F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a F doc/wal-lock.md 781726aaba20bafeceb7ba9f91d5c98c6731691b30c954e37cf0b49a053d461d F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd @@ -49,8 +50,8 @@ F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 -F ext/expert/expert1.test 2e10ff875c31c9e6fc5e324767624181273859771fe34c5daeeadf3f2974a4f7 -F ext/expert/sqlite3expert.c b5eae75862d34a204d16c45dcb813888b5f86bdc156c6136b0f79094c0da4f79 +F ext/expert/expert1.test dba6e752cc701621771f925f3872b183fa688f7b4a9f4822631fc02bdbffc45a +F ext/expert/sqlite3expert.c 2778d9f06b3a8bfa859cb6b75b82f004477bf5dd78edd17d954319750ca963f3 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e @@ -108,24 +109,24 @@ F ext/fts3/tool/fts3view.c 413c346399159df81f86c4928b7c4a455caab73bfbc8cd68f950f632e5751674 F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 -F ext/fts3/unicode/mkunicode.tcl bf7fcaa6d68e6d38223467983785d054f1cff4d9e3905dd51f6ed8801bb590d5 +F ext/fts3/unicode/mkunicode.tcl d5aebf022fa4577ee8cdf27468f0d847879993959101f6dbd6348ef0cfc324a7 F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h c132a9323f22a972c4c93a8d5a3d901113a6e612faf30ca8e695788438c5ca2a -F ext/fts5/fts5Int.h d7cbc214ee167496f70905667e18f73ea0402f7ef09236ce305e117e0efc866a -F ext/fts5/fts5_aux.c dcc627d8b6e3fc773db528ff67b39955dab7b51628f9dba8e15849e5bedfd7fa +F ext/fts5/fts5Int.h 26c74dd5776f798436fbf604a0bf0e8de263b35b5060b05c15f9085845d9fda2 +F ext/fts5/fts5_aux.c f558e1fb9f0f86a4f7489e258c162e1f947de5ff2709087fbb465fddb7092f98 F ext/fts5/fts5_buffer.c 5a5fe0159752c0fb0a5a93c722e9db2662822709490769d482b76a6dc8aaca70 -F ext/fts5/fts5_config.c b447948f35ad3354e8fe5e242e0a7e7b5b941555400b9404259944e3aa570037 -F ext/fts5/fts5_expr.c 2be456484786333d559dc2987a00f2750981fab91d52db8452a8046278c5f22e -F ext/fts5/fts5_hash.c 1cc0095646f5f3b46721aa112fb4f9bf29ae175cb5338f89dcec66ed97acfe75 -F ext/fts5/fts5_index.c de14c9a30f45e2b847ff9284b14776d9d07961e545e8f1546a6aa3f915af721f -F ext/fts5/fts5_main.c e881a2ea0bf01b3a3ff0bc1b31373c58fd54b6c9f3c43ea3d431bea4e5d4025e -F ext/fts5/fts5_storage.c 3ecda8edadc1f62a355d6789776be0da609f8658c50d72e422674093ab7e1528 +F ext/fts5/fts5_config.c be54f44fca491e96c6923a4b9a736f2da2b13811600eb6e38d1bcc91c4ea2e61 +F ext/fts5/fts5_expr.c e527e3a7410393075598cec544e3831798a8c88b3e8878e2cfb7cb147113e925 +F ext/fts5/fts5_hash.c 1aa93c9b5f461afba66701ee226297dc78402b3bdde81e90a10de5fe3df14959 +F ext/fts5/fts5_index.c 9f152a596df3a2227ddd59adb82549c2b6858ab36bc1d26fd8933f43d3d63d36 +F ext/fts5/fts5_main.c b4e4931c7fcc9acfa0c3b8b5e5e80b5b424b8d9207aae3a22b674bd35ccf149d +F ext/fts5/fts5_storage.c 58ba71e6cd3d43a5735815e7956ee167babb4d2cbfe206905174792af4d09d75 F ext/fts5/fts5_tcl.c 39bcbae507f594aad778172fa914cad0f585bf92fd3b078c686e249282db0d95 F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c f96c6e193c466711d6d7828d5f190407fe7ab897062d371426dd3036f01258e7 -F ext/fts5/fts5_tokenize.c 2e508c6a3bd8ee56c48e98a38052e1a650e49b32a484cce9b189984114bc3b88 -F ext/fts5/fts5_unicode2.c 8bd0cd07396b74c1a05590e4070d635bccfc849812c305619f109e6c0485e250 +F ext/fts5/fts5_tokenize.c 5e251efb0f1af99a25ed50010ba6b1ad1250aca5921af1988fdcabe5ebc3cb43 +F ext/fts5/fts5_unicode2.c eca63dbc797f8ff0572e97caf4631389c0ab900d6364861b915bdd4735973f00 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 F ext/fts5/fts5_vocab.c 7a071833064dc8bca236c3c323e56aac36f583aa2c46ce916d52e31ce87462c9 F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05 @@ -151,7 +152,7 @@ F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36 F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62 -F ext/fts5/test/fts5colset.test a30473451321bbf0b6218af62e96b4ae5fa99931cfdb210b5ecc804623b30f75 +F ext/fts5/test/fts5colset.test 7031ce84fb4d312df5a99fc4e7b324e660ccb513c97eccdef469bfd52d3d0f8f F ext/fts5/test/fts5columnsize.test 45459ce4dd9fd853b6044cdc9674921bff89e3d840f348ca8c1630f9edbf5482 F ext/fts5/test/fts5config.test 60094712debc59286c59aef0e6cf511c37d866802776a825ce437d26afe0817f F ext/fts5/test/fts5conflict.test 655925678e630d3cdf145d18725a558971806416f453ac8410ca8c04d934238d @@ -159,9 +160,9 @@ F ext/fts5/test/fts5content.test 213506436fb2c87567b8e31f6d43ab30aab99354cec74ed679f22aad0cdbf283 F ext/fts5/test/fts5corrupt.test 77ae6f41a7eba10620efb921cf7dbe218b0ef232b04519deb43581cb17a57ebe F ext/fts5/test/fts5corrupt2.test 7453752ba12ce91690c469a6449d412561cc604b1dec994e16ab132952e7805f -F ext/fts5/test/fts5corrupt3.test 7afe0fea5b2160798fdc3306395048768c6fc13acefc0e7129d4075b6e1bb224 +F ext/fts5/test/fts5corrupt3.test dd5435659d5363fc3b3ac32175e2fc793fdc17980b47e3d598695d867eaa77a2 F ext/fts5/test/fts5corrupt4.test ea805c4d7c68b5f185b9db5d2060a7ae5875339738dd48203c92162f41e7ca91 -F ext/fts5/test/fts5delete.test cbf87e3b8867c4d5cfcaed975c7475fd3f99d072bce2075fcedf43d1f82af775 +F ext/fts5/test/fts5delete.test 4a15fb03b6c7eac62ac807a3a32b7f0dc74f0d479c410e3e3568ae96b9469290 F ext/fts5/test/fts5detail.test 31b240dbf6d44ac3507e2f8b65f29fdc12465ffd531212378c7ce1066766f54e F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11 F ext/fts5/test/fts5dlidx.test b90852c55881b29dbac6380b274de27beae623ac4b6d567c6c8fb9cdc315a86e @@ -179,12 +180,13 @@ F ext/fts5/test/fts5fault9.test 098e6b894bbdf9b2192f994a30f4043673fb3f338b6b8ab1624c704422f39119 F ext/fts5/test/fts5faultA.test be4487576bff8c22cee6597d1893b312f306504a8c6ccd3c53ca85af12290c8c F ext/fts5/test/fts5faultB.test d606bdb8e81aaeb6f41de3fc9fc7ae315733f0903fbff05cf54f5b045b729ab5 -F ext/fts5/test/fts5faultD.test cc5d1225556e356615e719c612e845d41bff7d5a +F ext/fts5/test/fts5faultD.test e7ed7895abfe6bc98a5e853826f6b74956e7ba7f594f1860bbf9e504b9647996 +F ext/fts5/test/fts5faultE.test 844586ce71dab4be85bb86880e87b624d089f851654cd22e4710c77eb8ce7075 F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b996159f6909dc8079 F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717 F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e -F ext/fts5/test/fts5hash.test a4cf51acad99bfc43c16fb74f9d22495dc221ae0701fc5e908ca963a9b26a02b -F ext/fts5/test/fts5integrity.test 8ffabcd91b058d812aba3e3e0a06f76ce165ba402a18cca20e34204a7feec92e +F ext/fts5/test/fts5hash.test dc7bc7e0cdeb42cfce31294ad2f8fcf43192bfd0145bb7f3ecc5465d8c72696f +F ext/fts5/test/fts5integrity.test e387b2bd1c83e50f4a12f58a5fd399111bbab36be2f1c9fd5bb974be08a32de6 F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227 F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28 F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad @@ -198,7 +200,7 @@ F ext/fts5/test/fts5onepass.test f9b7d9b2c334900c6542a869760290e2ab5382af8fbd618834bf1fcc3e7b84da F ext/fts5/test/fts5optimize.test 36a752d24c818792032e4ff502936fc9cc5ef938721696396fdc79214b2717f1 F ext/fts5/test/fts5phrase.test 13e5d8e9083077b3d9c74315b3c92ec723cc6eb37c8155e0bfe1bba00559f07b -F ext/fts5/test/fts5plan.test 771b999d161e24fd803ce0290adb7c6e7c9b9cc2c6a0adb344813fb89473aa32 +F ext/fts5/test/fts5plan.test 79d35b5e83bbdcba48d946a7f008df161f6b0ede1a966892d0aa6c8dd0b6e773 F ext/fts5/test/fts5porter.test 8d08010c28527db66bc3feebd2b8767504aaeb9b101a986342fa7833d49d0d15 F ext/fts5/test/fts5porter2.test 0d251a673f02fa13ca7f011654873b3add20745f7402f108600a23e52d8c7457 F ext/fts5/test/fts5prefix.test a0fa67b06650f2deaa7bf27745899d94e0fb547ad9ecbd08bfad98c04912c056 @@ -213,9 +215,10 @@ F ext/fts5/test/fts5simple3.test d5c74a9d3ca71bd5dd5cacb7c55b86ea12cdddfc8b1910e3de2995206898380f F ext/fts5/test/fts5synonym.test 1651815b8008de170e8e600dcacc17521d765482ea8f074ae82cfa870d8bb7fb F ext/fts5/test/fts5synonym2.test b54cce5c34ec08ed616f646635538ae82e34a0e28f947ec60b6fadbc4b3fb17a -F ext/fts5/test/fts5tok1.test ce6551e41ff56f30b69963577324624733bed0d1753589f06120d664d9cd45c9 +F ext/fts5/test/fts5tok1.test 1f7817499f5971450d8c4a652114b3d833393c8134e32422d0af27884ffe9cef F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test ac3c9112b263a639fb0508ae73a3ee886bf4866d2153771a8e8a20c721305a43 +F ext/fts5/test/fts5trigram.test e2ce256fd0ccd6707e740aa3596206aedb0d5834b100c0cb49e344dcd1d8463c F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602 F ext/fts5/test/fts5unicode.test 17056f4efe6b0a5d4f41fdf7a7dc9af2873004562eaa899d40633b93dc95f5a9 F ext/fts5/test/fts5unicode2.test 9b3df486de05fb4bde4aa7ee8de2e6dae1df6eb90e3f2e242c9383b95d314e3e @@ -227,7 +230,7 @@ F ext/fts5/test/fts5vocab.test 7ed80d9af1ddaaa1637da05e406327b5aac250848bc604c1c1cc667908b87760 F ext/fts5/test/fts5vocab2.test e0fdc3a3095f6eda68ac9bf9a443ff929a124d46f00af19933604085712e9d47 F ext/fts5/tool/fts5speed.tcl b0056f91a55b2d1a3684ec05729de92b042e2f85 -F ext/fts5/tool/fts5txt2db.tcl 526a9979c963f1c54fd50976a05a502e533a4c59 +F ext/fts5/tool/fts5txt2db.tcl c0d43c8590656f8240e622b00957b3a0facc49482411a9fdc2870b45c0c82f9f F ext/fts5/tool/loadfts5.tcl 95b03429ee6b138645703c6ca192c3ac96eaf093 F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45 F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c @@ -285,12 +288,13 @@ F ext/misc/appendvfs.c 55121d311d408ba9c62c3cfa367408887638f02f9522dd9859891d0ee69a7eba F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0edb2a F ext/misc/btreeinfo.c d28ce349b40054eaa9473e835837bad7a71deec33ba13e39f963d50933bfa0f9 -F ext/misc/carray.c 91e9a7f512fda934894bed30464552fffa7d3073b5be04189ae0bd0c59f26bfd -F ext/misc/cksumvfs.c 0f022867786b615d7f68fb3ab3a16627fe6a730442abf804735e18a73f835a83 +F ext/misc/carray.c b75a0f207391038bf1540d3372f482a95c3613511c7c474db51ede1196321c7c +F ext/misc/carray.h de74ac70b2338f416723f7d538026e8ec0b7f1d388319f8f140c9a4d7677f02e +F ext/misc/cksumvfs.c c4e7ebeae5aa578df98f23bddb63ecbcbe913ee3c32b8b769525af100d752061 F ext/misc/closure.c dbfd8543b2a017ae6b1a5843986b22ddf99ff126ec9634a2f4047cd14c85c243 F ext/misc/completion.c 6dafd7f4348eecc7be9e920d4b419d1fb2af75d938cd9c59a20cfe8beb2f22b9 F ext/misc/compress.c 3354c77a7c8e86e07d849916000cdac451ed96500bfb5bd83b20eb61eee012c9 -F ext/misc/csv.c 3ed979c1eb35e35a98b30ef545a2facf62994594217681d9138b4b75faf6b0d7 +F ext/misc/csv.c 53b3338d4fa812eda51a2637df30233a4dae16b964ee5666e2051b9672ed8bb4 F ext/misc/dbdata.c e316fba936571584e55abd5b974a32a191727a6b746053a0c9d439bd2cf93940 F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f823e01 F ext/misc/decimal.c 3ddbf8162015be4d5ec2395dee4538f1e638bb517174bb148274b132df6e1d08 @@ -314,7 +318,7 @@ F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c 4057dda3579b38ff88b2d3b13b4dd92dbd9d6f90dac2b55c19b0a8ed87ee4959 +F ext/misc/series.c fbb8e6be97b54d10d2f235e163fa2f53a8f4421c66ebd532a233fd1c69c3f522 F ext/misc/sha1.c c8f2253c8792ffab9517695ea7d88c079f0395a5505eefef5c8198fe184ed5ac F ext/misc/shathree.c 135b7c145db4a09b1650c3e7aff9cb538763a9a361e834c015dd1aaf8d5c9a00 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -332,7 +336,7 @@ F ext/misc/vtablog.c 5538acd0c8ddaae372331bee11608d76973436b77d6a91e8635cfc9432fba5ae F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 520f34c3099e5b7d546f13708607dc2fa173c46b68952eecf0d19cd675fec85e -F ext/misc/zipfile.c d1be54ea83ac9ad71b8b6ffc4b60db8946ce2ceacdf6bff063fcd9489f41bb49 +F ext/misc/zipfile.c e35e035bc2765b1ccdcb15f9815c2112843fcbc8f36aa071f0e5935df7072228 F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64 F ext/rbu/rbu.c 8681f6157db6adc82c34af24b14ea8a3be0146ad2a3b6c1d5da6cb8a5796c8ce F ext/rbu/rbu1.test 221d9c18a5e600ac9ac6b1810d99d9f99163a7909ba61597876ab6e4d4beb3d6 @@ -387,8 +391,8 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c335096108c12c01bddbadcec F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/geopoly.c f15cc6845d64a629035627d863cbe3eadc9cb30f9ca77bd823b0ca8a5a3f8b00 -F ext/rtree/rtree.c f87ffcc91f49272862119cfdd256b02514351893786a710d88f85933790608d4 +F ext/rtree/geopoly.c 1b1ddecb79877b12331d35de9f393b80bbb731e0bf6db6c572f23191987ea803 +F ext/rtree/rtree.c 60f6f1675134201974be4189dbd219494c13e1ed30e80bd92ae0dcc86df1b035 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 00792b030a4e188ff1b22e8530e8aa0452bb5dd81c2b18cb004afc7dc63e040e F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d @@ -450,14 +454,14 @@ F ext/session/sessionwor.test 67b5ab91d4f93ce65ff1f58240ac5ddf73f8670facc1ffa49cef56293d52818d F ext/session/sqlite3session.c 2c76b8c3a5d6dab736686f8a48833b8bdac0871ecc6f447f9839d28bd4a63d6c F ext/session/sqlite3session.h a2db5b72b938d12c727b4b4ec632254ca493670a9c0de597af3271a7f774fc57 -F ext/session/test_session.c 98797aba475a799376c9a42214f2d1debf2d0c3cb657d9c8bbf4f70bf3fb4aec +F ext/session/test_session.c 24286d958dc6f4ca4d7e710f09bc0fa9d50956a40dd99fd8223e7488024c71fe F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk b1cd0bc6aedad7ebb667b7f74f835f932f60ee33be2a5c3051fd93eb465f5c75 +F main.mk 57451ea5b3d5cd86e9c5324b10c9de184b12e8dcccc31c65d24fbcb55ccd9c53 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -469,44 +473,44 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a -F src/alter.c 805de23ddca536181f8f0439df989fdd4a2f76c40bc305ec9fe2f211f68c89e8 -F src/analyze.c 5cffff3d355858cd22bfc6e20ac7203510d2e1cc935086eb06f4abb2f579f628 -F src/attach.c 0b11e00c166b622c84ec176773b1d691c61ad07d247809e3e1635d4e99e71d30 +F src/alter.c b6de60d59419e34f5b48ff2b21fe0f9bb66fc714e5545a6ac790ac7a0c46548c +F src/analyze.c 01c6c6765cb4d40b473b71d85535093730770bb186f2f473abac25f07fcdee5c +F src/attach.c 0f497c15c4cfe3bdcb214f0dbdbbb6c5ed7e8a9308ac445c7959f5e5780437a9 F src/auth.c a3d5bfdba83d25abed1013a8c7a5f204e2e29b0c25242a56bc02bb0c07bf1e06 -F src/backup.c b1c90cd4110248c8e1273ff4578d3a84c0c34725e1b96dacd4a6294a908702de +F src/backup.c 3014889fa06e20e6adfa0d07b60097eec1f6e5b06671625f476a714d2356513d F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6 -F src/btree.c 1439fd9b45d4d1883c53752daef42af489adaa1a1508fa39dedbc9c80ea21a2f -F src/btree.h 7af72bbb4863c331c8f6753277ab40ee67d2a2125a63256d5c25489722ec162b -F src/btreeInt.h 83166f6daeb91062b6ae9ee6247b3ad07e40eba58f3c05ba9e8dedad4ab1ea38 -F src/build.c dbdaee54ffef924a070eb6202017e10d6be56baab953ef0a8e714a6def683198 +F src/btree.c ee14224322b9e4172d01e691e2f289f6c630ae39b7906f84b72dc780b9e42a76 +F src/btree.h dcdff4037d75b3f032a5de0d922fcfaf35d48589417f634fa8627362709315f9 +F src/btreeInt.h ffd66480520d9d70222171b3a026d78b80833b5cea49c89867949f3e023d5f43 +F src/build.c f6449d4e85e998e14d3f537e8ea898dca2fcb83c277db3e60945af9b9177db81 F src/callback.c d0b853dd413255d2e337b34545e54d888ea02f20da5ad0e63585b389624c4a6c F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c e98518d2d3d4029a13c805e07313fb60c877be56db76e90dd5f3af73085d0ce6 F src/date.c dace306a10d9b02ee553d454c8e1cf8d3c9b932e137738a6b15b90253a9bfc10 F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a F src/dbstat.c 3aa79fc3aed7ce906e4ea6c10e85d657299e304f6049861fe300053ac57de36c -F src/delete.c 410c771c25afc113c273d9efad6ab6881bda28c75a1838b9d2c52ba20d1dc704 -F src/expr.c 58c06940d964c2cf455b979cf66a648499d294a5ee6dadcaeaed447257c1dc75 +F src/delete.c 927cf8f900583e79aca8f1a321979e0a8f053babd9a690b44b38f79de2cc09fe +F src/expr.c 0d196ed5a2ebf96be7e8df88add4fabfad0dce16c0fed81a4b8f6a26e259797f F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 83372403298e6a7dd989a47aaacdbaa5b4307b5199dbd56e07d4896066b3de72 -F src/func.c 2333eb4277f55a5efdc12ef754e7d7ec9105d257b2fd00301d23ce1e8fa67dc0 +F src/func.c 574f7e5a67e4b7a7855cf3478037717c8f44686c0cd727e1d7f7773414165c03 F src/global.c 943256ac44f333039d35a9830c18d075a81fa6b6bf2af05771494a9acfb9a40b F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19 F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38 F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 957254a2d0542597455d0d4c640e4e3f3eea8c6d78f04582df03dfc626f07925 +F src/insert.c 7e081d33aab4a9d761c39dccf3c3872c35501565d2ed9db66301918d23bc7901 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa -F src/loadext.c 436af4968c6954d304fce9efa12719367bd8f37b19b93b71d6ad607e85adbb47 -F src/main.c 09580279145f27f3db206ef44dcb3a8875a42644230f79c7e54aff35e71668f0 -F src/malloc.c 22d5bdd9fe88ae4fad1b91a1b9735104b82853ffef868f1f05517d60dc1875f5 +F src/loadext.c 8c9c8cd2bd8eecdb06d9b6e89de7e9e65bae45cc8fc33609cc74023a5c296067 +F src/main.c 54d61d1e94f225636053c862c930d7dd7b29162b93d3f3ecb00439910ccba02a +F src/malloc.c c1af4ac5a463648cd2953fd4ac679b3ba9022ce5ec794a60806150ad69dfd33a F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c b93b8762ab999a29ae7751532dadf0a1ac78040308a5fb1d17fcc365171d67eb F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6 F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memdb.c d58e398e315e88f95f8d07d17e80ab11259ebd6d1a10397434329eeabd1985e3 +F src/memdb.c ab0632d42407e866d2b616bd19d4211ac0ad1b430f04c4e187d60005b8700b98 F src/memjournal.c 90b2ca7e2f465d57c16b69d15a9f3e3294af61088eb4938f2f7664d5ac50f813 F src/msvc.h 3a15918220367a8876be3fa4f2abe423a861491e84b864fb2b7426bf022a28f8 F src/mutex.c 5e3409715552348732e97b9194abe92fdfcd934cfb681df4ba0ab87ac6c18d25 @@ -519,38 +523,38 @@ F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 9b1b860163fd2d4d7679b5260d384d1a9f88ef917a90f28963eca8acd472d8c8 -F src/os_win.c a2149ff0a85c1c3f9cc102a46c673ce87e992396ba3411bfb53db66813b32f1d +F src/os_unix.c adbbcea4c63d3b400d405f60a5da4c01433753ec4a12e2dc695beb2bbd671fe9 +F src/os_win.c 77d39873836f1831a9b0b91894fec45ab0e9ca8e067dc8c549e1d1eca1566fe9 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 3700a1c55427a3d4168ad1f1b8a8b0cb9ace1d107e4506e30a8f1e66d8a1195e +F src/pager.c c49952ac5e9cc536778eff528091d79d38b3e45cbeeed4695dc05e207dc6547d F src/pager.h 4bf9b3213a4b2bebbced5eaa8b219cf25d4a82f385d093cd64b7e93e5285f66f -F src/parse.y 5bdb760a29c0b25caf7e80e82210b81cd2ea3066d5199ca29e6eac40b34bc184 +F src/parse.y 9ce4dfb772608ed5bd3c32f33e943e021e3b06cfd2c01932d4280888fdd2ebed F src/pcache.c 385ff064bca69789d199a98e2169445dc16e4291fa807babd61d4890c3b34177 F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache1.c 6596e10baf3d8f84cc1585d226cf1ab26564a5f5caf85a15757a281ff977d51a -F src/pragma.c bdb600be936f66b9fe69d26dfbba4528beaaf4f95c479c85b328a92484e0bf71 +F src/pragma.c 6daaaecc26a4b09481d21722525b079ce756751a43a79cc1d8f122d686806193 F src/pragma.h 8dc78ab7e9ec6ce3ded8332810a2066f1ef6267e2e03cd7356ee00276125c6cf -F src/prepare.c 3d5a761d026052bc888d1b803a06dd2bfe245e8e836d4689f927003549148b0f -F src/printf.c 9efcd4e984f22bcccb1ded37a1178cac98f6e3a0534e1e0629f64899971f8838 +F src/prepare.c 270170a239c0f66bd3c228f373afe24447c2614a6829ae22080babc64f241931 +F src/printf.c 30e92b638fac71dcd85cdea1d12ecfae354c9adee2c71e8e1ae4727cde7c91ed F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 -F src/resolve.c d74715aceed2a8f493ba244d535646fa93132042a4400a29dfd26ec841514048 +F src/resolve.c 1948a92ca9eab776632816b97e57c61d933474a78aad4f4ef835c916a83dbb1c F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 -F src/select.c 510fdf819f218be3dac2683d3eaaf64e5080f548061a4dd12205590beda976bb -F src/shell.c.in b9b819feede7b85585ab0826490a352e04e2ee46e8132c92597d29972b2be1d7 -F src/sqlite.h.in d2c03414a8ee5d4a6855c04dd7cd5998e45139b0fe66b65bae86d4223edd091f +F src/select.c 31387e56f5e6d1adc798dfa04b946001289a61e65acf4615f7b7130f121f3b9c +F src/shell.c.in 55113760ae91a05c6ce4558714a1c8fc7a44bf266f735de6e71ea40f79e69830 +F src/sqlite.h.in 1dbae67057d999161c30b21c3c7fa45d51f665b510d397dd1b7d671287d772b0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 2d1af80082edffd71c6f96f70ad1ce6a4fb46615ad10291fc77fe0dea9ff0197 -F src/sqliteInt.h a1aa5457ca881cbf5adb55933bf81d7d4889375afb9a0a5df382a451c058087d -F src/sqliteLimit.h 95cb8479ca459496d9c1c6a9f76b38aee12203a56ce1092fe13e50ae2454c032 +F src/sqlite3ext.h 61b38c073d5e1e96a3d45271b257aef27d0d13da2bea5347692ae579475cd95e +F src/sqliteInt.h c01115c8dd967f7d334a98ba37ac821eafb04144c8085a795daaf2185743d27a +F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657 F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c 986b6391f02cd9b53c1d688be55899f6ffddeb8e8014cd83c1b73ff912579a71 -F src/test1.c 24b9cd0863ecc4d3920f4999c40e876c2bd92f3cc5879c48b99abe02c546ed18 +F src/test1.c 465b7a35b7e231bf2833e47c1371b5dfc99bd803ebe73783862399d479d696a5 F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644 F src/test4.c 7c4420e01c577b5c4add2cb03119743b1a357543d347773b9e717195ea967159 F src/test5.c 328aae2c010c57a9829d255dc099d6899311672d -F src/test6.c e8d839fbc552ce044bec8234561a2d5b8819b48e29548ad0ba400471697946a8 +F src/test6.c ae73a3a42bbc982fb9e301b84d30bda65a307be48c6dff20aba1461e17a9b0ce F src/test7.c 5612e9aecf934d6df7bba6ce861fdf5ba5456010 F src/test8.c 7fb971777c2c79c734bb52757191d68d4af659b8de9b4a071be3f527a9d19a02 F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 @@ -563,10 +567,10 @@ F src/test_config.c 5ea19bf0972a9d91728518b4d30e91477acce80496003ecbef3a7fb18d0bd081 F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f F src/test_demovfs.c 86142ba864d4297d54c5b2e972e74f3141ae4b30f05b3a95824184ed2d3d7f91 -F src/test_devsym.c 6109b45c3db3ef7b002320947ed448c027356ab8b885156ff535fd8684d4a571 +F src/test_devsym.c aff2255ea290d7718da08af30cdf18e470ff7325a5eff63e0057b1496ed66593 F src/test_fs.c ba1e1dc18fd3159fdba0b9c4256f14032159785320dfbd6776eb9973cb75d480 F src/test_func.c 181f992e5495644434c4f0e3cc72362a78c295eb2cf3ff4d02498b8bde7aa276 -F src/test_hexio.c d170d0e1a6431afdeac086a250d2595078288c2257615d37949355361399bcaa +F src/test_hexio.c 9478e56a0f08e07841a014a93b20e4ba2709ab56d039d1ca8020e26846aa19bd F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664 F src/test_intarray.c 39b4181662a0f33a427748d87218e7578d913e683dc27eab7098bb41617cac71 F src/test_intarray.h d57ae92f420cda25e22790dac474d60961bd0c500cbaa3338a05152d4a669ef7 @@ -592,7 +596,7 @@ F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc F src/test_thread.c 269ea9e1fa5828dba550eb26f619aa18aedbc29fd92f8a5f6b93521fbb74a61c F src/test_vdbecov.c f60c6f135ec42c0de013a1d5136777aa328a776d33277f92abac648930453d43 -F src/test_vfs.c 36822d696789535bdd0260f07d2c9a46546082fea8bb1d0a7354c7f9366e37ea +F src/test_vfs.c 2cc38a79892017702d13da79ad5152c196eec19bbd67fbde4d88065aac894a84 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1 F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a90484215 @@ -601,20 +605,20 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 4dc01b267593537e2a0d0efe9f80dabe24c5b6f7627bc6971c487fa6a1dacbbf F src/treeview.c 4b92992176fb2caefbe06ba5bd06e0e0ebcde3d5564758da672631f17aa51cda -F src/trigger.c ef67bde309a831515dc3c2173d792574309f2f42d45f8c078743fae9f7f98c75 -F src/update.c fb15bec5b54fd098f4b84f6abc83c7103b45ba8484011fff8edf5ae31656eab6 +F src/trigger.c 515e79206d40d1d4149129318582e79a6e9db590a7b74e226fdb5b2a6c7e1b10 +F src/update.c 9f126204a6acb96bbe47391ae48e0fc579105d8e76a6d9c4fab3271367476580 F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 -F src/util.c c8bf30c4356b091bcc3b624d0e24b2b4d11b8be4d6c90d8e0705971e15cc819b -F src/vacuum.c 1c4f8e2f39d950037f4cf946b6858c993d3a54c3101f78e05c76460a073afcf0 -F src/vdbe.c e9f7f818f128c8600058c0eabb6b3975974c95153a104d340f419adabbc15b9f +F src/util.c c0c7977de7ef9b8cb10f6c85f2d0557889a658f817b0455909a49179ba4c8002 +F src/vacuum.c 492422c1463c076473bae1858799c7a0a5fe87a133d1223239447c422cd26286 +F src/vdbe.c d24a43b6b1ed2dba893636a14f5e56001444ab3fd5465e3bca8ab01799840acd F src/vdbe.h 83603854bfa5851af601fc0947671eb260f4363e62e960e8a994fb9bbcd2aaa1 -F src/vdbeInt.h 762abffb7709f19c2cb74af1bba73a900f762e64f80d69c31c9ae89ed1066b60 +F src/vdbeInt.h 3ca5e9fd6e095a8b6cf6bc3587a46fc93499503b2fe48951e1034ba9e2ce2f6e F src/vdbeapi.c c5e7cb2ab89a24d7f723e87b508f21bfb1359a04db5277d8a99fd1e015c12eb9 -F src/vdbeaux.c 73854da7a9a4f12db72a855758214173c82f46a14be6cb19e63677ba02c97cae +F src/vdbeaux.c c76b7e96e189f5056d1de914d33d07bd03d3b88741f75375c8e18c9b11ffd379 F src/vdbeblob.c 253ed82894924c362a7fa3079551d3554cd1cdace39aa833da77d3bc67e7c1b1 F src/vdbemem.c 947f2a65910edb4014dc981d33e414a68c51f169f9df8c4c493a0ba840b6eb1f -F src/vdbesort.c 2be76d26998ce2b3324cdcc9f6443728e54b6c7677c553ad909c7d7cfab587df +F src/vdbesort.c f5b5e473a7cee44e47a94817b042fd7172cf3aa2c0a7928a8339d612bcfdec5a F src/vdbetrace.c fa3bf238002f0bbbdfb66cc8afb0cea284ff9f148d6439bc1f6f2b4c3b7143f0 F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c F src/vtab.c 5f5fc793092f53bbdfde296c50f563fb7bda58cf48e9cf6a8bdfbc5abd409845 @@ -622,14 +626,14 @@ F src/wal.c 69e770e96fd56cc21608992bf2c6f1f3dc5cf2572d0495c6a643b06c3a679f14 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c 3df26a33dc4f54e8771600fb7fdebe1ece0896c2ad68c30ab40b017aa4395049 -F src/where.c 2ea911238674e9baaeddf105dddabed92692a01996073c4d4983f9a7efe481f9 -F src/whereInt.h 6b874aa15f94e43a2cec1080be64d955b04deeafeac90ffb5d6975c0d511be3c -F src/wherecode.c 8064fe5c042824853a9b1fda670054a51a49033a6c79059988c97751ccf8088e -F src/whereexpr.c 264d58971eaf8256eb5b0917bcd7fc7a1f1109fdda183a8382308a1b18a2dce7 +F src/where.c ad738741bf45999188a3047f6277063e3f6843304d581e3ad5875419afdeb6b2 +F src/whereInt.h 59077fbd0b3d01bc8715e746c86a99ebf4c85bde8a57077ec04d2a23e59666ec +F src/wherecode.c a3a1aff30fe99a818d8e7c607980f033f40c68d890e03ed25838b9dbb7908bee +F src/whereexpr.c 3a463e156ea388083c501502229c2c7f4f5c6b5330ea59bdf40d6eb6e155a25f F src/window.c edd6f5e25a1e8f2b6f5305b7f5f7da7bb35f07f0d432b255b1d4c2fcab4205aa F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 -F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d +F test/affinity3.test eecb0dabee4b7765a8465439d5e99429279ffba23ca74a7eae270a452799f9e7 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 2f65ec8132e0ca896de550b9908094d49ad65a99116a9d79deeb6017604ad4f6 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -644,12 +648,12 @@ F test/alterlegacy.test 82022721ce0de29cedc9a7af63bc9fcc078b0ee000f8283b4b6ea9c3eab2f44b F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9 F test/altermalloc2.test fa7b1c1139ea39b8dec407cf1feb032ca8e0076bd429574969b619175ad0174b -F test/altertab.test b8b2104212e8ea87c75c3cbe3cb78ed7236a6c828ee2e59ed09d3dbe9812d002 +F test/altertab.test 6d7bbac2c4a6ef71b775094a3298fa3a92274d95034ee23157ffba92768e47e6 F test/altertab2.test b0d62f323ca5dab42b0bc028c52e310ebdd13e655e8fac070fe622bad7852c2b -F test/altertab3.test d0d51e652aaa11e37de1f1215181d88334fefcb185f3b9bd91e06e98260c4694 +F test/altertab3.test 1db384eb85b4a30b0b332842f5c596b0dc0126f7c61959be3f85ae8b1c271d9a F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 547bb700f903107b38611b014ca645d6b5bb819f5210d7bf39c40802aafeb7d7 -F test/analyze3.test 01f0b122e3e54ad2544f14f7cc7dcb4c2cb8753cad5e88c6b8d49615b3fd6a2b +F test/analyze3.test fca2a9de0017becfdcc201647f03b1cfd5ba0e7b5b5c852936e4ec62780cde49 F test/analyze4.test cdf88f3f72b0f0643a1ff6c730fc5af1e42464d47478d9fbac84c333f72c014e F test/analyze5.test fa5131952303ac4146aba101b116b9c8cb89e2637531c334a6df7f7d19dddc0d F test/analyze6.test 6c3f7df2996cb6872f355a6ac1eb6d5de00a5a9288214bad7ef25c97d9cc72dc @@ -667,7 +671,7 @@ F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0 -F test/atof1.test 1ccfc96a6888566597b83d882c81b3c04258dc39317e8c1cec89ba481eaa2fba +F test/atof1.test 10049623e77006691c4c2978c1dc8a3f75276377a53417811aa85bda7493f963 F test/atomic.test 065a453dde33c77ff586d91ccaa6ed419829d492dbb1a5694b8a09f3f9d7d061 F test/atomic2.test b6863b4aa552543874f80b42fb3063f1c8c2e3d8e56b6562f00a3cc347b5c1da F test/atrc.c c388fac43dbba05c804432a7135ae688b32e8f25818e9994ffba4b64cf60c27c @@ -709,7 +713,7 @@ F test/between.test 68137a6e941c221417c15b6fe2d55f27bb1b6ab48bdf9e2aa51efdd85bc53802 F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc -F test/bigmmap.test 31dad31573638bd32de866cdefd11843f75685be4ba6aec1a47918f098f1899b +F test/bigmmap.test e906cf9729d7c362270ffe9fa6471f4c39c28ba83f0f77fb795e1b4d38a22ba0 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 F test/bigsort.test 8299fa9298f4f1e02fc7d2712e8b77d6cd60e5a2 F test/bind.test 1e136709b306f7ed3192d349c2930d89df6ab621654ad6f1a72381d3fe76f483 @@ -728,7 +732,7 @@ F test/btree02.test 7555a5440453d900410160a52554fe6478af4faf53098f7235f1f443d5a1d6cc F test/btreefault.test c2bcb542685eea44621275cfedbd8a13f65201e3 F test/busy.test 510dc6daaad18bcbbc085bcc6217d6dc418def5e73f72ce1475eea0cb7834727 -F test/busy2.test 2499cb62c9e58e18335892602c158cb35639c411803adca6423401b31e46c503 +F test/busy2.test 0a1633fef7987fc8ea25ed5838f7eef2f08fc6d2a3dcc77d23e6402e53946a7a F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61 F test/cachespill.test 895997f84a25b323b166aecb69baab2d6380ea98f9e0bcc688c4493c535cfab9 @@ -738,9 +742,10 @@ F test/capi3c.test 54e2dc0c8fd7c34ad1590d1be6864397da2438c95a9f5aee2f8fbc60c112e44b F test/capi3d.test aba917805573a03deed961a21f07a5a84505ad0a616f7e3fc1508844a15bccc4 F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe -F test/cast.test 2906ccab6a3ebd147ffa63304b635be903ce58264110d0a0eb4fd9939422bb53 +F test/carray01.test 3f2658bbddd75a013735a296ae2178ff441aca3f00ba623cfbae00b732ede792 +F test/cast.test 336fa21989b5170ebcaf90c24266be22dd97b3e23d1fad5ecf6ad4efb04c4423 F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef -F test/check.test 9776af795bb5d0f197b7f8fe248052e3ca2ed35304d863efcdbf8b1316e11f65 +F test/check.test 4a2a91ed67eee84a6be16057c48d5198b6fb24849cd6da6cd855981de3fbb416 F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096970f014 F test/chunksize.test 427d87791743486cbf0c3b8c625002f3255cb3a89c6eba655a98923b1387b760 F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c @@ -759,8 +764,8 @@ F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151ecac0b95 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 87ad5458bb8709312dac0d6755fd30e8e4ca83298d0a9ef6e5c24277a3c3390e -F test/conflict.test 58857e2533fb9f2e0358ea7cb191215657846be1dd9da3b3d6df3e750c02ae03 -F test/conflict2.test bb0b94cf7196c64a3cbd815c66d3ee98c2fecd9c +F test/conflict.test ac0667090f66130ac77d5fb764655558ca6600dd6d88f670ca9123b61c448337 +F test/conflict2.test 5557909ce683b1073982f5d1b61dfb1d41e369533bfdaf003180c5bc87282dd1 F test/conflict3.test 81865d9599609aca394fb3b9cd5f561d4729ea5b176bece3644f6ecb540f88ac F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 F test/corrupt.test d7cb0300e4a297147b6a05e92a1684bc8973635c3bcaa3d66e983c9cbdbf47a3 @@ -807,7 +812,7 @@ F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 F test/date.test 9b73bbeb1b82d9c1f44dec5cf563bf7da58d2373 -F test/date2.test 5ef8265c71460cda6b1698bf18f4bb0ffb40ac08c5092f6afe84d398c2feb5be +F test/date2.test 520a1708e4e14c682cf514560f3e9f2e5affa9d66560fbc2a6941ae291260daf F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603 F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e F test/dbfuzz001.test 55e1a3504f8dea84155e09912fe3b1c3ad77e0b1a938ec42ca03b8e51b321e30 @@ -828,18 +833,18 @@ F test/descidx3.test 953c831df7ea219c73826dfbf2f6ee02d95040725aa88ccb4fa43d1a1999b926 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e F test/distinct.test e7d0cf371944dd0cbedff86420744e2f1ea2b528156451c97eb6ff41a99b9236 -F test/distinct2.test 11b0594c932098e969d084ba45ab81d5040f4d4e766db65d49146705a305ed98 +F test/distinct2.test cd1d15a4a2abf579298f7161e821ed50c0119136fe0424db85c52cf0adc230d1 F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376 F test/e_blobbytes.test 439a945953b35cb6948a552edaec4dc31fd70a05 F test/e_blobclose.test 4b3c8c60c2171164d472059c73e9f3c1844bb66d F test/e_blobopen.test e95e1d40f995056f6f322cd5e1a1b83a27e1a145 F test/e_blobwrite.test f87ff598b67af5b3ec002a8d83e804dc8d23808e88cf0080c176612fc9ffce14 F test/e_changes.test fd66105385153dbf21fdb35eb8ef6c3e1eade579 -F test/e_createtable.test ea27082d6f84df61e1d9e383f3fd79220418856a4a8afc41af75d458b8e7ac33 +F test/e_createtable.test 7107f5deda2324ea12dbf105044dc9265195401e9dbb3eead6a2c1a3da4bb5b7 F test/e_delete.test ab39084f26ae1f033c940b70ebdbbd523dc4962e F test/e_droptrigger.test 235c610f8bf8ec44513e222b9085c7e49fad65ad0c1975ac2577109dd06fd8fa F test/e_dropview.test 74e405df7fa0f762e0c9445b166fe03955856532e2bb234c372f7c51228d75e7 -F test/e_expr.test 62000e6675d5bcf4b09276fe011a27779629ff8f6678ba5937fb6f1b78d645ff +F test/e_expr.test 6ba7a51ece7b3e7fc145f14f924eed25ebb5a24e7b8596c78f3838d372cf0385 F test/e_fkey.test 0b458b85f192cdb9e9933d5891848bb19bcc44d3f49faf111a375f2844a164d3 F test/e_fts3.test 17ba7c373aba4d4f5696ba147ee23fd1a1ef70782af050e03e262ca187c5ee07 F test/e_insert.test f02f7f17852b2163732c6611d193f84fc67bc641fb4882c77a464076e5eba80e @@ -879,7 +884,7 @@ F test/filter2.test 485cf95d1f6d6ceee5632201ca52a71868599836f430cdee42e5f7f14666e30a F test/filterfault.test c08fb491d698e8df6c122c98f7db1c65ffcfcad2c1ab0e07fa8a5be1b34eaa8b F test/fkey1.test d11dbb8a93ead9b5c46ae5d02da016d61245d47662fb2d844c99214f6163f768 -F test/fkey2.test b1b6a8c5556dc0ccf31291b1fed8aa57e404b38f3236110e19ab4dc6aa93edf2 +F test/fkey2.test 1063d65e5923c054cfb8f0555a92a3ae0fa8c067275a33ee1715bd856cdb304c F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 6727452e163a427147e84e739da18713da553d79f9783559b04fdcd36d5c7421 @@ -1017,7 +1022,7 @@ F test/func.test f673822636fb8ed618dd2b80230d16e495d19c8f2e2e7d6c22e93e2b3de097ad F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 2bb0f31ab7baaed690b962a88544d7be6b34fa389364bc36a44e441ed3e3f1e6 -F test/func4.test a94858a8c1f10a408b0b3db439c990b59dbb2349411d503de011ac4e2b5f27a6 +F test/func4.test 2285fb5792d593fef442358763f0fd9de806eda47dbc7a5934df57ffdc484c31 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a F test/func6.test 90e42b64c4f9fb6f04f44cb8a1da586c8542502e926b19c76504fe74ff2a9b7c F test/fuzz-oss1.test e58330d01cbbd8215ee636b17a03fe220b37dbfa @@ -1027,7 +1032,7 @@ F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c 656ee850f331872a784e7d6a10649efe2af123bdaacb728b5a03e4faee8b959c +F test/fuzzcheck.c 5f81f2cc65f13068620245f2e2c6059657d3b26be476df379ae2da539f17676d F test/fuzzdata1.db d36e88741b4f23bcbaaf55b006290669d03c6c891cf13c7b3a53bc1b097b693f F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1035,7 +1040,7 @@ F test/fuzzdata5.db e35f64af17ec48926481cfaf3b3855e436bd40d1cfe2d59a9474cb4b748a52a5 F test/fuzzdata6.db 92a80e4afc172c24f662a10a612d188fb272de4a9bd19e017927c95f737de6d7 F test/fuzzdata7.db 0166b56fd7a6b9636a1d60ef0a060f86ddaecf99400a666bb6e5bbd7199ad1f2 -F test/fuzzdata8.db 99f99201280962430f3287e879e050ba88fe458d05cbf28e37ecab369ffe2e86 +F test/fuzzdata8.db f8451a1fd38efbea8c1a7cdf5d02259c4702446a9fabf566becd306b64a50236 F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536 @@ -1050,7 +1055,7 @@ F test/icu.test 716a6b89fbabe5cc63e0cd4c260befb08fd7b9d761f04d43669233292f0753b1 F test/ieee754.test b0945d12be7d255f3dfa18e2511b17ca37e0edd2b803231c52d05b86c04ab26e F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 -F test/in.test ae4ba0fe3232fdd84ef1090a68c5cd6ccd93f1f8774d5c967dd0c1b301492eed +F test/in.test 688ed2011d922d83141a45af431601738674a4c0bdde34b6351f688b82a169b3 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test 65460600d48933adba4283c6ebd089aae173d16136ab9d01f74c89089090c5a5 @@ -1084,7 +1089,7 @@ F test/insert.test 4e3f0de67aac3c5be1f4aaedbcea11638f1b5cdc9a3115be14d19aa9db7623c6 F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30 -F test/insert4.test fb9e0f752c75f453555990250b449f6d123ae6a3ebf054d14e4470de4498dce3 +F test/insert4.test 59cb99521be01a5aefc9be8e8b5a51ee7f3944781d4d7f6201b9f774fcd51662 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/insertfault.test ac63d14ea3b49c573673a572f4014b9117383a03e497c58f308b5c776e4a7f74 F test/instr.test 107df2b9b74a4b59315916b575590a08f2a714de0754abe541f10a0971d0a2a4 @@ -1101,13 +1106,13 @@ F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4 F test/ioerr6.test a395a6ab144b26a9e3e21059a1ab6a7149cca65b -F test/istrue.test 06f92ea38750fa74df7dbbe6920205251c2310861fbbe23a3adfa918a2e2ba74 -F test/join.test bca044589e94bb466e4c1e91fb6fecdc3f3326ca6b3f590f555f1958156eb321 -F test/join2.test 7d24d095ab88d3910228d53a3b548b7baf2e0e7d8aac6731a273e300e1b34b61 +F test/istrue.test 9619a2d77580f676048aaff7a16a0bcfea2b96c6c660dfaded2e53c873418899 +F test/join.test 25da4f53523a4aa17c893134b47fba6aa4799bb33350517b157785878290e238 +F test/join2.test 21fc30e54ab35ed66bf51b89cec18729205497f5cc43c83bc042f96a73721593 F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 F test/join5.test 3a96dc62f0b45402d7207e22d1993fe0c2fce1c57644a11439891dd62b990eb7 -F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b +F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497 F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4 F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ffa140e @@ -1207,7 +1212,7 @@ F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161 F test/notify3.test 10ff25cde502e72a92053a2f215d64bece4ef934 F test/notnull.test a37b663d5bb728d66fc182016613fb8e4a0a4bbf3d75b8876a7527f7d4ed3f18 -F test/null.test 0dcce4f04284ec66108c503327ad6d224c0752b3 +F test/null.test b7ff206a1c60fe01aa2abd33ef9ea83c93727d993ca8a613de86e925c9f2bc6f F test/nulls1.test 82c5bc33148405f21205865abf13c786084438d573a4ac4e87e11b6091cde526 F test/numcast.test 5d126f7f581432e86a90d1e35cac625164aec4a1 F test/numindex1.test 20a5450d4b056e48cd5db30e659f13347a099823 @@ -1230,7 +1235,7 @@ F test/ossfuzz.c 9636dad2092a05a32110df0ca06713038dd0c43dd89a77dabe4b8b0d71096715 F test/ossshell.c f125c5bd16e537a2549aa579b328dd1c59905e7ab1338dfc210e755bb7b69f17 F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f -F test/pager1.test 4fba160bf450cea19f6bf1d6483ef467545bac6405570e176c83c2c4b5d6d0d5 +F test/pager1.test 293c7ad1f19a07e548179b97534c6588249d4e40058b378ea26e75cc84d936f5 F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71 F test/pager3.test 4e9a83d6ca0838d7c602c9eb93d1357562d9059c1e02ffb138a8271020838370 F test/pager4.test a122e9e6925d5b23b31e3dfef8c6a44bbf19590e @@ -1262,7 +1267,7 @@ F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26 F test/quota.test bfb269ce81ea52f593f9648316cd5013d766dd2a F test/quota2.test 7dc12e08b11cbc4c16c9ba2aa2e040ea8d8ab4b8 -F test/quote.test 626149eda89ee64d81a3790de370f9f0211921b11568a49c28c861f394330508 +F test/quote.test 3f9238ab0e1db70dea89af9afa5859dbd759b0ce0a63da67d547553e2c316475 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 @@ -1272,7 +1277,7 @@ F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d F test/releasetest.tcl fb76d8fcc95ac29d6356cd9e52b726ab9e43a24082897618dfbcb7c2b0049153 x -F test/releasetest_data.tcl 9919fc6ac5bc92f8878fecfd1840db15999f660a6c9f609240b41aa62b885c88 +F test/releasetest_data.tcl b9cb30360759b80d92d4ea86b84ebfd8035b97f9078a482deb3cf9d0b2442655 F test/resetdb.test 8062cf10a09d8c048f8de7711e94571c38b38168db0e5877ba7561789e5eeb2b F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa @@ -1312,7 +1317,7 @@ F test/schemafault.test 1936bceca55ac82c5efbcc9fc91a1933e45c8d1e1d106b9a7e56c972a5a2a51e F test/securedel.test 2f70b2449186a1921bd01ec9da407fbfa98c3a7a5521854c300c194b2ff09384 F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 -F test/select1.test 009a6d8eacd9684d046302b8d13b50846a87e39d6f08e92178aa13e95ea29a2d +F test/select1.test 0ed936740777f52858b6607f39ffac4b2b63b8fc7edf3ab2ebad3c3553ceecee F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test c49fbb758903f3718e2de5aa4655eda4838131cbea24a86db908f8b6889aa68c F test/select4.test e8a2502e3623f3058871030599a48abb35789d2244d5b380ecf3696873fdd4a4 @@ -1332,9 +1337,9 @@ F test/session.test 78fa2365e93d3663a6e933f86e7afc395adf18be F test/sessionfuzz-data1.db 1f8d5def831f19b1c74571037f0d53a588ea49a6c4ca2a028fc0c27ef896dbcb F test/sessionfuzz.c f74c4e806bab5a093fb9c11b6123d17a6e0cf73fb7a0f49b12f5a75bf0b7b1a8 -F test/shared.test 1826673eb5eb745fb91a3bdac99a7737057742ae38dcb0fe076a384d6727578b +F test/shared.test f022874d9d299fe913529dc10f52ad5a386e4e7ff709270b9b1111b3a0f3420a F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 -F test/shared3.test ab693f9b6e156b8bfb2a0ad94f29fe69602a5d38 +F test/shared3.test f8cd07c1a2b7cdb315c01671a0b2f8e3830b11ef31da6baa9a9cd8da88965403 F test/shared4.test c75f476804e76e26bf6fa0e7b421fb0ca7d07558 F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test a81e99f83e6c51b02ac99c96fb3a2a7b5978c956 @@ -1344,7 +1349,7 @@ F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 1305efc92f132a1fcf97c00ac02b1b192865b4d33d44cab499e0bdcff71ce045 +F test/shell1.test 0ba53c72545de142e1b76fa793ee33293134aa02abb9b50b35398670481ea661 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test ac8c2b744014c3e9a0e26bfd829ab65f00923dc1a91ffd044863e9423cc91494 F test/shell4.test 1c6aef11daaa2d6830acaba3ac9cbec93fbc1c3d5530743a637f39b3987d08ce @@ -1360,7 +1365,7 @@ F test/skipscan1.test ed524bc86f27646b3a297f45d6557b55db338977b6838f8064b196b35848b31b F test/skipscan2.test 3eb703ce794f139e7b83567911046298bcde29606116727f9b700ce34f559d2d F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 -F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 +F test/skipscan5.test 980875ad45d8aacfe7bdec7c288343520cd1d14e84befdcfe50c785f9e6c8709 F test/skipscan6.test 0b4cd1b4ac9f84d91454df513c99a4932fa07e8f27b8049bea605068b3e34ac7 F test/snapshot.test a504f2e7009f512ef66c719f0ea1c55a556bdaf1e1312c80a04d46fc1a3e9632 F test/snapshot2.test 8d6ff5dd9cc503f6e12d408a30409c3f9c653507b24408d9cd7195931c89bc54 @@ -1385,7 +1390,7 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest1.c ac0e6ebadb97b54b7ac45288d1beea633a219d5fb98aa3395cb8364c31c985cb +F test/speedtest1.c 849dbcb0bded9f966e43f28e8ce824b2915cb5dd0031a2e85996f7e3de36c2b1 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -1401,7 +1406,7 @@ F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f F test/subquery2.test 90cf944b9de8204569cf656028391e4af1ccc8c0cc02d4ef38ee3be8de1ffb12 F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303 -F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a +F test/substr.test a673e3763e247e9b5e497a6cacbaf3da2bd8ec8921c0677145c109f2e633f36b F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8 F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12 F test/swarmvtab.test 9a3fd5ab3e9b3c976ad1b3d7646aab725114f2ac26b59395d0778b33bab6cdaf @@ -1426,7 +1431,7 @@ F test/temptable2.test d2940417496e2b9548e01d09990763fbe88c316504033256d51493e1f1a5ce6a F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl 6417cbb60c4169804e2e1b36ce1a840c9f33d0b0d97956e058f3cc49ed3904f0 +F test/tester.tcl 754521f0db534d51ab504b2d14fe0bdca1f1c15de731ceb8ee5bfd78372a2a5f F test/thread001.test b61a29dd87cf669f5f6ac96124a7c97d71b0c80d9012746072055877055cf9ef F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1437,7 +1442,7 @@ F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8 -F test/threadtest3.c 38a612ea62854349ed66372f330a40d73c5cf956 +F test/threadtest3.c e63013af10cf236c7610eb06d33bde08c861806dc64be811940ff4d9ddd34a4f F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925 F test/time-wordcount.sh 8e0b0f8109367827ad5d58f5cc849705731e4b90 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c @@ -1533,7 +1538,7 @@ F test/tkt2820.test 39940276b3436d125deb7d8ebeee053e4cf13213 F test/tkt2822.test f391776423a7c0d0949edfce375708bfb0f3141e F test/tkt2832.test a9b0b74a02dca166a04d9e37739c414b10929caa -F test/tkt2854.test e432965db29e27e16f539b2ba7f502eb2ccc49af +F test/tkt2854.test 47a2ae03bf36812f675ec06806a7b958e0de75312261dd8280c187f4a4a8281a F test/tkt2920.test a8737380e4ae6424e00c0273dc12775704efbebf F test/tkt2927.test 4752868b9eeeb07a217f7f19f4cbaac98d6d086d F test/tkt2942.test c5c87d179799ca6d1fbe83c815510b87cd5ec7ce @@ -1567,8 +1572,8 @@ F test/tkt3762.test 4d439ff7abdc8d9323150269d182c37c2d514576 F test/tkt3773.test 7bca904d2a647a6a4a291bd86d7fd7c73855b789 F test/tkt3791.test a6624b9a80b216a26cf473607f42f3e51898c267 -F test/tkt3793.test d90ffd75c52413908d15e1c44fc2ea9c80fcc449 -F test/tkt3810.test 09608d81c63a6ff3aaf7bc70717909c51f5f4048 +F test/tkt3793.test 9ee9c6f300adce634e8990a131ad5e20e22241643a1240c6b372b351205ef7cb +F test/tkt3810.test 3a3be9965d1861bd84019875851ad5ea90fd8d76b638361514a36a48ea53191b F test/tkt3824.test 150aa00bb6220672e5f0eb14dc8eaa36750425f0 F test/tkt3832.test 2300d10d57562b89875b72148338ac3e14f8847d F test/tkt3838.test 292e72489101cd1320d7278dc111c173ebf334d4 @@ -1588,7 +1593,7 @@ F test/trace.test a659a9862957f4789e37a92b3bf6d2caf5c86b02cdeefc41e850ae53acf6992a F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 F test/trace3.test 1dff966888773ff1bfea01c080caf15417892b3f998408fe920c4791f7337144 -F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 +F test/trans.test 45f6f9ab6f66a7b5744f1caac06b558f95da62501916906cf55586a896f9f439 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 F test/transitive1.test 293300f46916569f08875cdb2fe2134be2c27677 @@ -1613,6 +1618,7 @@ F test/tt3_checkpoint.c 9e75cf7c1c364f52e1c47fd0f14c4340a9db0fe1 F test/tt3_index.c 39eec10a35f57672225be4d182862152896dee4a F test/tt3_lookaside1.c 0377e202c3c2a50d688cb65ba203afeda6fafeb9 +F test/tt3_shared.c b37d22defc944a2ac4c91c927fd06c1d48cd51e2ce9d004fe868625bd2399f93 F test/tt3_stress.c f9a769ca8b026ecc76ee93ca8c9700a5619f8e51c581107c4053ba6ac97f616f F test/tt3_vacuum.c 1753f45917699c9c1f66b64c717a717c9379f776 F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff @@ -1649,7 +1655,7 @@ F test/vacuummem.test 7b42abb3208bd82dd23a7536588396f295a314f2 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 -F test/view.test 10ea54300a097d7c0337fd104abffe4a4786d1598b94017a37efe0e0d3e04dd5 +F test/view.test fd48eddb32a35a98c3de70062ebac66ebf4a2bbfc75a1cc1109159ef8bfc47a9 F test/vtab1.test c5d9e90ed02bcacd776dcbb7360199d290f7f53c26b484ddece543060c54319f F test/vtab2.test 14d4ab26cee13ba6cf5c5601b158e4f57552d3b055cdd9406cf7f711e9c84082 F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e @@ -1667,7 +1673,7 @@ F test/vtabF.test 1918844c7c902f6a16c8dacf1ec8f84886d6e78b F test/vtabH.test 2efb5a24b0bb50796b21eca23032cfb77abfa4b0c03938e38ce5897abac404ca F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f -F test/vtabJ.test d7b73675708cf63cfcb9d443bb451fc01a028347275b7311e51f9fdf3ca6757f +F test/vtabJ.test a6aef49d558af90fae10565b29501f82a95781cb4f797f2d13e2d19f9b6bc77b F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783 F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65 F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad @@ -1710,7 +1716,7 @@ F test/walvfs.test a2913001a83b19c1d20220e556cee14d87d47ecb6949b5e0a2e9e2590abecf1e F test/wapp.tcl b440cd8cf57953d3a49e7ee81e6a18f18efdaf113b69f7d8482b0710a64566ec F test/wapptest.tcl 899594e25684861d5b0c0880fb012364def50ef8097041b8ddf74be5ba7fa270 x -F test/where.test f5e62453537e5b335b69f3b09f8a02ce3328289fad5d866e25371284b837d78d +F test/where.test e713c0c64e3e6b062235e39a2f7e5508c517df16b63d69fd786e26bc7330b1c6 F test/where2.test 478d2170637b9211f593120648858593bf2445a1 F test/where3.test 2341a294e17193a6b1699ea7f192124a5286ca6acfcc3f4b06d16c931fbcda2c F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8 @@ -1719,13 +1725,13 @@ F test/where7.test 75722434c486ac9e74718caa6cce234f45ba34c0b6c0f9555b29eb8bb5f6ade1 F test/where8.test 461ca40265ed996a6305da99bb024b0e41602bb586acf544c08f95922358e49f F test/where9.test 8e3e0ff42cc17156f52361a1c012281550d0d632912fec92d1d6df74db7a8e6d -F test/whereA.test 6c6a420ca7d313242f9b1bd471dc80e4d0f8323700ba9c78df0bb843d4daa3b4 +F test/whereA.test 9d1077b117f1b68d5f739d94f36956c36cf995eb87bb19b77b2e81af020edd20 F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/whereC.test cae295158703cb3fc23bf1a108a9ab730efff0f6 F test/whereD.test c1c335e914e28b122e000e9310f02d2be83e1c9dbca2e29f46bd732703944d1b F test/whereE.test b3a055eef928c992b0a33198a7b8dc10eea5ad2f F test/whereF.test 3d9412b1199d3e2bed34fcb76b4c48d0bf4df95d27e3f8dd27b6f8b4716d0d89 -F test/whereG.test 9363b2a97d914cb1b81aff5069ef0cf2a071a67e2b604eac6fe9c0114017d9aa +F test/whereG.test 77127a4d214bb21da3b5c695cf4106cd9e418c60d9c24471ba55d3772067cd35 F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2 F test/whereI.test a2874062140ed4aba9ffae76e6190a3df6fc73d1373fdfa8fd632945082a5364 F test/whereJ.test 88287550f6ee604422403b053455b1ad894eeaa5c35d348532dfa1439286cb9a @@ -1758,14 +1764,15 @@ F test/windowerr.tcl f5acd6fbc210d7b5546c0e879d157888455cd4a17a1d3f28f07c1c8a387019e0 F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3cc1819b F test/windowfault.test 72375ae71031eabf96bc88d0af128c8628a091ddc99b5a394e848b3df5fc17ad -F test/with1.test 584580a5ae79868a91873863f8cb2d00040006dc1e4c332ef1d8642f2815dc6e +F test/with1.test 780be387f01e290e768bdfd1827280f9e37ba37223eb4736aba386864fac5a94 F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab -F test/with3.test 13b3336739da648a9e4dfa11bb04e73a920c97620041007c5f75d5d14084c346 +F test/with3.test a261f0ea225c4af0ce6447f1157bb603959b2a665f14a03951c2883d2ef1c0f0 F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205 +F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8 F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64 -F test/without_rowid1.test 9cfb83705c506e3849fa7efc88a3c9a15f9a50bf9b1516b41757a7cef9bba8c3 +F test/without_rowid1.test e4034c0849ccc2e8bb749c69f15bd69bb9fcf8fe77e8d17ce02369604242fe83 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 -F test/without_rowid3.test 96426a6c9a2a5cf62bbe55ea1ad038eaaf4bf743f40a1ad517233b8e5a3d4339 +F test/without_rowid3.test 39ab0dd773eaa62e59b17093f875327630f54c4145458f6d2b053d68d4b2f67b F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 8463b20098e9f75a501a9f17dfb42fffc79068eac0b2775fe56ef2281d2df45e @@ -1778,7 +1785,7 @@ F test/zipfile2.test 9903388a602a3834189857a985106ff95c3bba6a3969e0134127df991889db5d F test/zipfilefault.test 44d4d7a7f7cca7521d569d7f71026b241d65a6b1757aa409c1a168827edbbc2c F tool/GetFile.cs 47852aa0d806fe47ed1ac5138bdce7f000fe87aaa7f28107d0cb1e26682aeb44 -F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d +F tool/GetTclKit.bat e95747c0f7a9fe279a9979178b71f6431a21f945b390fc3120244897ff3f5135 F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/build-all-msvc.bat c12328d06c45fec8baada5949e3d5af54bf8c887 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 @@ -1798,8 +1805,8 @@ F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c 600a58b9d1b8ec5419373982428e927ca208826edacb91ca42ab94514d006039 -F tool/lempar.c e8899b28488f060d0ff931539ea6311b16b22dce068c086c788a06d5e8d01ab7 +F tool/lemon.c 70eedc31614a58fe31a71025c17ebd1502a6ce9cfef0ed5e33acb0b5b737b291 +F tool/lempar.c 0e1d5eeb9736108d3dba782a9dd56f4e7cb69006b6ee181308b7ebfb15313a12 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1817,7 +1824,7 @@ F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f -F tool/mksqlite3c.tcl f4ef476510eca4124c874a72029f1e01bc54a896b1724e8f9eef0d8bfae0e84c +F tool/mksqlite3c.tcl 00c4c0382eb000153182da2bee2547ca05554eeeed10177efe5894c54e4e6d4d F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 @@ -1844,7 +1851,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c -F tool/sqldiff.c 5046b8e227213ad016b336eb5a933e252e1f0fd1e07060c5755e259a30891287 +F tool/sqldiff.c 4151108387cb56c08906e5ac8d6a353dcfe8fc6014eeded0f0910e2230ea0f5b F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -1879,11 +1886,11 @@ F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b050976079ba4a22d4dfeadb81f40cf71da6588c95bf2b634d88b416de5accd7 -R 799818c17104aa7af945cf9f5cad3762 +P 23212b1a054f05773a9f69f9802035eea6a9d759a2a09e22f46d1046c058b417 +R 02db8b9bcb7f3c64353edbc1fa9fbf5b T +bgcolor * #d0c0ff T +sym-release * -T +sym-version-3.33.0 * +T +sym-version-3.34.0 * U drh -Z 652aa26f564c1138ae3a9226a8f034b3 -# Remove this line to create a well-formed manifest. +Z b7b093d44b407c1b4e832f8c913357ae +# Remove this line to create a well-formed Fossil manifest. diff -Nru sqlite3-3.33.0/manifest.uuid sqlite3-3.34.0/manifest.uuid --- sqlite3-3.33.0/manifest.uuid 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/manifest.uuid 2020-12-01 16:36:02.000000000 +0000 @@ -1 +1 @@ -fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f +a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b diff -Nru sqlite3-3.33.0/src/alter.c sqlite3-3.34.0/src/alter.c --- sqlite3-3.33.0/src/alter.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/alter.c 2020-12-01 16:36:02.000000000 +0000 @@ -1196,13 +1196,21 @@ int i; for(i=0; inSrc && rc==SQLITE_OK; i++){ struct SrcList_item *p = &pSrc->a[i]; - p->pTab = sqlite3LocateTableItem(pParse, 0, p); p->iCursor = pParse->nTab++; - if( p->pTab==0 ){ - rc = SQLITE_ERROR; + if( p->pSelect ){ + sqlite3SelectPrep(pParse, p->pSelect, 0); + sqlite3ExpandSubquery(pParse, p); + assert( i>0 ); + assert( pStep->pFrom->a[i-1].pSelect ); + sqlite3SelectPrep(pParse, pStep->pFrom->a[i-1].pSelect, 0); }else{ - p->pTab->nTabRef++; - rc = sqlite3ViewGetColumnNames(pParse, p->pTab); + p->pTab = sqlite3LocateTableItem(pParse, 0, p); + if( p->pTab==0 ){ + rc = SQLITE_ERROR; + }else{ + p->pTab->nTabRef++; + rc = sqlite3ViewGetColumnNames(pParse, p->pTab); + } } } sNC.pSrcList = pSrc; @@ -1264,6 +1272,12 @@ sqlite3WalkExpr(pWalker, pUpsert->pUpsertWhere); sqlite3WalkExpr(pWalker, pUpsert->pUpsertTargetWhere); } + if( pStep->pFrom ){ + int i; + for(i=0; ipFrom->nSrc; i++){ + sqlite3WalkSelect(pWalker, pStep->pFrom->a[i].pSelect); + } + } } } diff -Nru sqlite3-3.33.0/src/analyze.c sqlite3-3.34.0/src/analyze.c --- sqlite3-3.33.0/src/analyze.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/analyze.c 2020-12-01 16:36:02.000000000 +0000 @@ -1772,6 +1772,7 @@ } pSpace = (tRowcnt*)&pIdx->aSample[nSample]; pIdx->aAvgEq = pSpace; pSpace += nIdxCol; + pIdx->pTable->tabFlags |= TF_HasStat4; for(i=0; iaSample[i].anEq = pSpace; pSpace += nIdxCol; pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol; diff -Nru sqlite3-3.33.0/src/attach.c sqlite3-3.34.0/src/attach.c --- sqlite3-3.33.0/src/attach.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/attach.c 2020-12-01 16:36:02.000000000 +0000 @@ -293,7 +293,9 @@ sqlite3_snprintf(sizeof(zErr),zErr, "cannot detach database %s", zName); goto detach_error; } - if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){ + if( sqlite3BtreeTxnState(pDb->pBt)!=SQLITE_TXN_NONE + || sqlite3BtreeIsInBackup(pDb->pBt) + ){ sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName); goto detach_error; } diff -Nru sqlite3-3.33.0/src/backup.c sqlite3-3.34.0/src/backup.c --- sqlite3-3.33.0/src/backup.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/backup.c 2020-12-01 16:36:02.000000000 +0000 @@ -123,7 +123,7 @@ ** message in database handle db. */ static int checkReadTransaction(sqlite3 *db, Btree *p){ - if( sqlite3BtreeIsInReadTrans(p) ){ + if( sqlite3BtreeTxnState(p)!=SQLITE_TXN_NONE ){ sqlite3ErrorWithMsg(db, SQLITE_ERROR, "destination database is in use"); return SQLITE_ERROR; } @@ -354,7 +354,7 @@ ** one now. If a transaction is opened here, then it will be closed ** before this function exits. */ - if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){ + if( rc==SQLITE_OK && SQLITE_TXN_NONE==sqlite3BtreeTxnState(p->pSrc) ){ rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0); bCloseTrans = 1; } @@ -726,7 +726,7 @@ sqlite3BtreeEnter(pTo); sqlite3BtreeEnter(pFrom); - assert( sqlite3BtreeIsInTrans(pTo) ); + assert( sqlite3BtreeTxnState(pTo)==SQLITE_TXN_WRITE ); pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); if( pFd->pMethods ){ i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); @@ -762,7 +762,7 @@ sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); } - assert( sqlite3BtreeIsInTrans(pTo)==0 ); + assert( sqlite3BtreeTxnState(pTo)!=SQLITE_TXN_WRITE ); copy_finished: sqlite3BtreeLeave(pFrom); sqlite3BtreeLeave(pTo); diff -Nru sqlite3-3.33.0/src/btree.c sqlite3-3.34.0/src/btree.c --- sqlite3-3.33.0/src/btree.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/btree.c 2020-12-01 16:36:02.000000000 +0000 @@ -112,6 +112,17 @@ #define hasReadConflicts(a, b) 0 #endif +#ifdef SQLITE_DEBUG +/* +** Return and reset the seek counter for a Btree object. +*/ +sqlite3_uint64 sqlite3BtreeSeekCount(Btree *pBt){ + u64 n = pBt->nSeek; + pBt->nSeek = 0; + return n; +} +#endif + /* ** Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single ** (MemPage*) as an argument. The (MemPage*) must not be NULL. @@ -2605,7 +2616,7 @@ ** do not change the pager-cache size. */ if( sqlite3BtreeSchema(p, 0, 0)==0 ){ - sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE); + sqlite3BtreeSetCacheSize(p, SQLITE_DEFAULT_CACHE_SIZE); } pFile = sqlite3PagerFile(pBt->pPager); @@ -5459,6 +5470,10 @@ } } +#ifdef SQLITE_DEBUG + pCur->pBtree->nSeek++; /* Performance measurement during testing */ +#endif + if( pIdxKey ){ xRecordCompare = sqlite3VdbeFindCompare(pIdxKey); pIdxKey->errCode = 0; @@ -5735,7 +5750,7 @@ pPage = pCur->pPage; idx = ++pCur->ix; - if( !pPage->isInit ){ + if( !pPage->isInit || sqlite3FaultSim(412) ){ /* The only known way for this to happen is for there to be a ** recursive SQL function that does a DELETE operation as part of a ** SELECT which deletes content out from under an active cursor @@ -10310,11 +10325,12 @@ } /* -** Return non-zero if a transaction is active. +** Return one of SQLITE_TXN_NONE, SQLITE_TXN_READ, or SQLITE_TXN_WRITE +** to describe the current transaction state of Btree p. */ -int sqlite3BtreeIsInTrans(Btree *p){ +int sqlite3BtreeTxnState(Btree *p){ assert( p==0 || sqlite3_mutex_held(p->db->mutex) ); - return (p && (p->inTrans==TRANS_WRITE)); + return p ? p->inTrans : 0; } #ifndef SQLITE_OMIT_WAL @@ -10343,14 +10359,8 @@ #endif /* -** Return non-zero if a read (or write) transaction is active. +** Return true if there is currently a backup running on Btree p. */ -int sqlite3BtreeIsInReadTrans(Btree *p){ - assert( p ); - assert( sqlite3_mutex_held(p->db->mutex) ); - return p->inTrans!=TRANS_NONE; -} - int sqlite3BtreeIsInBackup(Btree *p){ assert( p ); assert( sqlite3_mutex_held(p->db->mutex) ); diff -Nru sqlite3-3.33.0/src/btree.h sqlite3-3.34.0/src/btree.h --- sqlite3-3.33.0/src/btree.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/btree.h 2020-12-01 16:36:02.000000000 +0000 @@ -85,16 +85,24 @@ int sqlite3BtreeRollback(Btree*,int,int); int sqlite3BtreeBeginStmt(Btree*,int); int sqlite3BtreeCreateTable(Btree*, Pgno*, int flags); -int sqlite3BtreeIsInTrans(Btree*); -int sqlite3BtreeIsInReadTrans(Btree*); +int sqlite3BtreeTxnState(Btree*); int sqlite3BtreeIsInBackup(Btree*); + void *sqlite3BtreeSchema(Btree *, int, void(*)(void *)); int sqlite3BtreeSchemaLocked(Btree *pBtree); #ifndef SQLITE_OMIT_SHARED_CACHE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock); #endif + +/* Savepoints are named, nestable SQL transactions mostly implemented */ +/* in vdbe.c and pager.c See https://sqlite.org/lang_savepoint.html */ int sqlite3BtreeSavepoint(Btree *, int, int); +/* "Checkpoint" only refers to WAL. See https://sqlite.org/wal.html#ckpt */ +#ifndef SQLITE_OMIT_WAL + int sqlite3BtreeCheckpoint(Btree*, int, int *, int *); +#endif + const char *sqlite3BtreeGetFilename(Btree *); const char *sqlite3BtreeGetJournalname(Btree *); int sqlite3BtreeCopyFile(Btree *, Btree *); @@ -331,6 +339,12 @@ int sqlite3BtreeIsReadonly(Btree *pBt); int sqlite3HeaderSizeBtree(void); +#ifdef SQLITE_DEBUG +sqlite3_uint64 sqlite3BtreeSeekCount(Btree*); +#else +# define sqlite3BtreeSeekCount(X) 0 +#endif + #ifndef NDEBUG int sqlite3BtreeCursorIsValid(BtCursor*); #endif diff -Nru sqlite3-3.33.0/src/btreeInt.h sqlite3-3.34.0/src/btreeInt.h --- sqlite3-3.33.0/src/btreeInt.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/btreeInt.h 2020-12-01 16:36:02.000000000 +0000 @@ -353,6 +353,9 @@ u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */ Btree *pNext; /* List of other sharable Btrees from the same db */ Btree *pPrev; /* Back pointer of the same list */ +#ifdef SQLITE_DEBUG + u64 nSeek; /* Calls to sqlite3BtreeMovetoUnpacked() */ +#endif #ifndef SQLITE_OMIT_SHARED_CACHE BtLock lock; /* Object used to lock page 1 */ #endif @@ -364,11 +367,25 @@ ** If the shared-data extension is enabled, there may be multiple users ** of the Btree structure. At most one of these may open a write transaction, ** but any number may have active read transactions. +** +** These values must match SQLITE_TXN_NONE, SQLITE_TXN_READ, and +** SQLITE_TXN_WRITE */ #define TRANS_NONE 0 #define TRANS_READ 1 #define TRANS_WRITE 2 +#if TRANS_NONE!=SQLITE_TXN_NONE +# error wrong numeric code for no-transaction +#endif +#if TRANS_READ!=SQLITE_TXN_READ +# error wrong numeric code for read-transaction +#endif +#if TRANS_WRITE!=SQLITE_TXN_WRITE +# error wrong numeric code for write-transaction +#endif + + /* ** An instance of this object represents a single database file. ** diff -Nru sqlite3-3.33.0/src/build.c sqlite3-3.34.0/src/build.c --- sqlite3-3.33.0/src/build.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/build.c 2020-12-01 16:36:02.000000000 +0000 @@ -53,7 +53,7 @@ u8 isWriteLock, /* True for a write lock */ const char *zName /* Name of the table to be locked */ ){ - Parse *pToplevel = sqlite3ParseToplevel(pParse); + Parse *pToplevel; int i; int nBytes; TableLock *p; @@ -61,6 +61,7 @@ if( iDb==1 ) return; if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return; + pToplevel = sqlite3ParseToplevel(pParse); for(i=0; inTableLock; i++){ p = &pToplevel->aTableLock[i]; if( p->iDb==iDb && p->iTab==iTab ){ @@ -90,10 +91,8 @@ */ static void codeTableLocks(Parse *pParse){ int i; - Vdbe *pVdbe; - - pVdbe = sqlite3GetVdbe(pParse); - assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */ + Vdbe *pVdbe = pParse->pVdbe; + assert( pVdbe!=0 ); for(i=0; inTableLock; i++){ TableLock *p = &pParse->aTableLock[i]; @@ -1618,8 +1617,10 @@ ** Add a new CHECK constraint to the table currently under construction. */ void sqlite3AddCheckConstraint( - Parse *pParse, /* Parsing context */ - Expr *pCheckExpr /* The check expression */ + Parse *pParse, /* Parsing context */ + Expr *pCheckExpr, /* The check expression */ + const char *zStart, /* Opening "(" */ + const char *zEnd /* Closing ")" */ ){ #ifndef SQLITE_OMIT_CHECK Table *pTab = pParse->pNewTable; @@ -1630,6 +1631,13 @@ pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr); if( pParse->constraintName.n ){ sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1); + }else{ + Token t; + for(zStart++; sqlite3Isspace(zStart[0]); zStart++){} + while( sqlite3Isspace(zEnd[-1]) ){ zEnd--; } + t.z = zStart; + t.n = (int)(zEnd - t.z); + sqlite3ExprListSetName(pParse, pTab->pCheck, &t, 1); } }else #endif @@ -1648,7 +1656,7 @@ char *zColl; /* Dequoted name of collation sequence */ sqlite3 *db; - if( (p = pParse->pNewTable)==0 ) return; + if( (p = pParse->pNewTable)==0 || IN_RENAME_OBJECT ) return; i = p->nCol-1; db = pParse->db; zColl = sqlite3NameFromToken(db, pToken); @@ -1883,12 +1891,15 @@ int nByte; if( pIdx->nColumn>=N ) return SQLITE_OK; assert( pIdx->isResized==0 ); - nByte = (sizeof(char*) + sizeof(i16) + 1)*N; + nByte = (sizeof(char*) + sizeof(LogEst) + sizeof(i16) + 1)*N; zExtra = sqlite3DbMallocZero(db, nByte); if( zExtra==0 ) return SQLITE_NOMEM_BKPT; memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn); pIdx->azColl = (const char**)zExtra; zExtra += sizeof(char*)*N; + memcpy(zExtra, pIdx->aiRowLogEst, sizeof(LogEst)*(pIdx->nKeyCol+1)); + pIdx->aiRowLogEst = (LogEst*)zExtra; + zExtra += sizeof(LogEst)*N; memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn); pIdx->aiColumn = (i16*)zExtra; zExtra += sizeof(i16)*N; @@ -4449,7 +4460,7 @@ assert(pList || pParse->db->mallocFailed ); if( pList ){ for(i=0, pItem=pList->a; inSrc; i++, pItem++){ - if( pItem->iCursor>=0 ) break; + if( pItem->iCursor>=0 ) continue; pItem->iCursor = pParse->nTab++; if( pItem->pSelect ){ sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc); @@ -4466,15 +4477,15 @@ struct SrcList_item *pItem; if( pList==0 ) return; for(pItem=pList->a, i=0; inSrc; i++, pItem++){ - sqlite3DbFree(db, pItem->zDatabase); + if( pItem->zDatabase ) sqlite3DbFreeNN(db, pItem->zDatabase); sqlite3DbFree(db, pItem->zName); - sqlite3DbFree(db, pItem->zAlias); + if( pItem->zAlias ) sqlite3DbFreeNN(db, pItem->zAlias); if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy); if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg); sqlite3DeleteTable(db, pItem->pTab); - sqlite3SelectDelete(db, pItem->pSelect); - sqlite3ExprDelete(db, pItem->pOn); - sqlite3IdListDelete(db, pItem->pUsing); + if( pItem->pSelect ) sqlite3SelectDelete(db, pItem->pSelect); + if( pItem->pOn ) sqlite3ExprDelete(db, pItem->pOn); + if( pItem->pUsing ) sqlite3IdListDelete(db, pItem->pUsing); } sqlite3DbFreeNN(db, pList); } @@ -4646,7 +4657,16 @@ if( !v ) return; if( type!=TK_DEFERRED ){ for(i=0; inDb; i++){ - sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1); + int eTxnType; + Btree *pBt = db->aDb[i].pBt; + if( pBt && sqlite3BtreeIsReadonly(pBt) ){ + eTxnType = 0; /* Read txn */ + }else if( type==TK_EXCLUSIVE ){ + eTxnType = 2; /* Exclusive txn */ + }else{ + eTxnType = 1; /* Write txn */ + } + sqlite3VdbeAddOp2(v, OP_Transaction, i, eTxnType); sqlite3VdbeUsesBtree(v, i); } } @@ -4735,13 +4755,11 @@ ** will occur at the end of the top-level VDBE and will be generated ** later, by sqlite3FinishCoding(). */ -void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ - Parse *pToplevel = sqlite3ParseToplevel(pParse); - - assert( iDb>=0 && iDbdb->nDb ); - assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 ); +static void sqlite3CodeVerifySchemaAtToplevel(Parse *pToplevel, int iDb){ + assert( iDb>=0 && iDbdb->nDb ); + assert( pToplevel->db->aDb[iDb].pBt!=0 || iDb==1 ); assert( iDbdb, iDb, 0) ); + assert( sqlite3SchemaMutexHeld(pToplevel->db, iDb, 0) ); if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){ DbMaskSet(pToplevel->cookieMask, iDb); if( !OMIT_TEMPDB && iDb==1 ){ @@ -4749,6 +4767,10 @@ } } } +void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ + sqlite3CodeVerifySchemaAtToplevel(sqlite3ParseToplevel(pParse), iDb); +} + /* ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each @@ -4780,7 +4802,7 @@ */ void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){ Parse *pToplevel = sqlite3ParseToplevel(pParse); - sqlite3CodeVerifySchema(pParse, iDb); + sqlite3CodeVerifySchemaAtToplevel(pToplevel, iDb); DbMaskSet(pToplevel->writeMask, iDb); pToplevel->isMultiWrite |= setStatement; } @@ -4831,7 +4853,9 @@ i8 p4type, /* P4_STATIC or P4_TRANSIENT */ u8 p5Errmsg /* P5_ErrMsg type */ ){ - Vdbe *v = sqlite3GetVdbe(pParse); + Vdbe *v; + assert( pParse->pVdbe!=0 ); + v = sqlite3GetVdbe(pParse); assert( (errCode&0xff)==SQLITE_CONSTRAINT || pParse->nested ); if( onError==OE_Abort ){ sqlite3MayAbort(pParse); diff -Nru sqlite3-3.33.0/src/delete.c sqlite3-3.34.0/src/delete.c --- sqlite3-3.33.0/src/delete.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/delete.c 2020-12-01 16:36:02.000000000 +0000 @@ -425,7 +425,7 @@ }else #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ { - u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK|WHERE_SEEK_TABLE; + u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; if( sNC.ncFlags & NC_VarSelect ) bComplex = 1; wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW); if( HasRowid(pTab) ){ @@ -461,6 +461,9 @@ assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI ); assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF ); if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse); + if( sqlite3WhereUsesDeferredSeek(pWInfo) ){ + sqlite3VdbeAddOp1(v, OP_FinishSeek, iTabCur); + } /* Keep track of the number of rows to be deleted */ if( memCnt ){ @@ -495,6 +498,7 @@ if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iTabCur] = 0; if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iTabCur] = 0; if( addrEphOpen ) sqlite3VdbeChangeToNoop(v, addrEphOpen); + addrBypass = sqlite3VdbeMakeLabel(pParse); }else{ if( pPk ){ /* Add the PK key for this row to the temporary table */ @@ -508,13 +512,6 @@ nKey = 1; /* OP_DeferredSeek always uses a single rowid */ sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey); } - } - - /* If this DELETE cannot use the ONEPASS strategy, this is the - ** end of the WHERE loop */ - if( eOnePass!=ONEPASS_OFF ){ - addrBypass = sqlite3VdbeMakeLabel(pParse); - }else{ sqlite3WhereEnd(pWInfo); } @@ -945,10 +942,6 @@ } if( regOut ){ sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut); - if( pIdx->pTable->pSelect ){ - const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx); - sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); - } } sqlite3ReleaseTempRange(pParse, regBase, nCol); return regBase; diff -Nru sqlite3-3.33.0/src/expr.c sqlite3-3.34.0/src/expr.c --- sqlite3-3.33.0/src/expr.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/expr.c 2020-12-01 16:36:02.000000000 +0000 @@ -44,8 +44,10 @@ */ char sqlite3ExprAffinity(const Expr *pExpr){ int op; - while( ExprHasProperty(pExpr, EP_Skip) ){ - assert( pExpr->op==TK_COLLATE || pExpr->op==TK_IF_NULL_ROW ); + while( ExprHasProperty(pExpr, EP_Skip|EP_IfNullRow) ){ + assert( pExpr->op==TK_COLLATE + || pExpr->op==TK_IF_NULL_ROW + || (pExpr->op==TK_REGISTER && pExpr->op2==TK_IF_NULL_ROW) ); pExpr = pExpr->pLeft; assert( pExpr!=0 ); } @@ -115,7 +117,7 @@ */ Expr *sqlite3ExprSkipCollate(Expr *pExpr){ while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){ - assert( pExpr->op==TK_COLLATE || pExpr->op==TK_IF_NULL_ROW ); + assert( pExpr->op==TK_COLLATE ); pExpr = pExpr->pLeft; } return pExpr; @@ -134,7 +136,7 @@ assert( pExpr->op==TK_FUNCTION ); pExpr = pExpr->x.pList->a[0].pExpr; }else{ - assert( pExpr->op==TK_COLLATE || pExpr->op==TK_IF_NULL_ROW ); + assert( pExpr->op==TK_COLLATE ); pExpr = pExpr->pLeft; } } @@ -768,6 +770,7 @@ ** Expr.flags. */ void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){ + if( pParse->nErr ) return; if( p && p->x.pList && !ExprHasProperty(p, EP_xIsSelect) ){ p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList); } @@ -3620,6 +3623,7 @@ */ static void exprToRegister(Expr *pExpr, int iReg){ Expr *p = sqlite3ExprSkipCollateAndLikely(pExpr); + if( NEVER(p==0) ) return; p->op2 = p->op; p->op = TK_REGISTER; p->iTable = iReg; @@ -4607,6 +4611,7 @@ int r2; pExpr = sqlite3ExprSkipCollateAndLikely(pExpr); if( ConstFactorOk(pParse) + && ALWAYS(pExpr!=0) && pExpr->op!=TK_REGISTER && sqlite3ExprIsConstantNotJoin(pExpr) ){ diff -Nru sqlite3-3.33.0/src/func.c sqlite3-3.34.0/src/func.c --- sqlite3-3.33.0/src/func.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/func.c 2020-12-01 16:36:02.000000000 +0000 @@ -1995,6 +1995,8 @@ FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ), FUNCTION(substr, 2, 0, 0, substrFunc ), FUNCTION(substr, 3, 0, 0, substrFunc ), + FUNCTION(substring, 2, 0, 0, substrFunc ), + FUNCTION(substring, 3, 0, 0, substrFunc ), WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0), WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0), WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0), diff -Nru sqlite3-3.33.0/src/insert.c sqlite3-3.34.0/src/insert.c --- sqlite3-3.33.0/src/insert.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/insert.c 2020-12-01 16:36:02.000000000 +0000 @@ -32,7 +32,8 @@ ){ Vdbe *v; assert( !IsVirtual(pTab) ); - v = sqlite3GetVdbe(pParse); + assert( pParse->pVdbe!=0 ); + v = pParse->pVdbe; assert( opcode==OP_OpenWrite || opcode==OP_OpenRead ); sqlite3TableLock(pParse, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName); @@ -1531,7 +1532,7 @@ isUpdate = regOldData!=0; db = pParse->db; - v = sqlite3GetVdbe(pParse); + v = pParse->pVdbe; assert( v!=0 ); assert( pTab->pSelect==0 ); /* This table is not a VIEW */ nCol = pTab->nCol; @@ -1685,7 +1686,7 @@ sqlite3VdbeGoto(v, ignoreDest); }else{ char *zName = pCheck->a[i].zEName; - if( zName==0 ) zName = pTab->zName; + assert( zName!=0 || pParse->db->mallocFailed ); if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-26383-51744 */ sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK, onError, zName, P4_TRANSIENT, @@ -2304,7 +2305,7 @@ || update_flags==(OPFLAG_ISUPDATE|OPFLAG_SAVEPOSITION) ); - v = sqlite3GetVdbe(pParse); + v = pParse->pVdbe; assert( v!=0 ); assert( pTab->pSelect==0 ); /* This table is not a VIEW */ for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ @@ -2405,7 +2406,7 @@ return 0; } iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); - v = sqlite3GetVdbe(pParse); + v = pParse->pVdbe; assert( v!=0 ); if( iBase<0 ) iBase = pParse->nTab; iDataCur = iBase++; diff -Nru sqlite3-3.33.0/src/loadext.c sqlite3-3.34.0/src/loadext.c --- sqlite3-3.33.0/src/loadext.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/loadext.c 2020-12-01 16:36:02.000000000 +0000 @@ -478,6 +478,8 @@ sqlite3_create_filename, sqlite3_free_filename, sqlite3_database_file_object, + /* Version 3.34.0 and later */ + sqlite3_txn_state, }; /* True if x is the directory separator character diff -Nru sqlite3-3.33.0/src/main.c sqlite3-3.34.0/src/main.c --- sqlite3-3.33.0/src/main.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/main.c 2020-12-01 16:36:02.000000000 +0000 @@ -897,7 +897,7 @@ sqlite3BtreeEnterAll(db); for(i=0; rc==SQLITE_OK && inDb; i++){ Btree *pBt = db->aDb[i].pBt; - if( pBt && sqlite3BtreeIsInTrans(pBt) ){ + if( pBt && sqlite3BtreeTxnState(pBt)==SQLITE_TXN_WRITE ){ Pager *pPager = sqlite3BtreePager(pBt); rc = sqlite3PagerFlush(pPager); if( rc==SQLITE_BUSY ){ @@ -1242,6 +1242,36 @@ } /* +** Return the transaction state for a single databse, or the maximum +** transaction state over all attached databases if zSchema is null. +*/ +int sqlite3_txn_state(sqlite3 *db, const char *zSchema){ + int iDb, nDb; + int iTxn = -1; +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; + return -1; + } +#endif + sqlite3_mutex_enter(db->mutex); + if( zSchema ){ + nDb = iDb = sqlite3FindDbName(db, zSchema); + if( iDb<0 ) nDb--; + }else{ + iDb = 0; + nDb = db->nDb-1; + } + for(; iDb<=nDb; iDb++){ + Btree *pBt = db->aDb[iDb].pBt; + int x = pBt!=0 ? sqlite3BtreeTxnState(pBt) : SQLITE_TXN_NONE; + if( x>iTxn ) iTxn = x; + } + sqlite3_mutex_leave(db->mutex); + return iTxn; +} + +/* ** Two variations on the public interface for closing a database ** connection. The sqlite3_close() version returns SQLITE_BUSY and ** leaves the connection option if there are unfinalized prepared @@ -1401,7 +1431,7 @@ for(i=0; inDb; i++){ Btree *p = db->aDb[i].pBt; if( p ){ - if( sqlite3BtreeIsInTrans(p) ){ + if( sqlite3BtreeTxnState(p)==SQLITE_TXN_WRITE ){ inTrans = 1; } sqlite3BtreeRollback(p, tripCode, !schemaChange); @@ -3822,7 +3852,9 @@ } rc = SQLITE_OK; }else{ + int nSave = db->busyHandler.nBusy; rc = sqlite3OsFileControl(fd, op, pArg); + db->busyHandler.nBusy = nSave; } sqlite3BtreeLeave(pBtree); } @@ -4205,6 +4237,25 @@ sqlite3ResultIntReal(pCtx); break; } + + /* sqlite3_test_control(SQLITE_TESTCTRL_SEEK_COUNT, + ** sqlite3 *db, // Database connection + ** u64 *pnSeek // Write seek count here + ** ); + ** + ** This test-control queries the seek-counter on the "main" database + ** file. The seek-counter is written into *pnSeek and is then reset. + ** The seek-count is only available if compiled with SQLITE_DEBUG. + */ + case SQLITE_TESTCTRL_SEEK_COUNT: { + sqlite3 *db = va_arg(ap, sqlite3*); + u64 *pn = va_arg(ap, sqlite3_uint64*); + *pn = sqlite3BtreeSeekCount(db->aDb->pBt); + (void)db; /* Silence harmless unused variable warning */ + break; + } + + } va_end(ap); #endif /* SQLITE_UNTESTABLE */ @@ -4440,7 +4491,7 @@ int iDb = sqlite3FindDbName(db, zDb); if( iDb==0 || iDb>1 ){ Btree *pBt = db->aDb[iDb].pBt; - if( 0==sqlite3BtreeIsInTrans(pBt) ){ + if( SQLITE_TXN_WRITE!=sqlite3BtreeTxnState(pBt) ){ rc = sqlite3BtreeBeginTrans(pBt, 0, 0); if( rc==SQLITE_OK ){ rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot); @@ -4476,10 +4527,10 @@ iDb = sqlite3FindDbName(db, zDb); if( iDb==0 || iDb>1 ){ Btree *pBt = db->aDb[iDb].pBt; - if( sqlite3BtreeIsInTrans(pBt)==0 ){ + if( sqlite3BtreeTxnState(pBt)!=SQLITE_TXN_WRITE ){ Pager *pPager = sqlite3BtreePager(pBt); int bUnlock = 0; - if( sqlite3BtreeIsInReadTrans(pBt) ){ + if( sqlite3BtreeTxnState(pBt)!=SQLITE_TXN_NONE ){ if( db->nVdbeActive==0 ){ rc = sqlite3PagerSnapshotCheck(pPager, pSnapshot); if( rc==SQLITE_OK ){ @@ -4528,7 +4579,7 @@ iDb = sqlite3FindDbName(db, zDb); if( iDb==0 || iDb>1 ){ Btree *pBt = db->aDb[iDb].pBt; - if( 0==sqlite3BtreeIsInReadTrans(pBt) ){ + if( SQLITE_TXN_NONE==sqlite3BtreeTxnState(pBt) ){ rc = sqlite3BtreeBeginTrans(pBt, 0, 0); if( rc==SQLITE_OK ){ rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt)); diff -Nru sqlite3-3.33.0/src/malloc.c sqlite3-3.34.0/src/malloc.c --- sqlite3-3.33.0/src/malloc.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/malloc.c 2020-12-01 16:36:02.000000000 +0000 @@ -474,12 +474,17 @@ if( nOld==nNew ){ pNew = pOld; }else if( sqlite3GlobalConfig.bMemstat ){ + sqlite3_int64 nUsed; sqlite3_mutex_enter(mem0.mutex); sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes); nDiff = nNew - nOld; - if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= + if( nDiff>0 && (nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)) >= mem0.alarmThreshold-nDiff ){ sqlite3MallocAlarm(nDiff); + if( mem0.hardLimit>0 && nUsed >= mem0.hardLimit - nDiff ){ + sqlite3_mutex_leave(mem0.mutex); + return 0; + } } pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT @@ -786,12 +791,15 @@ } /* -** Take actions at the end of an API call to indicate an OOM error +** Take actions at the end of an API call to deal with error codes. */ -static SQLITE_NOINLINE int apiOomError(sqlite3 *db){ - sqlite3OomClear(db); - sqlite3Error(db, SQLITE_NOMEM); - return SQLITE_NOMEM_BKPT; +static SQLITE_NOINLINE int apiHandleError(sqlite3 *db, int rc){ + if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){ + sqlite3OomClear(db); + sqlite3Error(db, SQLITE_NOMEM); + return SQLITE_NOMEM_BKPT; + } + return rc & db->errMask; } /* @@ -813,8 +821,8 @@ */ assert( db!=0 ); assert( sqlite3_mutex_held(db->mutex) ); - if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){ - return apiOomError(db); + if( db->mallocFailed || rc ){ + return apiHandleError(db, rc); } return rc & db->errMask; } diff -Nru sqlite3-3.33.0/src/memdb.c sqlite3-3.34.0/src/memdb.c --- sqlite3-3.33.0/src/memdb.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/memdb.c 2020-12-01 16:36:02.000000000 +0000 @@ -126,11 +126,14 @@ ** Close an memdb-file. ** ** The pData pointer is owned by the application, so there is nothing -** to free. +** to free. Unless the SQLITE_DESERIALIZE_FREEONCLOSE flag is set, +** in which case we own the pData pointer and need to free it. */ static int memdbClose(sqlite3_file *pFile){ MemFile *p = (MemFile *)pFile; - if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ) sqlite3_free(p->aData); + if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ){ + sqlite3_free(p->aData); + } return SQLITE_OK; } @@ -573,8 +576,12 @@ goto end_deserialize; } zSql = sqlite3_mprintf("ATTACH x AS %Q", zSchema); - rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); - sqlite3_free(zSql); + if( zSql==0 ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + } if( rc ) goto end_deserialize; db->init.iDb = (u8)iDb; db->init.reopenMemdb = 1; @@ -589,6 +596,7 @@ rc = SQLITE_ERROR; }else{ p->aData = pData; + pData = 0; p->sz = szDb; p->szAlloc = szBuf; p->szMax = szBuf; @@ -601,6 +609,9 @@ end_deserialize: sqlite3_finalize(pStmt); + if( pData && (mFlags & SQLITE_DESERIALIZE_FREEONCLOSE)!=0 ){ + sqlite3_free(pData); + } sqlite3_mutex_leave(db->mutex); return rc; } diff -Nru sqlite3-3.33.0/src/os_unix.c sqlite3-3.34.0/src/os_unix.c --- sqlite3-3.33.0/src/os_unix.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/os_unix.c 2020-12-01 16:36:02.000000000 +0000 @@ -122,7 +122,8 @@ # if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \ (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000)) # if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \ - && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0)) + && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))\ + && (!defined(TARGET_OS_MACCATALYST) || (TARGET_OS_MACCATALYST==0)) # undef HAVE_GETHOSTUUID # define HAVE_GETHOSTUUID 1 # else @@ -1544,6 +1545,9 @@ return rc; } +/* Forward declaration*/ +static int unixSleep(sqlite3_vfs*,int); + /* ** Set a posix-advisory-lock. ** @@ -1573,7 +1577,7 @@ ** generic posix, however, there is no such API. So we simply try the ** lock once every millisecond until either the timeout expires, or until ** the lock is obtained. */ - usleep(1000); + unixSleep(0,1000); rc = osFcntl(h,F_SETLK,pLock); tm--; } @@ -2144,6 +2148,7 @@ } sqlite3_mutex_leave(pInode->pLockMutex); releaseInodeInfo(pFile); + assert( pFile->pShm==0 ); rc = closeUnixFile(id); unixLeaveMutex(); return rc; @@ -3370,7 +3375,24 @@ if( got==amt ){ return SQLITE_OK; }else if( got<0 ){ - /* lastErrno set by seekAndRead */ + /* pFile->lastErrno has been set by seekAndRead(). + ** Usually we return SQLITE_IOERR_READ here, though for some + ** kinds of errors we return SQLITE_IOERR_CORRUPTFS. The + ** SQLITE_IOERR_CORRUPTFS will be converted into SQLITE_CORRUPT + ** prior to returning to the application by the sqlite3ApiExit() + ** routine. + */ + switch( pFile->lastErrno ){ + case ERANGE: + case EIO: +#ifdef ENXIO + case ENXIO: +#endif +#ifdef EDEVERR + case EDEVERR: +#endif + return SQLITE_IOERR_CORRUPTFS; + } return SQLITE_IOERR_READ; }else{ storeLastErrno(pFile, 0); /* not a system error */ @@ -4254,6 +4276,7 @@ char **apRegion; /* Array of mapped shared-memory regions */ int nRef; /* Number of unixShm objects pointing to this */ unixShm *pFirst; /* All unixShm objects pointing to this */ + int aLock[SQLITE_SHM_NLOCK]; /* # shared locks on slot, -1==excl lock */ #ifdef SQLITE_DEBUG u8 exclMask; /* Mask of exclusive locks held */ u8 sharedMask; /* Mask of shared locks held */ @@ -4795,6 +4818,38 @@ } /* +** Check that the pShmNode->aLock[] array comports with the locking bitmasks +** held by each client. Return true if it does, or false otherwise. This +** is to be used in an assert(). e.g. +** +** assert( assertLockingArrayOk(pShmNode) ); +*/ +#ifdef SQLITE_DEBUG +static int assertLockingArrayOk(unixShmNode *pShmNode){ + unixShm *pX; + int aLock[SQLITE_SHM_NLOCK]; + assert( sqlite3_mutex_held(pShmNode->pShmMutex) ); + + memset(aLock, 0, sizeof(aLock)); + for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ + int i; + for(i=0; iexclMask & (1<sharedMask & (1<=0 ); + aLock[i]++; + } + } + } + + assert( 0==memcmp(pShmNode->aLock, aLock, sizeof(aLock)) ); + return (memcmp(pShmNode->aLock, aLock, sizeof(aLock))==0); +} +#endif + +/* ** Change the lock state for a shared-memory segment. ** ** Note that the relationship between SHAREd and EXCLUSIVE locks is a little @@ -4810,10 +4865,10 @@ ){ unixFile *pDbFd = (unixFile*)fd; /* Connection holding shared memory */ unixShm *p = pDbFd->pShm; /* The shared memory being locked */ - unixShm *pX; /* For looping over all siblings */ unixShmNode *pShmNode = p->pShmNode; /* The underlying file iNode */ int rc = SQLITE_OK; /* Result code */ u16 mask; /* Mask of locks to take or release */ + int *aLock = pShmNode->aLock; assert( pShmNode==pDbFd->pInode->pShmNode ); assert( pShmNode->pInode==pDbFd->pInode ); @@ -4852,78 +4907,76 @@ mask = (1<<(ofst+n)) - (1<1 || mask==(1<pShmMutex); + assert( assertLockingArrayOk(pShmNode) ); if( flags & SQLITE_SHM_UNLOCK ){ - u16 allMask = 0; /* Mask of locks held by siblings */ + if( (p->exclMask|p->sharedMask) & mask ){ + int ii; + int bUnlock = 1; + + for(ii=ofst; ii((p->sharedMask & (1<pFirst; pX; pX=pX->pNext){ - if( pX==p ) continue; - assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 ); - allMask |= pX->sharedMask; - } + if( bUnlock ){ + rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n); + if( rc==SQLITE_OK ){ + memset(&aLock[ofst], 0, sizeof(int)*n); + } + }else if( ALWAYS(p->sharedMask & (1<1 ); + aLock[ofst]--; + } - /* Unlock the system-level locks */ - if( (mask & allMask)==0 ){ - rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n); - }else{ - rc = SQLITE_OK; + /* Undo the local locks */ + if( rc==SQLITE_OK ){ + p->exclMask &= ~mask; + p->sharedMask &= ~mask; + } } - - /* Undo the local locks */ - if( rc==SQLITE_OK ){ - p->exclMask &= ~mask; - p->sharedMask &= ~mask; - } }else if( flags & SQLITE_SHM_SHARED ){ - u16 allShared = 0; /* Union of locks held by connections other than "p" */ - - /* Find out which shared locks are already held by sibling connections. - ** If any sibling already holds an exclusive lock, go ahead and return - ** SQLITE_BUSY. - */ - for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ - if( (pX->exclMask & mask)!=0 ){ + assert( n==1 ); + assert( (p->exclMask & (1<sharedMask & mask)==0 ){ + if( aLock[ofst]<0 ){ rc = SQLITE_BUSY; - break; - } - allShared |= pX->sharedMask; - } - - /* Get shared locks at the system level, if necessary */ - if( rc==SQLITE_OK ){ - if( (allShared & mask)==0 ){ + }else if( aLock[ofst]==0 ){ rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n); - }else{ - rc = SQLITE_OK; } - } - /* Get the local shared locks */ - if( rc==SQLITE_OK ){ - p->sharedMask |= mask; + /* Get the local shared locks */ + if( rc==SQLITE_OK ){ + p->sharedMask |= mask; + aLock[ofst]++; + } } }else{ /* Make sure no sibling connections hold locks that will block this - ** lock. If any do, return SQLITE_BUSY right away. - */ - for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ - if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){ + ** lock. If any do, return SQLITE_BUSY right away. */ + int ii; + for(ii=ofst; iisharedMask & mask)==0 ); + if( ALWAYS((p->exclMask & (1<sharedMask & mask)==0 ); p->exclMask |= mask; + for(ii=ofst; iipShmMutex); OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n", p->id, osGetpid(0), p->sharedMask, p->exclMask)); @@ -6300,7 +6353,26 @@ } /* +** If the last component of the pathname in z[0]..z[j-1] is something +** other than ".." then back it out and return true. If the last +** component is empty or if it is ".." then return false. +*/ +static int unixBackupDir(const char *z, int *pJ){ + int j = *pJ; + int i; + if( j<=0 ) return 0; + for(i=j-1; ALWAYS(i>0) && z[i-1]!='/'; i--){} + if( z[i]=='.' && i==j-2 && z[i+1]=='.' ) return 0; + *pJ = i-1; + return 1; +} + +/* +** Convert a relative pathname into a full pathname. Also +** simplify the pathname as follows: ** +** Remove all instances of /./ +** Remove all isntances of /X/../ for any X */ static int mkFullPathname( const char *zPath, /* Input path */ @@ -6309,6 +6381,7 @@ ){ int nPath = sqlite3Strlen30(zPath); int iOff = 0; + int i, j; if( zPath[0]!='/' ){ if( osGetcwd(zOut, nOut-2)==0 ){ return unixLogError(SQLITE_CANTOPEN_BKPT, "getcwd", zPath); @@ -6323,6 +6396,41 @@ return SQLITE_CANTOPEN_BKPT; } sqlite3_snprintf(nOut-iOff, &zOut[iOff], "%s", zPath); + + /* Remove duplicate '/' characters. Except, two // at the beginning + ** of a pathname is allowed since this is important on windows. */ + for(i=j=1; zOut[i]; i++){ + zOut[j++] = zOut[i]; + while( zOut[i]=='/' && zOut[i+1]=='/' ) i++; + } + zOut[j] = 0; + + assert( zOut[0]=='/' ); + for(i=j=0; zOut[i]; i++){ + if( zOut[i]=='/' ){ + /* Skip over internal "/." directory components */ + if( zOut[i+1]=='.' && zOut[i+2]=='/' ){ + i += 1; + continue; + } + + /* If this is a "/.." directory component then back out the + ** previous term of the directory if it is something other than "..". + */ + if( zOut[i+1]=='.' + && zOut[i+2]=='.' + && zOut[i+3]=='/' + && unixBackupDir(zOut, &j) + ){ + i += 2; + continue; + } + } + if( ALWAYS(j>=0) ) zOut[j] = zOut[i]; + j++; + } + if( NEVER(j==0) ) zOut[j++] = '/'; + zOut[j] = 0; return SQLITE_OK; } @@ -6543,7 +6651,8 @@ UNUSED_PARAMETER(NotUsed); return microseconds; #elif defined(HAVE_USLEEP) && HAVE_USLEEP - usleep(microseconds); + if( microseconds>=1000000 ) sleep(microseconds/1000000); + if( microseconds%1000000 ) usleep(microseconds%1000000); UNUSED_PARAMETER(NotUsed); return microseconds; #else @@ -7116,7 +7225,7 @@ if( nTries==1 ){ conchModTime = buf.st_mtimespec; - usleep(500000); /* wait 0.5 sec and try the lock again*/ + unixSleep(0,500000); /* wait 0.5 sec and try the lock again*/ continue; } @@ -7142,7 +7251,7 @@ /* don't break the lock on short read or a version mismatch */ return SQLITE_BUSY; } - usleep(10000000); /* wait 10 sec and try the lock again */ + unixSleep(0,10000000); /* wait 10 sec and try the lock again */ continue; } diff -Nru sqlite3-3.33.0/src/os_win.c sqlite3-3.34.0/src/os_win.c --- sqlite3-3.33.0/src/os_win.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/os_win.c 2020-12-01 16:36:02.000000000 +0000 @@ -5126,7 +5126,11 @@ dwCreationDisposition = OPEN_EXISTING; } - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + if( 0==sqlite3_uri_boolean(zName, "exclusive", 0) ){ + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + }else{ + dwShareMode = 0; + } if( isDelete ){ #if SQLITE_OS_WINCE diff -Nru sqlite3-3.33.0/src/pager.c sqlite3-3.34.0/src/pager.c --- sqlite3-3.33.0/src/pager.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/pager.c 2020-12-01 16:36:02.000000000 +0000 @@ -2486,6 +2486,7 @@ i64 nSuperJournal; /* Size of super-journal file */ char *zJournal; /* Pointer to one journal within MJ file */ char *zSuperPtr; /* Space to hold super-journal filename */ + char *zFree = 0; /* Free this buffer */ int nSuperPtr; /* Amount of space allocated to zSuperPtr[] */ /* Allocate space for both the pJournal and pSuper file descriptors. @@ -2510,11 +2511,13 @@ rc = sqlite3OsFileSize(pSuper, &nSuperJournal); if( rc!=SQLITE_OK ) goto delsuper_out; nSuperPtr = pVfs->mxPathname+1; - zSuperJournal = sqlite3Malloc(nSuperJournal + nSuperPtr + 2); - if( !zSuperJournal ){ + zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2); + if( !zFree ){ rc = SQLITE_NOMEM_BKPT; goto delsuper_out; } + zFree[0] = zFree[1] = zFree[2] = zFree[3] = 0; + zSuperJournal = &zFree[4]; zSuperPtr = &zSuperJournal[nSuperJournal+2]; rc = sqlite3OsRead(pSuper, zSuperJournal, (int)nSuperJournal, 0); if( rc!=SQLITE_OK ) goto delsuper_out; @@ -2562,7 +2565,7 @@ rc = sqlite3OsDelete(pVfs, zSuper, 0); delsuper_out: - sqlite3_free(zSuperJournal); + sqlite3_free(zFree); if( pSuper ){ sqlite3OsClose(pSuper); assert( !isOpen(pJournal) ); @@ -2900,7 +2903,11 @@ pPager->changeCountDone = pPager->tempFile; if( rc==SQLITE_OK ){ - zSuper = pPager->pTmpSpace; + /* Leave 4 bytes of space before the super-journal filename in memory. + ** This is because it may end up being passed to sqlite3OsOpen(), in + ** which case it requires 4 0x00 bytes in memory immediately before + ** the filename. */ + zSuper = &pPager->pTmpSpace[4]; rc = readSuperJournal(pPager->jfd, zSuper, pPager->pVfs->mxPathname+1); testcase( rc!=SQLITE_OK ); } @@ -2917,6 +2924,8 @@ /* If there was a super-journal and this routine will return success, ** see if it is possible to delete the super-journal. */ + assert( zSuper==&pPager->pTmpSpace[4] ); + memset(&zSuper[-4], 0, 4); rc = pager_delsuper(pPager, zSuper); testcase( rc!=SQLITE_OK ); } diff -Nru sqlite3-3.33.0/src/parse.y sqlite3-3.34.0/src/parse.y --- sqlite3-3.33.0/src/parse.y 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/parse.y 2020-12-01 16:36:02.000000000 +0000 @@ -1,5 +1,6 @@ +%include { /* -** 2001 September 15 +** 2001-09-15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: @@ -9,11 +10,16 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** This file contains SQLite's grammar for SQL. Process this file -** using the lemon parser generator to generate C code that runs -** the parser. Lemon will also generate a header file containing -** numeric codes for all of the tokens. +** This file contains SQLite's SQL parser. +** +** The canonical source code to this file ("parse.y") is a Lemon grammar +** file that specifies the input grammar and actions to take while parsing. +** That input file is processed by Lemon to generate a C-language +** implementation of a parser for the given grammer. You might be reading +** this comment as part of the translated C-code. Edits should be made +** to the original parse.y sources. */ +} // All token codes are small integers with #defines that begin with "TK_" %token_prefix TK_ @@ -366,7 +372,7 @@ {sqlite3AddPrimaryKey(pParse,0,R,I,Z);} ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} -ccons ::= CHECK LP expr(X) RP. {sqlite3AddCheckConstraint(pParse,X);} +ccons ::= CHECK LP(A) expr(X) RP(B). {sqlite3AddCheckConstraint(pParse,X,A.z,B.z);} ccons ::= REFERENCES nm(T) eidlist_opt(TA) refargs(R). {sqlite3CreateForeignKey(pParse,0,&T,TA,R);} ccons ::= defer_subclause(D). {sqlite3DeferForeignKey(pParse,D);} @@ -420,8 +426,8 @@ tcons ::= UNIQUE LP sortlist(X) RP onconf(R). {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} -tcons ::= CHECK LP expr(E) RP onconf. - {sqlite3AddCheckConstraint(pParse,E);} +tcons ::= CHECK LP(A) expr(E) RP(B) onconf. + {sqlite3AddCheckConstraint(pParse,E,A.z,B.z);} tcons ::= FOREIGN KEY LP eidlist(FA) RP REFERENCES nm(T) eidlist_opt(TA) refargs(R) defer_subclause_opt(D). { sqlite3CreateForeignKey(pParse, FA, &T, TA, R); diff -Nru sqlite3-3.33.0/src/pragma.c sqlite3-3.34.0/src/pragma.c --- sqlite3-3.33.0/src/pragma.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/pragma.c 2020-12-01 16:36:02.000000000 +0000 @@ -131,7 +131,9 @@ static int invalidateTempStorage(Parse *pParse){ sqlite3 *db = pParse->db; if( db->aDb[1].pBt!=0 ){ - if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){ + if( !db->autoCommit + || sqlite3BtreeTxnState(db->aDb[1].pBt)!=SQLITE_TXN_NONE + ){ sqlite3ErrorMsg(pParse, "temporary storage cannot be changed " "from within a transaction"); return SQLITE_ERROR; @@ -1451,7 +1453,7 @@ aiCols = 0; if( pParent ){ x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); - assert( x==0 ); + assert( x==0 || db->mallocFailed ); } addrOk = sqlite3VdbeMakeLabel(pParse); @@ -1476,7 +1478,7 @@ int jmp = sqlite3VdbeCurrentAddr(v)+2; sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v); sqlite3VdbeGoto(v, addrOk); - assert( pFK->nCol==1 ); + assert( pFK->nCol==1 || db->mallocFailed ); } /* Generate code to report an FK violation to the caller. */ diff -Nru sqlite3-3.33.0/src/prepare.c sqlite3-3.34.0/src/prepare.c --- sqlite3-3.33.0/src/prepare.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/prepare.c 2020-12-01 16:36:02.000000000 +0000 @@ -240,7 +240,7 @@ ** on the b-tree database, open one now. If a transaction is opened, it ** will be closed before this function returns. */ sqlite3BtreeEnter(pDb->pBt); - if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){ + if( sqlite3BtreeTxnState(pDb->pBt)==SQLITE_TXN_NONE ){ rc = sqlite3BtreeBeginTrans(pDb->pBt, 0, 0); if( rc!=SQLITE_OK ){ sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc)); @@ -483,7 +483,7 @@ /* If there is not already a read-only (or read-write) transaction opened ** on the b-tree database, open one now. If a transaction is opened, it ** will be closed immediately after reading the meta-value. */ - if( !sqlite3BtreeIsInReadTrans(pBt) ){ + if( sqlite3BtreeTxnState(pBt)==SQLITE_TXN_NONE ){ rc = sqlite3BtreeBeginTrans(pBt, 0, 0); if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ sqlite3OomFault(db); @@ -746,6 +746,7 @@ sqlite3BtreeLeaveAll(db); rc = sqlite3ApiExit(db, rc); assert( (rc&db->errMask)==rc ); + db->busyHandler.nBusy = 0; sqlite3_mutex_leave(db->mutex); return rc; } diff -Nru sqlite3-3.33.0/src/printf.c sqlite3-3.34.0/src/printf.c --- sqlite3-3.33.0/src/printf.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/printf.c 2020-12-01 16:36:02.000000000 +0000 @@ -427,11 +427,10 @@ v = va_arg(ap,int); } if( v<0 ){ - if( v==SMALLEST_INT64 ){ - longvalue = ((u64)1)<<63; - }else{ - longvalue = -v; - } + testcase( v==SMALLEST_INT64 ); + testcase( v==(-1) ); + longvalue = ~v; + longvalue++; prefix = '-'; }else{ longvalue = v; diff -Nru sqlite3-3.33.0/src/resolve.c sqlite3-3.34.0/src/resolve.c --- sqlite3-3.33.0/src/resolve.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/resolve.c 2020-12-01 16:36:02.000000000 +0000 @@ -1075,7 +1075,7 @@ assert( !ExprHasProperty(pExpr, EP_Reduced) ); /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", ** and "x IS NOT FALSE". */ - if( pRight && pRight->op==TK_ID ){ + if( pRight && (pRight->op==TK_ID || pRight->op==TK_TRUEFALSE) ){ int rc = resolveExprStep(pWalker, pRight); if( rc==WRC_Abort ) return WRC_Abort; if( pRight->op==TK_TRUEFALSE ){ @@ -1284,6 +1284,7 @@ Expr *pE, *pDup; if( pItem->done ) continue; pE = sqlite3ExprSkipCollateAndLikely(pItem->pExpr); + if( NEVER(pE==0) ) continue; if( sqlite3ExprIsInteger(pE, &iCol) ){ if( iCol<=0 || iCol>pEList->nExpr ){ resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr); @@ -1463,6 +1464,7 @@ for(i=0, pItem=pOrderBy->a; inExpr; i++, pItem++){ Expr *pE = pItem->pExpr; Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pE); + if( NEVER(pE2==0) ) continue; if( zType[0]!='G' ){ iCol = resolveAsName(pParse, pSelect->pEList, pE2); if( iCol>0 ){ diff -Nru sqlite3-3.33.0/src/select.c sqlite3-3.34.0/src/select.c --- sqlite3-3.33.0/src/select.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/select.c 2020-12-01 16:36:02.000000000 +0000 @@ -1972,6 +1972,7 @@ char *zName; /* Column name */ int nName; /* Size of name in zName[] */ Hash ht; /* Hash table of column names */ + Table *pTab; sqlite3HashInit(&ht); if( pEList ){ @@ -1994,15 +1995,13 @@ /* If the column contains an "AS " phrase, use as the name */ }else{ Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pEList->a[i].pExpr); - while( pColExpr->op==TK_DOT ){ + while( ALWAYS(pColExpr!=0) && pColExpr->op==TK_DOT ){ pColExpr = pColExpr->pRight; assert( pColExpr!=0 ); } - if( pColExpr->op==TK_COLUMN ){ + if( pColExpr->op==TK_COLUMN && (pTab = pColExpr->y.pTab)!=0 ){ /* For columns use the column name name */ int iCol = pColExpr->iColumn; - Table *pTab = pColExpr->y.pTab; - assert( pTab!=0 ); if( iCol<0 ) iCol = pTab->iPKey; zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid"; }else if( pColExpr->op==TK_ID ){ @@ -2340,6 +2339,7 @@ int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */ Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */ Select *pSetup = p->pPrior; /* The setup query */ + Select *pFirstRec; /* Left-most recursive term */ int addrTop; /* Top of the loop */ int addrCont, addrBreak; /* CONTINUE and BREAK addresses */ int iCurrent = 0; /* The Current table */ @@ -2415,7 +2415,25 @@ /* Detach the ORDER BY clause from the compound SELECT */ p->pOrderBy = 0; + /* Figure out how many elements of the compound SELECT are part of the + ** recursive query. Make sure no recursive elements use aggregate + ** functions. Mark the recursive elements as UNION ALL even if they + ** are really UNION because the distinctness will be enforced by the + ** iDistinct table. pFirstRec is left pointing to the left-most + ** recursive term of the CTE. + */ + pFirstRec = p; + for(pFirstRec=p; ALWAYS(pFirstRec!=0); pFirstRec=pFirstRec->pPrior){ + if( pFirstRec->selFlags & SF_Aggregate ){ + sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported"); + goto end_of_recursive_query; + } + pFirstRec->op = TK_ALL; + if( (pFirstRec->pPrior->selFlags & SF_Recursive)==0 ) break; + } + /* Store the results of the setup-query in Queue. */ + pSetup = pFirstRec->pPrior; pSetup->pNext = 0; ExplainQueryPlan((pParse, 1, "SETUP")); rc = sqlite3Select(pParse, pSetup, &destQueue); @@ -2448,15 +2466,11 @@ /* Execute the recursive SELECT taking the single row in Current as ** the value for the recursive-table. Store the results in the Queue. */ - if( p->selFlags & SF_Aggregate ){ - sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported"); - }else{ - p->pPrior = 0; - ExplainQueryPlan((pParse, 1, "RECURSIVE STEP")); - sqlite3Select(pParse, p, &destQueue); - assert( p->pPrior==0 ); - p->pPrior = pSetup; - } + pFirstRec->pPrior = 0; + ExplainQueryPlan((pParse, 1, "RECURSIVE STEP")); + sqlite3Select(pParse, p, &destQueue); + assert( pFirstRec->pPrior==0 ); + pFirstRec->pPrior = pSetup; /* Keep running the loop until the Queue is empty */ sqlite3VdbeGoto(v, addrTop); @@ -2526,6 +2540,16 @@ } /* +** Return true if the SELECT statement which is known to be the recursive +** part of a recursive CTE still has its anchor terms attached. If the +** anchor terms have already been removed, then return false. +*/ +static int hasAnchor(Select *p){ + while( p && (p->selFlags & SF_Recursive)!=0 ){ p = p->pPrior; } + return p!=0; +} + +/* ** This routine is called to process a compound query form from ** two or more separate queries using UNION, UNION ALL, EXCEPT, or ** INTERSECT @@ -2610,7 +2634,7 @@ assert( p->pEList->nExpr==pPrior->pEList->nExpr ); #ifndef SQLITE_OMIT_CTE - if( p->selFlags & SF_Recursive ){ + if( (p->selFlags & SF_Recursive)!=0 && hasAnchor(p) ){ generateWithRecursiveQuery(pParse, p, &dest); }else #endif @@ -2701,6 +2725,7 @@ findRightmost(p)->selFlags |= SF_UsesEphemeral; assert( p->pEList ); } + /* Code the SELECT statements to our left */ @@ -3506,7 +3531,7 @@ ifNullRow.op = TK_IF_NULL_ROW; ifNullRow.pLeft = pCopy; ifNullRow.iTable = pSubst->iNewTable; - ifNullRow.flags = EP_Skip; + ifNullRow.flags = EP_IfNullRow; pCopy = &ifNullRow; } testcase( ExprHasProperty(pCopy, EP_Subquery) ); @@ -3515,8 +3540,7 @@ ExprSetProperty(pNew, EP_CanBeNull); } if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){ - pNew->iRightJoinTable = pExpr->iRightJoinTable; - ExprSetProperty(pNew, EP_FromJoin); + sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable); } sqlite3ExprDelete(db, pExpr); pExpr = pNew; @@ -4795,8 +4819,10 @@ ExprList *pEList; Select *pSel; Select *pLeft; /* Left-most SELECT statement */ + Select *pRecTerm; /* Left-most recursive term */ int bMayRecursive; /* True if compound joined by UNION [ALL] */ With *pSavedWith; /* Initial value of pParse->pWith */ + int iRecTab = -1; /* Cursor for recursive table */ /* If pCte->zCteErr is non-NULL at this point, then this is an illegal ** recursive reference to CTE pCte. Leave an error in pParse and return @@ -4821,44 +4847,48 @@ assert( pFrom->pSelect ); /* Check if this is a recursive CTE. */ - pSel = pFrom->pSelect; + pRecTerm = pSel = pFrom->pSelect; bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION ); - if( bMayRecursive ){ + while( bMayRecursive && pRecTerm->op==pSel->op ){ int i; - SrcList *pSrc = pFrom->pSelect->pSrc; + SrcList *pSrc = pRecTerm->pSrc; + assert( pRecTerm->pPrior!=0 ); for(i=0; inSrc; i++){ struct SrcList_item *pItem = &pSrc->a[i]; if( pItem->zDatabase==0 && pItem->zName!=0 && 0==sqlite3StrICmp(pItem->zName, pCte->zName) - ){ + ){ pItem->pTab = pTab; - pItem->fg.isRecursive = 1; pTab->nTabRef++; - pSel->selFlags |= SF_Recursive; + pItem->fg.isRecursive = 1; + if( pRecTerm->selFlags & SF_Recursive ){ + sqlite3ErrorMsg(pParse, + "multiple references to recursive table: %s", pCte->zName + ); + return SQLITE_ERROR; + } + pRecTerm->selFlags |= SF_Recursive; + if( iRecTab<0 ) iRecTab = pParse->nTab++; + pItem->iCursor = iRecTab; } } + if( (pRecTerm->selFlags & SF_Recursive)==0 ) break; + pRecTerm = pRecTerm->pPrior; } - /* Only one recursive reference is permitted. */ - if( pTab->nTabRef>2 ){ - sqlite3ErrorMsg( - pParse, "multiple references to recursive table: %s", pCte->zName - ); - return SQLITE_ERROR; - } - assert( pTab->nTabRef==1 || - ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 )); - pCte->zCteErr = "circular reference: %s"; pSavedWith = pParse->pWith; pParse->pWith = pWith; - if( bMayRecursive ){ - Select *pPrior = pSel->pPrior; - assert( pPrior->pWith==0 ); - pPrior->pWith = pSel->pWith; - sqlite3WalkSelect(pWalker, pPrior); - pPrior->pWith = 0; + if( pSel->selFlags & SF_Recursive ){ + assert( pRecTerm!=0 ); + assert( (pRecTerm->selFlags & SF_Recursive)==0 ); + assert( pRecTerm->pNext!=0 ); + assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 ); + assert( pRecTerm->pWith==0 ); + pRecTerm->pWith = pSel->pWith; + sqlite3WalkSelect(pWalker, pRecTerm); + pRecTerm->pWith = 0; }else{ sqlite3WalkSelect(pWalker, pSel); } @@ -5808,13 +5838,11 @@ assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo ); assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistQueue ); assert( p->pOrderBy==0 || pDest->eDest!=SRT_Queue ); - if( IgnorableOrderby(pDest) ){ - assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || - pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard || - pDest->eDest==SRT_Queue || pDest->eDest==SRT_DistFifo || - pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo); - /* If ORDER BY makes no difference in the output then neither does - ** DISTINCT so it can be removed too. */ + if( IgnorableDistinct(pDest) ){ + assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || + pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard || + pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_DistFifo ); + /* All of these destinations are also able to ignore the ORDER BY clause */ sqlite3ExprListDelete(db, p->pOrderBy); p->pOrderBy = 0; p->selFlags &= ~SF_Distinct; diff -Nru sqlite3-3.33.0/src/shell.c.in sqlite3-3.34.0/src/shell.c.in --- sqlite3-3.33.0/src/shell.c.in 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/shell.c.in 2020-12-01 16:36:02.000000000 +0000 @@ -553,8 +553,6 @@ int i; int n; int aw = w<0 ? -w : w; - char zBuf[1000]; - if( aw>(int)sizeof(zBuf)/3 ) aw = (int)sizeof(zBuf)/3; for(i=n=0; zUtf[i]; i++){ if( (zUtf[i]&0xc0)!=0x80 ){ n++; @@ -1028,6 +1026,7 @@ INCLUDE ../ext/misc/uint.c INCLUDE ../ext/misc/decimal.c INCLUDE ../ext/misc/ieee754.c +INCLUDE ../ext/misc/series.c #ifdef SQLITE_HAVE_ZLIB INCLUDE ../ext/misc/zipfile.c INCLUDE ../ext/misc/sqlar.c @@ -1185,6 +1184,8 @@ #define SHFLG_CountChanges 0x00000020 /* .changes setting */ #define SHFLG_Echo 0x00000040 /* .echo or --echo setting */ #define SHFLG_HeaderSet 0x00000080 /* .header has been used */ +#define SHFLG_DumpDataOnly 0x00000100 /* .dump show data only */ +#define SHFLG_DumpNoSys 0x00000200 /* .dump omits system tables */ /* ** Macros for testing and setting shellFlgs @@ -3705,19 +3706,25 @@ const char *zType; const char *zSql; ShellState *p = (ShellState *)pArg; + int dataOnly; + int noSys; UNUSED_PARAMETER(azNotUsed); if( nArg!=3 || azArg==0 ) return 0; zTable = azArg[0]; zType = azArg[1]; zSql = azArg[2]; + dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0; + noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0; - if( strcmp(zTable, "sqlite_sequence")==0 ){ - raw_printf(p->out, "DELETE FROM sqlite_sequence;\n"); - }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){ - raw_printf(p->out, "ANALYZE sqlite_schema;\n"); + if( strcmp(zTable, "sqlite_sequence")==0 && !noSys ){ + if( !dataOnly ) raw_printf(p->out, "DELETE FROM sqlite_sequence;\n"); + }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){ + if( !dataOnly ) raw_printf(p->out, "ANALYZE sqlite_schema;\n"); }else if( strncmp(zTable, "sqlite_", 7)==0 ){ return 0; + }else if( dataOnly ){ + /* no-op */ }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){ char *zIns; if( !p->writableSchema ){ @@ -3890,8 +3897,10 @@ ".dbinfo ?DB? Show status information about the database", ".dump ?TABLE? Render database content as SQL", " Options:", - " --preserve-rowids Include ROWID values in the output", + " --data-only Output only INSERT statements", " --newlines Allow unescaped newline characters in output", + " --nosys Omit system tables (ex: \"sqlite_stat1\")", + " --preserve-rowids Include ROWID values in the output", " TABLE is a LIKE pattern for the tables to dump", " Additional LIKE patterns can be given in subsequent arguments", ".echo on|off Turn command echo on or off", @@ -4016,8 +4025,9 @@ ".save FILE Write in-memory database into FILE", ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off", ".schema ?PATTERN? Show the CREATE statements matching PATTERN", - " Options:", - " --indent Try to pretty-print the schema", + " Options:", + " --indent Try to pretty-print the schema", + " --nosys Omit objects whose names start with \"sqlite_\"", ".selftest ?OPTIONS? Run tests defined in the SELFTEST table", " Options:", " --init Create a new SELFTEST table", @@ -4427,6 +4437,20 @@ } /* +** Scalar function "usleep(X)" invokes sqlite3_sleep(X) and returns X. +*/ +static void shellUSleepFunc( + sqlite3_context *context, + int argcUnused, + sqlite3_value **argv +){ + int sleep = sqlite3_value_int(argv[0]); + (void)argcUnused; + sqlite3_sleep(sleep/1000); + sqlite3_result_int(context, sleep); +} + +/* ** Scalar function "shell_escape_crnl" used by the .recover command. ** The argument passed to this function is the output of built-in ** function quote(). If the first character of the input is "'", @@ -4590,6 +4614,7 @@ sqlite3_uint_init(p->db, 0, 0); sqlite3_decimal_init(p->db, 0, 0); sqlite3_ieee_init(p->db, 0, 0); + sqlite3_series_init(p->db, 0, 0); #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) sqlite3_dbdata_init(p->db, 0, 0); #endif @@ -4609,6 +4634,8 @@ shellInt32, 0, 0); sqlite3_create_function(p->db, "shell_idquote", 1, SQLITE_UTF8, 0, shellIdQuote, 0, 0); + sqlite3_create_function(p->db, "usleep",1,SQLITE_UTF8,0, + shellUSleepFunc, 0, 0); #ifndef SQLITE_NOHAVE_SYSTEM sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0, editFunc, 0, 0); @@ -7583,21 +7610,41 @@ }else if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 ){ - ShellState data; - char *zErrMsg = 0; + char **azName = 0; + int nName = 0; + sqlite3_stmt *pStmt; + int i; open_db(p, 0); - memcpy(&data, p, sizeof(data)); - data.showHeader = 0; - data.cMode = data.mode = MODE_List; - sqlite3_snprintf(sizeof(data.colSeparator),data.colSeparator,": "); - data.cnt = 0; - sqlite3_exec(p->db, "SELECT name, file FROM pragma_database_list", - callback, &data, &zErrMsg); - if( zErrMsg ){ - utf8_printf(stderr,"Error: %s\n", zErrMsg); - sqlite3_free(zErrMsg); + rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0); + if( rc ){ + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); rc = 1; + }else{ + while( sqlite3_step(pStmt)==SQLITE_ROW ){ + const char *zSchema = (const char *)sqlite3_column_text(pStmt,1); + const char *zFile = (const char*)sqlite3_column_text(pStmt,2); + azName = sqlite3_realloc(azName, (nName+1)*2*sizeof(char*)); + if( azName==0 ){ shell_out_of_memory(); /* Does not return */ } + azName[nName*2] = strdup(zSchema); + azName[nName*2+1] = strdup(zFile); + nName++; + } } + sqlite3_finalize(pStmt); + for(i=0; idb, azName[i*2]); + int bRdonly = sqlite3_db_readonly(p->db, azName[i*2]); + const char *z = azName[i*2+1]; + utf8_printf(p->out, "%s: %s %s%s\n", + azName[i*2], + z && z[0] ? z : "\"\"", + bRdonly ? "r/o" : "r/w", + eTxn==SQLITE_TXN_NONE ? "" : + eTxn==SQLITE_TXN_READ ? " read-txn" : " write-txn"); + free(azName[i*2]); + free(azName[i*2+1]); + } + sqlite3_free(azName); }else if( c=='d' && n>=3 && strncmp(azArg[0], "dbconfig", n)==0 ){ @@ -7656,7 +7703,9 @@ int i; int savedShowHeader = p->showHeader; int savedShellFlags = p->shellFlgs; - ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines|SHFLG_Echo); + ShellClearFlag(p, + SHFLG_PreserveRowid|SHFLG_Newlines|SHFLG_Echo + |SHFLG_DumpDataOnly|SHFLG_DumpNoSys); for(i=1; iout, "PRAGMA foreign_keys=OFF;\n"); - raw_printf(p->out, "BEGIN TRANSACTION;\n"); + if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){ + /* When playing back a "dump", the content might appear in an order + ** which causes immediate foreign key constraints to be violated. + ** So disable foreign-key constraint enforcement to prevent problems. */ + raw_printf(p->out, "PRAGMA foreign_keys=OFF;\n"); + raw_printf(p->out, "BEGIN TRANSACTION;\n"); + } p->writableSchema = 0; p->showHeader = 0; /* Set writable_schema=ON since doing so forces SQLite to initialize @@ -7713,14 +7770,16 @@ ); run_schema_dump_query(p,zSql); sqlite3_free(zSql); - zSql = sqlite3_mprintf( - "SELECT sql FROM sqlite_schema " - "WHERE (%s) AND sql NOT NULL" - " AND type IN ('index','trigger','view')", - zLike - ); - run_table_dump_query(p, zSql); - sqlite3_free(zSql); + if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){ + zSql = sqlite3_mprintf( + "SELECT sql FROM sqlite_schema " + "WHERE (%s) AND sql NOT NULL" + " AND type IN ('index','trigger','view')", + zLike + ); + run_table_dump_query(p, zSql); + sqlite3_free(zSql); + } sqlite3_free(zLike); if( p->writableSchema ){ raw_printf(p->out, "PRAGMA writable_schema=OFF;\n"); @@ -7728,7 +7787,9 @@ } sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0); - raw_printf(p->out, p->nErr?"ROLLBACK; -- due to errors\n":"COMMIT;\n"); + if( (p->shellFlgs & SHFLG_DumpDataOnly)==0 ){ + raw_printf(p->out, p->nErr?"ROLLBACK; -- due to errors\n":"COMMIT;\n"); + } p->showHeader = savedShowHeader; p->shellFlgs = savedShellFlags; }else @@ -8167,7 +8228,7 @@ while( (nSkip--)>0 ){ while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){} } - zSql = sqlite3_mprintf("SELECT * FROM %s", zTable); + zSql = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable); if( zSql==0 ){ import_cleanup(&sCtx); shell_out_of_memory(); @@ -8176,7 +8237,7 @@ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */ if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){ - char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); + char *zCreate = sqlite3_mprintf("CREATE TABLE \"%w\"", zTable); char cSep = '('; while( xRead(&sCtx) ){ zCreate = sqlite3_mprintf("%z%c\n \"%w\" TEXT", zCreate, cSep, sCtx.z); @@ -8197,7 +8258,7 @@ rc = sqlite3_exec(p->db, zCreate, 0, 0, 0); sqlite3_free(zCreate); if( rc ){ - utf8_printf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable, + utf8_printf(stderr, "CREATE TABLE \"%s\"(...) failed: %s\n", zTable, sqlite3_errmsg(p->db)); import_cleanup(&sCtx); rc = 1; @@ -8962,9 +9023,16 @@ rc = 1; goto meta_command_exit; } - if( notNormalFile(azArg[1]) - || (p->in = fopen(azArg[1], "rb"))==0 - ){ + if( azArg[1][0]=='|' ){ + p->in = popen(azArg[1]+1, "r"); + if( p->in==0 ){ + utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); + rc = 1; + }else{ + rc = process_input(p); + pclose(p->in); + } + }else if( notNormalFile(azArg[1]) || (p->in = fopen(azArg[1], "rb"))==0 ){ utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); rc = 1; }else{ @@ -9046,6 +9114,7 @@ const char *zName = 0; int iSchema = 0; int bDebug = 0; + int bNoSystemTabs = 0; int ii; open_db(p, 0); @@ -9058,10 +9127,16 @@ data.cMode = data.mode = MODE_Pretty; }else if( optionMatch(azArg[ii],"debug") ){ bDebug = 1; + }else if( optionMatch(azArg[ii],"nosys") ){ + bNoSystemTabs = 1; + }else if( azArg[ii][0]=='-' ){ + utf8_printf(stderr, "Unknown option: \"%s\"\n", azArg[ii]); + rc = 1; + goto meta_command_exit; }else if( zName==0 ){ zName = azArg[ii]; }else{ - raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .schema ?--indent? ?--nosys? ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } @@ -9147,7 +9222,10 @@ appendText(&sSelect, " AND ", 0); sqlite3_free(zQarg); } - appendText(&sSelect, "type!='meta' AND sql IS NOT NULL" + if( bNoSystemTabs ){ + appendText(&sSelect, "name NOT LIKE 'sqlite_%%' AND ", 0); + } + appendText(&sSelect, "sql IS NOT NULL" " ORDER BY snum, rowid", 0); if( bDebug ){ utf8_printf(p->out, "SQL: %s;\n", sSelect.z); @@ -9844,6 +9922,7 @@ { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" }, { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE, "" }, { "prng_seed", SQLITE_TESTCTRL_PRNG_SEED, "SEED ?db?" }, + { "seek_count", SQLITE_TESTCTRL_SEEK_COUNT, "" }, }; int testctrl = -1; int iCtrl = -1; @@ -9906,7 +9985,6 @@ /* sqlite3_test_control(int) */ case SQLITE_TESTCTRL_PRNG_SAVE: case SQLITE_TESTCTRL_PRNG_RESTORE: - case SQLITE_TESTCTRL_PRNG_RESET: case SQLITE_TESTCTRL_BYTEORDER: if( nArg==2 ){ rc2 = sqlite3_test_control(testctrl); @@ -9980,6 +10058,14 @@ } break; + case SQLITE_TESTCTRL_SEEK_COUNT: { + u64 x = 0; + rc2 = sqlite3_test_control(testctrl, p->db, &x); + utf8_printf(p->out, "%llu\n", x); + isOk = 3; + break; + } + #ifdef YYCOVERAGE case SQLITE_TESTCTRL_PARSER_COVERAGE: if( nArg==2 ){ @@ -10558,8 +10644,11 @@ if( stdin_is_interactive ){ utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc); } - process_input(p); + if( process_input(p) && bail_on_error ) exit(1); fclose(p->in); + }else if( sqliterc_override!=0 ){ + utf8_printf(stderr,"cannot open: \"%s\"\n", sqliterc); + if( bail_on_error ) exit(1); } p->in = inSaved; p->lineno = savedLineno; @@ -10618,6 +10707,7 @@ #endif " -stats print memory stats before each finalize\n" " -table set output mode to 'table'\n" + " -tabs set output mode to 'tabs'\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" #ifdef SQLITE_ENABLE_VFSTRACE @@ -10875,11 +10965,14 @@ (void)cmdline_option_value(argc, argv, ++i); #endif }else if( strcmp(z,"-pagecache")==0 ){ - int n, sz; - sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); + sqlite3_int64 n, sz; + sz = integerValue(cmdline_option_value(argc,argv,++i)); if( sz>70000 ) sz = 70000; if( sz<0 ) sz = 0; - n = (int)integerValue(cmdline_option_value(argc,argv,++i)); + n = integerValue(cmdline_option_value(argc,argv,++i)); + if( sz>0 && n>0 && 0xffffffffffffLL/sz0 && sz>0) ? malloc(n*sz) : 0, sz, n); data.shellFlgs |= SHFLG_Pagecache; @@ -10941,6 +11034,8 @@ #endif }else if( strcmp(z, "-memtrace")==0 ){ sqlite3MemTraceActivate(stderr); + }else if( strcmp(z,"-bail")==0 ){ + bail_on_error = 1; } } verify_uninitialized(); @@ -11015,6 +11110,8 @@ data.mode = MODE_List; }else if( strcmp(z,"-quote")==0 ){ data.mode = MODE_Quote; + sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator, SEP_Comma); + sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator, SEP_Row); }else if( strcmp(z,"-line")==0 ){ data.mode = MODE_Line; }else if( strcmp(z,"-column")==0 ){ @@ -11048,10 +11145,12 @@ data.openFlags |= SQLITE_OPEN_NOFOLLOW; }else if( strcmp(z,"-ascii")==0 ){ data.mode = MODE_Ascii; - sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator, - SEP_Unit); - sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator, - SEP_Record); + sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator, SEP_Unit); + sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator, SEP_Record); + }else if( strcmp(z,"-tabs")==0 ){ + data.mode = MODE_List; + sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator, SEP_Tab); + sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator, SEP_Row); }else if( strcmp(z,"-separator")==0 ){ sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator, "%s",cmdline_option_value(argc,argv,++i)); @@ -11083,7 +11182,7 @@ */ ShellSetFlag(&data, SHFLG_Backslash); }else if( strcmp(z,"-bail")==0 ){ - bail_on_error = 1; + /* No-op. The bail_on_error flag should already be set. */ }else if( strcmp(z,"-version")==0 ){ printf("%s %s\n", sqlite3_libversion(), sqlite3_sourceid()); return 0; @@ -11171,20 +11270,25 @@ for(i=0; icreate_filename #define sqlite3_free_filename sqlite3_api->free_filename #define sqlite3_database_file_object sqlite3_api->database_file_object +/* Version 3.34.0 and later */ +#define sqlite3_txn_state sqlite3_api->txn_state #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff -Nru sqlite3-3.33.0/src/sqlite.h.in sqlite3-3.34.0/src/sqlite.h.in --- sqlite3-3.33.0/src/sqlite.h.in 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/sqlite.h.in 2020-12-01 16:36:02.000000000 +0000 @@ -504,6 +504,7 @@ #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8)) #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) +#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) @@ -6187,6 +6188,57 @@ int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); /* +** CAPI3REF: Determine the transaction state of a database +** METHOD: sqlite3 +** +** ^The sqlite3_txn_state(D,S) interface returns the current +** [transaction state] of schema S in database connection D. ^If S is NULL, +** then the highest transaction state of any schema on database connection D +** is returned. Transaction states are (in order of lowest to highest): +**
      +**
    1. SQLITE_TXN_NONE +**
    2. SQLITE_TXN_READ +**
    3. SQLITE_TXN_WRITE +**
    +** ^If the S argument to sqlite3_txn_state(D,S) is not the name of +** a valid schema, then -1 is returned. +*/ +int sqlite3_txn_state(sqlite3*,const char *zSchema); + +/* +** CAPI3REF: Allowed return values from [sqlite3_txn_state()] +** KEYWORDS: {transaction state} +** +** These constants define the current transaction state of a database file. +** ^The [sqlite3_txn_state(D,S)] interface returns one of these +** constants in order to describe the transaction state of schema S +** in [database connection] D. +** +**
    +** [[SQLITE_TXN_NONE]]
    SQLITE_TXN_NONE
    +**
    The SQLITE_TXN_NONE state means that no transaction is currently +** pending.
    +** +** [[SQLITE_TXN_READ]]
    SQLITE_TXN_READ
    +**
    The SQLITE_TXN_READ state means that the database is currently +** in a read transaction. Content has been read from the database file +** but nothing in the database file has changed. The transaction state +** will advanced to SQLITE_TXN_WRITE if any changes occur and there are +** no other conflicting concurrent write transactions. The transaction +** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or +** [COMMIT].
    +** +** [[SQLITE_TXN_WRITE]]
    SQLITE_TXN_WRITE
    +**
    The SQLITE_TXN_WRITE state means that the database is currently +** in a write transaction. Content has been written to the database file +** but has not yet committed. The transaction state will change to +** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].
    +*/ +#define SQLITE_TXN_NONE 0 +#define SQLITE_TXN_READ 1 +#define SQLITE_TXN_WRITE 2 + +/* ** CAPI3REF: Find the next prepared statement ** METHOD: sqlite3 ** @@ -7712,7 +7764,8 @@ #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 -#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */ +#define SQLITE_TESTCTRL_SEEK_COUNT 30 +#define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */ /* ** CAPI3REF: SQL Keyword Checking @@ -9192,10 +9245,11 @@ ** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE ** ** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn] -** method of a [virtual table], then it returns true if and only if the +** method of a [virtual table], then it might return true if the ** column is being fetched as part of an UPDATE operation during which the -** column value will not change. Applications might use this to substitute -** a return value that is less expensive to compute and that the corresponding +** column value will not change. The virtual table implementation can use +** this hint as permission to substitute a return value that is less +** expensive to compute and that the corresponding ** [xUpdate] method understands as a "no-change" value. ** ** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that @@ -9204,6 +9258,12 @@ ** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces]. ** In that case, [sqlite3_value_nochange(X)] will return true for the ** same column in the [xUpdate] method. +** +** The sqlite3_vtab_nochange() routine is an optimization. Virtual table +** implementations should continue to give a correct answer even if the +** sqlite3_vtab_nochange() interface were to always return false. In the +** current implementation, the sqlite3_vtab_nochange() interface does always +** returns false for the enhanced [UPDATE FROM] statement. */ int sqlite3_vtab_nochange(sqlite3_context*); @@ -9345,6 +9405,7 @@ /* ** CAPI3REF: Flush caches to disk mid-transaction +** METHOD: sqlite3 ** ** ^If a write-transaction is open on [database connection] D when the ** [sqlite3_db_cacheflush(D)] interface invoked, any dirty @@ -9377,6 +9438,7 @@ /* ** CAPI3REF: The pre-update hook. +** METHOD: sqlite3 ** ** ^These interfaces are only available if SQLite is compiled using the ** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option. @@ -9417,7 +9479,7 @@ ** seventh parameter is the final rowid value of the row being inserted ** or updated. The value of the seventh parameter passed to the callback ** function is not defined for operations on WITHOUT ROWID tables, or for -** INSERT operations on rowid tables. +** DELETE operations on rowid tables. ** ** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()], ** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces @@ -9479,6 +9541,7 @@ /* ** CAPI3REF: Low-level system error code +** METHOD: sqlite3 ** ** ^Attempt to return the underlying operating system error code or error ** number that caused the most recent I/O error or failure to open a file. diff -Nru sqlite3-3.33.0/src/sqliteInt.h sqlite3-3.34.0/src/sqliteInt.h --- sqlite3-3.33.0/src/sqliteInt.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/sqliteInt.h 2020-12-01 16:36:02.000000000 +0000 @@ -2187,6 +2187,7 @@ #define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */ #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ #define TF_Shadow 0x1000 /* True for a shadow table */ +#define TF_HasStat4 0x2000 /* STAT4 info available for this table */ /* ** Test to see whether or not a table is a virtual table. This is @@ -2715,7 +2716,7 @@ #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ #define EP_Win 0x008000 /* Contains window functions */ #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */ - /* 0x020000 // available for reuse */ +#define EP_IfNullRow 0x020000 /* The TK_IF_NULL_ROW opcode */ #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ @@ -2953,9 +2954,9 @@ #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ -#define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */ + /* 0x0400 not currently used */ #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ -#define WHERE_SEEK_UNIQ_TABLE 0x1000 /* Do not defer seeks if unique */ + /* 0x1000 not currently used */ /* 0x2000 not currently used */ #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ /* 0x8000 not currently used */ @@ -3152,9 +3153,6 @@ ** statements within triggers whose only purpose is ** the side-effects of functions. ** -** All of the above are free to ignore their ORDER BY clause. Those that -** follow must honor the ORDER BY clause. -** ** SRT_Output Generate a row of output (using the OP_ResultRow ** opcode) for each row in the result set. ** @@ -3211,13 +3209,18 @@ #define SRT_Except 2 /* Remove result from a UNION index */ #define SRT_Exists 3 /* Store 1 if the result is not empty */ #define SRT_Discard 4 /* Do not save the results anywhere */ -#define SRT_Fifo 5 /* Store result as data with an automatic rowid */ -#define SRT_DistFifo 6 /* Like SRT_Fifo, but unique results only */ +#define SRT_DistFifo 5 /* Like SRT_Fifo, but unique results only */ +#define SRT_DistQueue 6 /* Like SRT_Queue, but unique results only */ + +/* The DISTINCT clause is ignored for all of the above. Not that +** IgnorableDistinct() implies IgnorableOrderby() */ +#define IgnorableDistinct(X) ((X->eDest)<=SRT_DistQueue) + #define SRT_Queue 7 /* Store result in an queue */ -#define SRT_DistQueue 8 /* Like SRT_Queue, but unique results only */ +#define SRT_Fifo 8 /* Store result as data with an automatic rowid */ /* The ORDER BY clause is ignored for all of the above */ -#define IgnorableOrderby(X) ((X->eDest)<=SRT_DistQueue) +#define IgnorableOrderby(X) ((X->eDest)<=SRT_Fifo) #define SRT_Output 9 /* Output each row of result */ #define SRT_Mem 10 /* Store result in a memory cell */ @@ -4184,7 +4187,7 @@ void sqlite3AddColumn(Parse*,Token*,Token*); void sqlite3AddNotNull(Parse*, int); void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); -void sqlite3AddCheckConstraint(Parse*, Expr*); +void sqlite3AddCheckConstraint(Parse*, Expr*, const char*, const char*); void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*); void sqlite3AddCollateType(Parse*, Token*); void sqlite3AddGenerated(Parse*,Expr*,Token*); diff -Nru sqlite3-3.33.0/src/sqliteLimit.h sqlite3-3.34.0/src/sqliteLimit.h --- sqlite3-3.33.0/src/sqliteLimit.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/sqliteLimit.h 2020-12-01 16:36:02.000000000 +0000 @@ -60,11 +60,7 @@ ** The maximum depth of an expression tree. This is limited to ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might ** want to place more severe limits on the complexity of an -** expression. -** -** A value of 0 used to mean that the limit was not enforced. -** But that is no longer true. The limit is now strictly enforced -** at all times. +** expression. A value of 0 means that there is no limit. */ #ifndef SQLITE_MAX_EXPR_DEPTH # define SQLITE_MAX_EXPR_DEPTH 1000 diff -Nru sqlite3-3.33.0/src/test1.c sqlite3-3.34.0/src/test1.c --- sqlite3-3.33.0/src/test1.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/test1.c 2020-12-01 16:36:02.000000000 +0000 @@ -3940,7 +3940,7 @@ char zBuf[200]; sqlite3_snprintf(sizeof(zBuf), zBuf, "cannot use %d blob bytes, have %d", bytes, len); - Tcl_AppendResult(interp, zBuf, -1); + Tcl_AppendResult(interp, zBuf, (char*)0); return TCL_ERROR; } @@ -3953,6 +3953,195 @@ return TCL_OK; } + +#ifndef SQLITE_OMIT_VIRTUALTABLE +/* +** sqlite3_carray_bind [options...] STMT NAME VALUE ... +** +** Options: +** -transient +** -static +** -int32 +** -int64 +** -double +** -text +** +** Each call clears static data. Called with no options does nothing +** but clear static data. +*/ +static int SQLITE_TCLAPI test_carray_bind( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + int eType = 0; /* CARRAY_INT32 */ + int nData = 0; + void *aData = 0; + int isTransient = 0; + int isStatic = 0; + int idx; + int i, j; + int rc; + void (*xDel)(void*) = sqlite3_free; + static void *aStaticData = 0; + static int nStaticData = 0; + static int eStaticType = 0; + extern int sqlite3_carray_bind( + sqlite3_stmt *pStmt, + int i, + void *aData, + int nData, + int mFlags, + void (*xDestroy)(void*) + ); + + if( aStaticData ){ + /* Always clear preexisting static data on every call */ + if( eStaticType==3 ){ + for(i=0; ipRealFile, ofst, n, flags); + sqlite3_file *pReal = ((CrashFile*)pFile)->pRealFile; + return pReal->pMethods->xShmLock(pReal, ofst, n, flags); } static void cfShmBarrier(sqlite3_file *pFile){ - sqlite3OsShmBarrier(((CrashFile*)pFile)->pRealFile); + sqlite3_file *pReal = ((CrashFile*)pFile)->pRealFile; + pReal->pMethods->xShmBarrier(pReal); } static int cfShmUnmap(sqlite3_file *pFile, int delFlag){ - return sqlite3OsShmUnmap(((CrashFile*)pFile)->pRealFile, delFlag); + sqlite3_file *pReal = ((CrashFile*)pFile)->pRealFile; + return pReal->pMethods->xShmUnmap(pReal, delFlag); } static int cfShmMap( sqlite3_file *pFile, /* Handle open on database file */ @@ -565,7 +568,8 @@ int w, /* True to extend file if necessary */ void volatile **pp /* OUT: Mapped memory */ ){ - return sqlite3OsShmMap(((CrashFile*)pFile)->pRealFile, iRegion, sz, w, pp); + sqlite3_file *pReal = ((CrashFile*)pFile)->pRealFile; + return pReal->pMethods->xShmMap(pReal, iRegion, sz, w, pp); } static const sqlite3_io_methods CrashFileVtab = { diff -Nru sqlite3-3.33.0/src/test_devsym.c sqlite3-3.34.0/src/test_devsym.c --- sqlite3-3.33.0/src/test_devsym.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/test_devsym.c 2020-12-01 16:36:02.000000000 +0000 @@ -191,7 +191,7 @@ */ static int devsymShmLock(sqlite3_file *pFile, int ofst, int n, int flags){ devsym_file *p = (devsym_file *)pFile; - return sqlite3OsShmLock(p->pReal, ofst, n, flags); + return p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags); } static int devsymShmMap( sqlite3_file *pFile, @@ -201,15 +201,15 @@ void volatile **pp ){ devsym_file *p = (devsym_file *)pFile; - return sqlite3OsShmMap(p->pReal, iRegion, szRegion, isWrite, pp); + return p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp); } static void devsymShmBarrier(sqlite3_file *pFile){ devsym_file *p = (devsym_file *)pFile; - sqlite3OsShmBarrier(p->pReal); + p->pReal->pMethods->xShmBarrier(p->pReal); } static int devsymShmUnmap(sqlite3_file *pFile, int delFlag){ devsym_file *p = (devsym_file *)pFile; - return sqlite3OsShmUnmap(p->pReal, delFlag); + return p->pReal->pMethods->xShmUnmap(p->pReal, delFlag); } diff -Nru sqlite3-3.33.0/src/test_hexio.c sqlite3-3.34.0/src/test_hexio.c --- sqlite3-3.33.0/src/test_hexio.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/test_hexio.c 2020-12-01 16:36:02.000000000 +0000 @@ -168,7 +168,7 @@ if( Tcl_GetIntFromObj(interp, objv[2], &offset) ) return TCL_ERROR; zFile = Tcl_GetString(objv[1]); zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[3], &nIn); - aOut = sqlite3_malloc( nIn/2 ); + aOut = sqlite3_malloc( 1 + nIn/2 ); if( aOut==0 ){ return TCL_ERROR; } @@ -213,7 +213,7 @@ return TCL_ERROR; } zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[1], &nIn); - aOut = sqlite3_malloc( nIn/2 ); + aOut = sqlite3_malloc( 1 + nIn/2 ); if( aOut==0 ){ return TCL_ERROR; } @@ -309,7 +309,7 @@ return TCL_ERROR; } zOrig = (unsigned char *)Tcl_GetStringFromObj(objv[1], &n); - z = sqlite3_malloc( n+3 ); + z = sqlite3_malloc( n+4 ); n = sqlite3TestHexToBin(zOrig, n, z); z[n] = 0; nOut = sqlite3Utf8To8(z); diff -Nru sqlite3-3.33.0/src/test_vfs.c sqlite3-3.34.0/src/test_vfs.c --- sqlite3-3.33.0/src/test_vfs.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/test_vfs.c 2020-12-01 16:36:02.000000000 +0000 @@ -895,7 +895,8 @@ Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData); if( p->isFullshm ){ - return sqlite3OsShmMap(pFd->pReal, iPage, pgsz, isWrite, pp); + sqlite3_file *pReal = pFd->pReal; + return pReal->pMethods->xShmMap(pReal, iPage, pgsz, isWrite, pp); } if( 0==pFd->pShm ){ @@ -945,7 +946,8 @@ char zLock[80]; if( p->isFullshm ){ - return sqlite3OsShmLock(pFd->pReal, ofst, n, flags); + sqlite3_file *pReal = pFd->pReal; + return pReal->pMethods->xShmLock(pReal, ofst, n, flags); } if( p->pScript && p->mask&TESTVFS_SHMLOCK_MASK ){ @@ -1009,7 +1011,8 @@ } if( p->isFullshm ){ - sqlite3OsShmBarrier(pFd->pReal); + sqlite3_file *pReal = pFd->pReal; + pReal->pMethods->xShmBarrier(pReal); return; } } @@ -1025,7 +1028,8 @@ TestvfsFd **ppFd; if( p->isFullshm ){ - return sqlite3OsShmUnmap(pFd->pReal, deleteFlag); + sqlite3_file *pReal = pFd->pReal; + return pReal->pMethods->xShmUnmap(pReal, deleteFlag); } if( !pBuffer ) return SQLITE_OK; diff -Nru sqlite3-3.33.0/src/trigger.c sqlite3-3.34.0/src/trigger.c --- sqlite3-3.33.0/src/trigger.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/trigger.c 2020-12-01 16:36:02.000000000 +0000 @@ -157,22 +157,11 @@ pTab = sqlite3SrcListLookup(pParse, pTableName); if( !pTab ){ /* The table does not exist. */ - if( db->init.iDb==1 ){ - /* Ticket #3810. - ** Normally, whenever a table is dropped, all associated triggers are - ** dropped too. But if a TEMP trigger is created on a non-TEMP table - ** and the table is dropped by a different database connection, the - ** trigger is not visible to the database connection that does the - ** drop so the trigger cannot be dropped. This results in an - ** "orphaned trigger" - a trigger whose associated table is missing. - */ - db->init.orphanTrigger = 1; - } - goto trigger_cleanup; + goto trigger_orphan_error; } if( IsVirtual(pTab) ){ sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); - goto trigger_cleanup; + goto trigger_orphan_error; } /* Check that the trigger name is not reserved and that no trigger of the @@ -210,12 +199,12 @@ if( pTab->pSelect && tr_tm!=TK_INSTEAD ){ sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0); - goto trigger_cleanup; + goto trigger_orphan_error; } if( !pTab->pSelect && tr_tm==TK_INSTEAD ){ sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" " trigger on table: %S", pTableName, 0); - goto trigger_cleanup; + goto trigger_orphan_error; } #ifndef SQLITE_OMIT_AUTHORIZATION @@ -275,6 +264,23 @@ }else{ assert( pParse->pNewTrigger==pTrigger ); } + return; + +trigger_orphan_error: + if( db->init.iDb==1 ){ + /* Ticket #3810. + ** Normally, whenever a table is dropped, all associated triggers are + ** dropped too. But if a TEMP trigger is created on a non-TEMP table + ** and the table is dropped by a different database connection, the + ** trigger is not visible to the database connection that does the + ** drop so the trigger cannot be dropped. This results in an + ** "orphaned trigger" - a trigger whose associated table is missing. + ** + ** 2020-11-05 see also https://sqlite.org/forum/forumpost/157dc791df + */ + db->init.orphanTrigger = 1; + } + goto trigger_cleanup; } /* diff -Nru sqlite3-3.33.0/src/update.c sqlite3-3.34.0/src/update.c --- sqlite3-3.33.0/src/update.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/update.c 2020-12-01 16:36:02.000000000 +0000 @@ -234,7 +234,7 @@ #endif pList = sqlite3ExprListAppend(pParse, pList, pNew); } - eDest = SRT_Upfrom; + eDest = IsVirtual(pTab) ? SRT_Table : SRT_Upfrom; }else if( pTab->pSelect ){ for(i=0; inCol; i++){ pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i)); @@ -651,6 +651,8 @@ if( nChangeFrom==0 && HasRowid(pTab) ){ sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid); + iEph = pParse->nTab++; + addrOpen = sqlite3VdbeAddOp3(v, OP_OpenEphemeral, iEph, 0, regRowSet); }else{ assert( pPk!=0 || HasRowid(pTab) ); nPk = pPk ? pPk->nKeyCol : 0; @@ -705,7 +707,7 @@ ** be deleted as a result of REPLACE conflict handling. Any of these ** things might disturb a cursor being used to scan through the table ** or index, causing a single-pass approach to malfunction. */ - flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE; + flags = WHERE_ONEPASS_DESIRED; if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){ flags |= WHERE_ONEPASS_MULTIROW; } @@ -742,9 +744,10 @@ ** leave it in register regOldRowid. */ sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid); if( eOnePass==ONEPASS_OFF ){ - /* We need to use regRowSet, so reallocate aRegIdx[nAllIdx] */ aRegIdx[nAllIdx] = ++pParse->nMem; - sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); + sqlite3VdbeAddOp3(v, OP_Insert, iEph, regRowSet, regOldRowid); + }else{ + if( ALWAYS(addrOpen) ) sqlite3VdbeChangeToNoop(v, addrOpen); } }else{ /* Read the PK of the current row into an array of registers. In @@ -832,8 +835,9 @@ VdbeCoverage(v); } }else{ - labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet,labelBreak, - regOldRowid); + sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v); + labelContinue = sqlite3VdbeMakeLabel(pParse); + addrTop = sqlite3VdbeAddOp2(v, OP_Rowid, iEph, regOldRowid); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); VdbeCoverage(v); @@ -1083,11 +1087,9 @@ }else if( eOnePass==ONEPASS_MULTI ){ sqlite3VdbeResolveLabel(v, labelContinue); sqlite3WhereEnd(pWInfo); - }else if( pPk || nChangeFrom ){ + }else{ sqlite3VdbeResolveLabel(v, labelContinue); sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v); - }else{ - sqlite3VdbeGoto(v, labelContinue); } sqlite3VdbeResolveLabel(v, labelBreak); @@ -1187,12 +1189,26 @@ regArg = pParse->nMem + 1; pParse->nMem += nArg; if( pSrc->nSrc>1 ){ + Index *pPk = 0; Expr *pRow; ExprList *pList; - if( pRowid ){ - pRow = sqlite3ExprDup(db, pRowid, 0); + if( HasRowid(pTab) ){ + if( pRowid ){ + pRow = sqlite3ExprDup(db, pRowid, 0); + }else{ + pRow = sqlite3PExpr(pParse, TK_ROW, 0, 0); + } }else{ - pRow = sqlite3PExpr(pParse, TK_ROW, 0, 0); + i16 iPk; /* PRIMARY KEY column */ + pPk = sqlite3PrimaryKeyIndex(pTab); + assert( pPk!=0 ); + assert( pPk->nKeyCol==1 ); + iPk = pPk->aiColumn[0]; + if( aXRef[iPk]>=0 ){ + pRow = sqlite3ExprDup(db, pChanges->a[aXRef[iPk]].pExpr, 0); + }else{ + pRow = exprRowColumn(pParse, iPk); + } } pList = sqlite3ExprListAppend(pParse, 0, pRow); @@ -1206,7 +1222,7 @@ } } - updateFromSelect(pParse, ephemTab, 0, pList, pSrc, pWhere, 0, 0); + updateFromSelect(pParse, ephemTab, pPk, pList, pSrc, pWhere, 0, 0); sqlite3ExprListDelete(db, pList); eOnePass = ONEPASS_OFF; }else{ diff -Nru sqlite3-3.33.0/src/util.c sqlite3-3.34.0/src/util.c --- sqlite3-3.33.0/src/util.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/util.c 2020-12-01 16:36:02.000000000 +0000 @@ -681,6 +681,7 @@ incr = 1; }else{ incr = 2; + length &= ~1; assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); for(i=3-enc; idb->nDb; j++) sqlite3VdbeUsesBtree(p, j); + sqlite3MayAbort(p->pParse); } /* @@ -703,7 +704,7 @@ if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename || opcode==OP_VDestroy || opcode==OP_VCreate - || (opcode==OP_ParseSchema && pOp->p4.z==0) + || opcode==OP_ParseSchema || ((opcode==OP_Halt || opcode==OP_HaltIfNull) && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort)) ){ @@ -1521,7 +1522,7 @@ sqlite3_str_appendf(&x, "%d", v1); }else if( pCtx->argc>1 ){ sqlite3_str_appendf(&x, "%d..%d", v1, v1+pCtx->argc-1); - }else{ + }else if( x.accError==0 ){ assert( x.nChar>2 ); x.nChar -= 2; ii++; @@ -2663,7 +2664,7 @@ */ for(i=0; rc==SQLITE_OK && inDb; i++){ Btree *pBt = db->aDb[i].pBt; - if( sqlite3BtreeIsInTrans(pBt) ){ + if( sqlite3BtreeTxnState(pBt)==SQLITE_TXN_WRITE ){ /* Whether or not a database might need a super-journal depends upon ** its journal mode (among other things). This matrix determines which ** journal modes use a super-journal and which do not */ @@ -2798,7 +2799,7 @@ */ for(i=0; inDb; i++){ Btree *pBt = db->aDb[i].pBt; - if( sqlite3BtreeIsInTrans(pBt) ){ + if( sqlite3BtreeTxnState(pBt)==SQLITE_TXN_WRITE ){ char const *zFile = sqlite3BtreeGetJournalname(pBt); if( zFile==0 ){ continue; /* Ignore TEMP and :memory: databases */ @@ -4294,9 +4295,12 @@ static int sqlite3IntFloatCompare(i64 i, double r){ if( sizeof(LONGDOUBLE_TYPE)>8 ){ LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; + testcase( xr ); + testcase( x==r ); if( xr ) return +1; - return 0; + if( x>r ) return +1; /*NO_TEST*/ /* work around bugs in gcov */ + return 0; /*NO_TEST*/ /* work around bugs in gcov */ }else{ i64 y; double s; diff -Nru sqlite3-3.33.0/src/vdbe.c sqlite3-3.34.0/src/vdbe.c --- sqlite3-3.33.0/src/vdbe.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/vdbe.c 2020-12-01 16:36:02.000000000 +0000 @@ -3487,7 +3487,8 @@ ** active. ** If P2 is non-zero, then a write-transaction is started, or if a ** read-transaction is already active, it is upgraded to a write-transaction. -** If P2 is zero, then a read-transaction is started. +** If P2 is zero, then a read-transaction is started. If P2 is 2 or more +** then an exclusive transaction is started. ** ** P1 is the index of the database file on which the transaction is ** started. Index 0 is the main database file and index 1 is the @@ -3521,6 +3522,7 @@ assert( p->bIsReader ); assert( p->readOnly==0 || pOp->p2==0 ); + assert( pOp->p2>=0 && pOp->p2<=2 ); assert( pOp->p1>=0 && pOp->p1nDb ); assert( DbMaskTest(p->btreeMask, pOp->p1) ); if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){ @@ -3546,7 +3548,7 @@ && pOp->p2 && (db->autoCommit==0 || db->nVdbeRead>1) ){ - assert( sqlite3BtreeIsInTrans(pBt) ); + assert( sqlite3BtreeTxnState(pBt)==SQLITE_TXN_WRITE ); if( p->iStatement==0 ){ assert( db->nStatement>=0 && db->nSavepoint>=0 ); db->nStatement++; @@ -3899,7 +3901,7 @@ } -/* Opcode: OpenEphemeral P1 P2 * P4 P5 +/* Opcode: OpenEphemeral P1 P2 P3 P4 P5 ** Synopsis: nColumn=P2 ** ** Open a new cursor P1 to a transient table. @@ -3919,6 +3921,10 @@ ** in btree.h. These flags control aspects of the operation of ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are ** added automatically. +** +** If P3 is positive, then reg[P3] is modified slightly so that it +** can be used as zero-length data for OP_Insert. This is an optimization +** that avoids an extra OP_Blob opcode to initialize that register. */ /* Opcode: OpenAutoindex P1 P2 * P4 * ** Synopsis: nColumn=P2 @@ -3941,6 +3947,15 @@ SQLITE_OPEN_TRANSIENT_DB; assert( pOp->p1>=0 ); assert( pOp->p2>=0 ); + if( pOp->p3>0 ){ + /* Make register reg[P3] into a value that can be used as the data + ** form sqlite3BtreeInsert() where the length of the data is zero. */ + assert( pOp->p2==0 ); /* Only used when number of columns is zero */ + assert( pOp->opcode==OP_OpenEphemeral ); + assert( aMem[pOp->p3].flags & MEM_Null ); + aMem[pOp->p3].n = 0; + aMem[pOp->p3].z = ""; + } pCx = p->apCsr[pOp->p1]; if( pCx && pCx->pBtx ){ /* If the ephermeral table is already open, erase all existing content @@ -4383,22 +4398,172 @@ break; } -/* Opcode: SeekHit P1 P2 * * * -** Synopsis: seekHit=P2 + +/* Opcode: SeekScan P1 P2 * * * +** Synopsis: Scan-ahead up to P1 rows ** -** Set the seekHit flag on cursor P1 to the value in P2. -** The seekHit flag is used by the IfNoHope opcode. +** This opcode is a prefix opcode to OP_SeekGE. In other words, this +** opcode must be immediately followed by OP_SeekGE. This constraint is +** checked by assert() statements. +** +** This opcode uses the P1 through P4 operands of the subsequent +** OP_SeekGE. In the text that follows, the operands of the subsequent +** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only +** the P1 and P2 operands of this opcode are also used, and are called +** This.P1 and This.P2. +** +** This opcode helps to optimize IN operators on a multi-column index +** where the IN operator is on the later terms of the index by avoiding +** unnecessary seeks on the btree, substituting steps to the next row +** of the b-tree instead. A correct answer is obtained if this opcode +** is omitted or is a no-op. +** +** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which +** is the desired entry that we want the cursor SeekGE.P1 to be pointing +** to. Call this SeekGE.P4/P5 row the "target". +** +** If the SeekGE.P1 cursor is not currently pointing to a valid row, +** then this opcode is a no-op and control passes through into the OP_SeekGE. +** +** If the SeekGE.P1 cursor is pointing to a valid row, then that row +** might be the target row, or it might be near and slightly before the +** target row. This opcode attempts to position the cursor on the target +** row by, perhaps by invoking sqlite3BtreeStep() on the cursor +** between 0 and This.P1 times. +** +** There are three possible outcomes from this opcode:
      +** +**
    1. If after This.P1 steps, the cursor is still point to a place that +** is earlier in the btree than the target row, +** then fall through into the subsquence OP_SeekGE opcode. +** +**
    2. If the cursor is successfully moved to the target row by 0 or more +** sqlite3BtreeNext() calls, then jump to This.P2, which will land just +** past the OP_IdxGT opcode that follows the OP_SeekGE. +** +**
    3. If the cursor ends up past the target row (indicating the the target +** row does not exist in the btree) then jump to SeekOP.P2. +**
    +*/ +case OP_SeekScan: { + VdbeCursor *pC; + int res; + int nStep; + UnpackedRecord r; + + assert( pOp[1].opcode==OP_SeekGE ); + + /* pOp->p2 points to the first instruction past the OP_IdxGT that + ** follows the OP_SeekGE. */ + assert( pOp->p2>=(int)(pOp-aOp)+2 ); + assert( aOp[pOp->p2-1].opcode==OP_IdxGT ); + assert( pOp[1].p1==aOp[pOp->p2-1].p1 ); + assert( pOp[1].p2==aOp[pOp->p2-1].p2 ); + assert( pOp[1].p3==aOp[pOp->p2-1].p3 ); + + assert( pOp->p1>0 ); + pC = p->apCsr[pOp[1].p1]; + assert( pC!=0 ); + assert( pC->eCurType==CURTYPE_BTREE ); + assert( !pC->isTable ); + if( !sqlite3BtreeCursorIsValidNN(pC->uc.pCursor) ){ +#ifdef SQLITE_DEBUG + if( db->flags&SQLITE_VdbeTrace ){ + printf("... cursor not valid - fall through\n"); + } +#endif + break; + } + nStep = pOp->p1; + assert( nStep>=1 ); + r.pKeyInfo = pC->pKeyInfo; + r.nField = (u16)pOp[1].p4.i; + r.default_rc = 0; + r.aMem = &aMem[pOp[1].p3]; +#ifdef SQLITE_DEBUG + { + int i; + for(i=0; i0 ){ + seekscan_search_fail: +#ifdef SQLITE_DEBUG + if( db->flags&SQLITE_VdbeTrace ){ + printf("... %d steps and then skip\n", pOp->p1 - nStep); + } +#endif + VdbeBranchTaken(1,3); + pOp++; + goto jump_to_p2; + } + if( res==0 ){ +#ifdef SQLITE_DEBUG + if( db->flags&SQLITE_VdbeTrace ){ + printf("... %d steps and then success\n", pOp->p1 - nStep); + } +#endif + VdbeBranchTaken(2,3); + goto jump_to_p2; + break; + } + if( nStep<=0 ){ +#ifdef SQLITE_DEBUG + if( db->flags&SQLITE_VdbeTrace ){ + printf("... fall through after %d steps\n", pOp->p1); + } +#endif + VdbeBranchTaken(0,3); + break; + } + nStep--; + rc = sqlite3BtreeNext(pC->uc.pCursor, 0); + if( rc ){ + if( rc==SQLITE_DONE ){ + rc = SQLITE_OK; + goto seekscan_search_fail; + }else{ + goto abort_due_to_error; + } + } + } + + break; +} + + +/* Opcode: SeekHit P1 P2 P3 * * +** Synopsis: set P2<=seekHit<=P3 +** +** Increase or decrease the seekHit value for cursor P1, if necessary, +** so that it is no less than P2 and no greater than P3. ** -** P1 must be a valid b-tree cursor. P2 must be a boolean value, -** either 0 or 1. +** The seekHit integer represents the maximum of terms in an index for which +** there is known to be at least one match. If the seekHit value is smaller +** than the total number of equality terms in an index lookup, then the +** OP_IfNoHope opcode might run to see if the IN loop can be abandoned +** early, thus saving work. This is part of the IN-early-out optimization. +** +** P1 must be a valid b-tree cursor. */ case OP_SeekHit: { VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); - assert( pOp->p2==0 || pOp->p2==1 ); - pC->seekHit = pOp->p2 & 1; + assert( pOp->p3>=pOp->p2 ); + if( pC->seekHitp2 ){ + pC->seekHit = pOp->p2; + }else if( pC->seekHit>pOp->p3 ){ + pC->seekHit = pOp->p3; + } break; } @@ -4456,16 +4621,20 @@ ** Synopsis: key=r[P3@P4] ** ** Register P3 is the first of P4 registers that form an unpacked -** record. -** -** Cursor P1 is on an index btree. If the seekHit flag is set on P1, then -** this opcode is a no-op. But if the seekHit flag of P1 is clear, then -** check to see if there is any entry in P1 that matches the -** prefix identified by P3 and P4. If no entry matches the prefix, -** jump to P2. Otherwise fall through. -** -** This opcode behaves like OP_NotFound if the seekHit -** flag is clear and it behaves like OP_Noop if the seekHit flag is set. +** record. Cursor P1 is an index btree. P2 is a jump destination. +** In other words, the operands to this opcode are the same as the +** operands to OP_NotFound and OP_IdxGT. +** +** This opcode is an optimization attempt only. If this opcode always +** falls through, the correct answer is still obtained, but extra works +** is performed. +** +** A value of N in the seekHit flag of cursor P1 means that there exists +** a key P3:N that will match some record in the index. We want to know +** if it is possible for a record P3:P4 to match some record in the +** index. If it is not possible, we can skips some work. So if seekHit +** is less than P4, attempt to find out if a match is possible by running +** OP_NotFound. ** ** This opcode is used in IN clause processing for a multi-column key. ** If an IN clause is attached to an element of the key other than the @@ -4507,7 +4676,7 @@ assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); - if( pC->seekHit ) break; + if( pC->seekHit>=pOp->p4.i ) break; /* Fall through into OP_NotFound */ /* no break */ deliberate_fall_through } @@ -4589,6 +4758,7 @@ }else{ VdbeBranchTaken(takeJump||alreadyExists==0,2); if( takeJump || !alreadyExists ) goto jump_to_p2; + if( pOp->opcode==OP_IfNoHope ) pC->seekHit = pOp->p4.i; } break; } @@ -4945,7 +5115,7 @@ if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = x.nKey; - assert( pData->flags & (MEM_Blob|MEM_Str) ); + assert( (pData->flags & (MEM_Blob|MEM_Str))!=0 || pData->n==0 ); x.pData = pData->z; x.nData = pData->n; seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0); @@ -5821,7 +5991,7 @@ break; } -/* Opcode: IdxGE P1 P2 P3 P4 P5 +/* Opcode: IdxGE P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** The P4 register values beginning with P3 form an unpacked index @@ -5832,7 +6002,7 @@ ** If the P1 index entry is greater than or equal to the key value ** then jump to P2. Otherwise fall through to the next instruction. */ -/* Opcode: IdxGT P1 P2 P3 P4 P5 +/* Opcode: IdxGT P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** The P4 register values beginning with P3 form an unpacked index @@ -5843,7 +6013,7 @@ ** If the P1 index entry is greater than the key value ** then jump to P2. Otherwise fall through to the next instruction. */ -/* Opcode: IdxLT P1 P2 P3 P4 P5 +/* Opcode: IdxLT P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** The P4 register values beginning with P3 form an unpacked index @@ -5854,7 +6024,7 @@ ** If the P1 index entry is less than the key value then jump to P2. ** Otherwise fall through to the next instruction. */ -/* Opcode: IdxLE P1 P2 P3 P4 P5 +/* Opcode: IdxLE P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** The P4 register values beginning with P3 form an unpacked index @@ -5880,7 +6050,6 @@ assert( pC->eCurType==CURTYPE_BTREE ); assert( pC->uc.pCursor!=0); assert( pC->deferredMoveto==0 ); - assert( pOp->p5==0 || pOp->p5==1 ); assert( pOp->p4type==P4_INT32 ); r.pKeyInfo = pC->pKeyInfo; r.nField = (u16)pOp->p4.i; @@ -5901,8 +6070,31 @@ } } #endif - res = 0; /* Not needed. Only used to silence a warning. */ - rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res); + + /* Inlined version of sqlite3VdbeIdxKeyCompare() */ + { + i64 nCellKey = 0; + BtCursor *pCur; + Mem m; + + assert( pC->eCurType==CURTYPE_BTREE ); + pCur = pC->uc.pCursor; + assert( sqlite3BtreeCursorIsValid(pCur) ); + nCellKey = sqlite3BtreePayloadSize(pCur); + /* nCellKey will always be between 0 and 0xffffffff because of the way + ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ + if( nCellKey<=0 || nCellKey>0x7fffffff ){ + rc = SQLITE_CORRUPT_BKPT; + goto abort_due_to_error; + } + sqlite3VdbeMemInit(&m, db, 0); + rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m); + if( rc ) goto abort_due_to_error; + res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0); + sqlite3VdbeMemRelease(&m); + } + /* End of inlined sqlite3VdbeIdxKeyCompare() */ + assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) ); if( (pOp->opcode&1)==(OP_IdxLT&1) ){ assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT ); @@ -5912,7 +6104,7 @@ res++; } VdbeBranchTaken(res>0,2); - if( rc ) goto abort_due_to_error; + assert( rc==SQLITE_OK ); if( res>0 ) goto jump_to_p2; break; } @@ -7038,7 +7230,7 @@ /* Open a transaction on the database file. Regardless of the journal ** mode, this transaction always uses a rollback journal. */ - assert( sqlite3BtreeIsInTrans(pBt)==0 ); + assert( sqlite3BtreeTxnState(pBt)!=SQLITE_TXN_WRITE ); if( rc==SQLITE_OK ){ rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1)); } @@ -7978,7 +8170,11 @@ ** an error of some kind. */ abort_due_to_error: - if( db->mallocFailed ) rc = SQLITE_NOMEM_BKPT; + if( db->mallocFailed ){ + rc = SQLITE_NOMEM_BKPT; + }else if( rc==SQLITE_IOERR_CORRUPTFS ){ + rc = SQLITE_CORRUPT_BKPT; + } assert( rc ); if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){ sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc)); diff -Nru sqlite3-3.33.0/src/vdbeInt.h sqlite3-3.34.0/src/vdbeInt.h --- sqlite3-3.33.0/src/vdbeInt.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/vdbeInt.h 2020-12-01 16:36:02.000000000 +0000 @@ -86,7 +86,7 @@ Bool isEphemeral:1; /* True for an ephemeral table */ Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */ Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */ - Bool seekHit:1; /* See the OP_SeekHit and OP_IfNoHope opcodes */ + u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */ Btree *pBtx; /* Separate file holding temporary table */ i64 seqCount; /* Sequence counter */ u32 *aAltMap; /* Mapping from table to index column numbers */ diff -Nru sqlite3-3.33.0/src/vdbesort.c sqlite3-3.34.0/src/vdbesort.c --- sqlite3-3.33.0/src/vdbesort.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/vdbesort.c 2020-12-01 16:36:02.000000000 +0000 @@ -970,13 +970,16 @@ if( pSorter==0 ){ rc = SQLITE_NOMEM_BKPT; }else{ + Btree *pBt = db->aDb[0].pBt; pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz); memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo); pKeyInfo->db = 0; if( nField && nWorker==0 ){ pKeyInfo->nKeyField = nField; } - pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt); + sqlite3BtreeEnter(pBt); + pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(pBt); + sqlite3BtreeLeave(pBt); pSorter->nTask = nWorker + 1; pSorter->iPrev = (u8)(nWorker - 1); pSorter->bUseThreads = (pSorter->nTask>1); diff -Nru sqlite3-3.33.0/src/where.c sqlite3-3.34.0/src/where.c --- sqlite3-3.33.0/src/where.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/where.c 2020-12-01 16:36:02.000000000 +0000 @@ -236,6 +236,16 @@ } /* +** If the right-hand branch of the expression is a TK_COLUMN, then return +** a pointer to the right-hand branch. Otherwise, return NULL. +*/ +static Expr *whereRightSubexprIsColumn(Expr *p){ + p = sqlite3ExprSkipCollateAndLikely(p->pRight); + if( ALWAYS(p!=0) && p->op==TK_COLUMN ) return p; + return 0; +} + +/* ** Advance to the next WhereTerm that matches according to the criteria ** established when the pScan object was initialized by whereScanInit(). ** Return NULL if there are no more matching WhereTerms. @@ -257,7 +267,7 @@ do{ for(pTerm=pWC->a+k; knTerm; k++, pTerm++){ if( pTerm->leftCursor==iCur - && pTerm->u.leftColumn==iColumn + && pTerm->u.x.leftColumn==iColumn && (iColumn!=XN_EXPR || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft, pScan->pIdxExpr,iCur)==0) @@ -265,8 +275,7 @@ ){ if( (pTerm->eOperator & WO_EQUIV)!=0 && pScan->nEquivaiCur) - && (pX = sqlite3ExprSkipCollateAndLikely(pTerm->pExpr->pRight))->op - ==TK_COLUMN + && (pX = whereRightSubexprIsColumn(pTerm->pExpr))!=0 ){ int j; for(j=0; jnEquiv; j++){ @@ -462,7 +471,8 @@ for(i=0; inExpr; i++){ Expr *p = sqlite3ExprSkipCollateAndLikely(pList->a[i].pExpr); - if( p->op==TK_COLUMN + if( ALWAYS(p!=0) + && p->op==TK_COLUMN && p->iColumn==pIdx->aiColumn[iCol] && p->iTable==iBase ){ @@ -526,6 +536,7 @@ */ for(i=0; inExpr; i++){ Expr *p = sqlite3ExprSkipCollateAndLikely(pDistinct->a[i].pExpr); + if( NEVER(p==0) ) continue; if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1; } @@ -679,8 +690,8 @@ return 0; } if( (pTerm->prereqRight & notReady)!=0 ) return 0; - if( pTerm->u.leftColumn<0 ) return 0; - aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity; + if( pTerm->u.x.leftColumn<0 ) return 0; + aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; testcase( pTerm->pExpr->op==TK_IS ); return 1; @@ -751,7 +762,7 @@ sqlite3ExprDup(pParse->db, pExpr, 0)); } if( termCanDriveIndex(pTerm, pSrc, notReady) ){ - int iCol = pTerm->u.leftColumn; + int iCol = pTerm->u.x.leftColumn; Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); testcase( iCol==BMS ); testcase( iCol==BMS-1 ); @@ -804,14 +815,14 @@ idxCols = 0; for(pTerm=pWC->a; pTermu.leftColumn; + int iCol = pTerm->u.x.leftColumn; Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); testcase( iCol==BMS-1 ); testcase( iCol==BMS ); if( (idxCols & cMask)==0 ){ Expr *pX = pTerm->pExpr; idxCols |= cMask; - pIdx->aiColumn[n] = pTerm->u.leftColumn; + pIdx->aiColumn[n] = pTerm->u.x.leftColumn; pColl = sqlite3ExprCompareCollSeq(pParse, pX); assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */ pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY; @@ -932,7 +943,7 @@ testcase( pTerm->eOperator & WO_ALL ); if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; if( pTerm->wtFlags & TERM_VNULL ) continue; - assert( pTerm->u.leftColumn>=(-1) ); + assert( pTerm->u.x.leftColumn>=(-1) ); nTerm++; } @@ -992,8 +1003,8 @@ ){ continue; } - assert( pTerm->u.leftColumn>=(-1) ); - pIdxCons[j].iColumn = pTerm->u.leftColumn; + assert( pTerm->u.x.leftColumn>=(-1) ); + pIdxCons[j].iColumn = pTerm->u.x.leftColumn; pIdxCons[j].iTermOffset = i; op = pTerm->eOperator & WO_ALL; if( op==WO_IN ) op = WO_EQ; @@ -1756,9 +1767,9 @@ if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C'; if( pTerm->eOperator & WO_SINGLE ){ sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}", - pTerm->leftCursor, pTerm->u.leftColumn); + pTerm->leftCursor, pTerm->u.x.leftColumn); }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){ - sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld", + sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%llx", pTerm->u.pOrInfo->indexable); }else{ sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor); @@ -1772,8 +1783,8 @@ sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx", pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight); } - if( pTerm->iField ){ - sqlite3DebugPrintf(" iField=%d", pTerm->iField); + if( pTerm->u.x.iField ){ + sqlite3DebugPrintf(" iField=%d", pTerm->u.x.iField); } if( pTerm->iParent>=0 ){ sqlite3DebugPrintf(" iParent=%d", pTerm->iParent); @@ -2440,9 +2451,9 @@ pNew = pBuilder->pNew; if( db->mallocFailed ) return SQLITE_NOMEM_BKPT; - WHERETRACE(0x800, ("BEGIN %s.addBtreeIdx(%s), nEq=%d, nSkip=%d\n", + WHERETRACE(0x800, ("BEGIN %s.addBtreeIdx(%s), nEq=%d, nSkip=%d, rRun=%d\n", pProbe->pTable->zName,pProbe->zName, - pNew->u.btree.nEq, pNew->nSkip)); + pNew->u.btree.nEq, pNew->nSkip, pNew->rRun)); assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 ); @@ -2536,7 +2547,7 @@ /* "x IN (value, value, ...)" */ nIn = sqlite3LogEst(pExpr->x.pList->nExpr); } - if( pProbe->hasStat1 ){ + if( pProbe->hasStat1 && rLogSize>=10 ){ LogEst M, logK, safetyMargin; /* Let: ** N = the total number of rows in the table @@ -2555,7 +2566,8 @@ ** a safety margin of 2 (LogEst: 10) that favors using the IN operator ** with the index, as using an index has better worst-case behavior. ** If we do not have real sqlite_stat1 data, always prefer to use - ** the index. + ** the index. Do not bother with this optimization on very small + ** tables (less than 2 rows) as it is pointless in that case. */ M = pProbe->aiRowLogEst[saved_nEq]; logK = estLog(nIn); @@ -2564,7 +2576,7 @@ WHERETRACE(0x40, ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n", saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize)); - continue; + pNew->wsFlags |= WHERE_IN_SEEKSCAN; }else{ WHERETRACE(0x40, ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n", @@ -2810,6 +2822,7 @@ if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0; for(ii=0; iinExpr; ii++){ Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr); + if( NEVER(pExpr==0) ) continue; if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){ if( pExpr->iColumn<0 ) return 1; for(jj=0; jjnKeyCol; jj++){ @@ -3041,8 +3054,23 @@ /* Full table scan */ pNew->iSortIdx = b ? iSortIdx : 0; - /* TUNING: Cost of full table scan is (N*3.0). */ + /* TUNING: Cost of full table scan is 3.0*N. The 3.0 factor is an + ** extra cost designed to discourage the use of full table scans, + ** since index lookups have better worst-case performance if our + ** stat guesses are wrong. Reduce the 3.0 penalty slightly + ** (to 2.75) if we have valid STAT4 information for the table. + ** At 2.75, a full table scan is preferred over using an index on + ** a column with just two distinct values where each value has about + ** an equal number of appearances. Without STAT4 data, we still want + ** to use an index in that case, since the constraint might be for + ** the scarcer of the two values, and in that case an index lookup is + ** better. + */ +#ifdef SQLITE_ENABLE_STAT4 + pNew->rRun = rSize + 16 - 2*((pTab->tabFlags & TF_HasStat4)!=0); +#else pNew->rRun = rSize + 16; +#endif ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); rc = whereLoopInsert(pBuilder, pNew); @@ -3773,6 +3801,7 @@ for(i=0; ia[i].pExpr); + if( NEVER(pOBExpr==0) ) continue; if( pOBExpr->op!=TK_COLUMN ) continue; if( pOBExpr->iTable!=iCur ) continue; pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, @@ -3899,6 +3928,7 @@ pOBExpr = sqlite3ExprSkipCollateAndLikely(pOrderBy->a[i].pExpr); testcase( wctrlFlags & WHERE_GROUPBY ); testcase( wctrlFlags & WHERE_DISTINCTBY ); + if( NEVER(pOBExpr==0) ) continue; if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0; if( iColumn>=XN_ROWID ){ if( pOBExpr->op!=TK_COLUMN ) continue; @@ -4053,16 +4083,24 @@ ** cost = (3.0 * N * log(N)) * (Y/X) ** ** The (Y/X) term is implemented using stack variable rScale - ** below. */ + ** below. + */ LogEst rScale, rSortCost; assert( nOrderBy>0 && 66==sqlite3LogEst(100) ); rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66; rSortCost = nRow + rScale + 16; /* Multiple by log(M) where M is the number of output rows. - ** Use the LIMIT for M if it is smaller */ + ** Use the LIMIT for M if it is smaller. Or if this sort is for + ** a DISTINCT operator, M will be the number of distinct output + ** rows, so fudge it downwards a bit. + */ if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimitiLimit; + }else if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT) ){ + /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT + ** reduces the number of output rows by a factor of 2 */ + if( nRow>10 ) nRow -= 10; assert( 10==sqlite3LogEst(2) ); } rSortCost += estLog(nRow); return rSortCost; @@ -5189,6 +5227,7 @@ if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0 && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0 && (pLoop->wsFlags & WHERE_BIGNULL_SORT)==0 + && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED ){ @@ -5246,6 +5285,7 @@ /* Done. */ VdbeModuleComment((v, "Begin WHERE-core")); + pWInfo->iEndWhere = sqlite3VdbeCurrentAddr(v); return pWInfo; /* Jump here if malloc fails */ @@ -5289,6 +5329,7 @@ WhereLoop *pLoop; SrcList *pTabList = pWInfo->pTabList; sqlite3 *db = pParse->db; + int iEnd = sqlite3VdbeCurrentAddr(v); /* Generate loop termination code. */ @@ -5349,7 +5390,9 @@ sqlite3VdbeJumpHere(v, pIn->addrInTop+1); if( pIn->eEndLoopOp!=OP_Noop ){ if( pIn->nPrefix ){ - assert( pLoop->wsFlags & WHERE_IN_EARLYOUT ); + int bEarlyOut = + (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 + && (pLoop->wsFlags & WHERE_IN_EARLYOUT)!=0; if( pLevel->iLeftJoin ){ /* For LEFT JOIN queries, cursor pIn->iCur may not have been ** opened yet. This occurs for WHERE clauses such as @@ -5360,12 +5403,10 @@ ** jump over the OP_Next or OP_Prev instruction about to ** be coded. */ sqlite3VdbeAddOp2(v, OP_IfNotOpen, pIn->iCur, - sqlite3VdbeCurrentAddr(v) + 2 + - ((pLoop->wsFlags & WHERE_VIRTUALTABLE)==0) - ); + sqlite3VdbeCurrentAddr(v) + 2 + bEarlyOut); VdbeCoverage(v); } - if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){ + if( bEarlyOut ){ sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur, sqlite3VdbeCurrentAddr(v)+2, pIn->iBase, pIn->nPrefix); @@ -5426,7 +5467,7 @@ assert( pWInfo->nLevel<=pTabList->nSrc ); for(i=0, pLevel=pWInfo->a; inLevel; i++, pLevel++){ int k, last; - VdbeOp *pOp; + VdbeOp *pOp, *pLastOp; Index *pIdx = 0; struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; Table *pTab = pTabItem->pTab; @@ -5484,20 +5525,31 @@ pIdx = pLevel->u.pCovidx; } if( pIdx - && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable)) && !db->mallocFailed ){ - last = sqlite3VdbeCurrentAddr(v); - k = pLevel->addrBody; + if( pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable) ){ + last = iEnd; + }else{ + last = pWInfo->iEndWhere; + } + k = pLevel->addrBody + 1; #ifdef SQLITE_DEBUG if( db->flags & SQLITE_VdbeAddopTrace ){ printf("TRANSLATE opcodes in range %d..%d\n", k, last-1); } + /* Proof that the "+1" on the k value above is safe */ + pOp = sqlite3VdbeGetOp(v, k - 1); + assert( pOp->opcode!=OP_Column || pOp->p1!=pLevel->iTabCur ); + assert( pOp->opcode!=OP_Rowid || pOp->p1!=pLevel->iTabCur ); + assert( pOp->opcode!=OP_IfNullRow || pOp->p1!=pLevel->iTabCur ); #endif pOp = sqlite3VdbeGetOp(v, k); - for(; kp1!=pLevel->iTabCur ) continue; - if( pOp->opcode==OP_Column + pLastOp = pOp + (last - k); + assert( pOpp1!=pLevel->iTabCur ){ + /* no-op */ + }else if( pOp->opcode==OP_Column #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC || pOp->opcode==OP_Offset #endif @@ -5528,7 +5580,10 @@ pOp->p1 = pLevel->iIdxCur; OpcodeRewriteTrace(db, k, pOp); } - } +#ifdef SQLITE_DEBUG + k++; +#endif + }while( (++pOp)flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n"); #endif diff -Nru sqlite3-3.33.0/src/wherecode.c sqlite3-3.34.0/src/wherecode.c --- sqlite3-3.33.0/src/wherecode.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/wherecode.c 2020-12-01 16:36:02.000000000 +0000 @@ -427,7 +427,7 @@ for(i=iEq; inLTerm; i++){ if( pLoop->aLTerm[i]->pExpr==pX ){ - int iField = pLoop->aLTerm[i]->iField - 1; + int iField = pLoop->aLTerm[i]->u.x.iField - 1; if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */ pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr); pOrigRhs->a[iField].pExpr = 0; @@ -570,6 +570,9 @@ if( pLevel->u.in.nIn==0 ){ pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); } + if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){ + pLoop->wsFlags |= WHERE_IN_EARLYOUT; + } i = pLevel->u.in.nIn; pLevel->u.in.nIn += nEq; @@ -596,7 +599,6 @@ if( iEq>0 ){ pIn->iBase = iReg - i; pIn->nPrefix = i; - pLoop->wsFlags |= WHERE_IN_EARLYOUT; }else{ pIn->nPrefix = 0; } @@ -606,6 +608,14 @@ pIn++; } } + testcase( iEq>0 + && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 + && (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ); + if( iEq>0 + && (pLoop->wsFlags & (WHERE_IN_SEEKSCAN|WHERE_VIRTUALTABLE))==0 + ){ + sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq); + } }else{ pLevel->u.in.nIn = 0; } @@ -1392,6 +1402,9 @@ pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC); VdbeCoverage(v); pLoop->u.vtab.needFree = 0; + /* An OOM inside of AddOp4(OP_VFilter) instruction above might have freed + ** the u.vtab.idxStr. NULL it out to prevent a use-after-free */ + if( db->mallocFailed ) pLoop->u.vtab.idxStr = 0; pLevel->p1 = iCur; pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext; pLevel->p2 = sqlite3VdbeCurrentAddr(v); @@ -1650,6 +1663,7 @@ u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */ int omitTable; /* True if we use the index only */ int regBignull = 0; /* big-null flag register */ + int addrSeekScan = 0; /* Opcode of the OP_SeekScan, if any */ pIdx = pLoop->u.btree.pIndex; iIdxCur = pLevel->iIdxCur; @@ -1788,9 +1802,6 @@ ** above has already left the cursor sitting on the correct row, ** so no further seeking is needed */ }else{ - if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){ - sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur); - } if( regBignull ){ sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull); VdbeComment((v, "NULL-scan pass ctr")); @@ -1798,6 +1809,20 @@ op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; assert( op!=0 ); + if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 && op==OP_SeekGE ){ + assert( regBignull==0 ); + /* TUNING: The OP_SeekScan opcode seeks to reduce the number + ** of expensive seek operations by replacing a single seek with + ** 1 or more step operations. The question is, how many steps + ** should we try before giving up and going with a seek. The cost + ** of a seek is proportional to the logarithm of the of the number + ** of entries in the tree, so basing the number of steps to try + ** on the estimated number of rows in the btree seems like a good + ** guess. */ + addrSeekScan = sqlite3VdbeAddOp1(v, OP_SeekScan, + (pIdx->aiRowLogEst[0]+9)/10); + VdbeCoverage(v); + } sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); VdbeCoverage(v); VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind ); @@ -1880,6 +1905,7 @@ testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE ); testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT ); testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE ); + if( addrSeekScan ) sqlite3VdbeJumpHere(v, addrSeekScan); } if( regBignull ){ /* During a NULL-scan, check to see if we have reached the end of @@ -1899,8 +1925,8 @@ testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE ); } - if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){ - sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1); + if( (pLoop->wsFlags & WHERE_IN_EARLYOUT)!=0 ){ + sqlite3VdbeAddOp3(v, OP_SeekHit, iIdxCur, nEq, nEq); } /* Seek the table cursor, if required */ @@ -1909,17 +1935,7 @@ if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ }else if( HasRowid(pIdx->pTable) ){ - if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) - || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)!=0 - && (pWInfo->eOnePass==ONEPASS_SINGLE || pLoop->nLTerm==0) ) - ){ - iRowidReg = ++pParse->nMem; - sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg); - VdbeCoverage(v); - }else{ - codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur); - } + codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur); }else if( iCur!=iIdxCur ){ Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable); iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol); @@ -2046,7 +2062,6 @@ int iRetInit; /* Address of regReturn init */ int untestedTerms = 0; /* Some terms not completely tested */ int ii; /* Loop counter */ - u16 wctrlFlags; /* Flags for sub-WHERE clause */ Expr *pAndExpr = 0; /* An ".. AND (...)" expression */ Table *pTab = pTabItem->pTab; @@ -2147,7 +2162,6 @@ ** eliminating duplicates from other WHERE clauses, the action for each ** sub-WHERE clause is to to invoke the main loop body as a subroutine. */ - wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE); ExplainQueryPlan((pParse, 1, "MULTI-INDEX OR")); for(ii=0; iinTerm; ii++){ WhereTerm *pOrTerm = &pOrWc->a[ii]; @@ -2166,7 +2180,7 @@ ExplainQueryPlan((pParse, 1, "INDEX %d", ii+1)); WHERETRACE(0xffff, ("Subplan for OR-clause:\n")); pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, - wctrlFlags, iCovCur); + WHERE_OR_SUBCLAUSE, iCovCur); assert( pSubWInfo || pParse->nErr || db->mallocFailed ); if( pSubWInfo ){ WhereLoop *pSubLoop; @@ -2264,6 +2278,9 @@ }else{ pCov = 0; } + if( sqlite3WhereUsesDeferredSeek(pSubWInfo) ){ + pWInfo->bDeferredSeek = 1; + } /* Finish the loop through table entries that match term pOrTerm. */ sqlite3WhereEnd(pSubWInfo); @@ -2416,7 +2433,7 @@ #endif assert( !ExprHasProperty(pE, EP_FromJoin) ); assert( (pTerm->prereqRight & pLevel->notReady)!=0 ); - pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady, + pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.x.leftColumn, notReady, WO_EQ|WO_IN|WO_IS, 0); if( pAlt==0 ) continue; if( pAlt->wtFlags & (TERM_CODED) ) continue; diff -Nru sqlite3-3.33.0/src/whereexpr.c sqlite3-3.34.0/src/whereexpr.c --- sqlite3-3.33.0/src/whereexpr.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/whereexpr.c 2020-12-01 16:36:02.000000000 +0000 @@ -798,7 +798,7 @@ assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) ); continue; } - iColumn = pOrTerm->u.leftColumn; + iColumn = pOrTerm->u.x.leftColumn; iCursor = pOrTerm->leftCursor; pLeft = pOrTerm->pExpr->pLeft; break; @@ -820,7 +820,7 @@ assert( pOrTerm->eOperator & WO_EQ ); if( pOrTerm->leftCursor!=iCursor ){ pOrTerm->wtFlags &= ~TERM_OR_OK; - }else if( pOrTerm->u.leftColumn!=iColumn || (iColumn==XN_EXPR + }else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR && sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1) )){ okToChngToIN = 0; @@ -855,7 +855,7 @@ if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue; assert( pOrTerm->eOperator & WO_EQ ); assert( pOrTerm->leftCursor==iCursor ); - assert( pOrTerm->u.leftColumn==iColumn ); + assert( pOrTerm->u.x.leftColumn==iColumn ); pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup); pLeft = pOrTerm->pExpr->pLeft; @@ -1091,15 +1091,15 @@ Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight); u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV; - if( pTerm->iField>0 ){ + if( pTerm->u.x.iField>0 ){ assert( op==TK_IN ); assert( pLeft->op==TK_VECTOR ); - pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr; + pLeft = pLeft->x.pList->a[pTerm->u.x.iField-1].pExpr; } if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){ pTerm->leftCursor = aiCurCol[0]; - pTerm->u.leftColumn = aiCurCol[1]; + pTerm->u.x.leftColumn = aiCurCol[1]; pTerm->eOperator = operatorMask(op) & opMask; } if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; @@ -1109,7 +1109,7 @@ WhereTerm *pNew; Expr *pDup; u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */ - assert( pTerm->iField==0 ); + assert( pTerm->u.x.iField==0 ); if( pTerm->leftCursor>=0 ){ int idxNew; pDup = sqlite3ExprDup(db, pExpr, 0); @@ -1135,7 +1135,7 @@ } pNew->wtFlags |= exprCommute(pParse, pDup); pNew->leftCursor = aiCurCol[0]; - pNew->u.leftColumn = aiCurCol[1]; + pNew->u.x.leftColumn = aiCurCol[1]; testcase( (prereqLeft | extraRight) != prereqLeft ); pNew->prereqRight = prereqLeft | extraRight; pNew->prereqAll = prereqAll; @@ -1309,7 +1309,7 @@ pNewTerm = &pWC->a[idxNew]; pNewTerm->prereqRight = prereqExpr; pNewTerm->leftCursor = pLeft->iTable; - pNewTerm->u.leftColumn = pLeft->iColumn; + pNewTerm->u.x.leftColumn = pLeft->iColumn; pNewTerm->eOperator = WO_AUX; pNewTerm->eMatchOp = eOp2; markTermAsChild(pWC, idxNew, idxTerm); @@ -1356,13 +1356,13 @@ /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create ** a virtual term for each vector component. The expression object ** used by each such virtual term is pExpr (the full vector IN(...) - ** expression). The WhereTerm.iField variable identifies the index within + ** expression). The WhereTerm.u.x.iField variable identifies the index within ** the vector on the LHS that the virtual term represents. ** ** This only works if the RHS is a simple SELECT (not a compound) that does ** not use window functions. */ - if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0 + if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->u.x.iField==0 && pExpr->pLeft->op==TK_VECTOR && pExpr->x.pSelect->pPrior==0 #ifndef SQLITE_OMIT_WINDOWFUNC @@ -1373,7 +1373,7 @@ for(i=0; ipLeft); i++){ int idxNew; idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL); - pWC->a[idxNew].iField = i+1; + pWC->a[idxNew].u.x.iField = i+1; exprAnalyze(pSrc, pWC, idxNew); markTermAsChild(pWC, idxNew, idxTerm); } @@ -1408,7 +1408,7 @@ pNewTerm = &pWC->a[idxNew]; pNewTerm->prereqRight = 0; pNewTerm->leftCursor = pLeft->iTable; - pNewTerm->u.leftColumn = pLeft->iColumn; + pNewTerm->u.x.leftColumn = pLeft->iColumn; pNewTerm->eOperator = WO_GT; markTermAsChild(pWC, idxNew, idxTerm); pTerm = &pWC->a[idxTerm]; @@ -1451,6 +1451,7 @@ void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){ Expr *pE2 = sqlite3ExprSkipCollateAndLikely(pExpr); pWC->op = op; + assert( pE2!=0 || pExpr==0 ); if( pE2==0 ) return; if( pE2->op!=op ){ whereClauseInsert(pWC, pExpr, 0); diff -Nru sqlite3-3.33.0/src/whereInt.h sqlite3-3.34.0/src/whereInt.h --- sqlite3-3.33.0/src/whereInt.h 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/src/whereInt.h 2020-12-01 16:36:02.000000000 +0000 @@ -261,9 +261,11 @@ u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */ int iParent; /* Disable pWC->a[iParent] when this term disabled */ int leftCursor; /* Cursor number of X in "X " */ - int iField; /* Field in (?,?,?) IN (SELECT...) vector */ union { - int leftColumn; /* Column number of X in "X " */ + struct { + int leftColumn; /* Column number of X in "X " */ + int iField; /* Field in (?,?,?) IN (SELECT...) vector */ + } x; /* Opcode other than OP_OR or OP_AND */ WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */ WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */ } u; @@ -488,6 +490,7 @@ unsigned sorted :1; /* True if really sorted (not just grouped) */ LogEst nRowOut; /* Estimated number of output rows */ int iTop; /* The very beginning of the WHERE loop */ + int iEndWhere; /* End of the WHERE clause itself */ WhereLoop *pLoops; /* List of all WhereLoop objects */ WhereExprMod *pExprMods; /* Expression modifications */ Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ @@ -616,5 +619,6 @@ #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */ #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */ #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */ +#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */ #endif /* !defined(SQLITE_WHEREINT_H) */ diff -Nru sqlite3-3.33.0/test/affinity3.test sqlite3-3.34.0/test/affinity3.test --- sqlite3-3.33.0/test/affinity3.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/affinity3.test 2020-12-01 16:36:02.000000000 +0000 @@ -72,10 +72,10 @@ CREATE TABLE mzed AS SELECT * FROM idmap; } -do_execsql_test affinity3-210 { - PRAGMA automatic_index=ON; - SELECT * FROM data JOIN idmap USING(id); -} {1 abc a 4 xyz e} +#do_execsql_test affinity3-210 { + #PRAGMA automatic_index=ON; + #SELECT * FROM data JOIN idmap USING(id); +#} {1 abc a 4 xyz e} do_execsql_test affinity3-220 { SELECT * FROM data JOIN mzed USING(id); } {1 abc a 4 xyz e} diff -Nru sqlite3-3.33.0/test/altertab3.test sqlite3-3.34.0/test/altertab3.test --- sqlite3-3.33.0/test/altertab3.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/altertab3.test 2020-12-01 16:36:02.000000000 +0000 @@ -600,5 +600,52 @@ # ALTER TABLE t2 RENAME COLUMN a TO aaa; #} -finish_test +#------------------------------------------------------------------------ +# +reset_db +do_execsql_test 26.1 { + CREATE TABLE t1(x); + + CREATE TABLE t3(y); + CREATE TABLE t4(z); + + CREATE TRIGGER tr1 INSERT ON t3 BEGIN + UPDATE t3 SET y=z FROM (SELECT z FROM t4); + END; + + CREATE TRIGGER tr2 INSERT ON t3 BEGIN + UPDATE t3 SET y=abc FROM (SELECT x AS abc FROM t1); + END; +} + +do_execsql_test 26.2 { + ALTER TABLE t1 RENAME TO t2; +} +do_execsql_test 26.3 { + ALTER TABLE t2 RENAME x TO xx; +} + +do_execsql_test 26.4 { + SELECT sql FROM sqlite_schema WHERE name='tr2' +} { +{CREATE TRIGGER tr2 INSERT ON t3 BEGIN + UPDATE t3 SET y=abc FROM (SELECT xx AS abc FROM "t2"); + END} +} + +# 2020-11-02 OSSFuzz +# +reset_db +do_execsql_test 26.5 { + CREATE TABLE t1(xx); + CREATE TRIGGER xx INSERT ON t1 BEGIN + UPDATE t1 SET xx=xx FROM(SELECT xx); + END; +} {} +do_catchsql_test 26.6 { + ALTER TABLE t1 RENAME TO t2; +} {1 {error in trigger xx: ambiguous column name: xx}} + + +finish_test diff -Nru sqlite3-3.33.0/test/altertab.test sqlite3-3.34.0/test/altertab.test --- sqlite3-3.33.0/test/altertab.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/altertab.test 2020-12-01 16:36:02.000000000 +0000 @@ -677,4 +677,39 @@ SELECT * FROM t1; } {1 2 78 a b 78} +#------------------------------------------------------------------------- +reset_db +db collate compare64 compare64 + +do_execsql_test 23.1 { + CREATE TABLE gigo(a text); + CREATE TABLE idx(x text COLLATE compare64); + CREATE VIEW v1 AS SELECT * FROM idx WHERE x='abc'; +} +db close +sqlite3 db test.db + +do_execsql_test 23.2 { + alter table gigo rename to ggiiggoo; + alter table idx rename to idx2; +} + +do_execsql_test 23.3 { + SELECT sql FROM sqlite_master; +} { + {CREATE TABLE "ggiiggoo"(a text)} + {CREATE TABLE "idx2"(x text COLLATE compare64)} + {CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE x='abc'} +} + +do_execsql_test 23.4 { + ALTER TABLE idx2 RENAME x TO y; + SELECT sql FROM sqlite_master; +} { + {CREATE TABLE "ggiiggoo"(a text)} + {CREATE TABLE "idx2"(y text COLLATE compare64)} + {CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE y='abc'} +} + finish_test + diff -Nru sqlite3-3.33.0/test/analyze3.test sqlite3-3.34.0/test/analyze3.test --- sqlite3-3.33.0/test/analyze3.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/analyze3.test 2020-12-01 16:36:02.000000000 +0000 @@ -23,6 +23,16 @@ return } +# This test cannot be run with the sqlite3_prepare() permutation, as it +# tests that stat4 data can be used to influence the plans of queries +# based on bound variable values. And this is not possible when using +# sqlite3_prepare() - as queries cannot be internally re-prepared after +# binding values are available. +if {[permutation]=="prepare"} { + finish_test + return +} + #---------------------------------------------------------------------- # Test Organization: # diff -Nru sqlite3-3.33.0/test/atof1.test sqlite3-3.34.0/test/atof1.test --- sqlite3-3.33.0/test/atof1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/atof1.test 2020-12-01 16:36:02.000000000 +0000 @@ -75,10 +75,10 @@ CREATE INDEX i1 ON t1(a); SELECT count(*) FROM t1 WHERE substr(a,','); } {1} - - - - +# 2020-08-27 OSSFuzz find related to the above. +do_execsql_test atof1-2.40 { + SELECT randomblob(0) - 1; +} {-1} finish_test diff -Nru sqlite3-3.33.0/test/bigmmap.test sqlite3-3.34.0/test/bigmmap.test --- sqlite3-3.33.0/test/bigmmap.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/bigmmap.test 2020-12-01 16:36:02.000000000 +0000 @@ -95,7 +95,7 @@ " [string map {"\n " "\n"} " QUERY PLAN |--SCAN TABLE t$t AS o USING COVERING INDEX sqlite_autoindex_t${t}_1 - `--CORRELATED SCALAR SUBQUERY + `--CORRELATED SCALAR SUBQUERY xxxxxx `--SEARCH TABLE t$t AS i USING INTEGER PRIMARY KEY (rowid=?) "] } diff -Nru sqlite3-3.33.0/test/busy2.test sqlite3-3.34.0/test/busy2.test --- sqlite3-3.33.0/test/busy2.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/busy2.test 2020-12-01 16:36:02.000000000 +0000 @@ -131,5 +131,41 @@ } } +#------------------------------------------------------------------------- +# Check that even if the busy-handler fails (returns zero) within a +# call to sqlite3_prepare() (or _v2(), or _v3()), it is still invoked +# the next time an SQLITE_BUSY is encountered. +# +do_multiclient_test tn { + code1 { + set ::busy_called 0 + proc busy {args} { + if {$::busy_called} { return 1 } + set ::busy_called 1 + return 0 + } + db busy busy + } + + do_test 3.$tn.1 { + sql2 { + CREATE TABLE t1(x); + BEGIN EXCLUSIVE; + INSERT INTO t1 VALUES('x'); + } + } {} + + do_test 3.$tn.2 { + set ::busy_called 0 + list [catch { sql1 { SELECT * FROM t1 } } msg] $::busy_called + } {1 1} + + do_test 3.$tn.3 { + set ::busy_called 0 + list [catch { sql1 { SELECT * FROM t1 } } msg] $::busy_called + } {1 1} + +} + finish_test diff -Nru sqlite3-3.33.0/test/carray01.test sqlite3-3.34.0/test/carray01.test --- sqlite3-3.33.0/test/carray01.test 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/test/carray01.test 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,100 @@ +# 2020-11-17 +# +# 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 tests for CARRAY extension +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix carray01 + +ifcapable !vtab { + finish_test + return +} +load_static_extension db carray + +# Parameter $stmt must be a prepared statement created using +# the sqlite3_prepare_v2 command and with parameters fullly bound. +# This routine simply runs the statement, gathers the result, and +# returns a list containing the result. +# +# If the optional second argument is true, then the stmt is finalized +# after it is run. +# +proc run_stmt {stmt {finalizeFlag 0}} { + set r {} + while {[sqlite3_step $stmt]=="SQLITE_ROW"} { + for {set i 0} {$i<[sqlite3_data_count $stmt]} {incr i} { + lappend r [sqlite3_column_text $stmt $i] + } + } + if {$finalizeFlag} { + sqlite3_finalize $stmt + } else { + sqlite3_reset $stmt + } + return $r +} + +do_test 100 { + set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1] + sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 7 + run_stmt $STMT 0 +} {1} +do_test 101 { + sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 7 + run_stmt $STMT 0 +} {1} +do_test 110 { + sqlite3_carray_bind $STMT 3 1 2 3 4 6 7 + run_stmt $STMT 0 +} {0} +do_test 120 { + sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 7 + run_stmt $STMT 0 +} {1} +do_test 130 { + sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 7 + run_stmt $STMT 0 +} {0} +do_test 131 { + sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7 + run_stmt $STMT 0 +} {0} +do_test 140 { + sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7 + run_stmt $STMT 0 +} {1} +do_test 150 { + sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7 + run_stmt $STMT 0 +} {0} +do_test 160 { + sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7 + run_stmt $STMT 0 +} {1} +do_test 170 { + sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7 + run_stmt $STMT 0 +} {0} +do_test 180 { + sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7 + run_stmt $STMT 0 +} {0} +do_test 190 { + sqlite3_carray_bind $STMT 3 + run_stmt $STMT 0 +} {0} + +sqlite3_finalize $STMT + +finish_test diff -Nru sqlite3-3.33.0/test/cast.test sqlite3-3.34.0/test/cast.test --- sqlite3-3.33.0/test/cast.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/cast.test 2020-12-01 16:36:02.000000000 +0000 @@ -474,5 +474,14 @@ } 1 } +reset_db +do_execsql_test cast-9.0 { + CREATE TABLE t0(c0); + INSERT INTO t0(c0) VALUES (0); + CREATE VIEW v1(c0, c1) AS + SELECT CAST(0.0 AS NUMERIC), COUNT(*) OVER () FROM t0; + SELECT v1.c0 FROM v1, t0 WHERE v1.c0=0; +} {0.0} + finish_test diff -Nru sqlite3-3.33.0/test/check.test sqlite3-3.34.0/test/check.test --- sqlite3-3.33.0/test/check.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/check.test 2020-12-01 16:36:02.000000000 +0000 @@ -40,7 +40,7 @@ catchsql { INSERT INTO t1 VALUES(6,7); } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: x<5}} do_test check-1.4 { execsql { SELECT * FROM t1; @@ -50,7 +50,7 @@ catchsql { INSERT INTO t1 VALUES(4,3); } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: y>x}} do_test check-1.6 { execsql { SELECT * FROM t1; @@ -87,7 +87,7 @@ catchsql { UPDATE t1 SET x=7 WHERE x==2 } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: x<5}} do_test check-1.13 { execsql { SELECT * FROM t1; @@ -97,7 +97,7 @@ catchsql { UPDATE t1 SET x=5 WHERE x==2 } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: x<5}} do_test check-1.15 { execsql { SELECT * FROM t1; @@ -186,7 +186,7 @@ catchsql { INSERT INTO t2b VALUES('xyzzy','hi',5); } -} {1 {CHECK constraint failed: t2b}} +} {1 {CHECK constraint failed: typeof(coalesce(x,0))=='integer'}} do_test check-2.12 { execsql { CREATE TABLE t2c( @@ -271,7 +271,7 @@ catchsql { INSERT INTO t3 VALUES(111,222,333); } -} {1 {CHECK constraint failed: t3}} +} {1 {CHECK constraint failed: t3.x<25}} do_test check-4.1 { execsql { @@ -313,7 +313,10 @@ catchsql { UPDATE t4 SET x=0, y=1; } -} {1 {CHECK constraint failed: t4}} +} {1 {CHECK constraint failed: x+y==11 + OR x*y==12 + OR x/y BETWEEN 5 AND 8 + OR -x==y+10}} do_test check-4.7 { execsql { SELECT * FROM t4; @@ -335,7 +338,10 @@ catchsql { UPDATE t4 SET x=0, y=2; } -} {1 {CHECK constraint failed: t4}} +} {1 {CHECK constraint failed: x+y==11 + OR x*y==12 + OR x/y BETWEEN 5 AND 8 + OR -x==y+10}} ifcapable vacuum { do_test check_4.10 { catchsql { @@ -386,7 +392,7 @@ catchsql { UPDATE OR FAIL t1 SET x=7-x, y=y+1; } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: x<5}} do_test check-6.6 { execsql { SELECT * FROM t1; @@ -398,7 +404,7 @@ INSERT INTO t1 VALUES(1,30.0); INSERT OR ROLLBACK INTO t1 VALUES(8,40.0); } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: x<5}} do_test check-6.8 { catchsql { COMMIT; @@ -417,7 +423,7 @@ catchsql { REPLACE INTO t1 VALUES(6,7); } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: x<5}} do_test check-6.13 { execsql {SELECT * FROM t1} } {3 12.0 2 20.0} @@ -446,7 +452,7 @@ do_execsql_test 7.1 { CREATE TABLE t6(a CHECK (myfunc(a))) } do_execsql_test 7.2 { INSERT INTO t6 VALUES(9) } do_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } \ - {1 {CHECK constraint failed: t6}} + {1 {CHECK constraint failed: myfunc(a)}} do_test 7.4 { sqlite3 db2 test.db @@ -469,7 +475,7 @@ do_test 7.8 { db2 func myfunc myfunc catchsql { INSERT INTO t6 VALUES(12) } db2 -} {1 {CHECK constraint failed: t6}} +} {1 {CHECK constraint failed: myfunc(a)}} # 2013-08-02: Silently ignore database name qualifiers in CHECK constraints. # @@ -550,10 +556,10 @@ } {} do_catchsql_test 12.21 { INSERT INTO t1(a) VALUES('xyz'); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: a<>+a}} do_catchsql_test 12.22 { INSERT INTO t1(a) VALUES(123); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: a<>+a}} do_execsql_test 12.30 { DROP TABLE t1; CREATE TABLE t1(a TEXT, CHECK(NOT(a=+a))); @@ -561,10 +567,10 @@ } {} do_catchsql_test 12.31 { INSERT INTO t1(a) VALUES('xyz'); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: NOT(a=+a)}} do_catchsql_test 12.32 { INSERT INTO t1(a) VALUES(123); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: NOT(a=+a)}} do_execsql_test 12.40 { DROP TABLE t1; CREATE TABLE t1(a TEXT, CHECK(NOT(a<>+a))); @@ -585,7 +591,7 @@ } {NULL} do_catchsql_test 12.61 { INSERT INTO t1(a) VALUES(456); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: a NOT BETWEEN 0 AND +a}} do_execsql_test 12.70 { DROP TABLE t1; CREATE TABLE t1(a TEXT, CHECK(a BETWEEN +a AND 999999)); @@ -600,6 +606,6 @@ } {NULL} do_catchsql_test 12.81 { INSERT INTO t1(a) VALUES(456); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: a NOT BETWEEN +a AND 999999}} finish_test diff -Nru sqlite3-3.33.0/test/conflict2.test sqlite3-3.34.0/test/conflict2.test --- sqlite3-3.33.0/test/conflict2.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/conflict2.test 2020-12-01 16:36:02.000000000 +0000 @@ -811,7 +811,7 @@ catchsql { REPLACE INTO t13 VALUES(2); } -} {1 {CHECK constraint failed: t13}} +} {1 {CHECK constraint failed: a!=2}} verify_ex_errcode conflict2-13.1b SQLITE_CONSTRAINT_CHECK do_test conflict2-13.2 { execsql { diff -Nru sqlite3-3.33.0/test/conflict.test sqlite3-3.34.0/test/conflict.test --- sqlite3-3.33.0/test/conflict.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/conflict.test 2020-12-01 16:36:02.000000000 +0000 @@ -813,7 +813,7 @@ catchsql { REPLACE INTO t13 VALUES(2); } -} {1 {CHECK constraint failed: t13}} +} {1 {CHECK constraint failed: a!=2}} verify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK do_test conflict-13.2 { execsql { diff -Nru sqlite3-3.33.0/test/date2.test sqlite3-3.34.0/test/date2.test --- sqlite3-3.33.0/test/date2.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/date2.test 2020-12-01 16:36:02.000000000 +0000 @@ -36,7 +36,7 @@ } {2017-07-20 one} do_catchsql_test date2-130 { INSERT INTO t1(x,y) VALUES('2017-08-01','two'); -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: date(x) BETWEEN '2017-07-01' AND '2017-07-31'}} do_execsql_test date2-200 { CREATE TABLE t2(x,y); @@ -138,7 +138,7 @@ } {0 {}} do_catchsql_test date2-602 { INSERT INTO t601(a,b) VALUES(1e100, '1970-01-01'); -} {1 {CHECK constraint failed: t601}} +} {1 {CHECK constraint failed: a0} + 1b "INSERT INTO t1 VALUES('one', -4.0)" {b>0} - 2a "INSERT INTO x2 VALUES('abc', 1)" {x2} - 2b "INSERT INTO t2 VALUES('abc', 1)" {t2} + 2a "INSERT INTO x2 VALUES('abc', 1)" {a||b} + 2b "INSERT INTO t2 VALUES('abc', 1)" {a||b} - 3a "INSERT INTO x2 VALUES(0, 'abc')" {x2} - 3b "INSERT INTO t2 VALUES(0, 'abc')" {t2} + 3a "INSERT INTO x2 VALUES(0, 'abc')" {a||b} + 3b "INSERT INTO t2 VALUES(0, 'abc')" {a||b} - 4a "UPDATE t1 SET b=-1 WHERE rowid=1" {t1} - 4b "UPDATE x1 SET b=-1 WHERE rowid=1" {x1} + 4a "UPDATE t1 SET b=-1 WHERE rowid=1" {b>0} + 4b "UPDATE x1 SET b=-1 WHERE rowid=1" {b>0} - 4a "UPDATE x2 SET a='' WHERE rowid=1" {x2} - 4b "UPDATE t2 SET a='' WHERE rowid=1" {t2} + 4a "UPDATE x2 SET a='' WHERE rowid=1" {a||b} + 4b "UPDATE t2 SET a='' WHERE rowid=1" {a||b} } # EVIDENCE-OF: R-34109-39108 If the CHECK expression evaluates to NULL, @@ -1639,7 +1639,7 @@ do_execsql_test 4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) } do_catchsql_test 4.18.3 { INSERT INTO t4 SELECT a+4, b+4 FROM t4 -} {1 {CHECK constraint failed: t4}} +} {1 {CHECK constraint failed: b!=10}} do_test e_createtable-4.18.4 { sqlite3_get_autocommit db } 0 do_execsql_test 4.18.5 { SELECT * FROM t4 } {1 2 3 4 5 6} diff -Nru sqlite3-3.33.0/test/e_expr.test sqlite3-3.34.0/test/e_expr.test --- sqlite3-3.33.0/test/e_expr.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/e_expr.test 2020-12-01 16:36:02.000000000 +0000 @@ -254,8 +254,9 @@ #------------------------------------------------------------------------- # Test the % operator. # -# EVIDENCE-OF: R-04223-04352 The operator % outputs the integer value of -# its left operand modulo its right operand. +# EVIDENCE-OF: R-53431-59159 The % operator casts both of its operands +# to type INTEGER and then computes the remainder after dividing the +# left integer by the right integer. # do_execsql_test e_expr-6.1 {SELECT 72%5} {2} do_execsql_test e_expr-6.2 {SELECT 72%-5} {2} diff -Nru sqlite3-3.33.0/test/fkey2.test sqlite3-3.34.0/test/fkey2.test --- sqlite3-3.33.0/test/fkey2.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/fkey2.test 2020-12-01 16:36:02.000000000 +0000 @@ -417,14 +417,14 @@ } {} do_test fkey2-3.1.3 { catchsql { UPDATE ab SET a = 5 } -} {1 {CHECK constraint failed: ef}} +} {1 {CHECK constraint failed: e!=5}} do_test fkey2-3.1.4 { execsql { SELECT * FROM ab } } {1 b} do_test fkey2-3.1.4 { execsql BEGIN; catchsql { UPDATE ab SET a = 5 } -} {1 {CHECK constraint failed: ef}} +} {1 {CHECK constraint failed: e!=5}} do_test fkey2-3.1.5 { execsql COMMIT; execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef } diff -Nru sqlite3-3.33.0/test/func4.test sqlite3-3.34.0/test/func4.test --- sqlite3-3.33.0/test/func4.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/func4.test 2020-12-01 16:36:02.000000000 +0000 @@ -381,32 +381,32 @@ catchsql { INSERT INTO t1 (x) VALUES (NULL); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.3 { catchsql { INSERT INTO t1 (x) VALUES (NULL); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.4 { catchsql { INSERT INTO t1 (x) VALUES (''); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.5 { catchsql { INSERT INTO t1 (x) VALUES ('bad'); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.6 { catchsql { INSERT INTO t1 (x) VALUES ('1234bad'); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.7 { catchsql { INSERT INTO t1 (x) VALUES ('1234.56bad'); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.8 { catchsql { INSERT INTO t1 (x) VALUES (1234); @@ -416,7 +416,7 @@ catchsql { INSERT INTO t1 (x) VALUES (1234.56); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.10 { catchsql { INSERT INTO t1 (x) VALUES ('1234'); @@ -426,27 +426,27 @@ catchsql { INSERT INTO t1 (x) VALUES ('1234.56'); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.12 { catchsql { INSERT INTO t1 (x) VALUES (ZEROBLOB(4)); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.13 { catchsql { INSERT INTO t1 (x) VALUES (X''); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.14 { catchsql { INSERT INTO t1 (x) VALUES (X'1234'); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.15 { catchsql { INSERT INTO t1 (x) VALUES (X'12345678'); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} do_test func4-3.16 { catchsql { INSERT INTO t1 (x) VALUES ('1234.00'); @@ -467,7 +467,7 @@ catchsql { INSERT INTO t1 (x) VALUES (9223372036854775808); } - } {1 {CHECK constraint failed: t1}} + } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} } do_execsql_test func4-3.20 { SELECT x FROM t1 WHERE x>0 ORDER BY x; @@ -483,32 +483,32 @@ catchsql { INSERT INTO t2 (x) VALUES (NULL); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.3 { catchsql { INSERT INTO t2 (x) VALUES (NULL); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.4 { catchsql { INSERT INTO t2 (x) VALUES (''); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.5 { catchsql { INSERT INTO t2 (x) VALUES ('bad'); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.6 { catchsql { INSERT INTO t2 (x) VALUES ('1234bad'); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.7 { catchsql { INSERT INTO t2 (x) VALUES ('1234.56bad'); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.8 { catchsql { INSERT INTO t2 (x) VALUES (1234); @@ -533,22 +533,22 @@ catchsql { INSERT INTO t2 (x) VALUES (ZEROBLOB(4)); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.13 { catchsql { INSERT INTO t2 (x) VALUES (X''); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.14 { catchsql { INSERT INTO t2 (x) VALUES (X'1234'); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_test func4-4.15 { catchsql { INSERT INTO t2 (x) VALUES (X'12345678'); } - } {1 {CHECK constraint failed: t2}} + } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} do_execsql_test func4-4.16 { SELECT x FROM t2 ORDER BY x; } {1234.0 1234.0 1234.56 1234.56} diff -Nru sqlite3-3.33.0/test/fuzzcheck.c sqlite3-3.34.0/test/fuzzcheck.c --- sqlite3-3.33.0/test/fuzzcheck.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/fuzzcheck.c 2020-12-01 16:36:02.000000000 +0000 @@ -627,7 +627,7 @@ unsigned char **paDecode, /* OUT: decoded database file */ int *pnDecode /* OUT: Size of decoded database */ ){ - unsigned char *a; /* Database under construction */ + unsigned char *a, *aNew; /* Database under construction */ int mx = 0; /* Current size of the database */ sqlite3_uint64 nAlloc = 4096; /* Space allocated in a[] */ unsigned int i; /* Next byte of zIn[] to read */ @@ -673,11 +673,12 @@ } newSize = MX_FILE_SZ; } - a = sqlite3_realloc64( a, newSize ); - if( a==0 ){ - fprintf(stderr, "Out of memory!\n"); - exit(1); + aNew = sqlite3_realloc64( a, newSize ); + if( aNew==0 ){ + sqlite3_free(a); + return -1; } + a = aNew; assert( newSize > nAlloc ); memset(a+nAlloc, 0, (size_t)(newSize - nAlloc)); nAlloc = newSize; @@ -851,7 +852,8 @@ int nAlloc = 0; int nNotUsed = 0; sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0); - fprintf(stderr,"Memory leak in mutator: %lld bytes in %d allocations\n", + fprintf(stderr,"memory leak prior to test start:" + " %lld bytes in %d allocations\n", sqlite3_memory_used(), nAlloc); exit(1); } @@ -866,7 +868,10 @@ fflush(stdout); } rc = sqlite3_open(0, &cx.db); - if( rc ) return 1; + if( rc ){ + sqlite3_free(aDb); + return 1; + } if( bVdbeDebug ){ sqlite3_exec(cx.db, "PRAGMA vdbe_debug=ON", 0, 0, 0); } @@ -1410,7 +1415,8 @@ " --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n" " --help Show this help text\n" " --info Show information about SOURCE-DB w/o running tests\n" -" --limit-depth N Limit expression depth to N\n" +" --limit-depth N Limit expression depth to N. Default: 500\n" +" --limit-heap N Limit heap memory to N. Default: 100M\n" " --limit-mem N Limit memory used by test SQLite instance to N bytes\n" " --limit-vdbe Panic if any test runs for more than 100,000 cycles\n" " --load-sql ARGS... Load SQL scripts fron files into SOURCE-DB\n" @@ -1424,6 +1430,7 @@ " -q|--quiet Reduced output\n" " --rebuild Rebuild and vacuum the database file\n" " --result-trace Show the results of each SQL command\n" +" --skip N Skip the first N test cases\n" " --spinner Use a spinner to show progress\n" " --sqlid N Use only SQL where sqlid=N\n" " --timeout N Abort if any single test needs more than N seconds\n" @@ -1451,6 +1458,7 @@ int rebuildFlag = 0; /* --rebuild */ int vdbeLimitFlag = 0; /* --limit-vdbe */ int infoFlag = 0; /* --info */ + int nSkip = 0; /* --skip */ int bSpinner = 0; /* True for --spinner */ int timeoutTest = 0; /* undocumented --timeout-test flag */ int runFlags = 0; /* Flags sent to runSql() */ @@ -1520,6 +1528,10 @@ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); depthLimit = integerValue(argv[++i]); }else + if( strcmp(z,"limit-heap")==0 ){ + if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); + heapLimit = integerValue(argv[++i]); + }else if( strcmp(z,"limit-mem")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); nMem = integerValue(argv[++i]); @@ -1578,6 +1590,10 @@ if( strcmp(z,"result-trace")==0 ){ runFlags |= SQL_OUTPUT; }else + if( strcmp(z,"skip")==0 ){ + if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); + nSkip = atoi(argv[++i]); + }else if( strcmp(z,"spinner")==0 ){ bSpinner = 1; }else @@ -1898,7 +1914,11 @@ prevAmt = amt; } } - runCombinedDbSqlInput(pSql->a, pSql->sz); + if( nSkip>0 ){ + nSkip--; + }else{ + runCombinedDbSqlInput(pSql->a, pSql->sz); + } nTest++; g.zTestName[0] = 0; disableOom(); @@ -1927,6 +1947,10 @@ prevAmt = amt; } } + if( nSkip>0 ){ + nSkip--; + continue; + } createVFile("main.db", pDb->sz, pDb->a); sqlite3_randomness(0,0); if( ossFuzzThisDb ){ Binary files /tmp/tmpuAqiiG/nlNCDCsC1K/sqlite3-3.33.0/test/fuzzdata8.db and /tmp/tmpuAqiiG/6WRgod1Ji3/sqlite3-3.34.0/test/fuzzdata8.db differ diff -Nru sqlite3-3.33.0/test/insert4.test sqlite3-3.34.0/test/insert4.test --- sqlite3-3.33.0/test/insert4.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/insert4.test 2020-12-01 16:36:02.000000000 +0000 @@ -55,7 +55,7 @@ catchsql { INSERT INTO t1 SELECT * FROM t2; } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: b>a}} xferopt_test insert4-1.2 0 do_test insert4-1.3 { execsql { @@ -102,7 +102,7 @@ INSERT INTO t1 SELECT * FROM t2 LIMIT 1; SELECT * FROM t1; } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: b>a}} xferopt_test insert4-2.3.4 0 # Do not run the transfer optimization if there is a DISTINCT @@ -120,7 +120,7 @@ DELETE FROM t1; INSERT INTO t1 SELECT DISTINCT * FROM t2; } -} {1 {CHECK constraint failed: t1}} +} {1 {CHECK constraint failed: b>a}} xferopt_test insert4-2.4.4 0 # The following procedure constructs two tables then tries to transfer @@ -316,7 +316,7 @@ catchsql { INSERT INTO t6b SELECT * FROM t6a; } -} {1 {CHECK constraint failed: t6b}} +} {1 {CHECK constraint failed: x<>'abc' COLLATE nocase}} do_test insert4-6.7 { execsql { DROP TABLE t6b; @@ -325,7 +325,7 @@ catchsql { INSERT INTO t6b SELECT * FROM t6a; } -} {1 {CHECK constraint failed: t6b}} +} {1 {CHECK constraint failed: x COLLATE nocase <>'abc'}} # Ticket [6284df89debdfa61db8073e062908af0c9b6118e] # Disable the xfer optimization if the destination table contains diff -Nru sqlite3-3.33.0/test/in.test sqlite3-3.34.0/test/in.test --- sqlite3-3.33.0/test/in.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/in.test 2020-12-01 16:36:02.000000000 +0000 @@ -332,7 +332,7 @@ catchsql { INSERT INTO t5 VALUES(4); } -} {1 {CHECK constraint failed: t5}} +} {1 {CHECK constraint failed: a IN (111,222,333)}} # Ticket #1821 # @@ -791,4 +791,10 @@ PRAGMA integrity_check; } {ok} +# Ticket f3ff1472887 +# +do_execsql_test in-20.1 { + SELECT (1 IN (2 IS TRUE)); +} {1} + finish_test diff -Nru sqlite3-3.33.0/test/istrue.test sqlite3-3.34.0/test/istrue.test --- sqlite3-3.33.0/test/istrue.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/istrue.test 2020-12-01 16:36:02.000000000 +0000 @@ -112,16 +112,16 @@ } {1 1 0 {} {}} do_catchsql_test istrue-521 { INSERT INTO t2 VALUES(2,false,false,null,null); -} {1 {CHECK constraint failed: t2}} +} {1 {CHECK constraint failed: b IS TRUE}} do_catchsql_test istrue-522 { INSERT INTO t2 VALUES(2,true,true,null,null); -} {1 {CHECK constraint failed: t2}} +} {1 {CHECK constraint failed: c IS FALSE}} do_catchsql_test istrue-523 { INSERT INTO t2 VALUES(2,true,false,true,null); -} {1 {CHECK constraint failed: t2}} +} {1 {CHECK constraint failed: d IS NOT TRUE}} do_catchsql_test istrue-524 { INSERT INTO t2 VALUES(2,true,false,null,false); -} {1 {CHECK constraint failed: t2}} +} {1 {CHECK constraint failed: e IS NOT FALSE}} foreach {tn val} [list 1 NaN 2 -NaN 3 NaN0 4 -NaN0 5 Inf 6 -Inf] { do_execsql_test istrue-600.$tn.1 { @@ -193,7 +193,7 @@ } {} do_catchsql_test istrue-841 { INSERT INTO False VALUES(5,6,7); -} {1 {CHECK constraint failed: false}} +} {1 {CHECK constraint failed: 5 IN (false.false)}} do_execsql_test istrue-850 { SELECT 9 IN (false.false) FROM false; } {0} diff -Nru sqlite3-3.33.0/test/join2.test sqlite3-3.34.0/test/join2.test --- sqlite3-3.33.0/test/join2.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/join2.test 2020-12-01 16:36:02.000000000 +0000 @@ -294,7 +294,10 @@ } #------------------------------------------------------------------------- -# Ticket [45f4bf4eb]. +# Ticket [45f4bf4eb] reported by Manuel Rigger (2020-04-25) +# +# Follow up error reported by Eric Speckman on the SQLite forum +# https://sqlite.org/forum/info/c49496d24d35bd7c (2020-08-19) # reset_db do_execsql_test 9.0 { @@ -324,5 +327,17 @@ UNION SELECT 0,0 WHERE 0; } {0 0} +do_execsql_test 9.10 { + CREATE TABLE t1 (aaa); + INSERT INTO t1 VALUES(23456); + CREATE TABLE t2(bbb); + CREATE VIEW v2(ccc) AS SELECT bbb IS 1234 FROM t2; + SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2; +} {{} 1} +optimization_control db query-flattener 0 +do_execsql_test 9.11 { + SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2; +} {{} 1} + finish_test diff -Nru sqlite3-3.33.0/test/join6.test sqlite3-3.34.0/test/join6.test --- sqlite3-3.33.0/test/join6.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/join6.test 2020-12-01 16:36:02.000000000 +0000 @@ -147,6 +147,22 @@ } {1 91 92 3 93 5} } +do_execsql_test join6-5.1 { + CREATE TABLE tx(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o PRIMARY KEY) + WITHOUT ROWID; + INSERT INTO tx VALUES( + 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + ); +} {} +do_execsql_test joint6-5.2 { + SELECT o FROM tx NATURAL JOIN tx; +} {15} + +do_execsql_test join6-5.3 { + CREATE TABLE ty(a,Ñ,x6,x7,x8,Q,I,v,x1,L,E,x2,x3,x4,x5,s,g PRIMARY KEY,b,c) + WITHOUT ROWID; + SELECT a FROM ty NATURAL JOIN ty; +} diff -Nru sqlite3-3.33.0/test/join.test sqlite3-3.34.0/test/join.test --- sqlite3-3.33.0/test/join.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/join.test 2020-12-01 16:36:02.000000000 +0000 @@ -1025,5 +1025,18 @@ SELECT * FROM t2 LEFT JOIN t1 ON a=0 WHERE (x='x' OR x IS NULL); } {1 {} {}} -finish_test +# 2020-09-30 ticket 66e4b0e271c47145 +# The query flattener inserts an "expr AND expr" expression as a substitution +# for the column of a view where that view column is part of an ON expression +# of a LEFT JOIN. +# +reset_db +do_execsql_test join-25.1 { + CREATE TABLE t0(c0 INT); + CREATE VIEW v0 AS SELECT (NULL AND 5) as c0 FROM t0; + INSERT INTO t0(c0) VALUES (NULL); + SELECT count(*) FROM v0 LEFT JOIN t0 ON v0.c0; +} {1} + +finish_test diff -Nru sqlite3-3.33.0/test/null.test sqlite3-3.34.0/test/null.test --- sqlite3-3.33.0/test/null.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/null.test 2020-12-01 16:36:02.000000000 +0000 @@ -296,5 +296,12 @@ SELECT * FROM t5 WHERE a IS NULL AND b = 'x'; } {{} x two {} x ii} +# 2020-09-30 ticket 5c4e7aa793943803 +reset_db +do_execsql_test null-10.1 { + CREATE TABLE t0(c0 PRIMARY KEY DESC); + INSERT INTO t0(c0) VALUES (0); + SELECT * FROM t0 WHERE t0.c0 > NULL; +} {} finish_test diff -Nru sqlite3-3.33.0/test/pager1.test sqlite3-3.34.0/test/pager1.test --- sqlite3-3.33.0/test/pager1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/pager1.test 2020-12-01 16:36:02.000000000 +0000 @@ -276,7 +276,7 @@ } {3 0} do_catchsql_test pager1-3.1.3 { INSERT INTO t1 SELECT a+3, randomblob(1500) FROM t1 -} {1 {CHECK constraint failed: counter}} +} {1 {CHECK constraint failed: i<5}} do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0} do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3} do_execsql_test pager1-3.6 { COMMIT } {} diff -Nru sqlite3-3.33.0/test/quote.test sqlite3-3.34.0/test/quote.test --- sqlite3-3.33.0/test/quote.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/quote.test 2020-12-01 16:36:02.000000000 +0000 @@ -122,7 +122,7 @@ } do_catchsql_test 2.3.2 { INSERT INTO xyz VALUES(1, 2, 'null'); -} {1 {CHECK constraint failed: xyz}} +} {1 {CHECK constraint failed: c!="null"}} do_execsql_test 2.4 { INSERT INTO t1 VALUES(1, 2, 3); diff -Nru sqlite3-3.33.0/test/releasetest_data.tcl sqlite3-3.34.0/test/releasetest_data.tcl --- sqlite3-3.33.0/test/releasetest_data.tcl 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/releasetest_data.tcl 2020-12-01 16:36:02.000000000 +0000 @@ -54,9 +54,10 @@ -DSQLITE_ENABLE_DESERIALIZE } "Sanitize" { - CC=clang -fsanitize=undefined + CC=clang -fsanitize=address,undefined -DSQLITE_ENABLE_STAT4 - --enable-session + --enable-debug + --enable-all } "Stdcall" { -DUSE_STDCALL=1 @@ -135,6 +136,11 @@ -DSQLITE_MUTATION_TEST --enable-fts5 --enable-json1 } + "Debug-Two" { + -DSQLITE_DEFAULT_MEMSTATUS=0 + -DSQLITE_MAX_EXPR_DEPTH=0 + --enable-debug + } "Fast-One" { -O6 -DSQLITE_ENABLE_FTS4=1 @@ -142,6 +148,7 @@ -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_RBU -DSQLITE_MAX_ATTACHED=125 + -DSQLITE_MAX_MMAP_SIZE=12884901888 -DLONGDOUBLE_TYPE=double --enable-session } @@ -284,6 +291,7 @@ "Check-Symbols*" checksymbols "Fast-One" "fuzztest test" "Debug-One" "mptest test" + "Debug-Two" "test" "Have-Not" test "Secure-Delete" test "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test" @@ -294,7 +302,7 @@ "No-lookaside" test "Devkit" test "Apple" test - "Sanitize" {QUICKTEST_OMIT=func4.test,nan.test test} + "Sanitize" {QUICKTEST_OMIT=crash*,shell*,sqldiff*,sessionB.test test} "Device-One" fulltest "Default" "threadtest fulltest" "Valgrind*" valgrindtest diff -Nru sqlite3-3.33.0/test/select1.test sqlite3-3.34.0/test/select1.test --- sqlite3-3.33.0/test/select1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/select1.test 2020-12-01 16:36:02.000000000 +0000 @@ -1201,4 +1201,13 @@ SELECT ifnull(a, max((SELECT 123))), count(a) FROM t1 ; } {10 1} +# 2020-10-02 dbsqlfuzz find +reset_db +do_execsql_test select-21.1 { + CREATE TABLE t1(a IMTEGES PRIMARY KEY,R); + CREATE TABLE t2(x UNIQUE); + CREATE VIEW v1a(z,y) AS SELECT x IS NULL, x FROM t2; + SELECT a,(+a)b,(+a)b,(+a)b,NOT EXISTS(SELECT null FROM t2),CASE z WHEN 487 THEN 992 WHEN 391 THEN 203 WHEN 10 THEN '?k 12 AND b < 16" {/*ANY(a) AND b>? AND b 2 AND b < 16" {/*SCAN TABLE t1*/} 4 "b > 18 AND b < 25" {/*ANY(a) AND b>? AND b 15" {/*ANY(a) AND b>?*/} + 5 "b > 16" {/*ANY(a) AND b>?*/} 6 "b > 5" {/*SCAN TABLE t1*/} 7 "b < 15" {/*SCAN TABLE t1*/} 8 "b < 5" {/*ANY(a) AND b '12' AND b < '16'" {/*ANY(a) AND b>? AND b '2' AND b < '16'" {/*SCAN TABLE t1*/} 13 "b > '18' AND b < '25'" {/*ANY(a) AND b>? AND b '15'" {/*ANY(a) AND b>?*/} + 14 "b > '16'" {/*ANY(a) AND b>?*/} 15 "b > '5'" {/*SCAN TABLE t1*/} 16 "b < '15'" {/*SCAN TABLE t1*/} 17 "b < '5'" {/*ANY(a) AND b 'q' } {/*ANY(a) AND ANY(b) AND c>?*/} 4 { c > 'e' } {/*SCAN TABLE t2*/} 5 { c < 'q' } {/*SCAN TABLE t2*/} - 6 { c < 'c' } {/*ANY(a) AND ANY(b) AND c=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); + g.nReserve = atoi(argv[++i]); }else if( strcmp(z,"without-rowid")==0 ){ g.zWR = "WITHOUT ROWID"; g.zPK = "PRIMARY KEY"; @@ -2354,6 +2367,9 @@ if( rc ) fatal_error("lookaside configuration failed: %d\n", rc); } #endif + if( g.nReserve>0 ){ + sqlite3_file_control(g.db, 0, SQLITE_FCNTL_RESERVE_BYTES, &g.nReserve); + } /* Set database connection options */ sqlite3_create_function(g.db, "random", 0, SQLITE_UTF8, 0, randomFunc, 0, 0); diff -Nru sqlite3-3.33.0/test/substr.test sqlite3-3.34.0/test/substr.test --- sqlite3-3.33.0/test/substr.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/substr.test 2020-12-01 16:36:02.000000000 +0000 @@ -11,7 +11,6 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the built-in SUBSTR() functions. # -# $Id: substr.test,v 1.7 2009/02/03 13:10:54 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -39,7 +38,7 @@ set qstr '[string map {' ''} $string]' do_test substr-$id.2 [subst { execsql { - SELECT substr($qstr, $i1, $i2) + SELECT substring($qstr, $i1, $i2) } }] [list $result] } @@ -55,7 +54,7 @@ }] [list $hexresult] do_test substr-$id.2 [subst { execsql { - SELECT hex(substr(x'$hex', $i1, $i2)) + SELECT hex(substring(x'$hex', $i1, $i2)) } }] [list $hexresult] } @@ -93,7 +92,7 @@ db eval {SELECT ifnull(substr('abcdefg',NULL,1),'nil')} } nil do_test substr-1.93 { - db eval {SELECT ifnull(substr('abcdefg',NULL),'nil')} + db eval {SELECT ifnull(substring('abcdefg',NULL),'nil')} } nil do_test substr-1.94 { db eval {SELECT ifnull(substr('abcdefg',1,NULL),'nil')} @@ -149,7 +148,7 @@ set qstr '[string map {' ''} $string]' do_test substr-$id.2 [subst { execsql { - SELECT substr($qstr, $idx) + SELECT substring($qstr, $idx) } }] [list $result] } diff -Nru sqlite3-3.33.0/test/tester.tcl sqlite3-3.34.0/test/tester.tcl --- sqlite3-3.33.0/test/tester.tcl 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/tester.tcl 2020-12-01 16:36:02.000000000 +0000 @@ -1731,6 +1731,9 @@ set msg "child process exited abnormally" } } + if {$r && [string match {*ERROR: LeakSanitizer*} $msg]} { + set msg "child process exited abnormally" + } lappend r $msg } diff -Nru sqlite3-3.33.0/test/threadtest3.c sqlite3-3.34.0/test/threadtest3.c --- sqlite3-3.33.0/test/threadtest3.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/threadtest3.c 2020-12-01 16:36:02.000000000 +0000 @@ -1433,6 +1433,7 @@ #include "tt3_lookaside1.c" #include "tt3_vacuum.c" #include "tt3_stress.c" +#include "tt3_shared.c" int main(int argc, char **argv){ struct ThreadTest { @@ -1457,6 +1458,7 @@ { vacuum1, "vacuum1", 10000 }, { stress1, "stress1", 10000 }, { stress2, "stress2", 60000 }, + { shared1, "shared1", 10000 }, }; static char *substArgv[] = { 0, "*", 0 }; int i, iArg; diff -Nru sqlite3-3.33.0/test/tkt2854.test sqlite3-3.34.0/test/tkt2854.test --- sqlite3-3.33.0/test/tkt2854.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/tkt2854.test 2020-12-01 16:36:02.000000000 +0000 @@ -28,17 +28,7 @@ do_test tkt2854-1.1 { sqlite3 db test.db sqlite3 db2 test.db - - # This is taken from shared.test. The Windows VFS expands - # ./test.db (and test.db) to be the same thing so the path - # matches and they share a cache. By changing the case - # for Windows platform, we get around this and get a separate - # connection. - if {$::tcl_platform(platform)=="unix"} { - sqlite3 db3 ./test.db - } else { - sqlite3 db3 TEST.DB - } + sqlite3 db3 "file:test.db?cache=private" -uri 1 db eval { CREATE TABLE abc(a, b, c); diff -Nru sqlite3-3.33.0/test/tkt3793.test sqlite3-3.34.0/test/tkt3793.test --- sqlite3-3.33.0/test/tkt3793.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/tkt3793.test 2020-12-01 16:36:02.000000000 +0000 @@ -13,7 +13,6 @@ # This file implements tests to verify that ticket #3793 has been # fixed. # -# $Id: tkt3793.test,v 1.2 2009/06/01 16:42:18 shane Exp $ set testdir [file dirname $argv0] @@ -26,18 +25,10 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1] do_test tkt3793-1.1 { - # This is taken from shared.test. The Windows VFS expands - # ./test.db (and test.db) to be the same thing so the path - # matches and they share a cache. By changing the case - # for Windows platform, we get around this and get a separate - # connection. - if {$::tcl_platform(platform)=="unix"} { - sqlite3 db1 test.db - sqlite3 db2 test.db - } else { - sqlite3 db1 TEST.DB - sqlite3 db2 TEST.DB - } + db close + sqlite3 db "file:test.db" -uri 1 + sqlite3 db1 "file:test.db?cache=private" -uri 1 + sqlite3 db2 "file:test.db?cache=shared" -uri 1 execsql { BEGIN; CREATE TABLE t1(a, b); diff -Nru sqlite3-3.33.0/test/tkt3810.test sqlite3-3.34.0/test/tkt3810.test --- sqlite3-3.33.0/test/tkt3810.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/tkt3810.test 2020-12-01 16:36:02.000000000 +0000 @@ -84,4 +84,20 @@ db2 close +# 2020-11-06 forum post https://sqlite.org/forum/forumpost/157dc791df +# +reset_db +do_test tkt3810-100 { + db eval { + ATTACH ':memory:' AS aux1; + CREATE TABLE aux1.t1(x); + CREATE TEMP TRIGGER r1 DELETE ON t1 BEGIN SELECT *; END; + CREATE VIEW t1 AS SELECT *; + } + catch {db eval { + CREATE VIRTUAL TABLE t2 USING nosuchmodule; + }} + db eval {CREATE TABLE t3(z);} +} {} + finish_test diff -Nru sqlite3-3.33.0/test/trans.test sqlite3-3.34.0/test/trans.test --- sqlite3-3.33.0/test/trans.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/trans.test 2020-12-01 16:36:02.000000000 +0000 @@ -11,7 +11,6 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks. # -# $Id: trans.test,v 1.41 2009/04/28 16:37:59 danielk1977 Exp $ set testdir [file dirname $argv0] @@ -39,6 +38,19 @@ SELECT b FROM two ORDER BY a; } } {I V X} +do_test trans-1.2.1 { + sqlite3_txn_state db +} {0} +do_test trans-1.2.2 { + sqlite3_txn_state db main +} {0} +do_test trans-1.2.3 { + sqlite3_txn_state db temp +} {0} +do_test trans-1.2.4 { + sqlite3_txn_state db no-such-schema +} {-1} + do_test trans-1.9 { sqlite3 altdb test.db execsql {SELECT b FROM one ORDER BY a} altdb @@ -55,6 +67,9 @@ set v [catch {execsql {BEGIN}} msg] lappend v $msg } {0 {}} +do_test trans-2.1b { + sqlite3_txn_state db +} {0} do_test trans-2.2 { set v [catch {execsql {END}} msg] lappend v $msg @@ -95,6 +110,16 @@ SELECT a FROM one ORDER BY a; } } {1 2 3} +do_test trans-3.1b { + sqlite3_txn_state db +} {2} +do_test trans-3.1c { + sqlite3_txn_state db main +} {2} +do_test trans-3.1d { + sqlite3_txn_state db temp +} {0} + do_test trans-3.2 { catchsql { SELECT a FROM two ORDER BY a; @@ -139,6 +164,10 @@ do_test trans-3.10 { execsql {END TRANSACTION} } {} +do_test trans-3.10b { + sqlite3_txn_state db +} {0} + do_test trans-3.11 { set v [catch {execsql { @@ -252,6 +281,15 @@ execsql {BEGIN TRANSACTION} execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name} } {} +do_test trans-5.2b { + sqlite3_txn_state db +} {1} +do_test trans-5.2c { + sqlite3_txn_state db main +} {1} +do_test trans-5.2d { + sqlite3_txn_state db temp +} {0} do_test trans-5.3 { execsql {CREATE TABLE one(a text, b int)} execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name} diff -Nru sqlite3-3.33.0/test/tt3_shared.c sqlite3-3.34.0/test/tt3_shared.c --- sqlite3-3.33.0/test/tt3_shared.c 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/test/tt3_shared.c 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,55 @@ +/* +** 2020 September 5 +** +** 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. +** +************************************************************************* +** +** +*/ + + +/* +*/ +static char *shared_thread1(int iTid, void *pArg){ + Error err = {0}; /* Error code and message */ + + while( !timetostop(&err) ){ + Sqlite db = {0}; /* SQLite database connection */ + opendb(&err, &db, "test.db", 0); + sql_script(&err, &db, "SELECT * FROM t1"); + closedb(&err, &db); + } + print_and_free_err(&err); + return sqlite3_mprintf("done!"); +} + + +static void shared1(int nMs){ + Error err = {0}; + Sqlite db = {0}; /* SQLite database connection */ + Threadset threads = {0}; + int ii; + + opendb(&err, &db, "test.db", 1); + sql_script(&err, &db, "CREATE TABLE t1(x)"); + closedb(&err, &db); + + setstoptime(&err, nMs); + sqlite3_enable_shared_cache(1); + + for(ii=0; ii<5; ii++){ + launch_thread(&err, &threads, shared_thread1, 0); + } + + join_all_threads(&err, &threads); + sqlite3_enable_shared_cache(0); + + print_and_free_err(&err); +} + diff -Nru sqlite3-3.33.0/test/view.test sqlite3-3.34.0/test/view.test --- sqlite3-3.33.0/test/view.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/view.test 2020-12-01 16:36:02.000000000 +0000 @@ -787,4 +787,18 @@ SELECT 0 IN (c0) FROM (SELECT c0 FROM t0); } {0} +#------------------------------------------------------------------------- +# 2020-10-26. https://sqlite.org/forum/forumpost/daa2c728cc +# +reset_db +do_catchsql_test view-29.0 { + CREATE TABLE t1(a,b,c); + CREATE VIEW IF NOT EXISTS IF AS SELECT null; +} {1 {malformed database schema (IF) - near "AS": syntax error}} +do_catchsql_test view-29.1 { + CREATE TABLE t2(c,d,e); + SELECT name FROM sqlite_schema ORDER BY name; +} {0 {t1 t2}} + + finish_test diff -Nru sqlite3-3.33.0/test/vtabJ.test sqlite3-3.34.0/test/vtabJ.test --- sqlite3-3.33.0/test/vtabJ.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/vtabJ.test 2020-12-01 16:36:02.000000000 +0000 @@ -122,5 +122,33 @@ SELECT name, value FROM tclvar where name = 'xx'; } {} +#------------------------------------------------------------------------- + +do_execsql_test 200 { + CREATE TABLE var(k TEXT, v TEXT); + INSERT INTO var VALUES('testvar1', 10); + INSERT INTO var VALUES('testvar2', 20); + INSERT INTO var VALUES('testvar3', 30); +} + +do_test 210 { + foreach {testvar1 testvar2 testvar3} {1 2 3} {} + execsql { + UPDATE tclvar SET value = var.v FROM var WHERE name = var.k; + } + list $testvar1 $testvar2 $testvar3 +} {10 20 30} + +do_test 220 { + execsql { + CREATE TABLE nam(k TEXT, v TEXT); + INSERT INTO nam VALUES('testvar1', 'tv1'); + INSERT INTO nam VALUES('testvar2', 'tv2'); + INSERT INTO nam VALUES('testvar3', 'tv3'); + UPDATE tclvar SET fullname = nam.v FROM nam WHERE name = nam.k; + } + list $tv1 $tv2 $tv3 +} {10 20 30} + finish_test diff -Nru sqlite3-3.33.0/test/whereA.test sqlite3-3.34.0/test/whereA.test --- sqlite3-3.33.0/test/whereA.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/whereA.test 2020-12-01 16:36:02.000000000 +0000 @@ -170,5 +170,20 @@ SELECT a FROM t1 WHERE b=-99 OR b>1; } {1} +# 2020-10-02 OSSFuzz find for an issue introduced by a check-in +# on the previous day. +# +reset_db +do_execsql_test whereA-6.1 { + CREATE TABLE t1(a, b); + CREATE INDEX t1aa ON t1(a,a); + INSERT INTO t1 VALUES(1,2); + ANALYZE; + UPDATE sqlite_stat1 SET stat='27 3 3' WHERE idx='t1aa'; + ANALYZE sqlite_schema; + PRAGMA reverse_unordered_selects (1) ; + SELECT a FROM t1 WHERE a=1 OR a=2; +} {1} + finish_test diff -Nru sqlite3-3.33.0/test/whereG.test sqlite3-3.34.0/test/whereG.test --- sqlite3-3.33.0/test/whereG.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/whereG.test 2020-12-01 16:36:02.000000000 +0000 @@ -220,9 +220,15 @@ SELECT * FROM t1 WHERE likely(b>?) } {SCAN TABLE t1} -do_eqp_test 5.3.1 { - SELECT * FROM t1 WHERE a=? -} {SEARCH TABLE t1 USING INDEX i1 (a=?)} +ifcapable stat4 { + do_eqp_test 5.3.1.stat4 { + SELECT * FROM t1 WHERE a=? + } {SCAN TABLE t1} +} else { + do_eqp_test 5.3.1 { + SELECT * FROM t1 WHERE a=? + } {SEARCH TABLE t1 USING INDEX i1} +} do_eqp_test 5.3.2 { SELECT * FROM t1 WHERE likelihood(a=?, 0.9) } {SCAN TABLE t1} diff -Nru sqlite3-3.33.0/test/where.test sqlite3-3.34.0/test/where.test --- sqlite3-3.33.0/test/where.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/where.test 2020-12-01 16:36:02.000000000 +0000 @@ -490,12 +490,12 @@ count { SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1; } - } {2 1 9 4} + } {2 1 9 5} do_test where-5.15 { count { SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1; } - } {2 1 9 3 1 16 8} + } {2 1 9 3 1 16 9} do_test where-5.100 { db eval { SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969) diff -Nru sqlite3-3.33.0/test/with1.test sqlite3-3.34.0/test/with1.test --- sqlite3-3.33.0/test/with1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/with1.test 2020-12-01 16:36:02.000000000 +0000 @@ -352,7 +352,7 @@ SELECT i FROM tree WHERE p IN (SELECT id FROM t) ) SELECT id FROM t; -} {1 {recursive reference in a subquery: t}} +} {1 {circular reference: t}} do_catchsql_test 7.5 { WITH t(id) AS ( @@ -1171,4 +1171,40 @@ SELECT x,O. * O FROM i ¬I,I? 10; } {1 {near "O": syntax error}} +# 2020-09-17 ticket c51489c3b8f919c5 +# DISTINCT cannot be ignored in a UNION ALL recursive CTE +# +reset_db +do_execsql_test 26.1 { + CREATE TABLE t (label VARCHAR(10), step INTEGER); + INSERT INTO T VALUES('a', 1); + INSERT INTO T VALUES('a', 1); + INSERT INTO T VALUES('b', 1); + WITH RECURSIVE cte(label, step) AS ( + SELECT DISTINCT * FROM t + UNION ALL + SELECT label, step + 1 FROM cte WHERE step < 3 + ) + SELECT * FROM cte ORDER BY +label, +step; +} {a 1 a 2 a 3 b 1 b 2 b 3} +do_execsql_test 26.2 { + WITH RECURSIVE cte(label, step) AS ( + SELECT * FROM t + UNION + SELECT label, step + 1 FROM cte WHERE step < 3 + ) + SELECT * FROM cte ORDER BY +label, +step; +} {a 1 a 2 a 3 b 1 b 2 b 3} +do_execsql_test 26.3 { + CREATE TABLE tworow(x); + INSERT INTO tworow(x) VALUES(1),(2); + DELETE FROM t WHERE rowid=2; + WITH RECURSIVE cte(label, step) AS ( + SELECT * FROM t + UNION ALL + SELECT DISTINCT label, step + 1 FROM cte, tworow WHERE step < 3 + ) + SELECT * FROM cte ORDER BY +label, +step; +} {a 1 a 2 a 3 b 1 b 2 b 3} + finish_test diff -Nru sqlite3-3.33.0/test/with3.test sqlite3-3.34.0/test/with3.test --- sqlite3-3.33.0/test/with3.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/with3.test 2020-12-01 16:36:02.000000000 +0000 @@ -30,7 +30,7 @@ SELECT 5 FROM t0 UNION SELECT 8 FROM m ) SELECT * FROM i; -} {1 {no such table: t0}} +} {1 {no such table: m}} # 2019-11-09 dbfuzzcheck find do_catchsql_test 1.1 { diff -Nru sqlite3-3.33.0/test/with5.test sqlite3-3.34.0/test/with5.test --- sqlite3-3.33.0/test/with5.test 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/test/with5.test 2020-12-01 16:36:02.000000000 +0000 @@ -0,0 +1,194 @@ +# 2020-10-19 +# +# 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 regression tests for SQLite library. The +# focus of this file is recursive common table expressions with +# multiple recursive terms in the compound select. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix with5 + +ifcapable {!cte} { + finish_test + return +} + +do_execsql_test 100 { + CREATE TABLE link(aa INT, bb INT); + CREATE INDEX link_f ON link(aa,bb); + CREATE INDEX link_t ON link(bb,aa); + INSERT INTO link(aa,bb) VALUES + (1,3), + (5,3), + (7,1), + (7,9), + (9,9), + (5,11), + (11,7), + (2,4), + (4,6), + (8,6); +} {} +do_execsql_test 110 { + WITH RECURSIVE closure(x) AS ( + VALUES(1) + UNION + SELECT aa FROM closure, link WHERE link.bb=closure.x + UNION + SELECT bb FROM closure, link WHERE link.aa=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 3 5 7 9 11} +do_execsql_test 111 { + WITH RECURSIVE closure(x) AS ( + VALUES(1) + UNION + SELECT aa FROM link, closure WHERE link.bb=closure.x + UNION + SELECT bb FROM closure, link WHERE link.aa=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 3 5 7 9 11} +do_execsql_test 112 { + WITH RECURSIVE closure(x) AS ( + VALUES(1) + UNION + SELECT bb FROM closure, link WHERE link.aa=closure.x + UNION + SELECT aa FROM link, closure WHERE link.bb=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 3 5 7 9 11} +do_execsql_test 113 { + WITH RECURSIVE closure(x) AS ( + VALUES(1),(200),(300),(400) + INTERSECT + VALUES(1) + UNION + SELECT bb FROM closure, link WHERE link.aa=closure.x + UNION + SELECT aa FROM link, closure WHERE link.bb=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 3 5 7 9 11} +do_execsql_test 114 { + WITH RECURSIVE closure(x) AS ( + VALUES(1),(200),(300),(400) + UNION ALL + VALUES(2) + UNION + SELECT bb FROM closure, link WHERE link.aa=closure.x + UNION + SELECT aa FROM link, closure WHERE link.bb=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 2 3 4 5 6 7 8 9 11 200 300 400} + +do_catchsql_test 120 { + WITH RECURSIVE closure(x) AS ( + VALUES(1),(200),(300),(400) + UNION ALL + VALUES(2) + UNION ALL + SELECT bb FROM closure, link WHERE link.aa=closure.x + UNION + SELECT aa FROM link, closure WHERE link.bb=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 {circular reference: closure}} +do_catchsql_test 121 { + WITH RECURSIVE closure(x) AS ( + VALUES(1),(200),(300),(400) + UNION ALL + VALUES(2) + UNION + SELECT bb FROM closure, link WHERE link.aa=closure.x + UNION ALL + SELECT aa FROM link, closure WHERE link.bb=closure.x + ) + SELECT x FROM closure ORDER BY x; +} {1 {circular reference: closure}} + +do_execsql_test 130 { + WITH RECURSIVE closure(x) AS ( + SELECT 1 AS x + UNION + SELECT aa FROM link JOIN closure ON bb=x + UNION + SELECT bb FROM link JOIN closure on aa=x + ORDER BY x LIMIT 4 + ) + SELECT * FROM closure; +} {1 3 5 7} +do_execsql_test 131 { + WITH RECURSIVE closure(x) AS ( + SELECT 1 AS x + UNION ALL + SELECT 2 + UNION + SELECT aa FROM link JOIN closure ON bb=x + UNION + SELECT bb FROM link JOIN closure on aa=x + ORDER BY x LIMIT 4 + ) + SELECT * FROM closure; +} {1 2 3 4} + +do_execsql_test 200 { + CREATE TABLE linkA(aa1,aa2); + INSERT INTO linkA(aa1,aa2) VALUES(1,3),(5,7),(9,11); + CREATE TABLE linkB(bb1,bb2); + INSERT INTO linkB(bb1,bb2) VALUES(7,9),(11,13),(3,5); + CREATE TABLE linkC(cc1,cc2); + INSERT INTO linkC(cc1,cc2) VALUES(1,2),(2,4),(6,8); + CREATE TABLE linkD(dd1,dd2); + INSERT INTO linkD(dd1,dd2) VALUES(4,6),(100,110); +} {} +do_execsql_test 210 { + WITH RECURSIVE closure(x) AS ( + VALUES(1) + UNION ALL + SELECT aa2 FROM linkA JOIN closure ON x=aa1 + UNION ALL + SELECT bb2 FROM linkB JOIN closure ON x=bb1 + UNION ALL + SELECT cc2 FROM linkC JOIN closure ON x=cc1 + UNION ALL + SELECT dd2 FROM linkD JOIN closure ON x=dd1 + ) + SELECT x FROM closure ORDER BY +x; +} {1 2 3 4 5 6 7 8 9 11 13} +do_execsql_test 220 { + CREATE TABLE linkA_ipk(aa1 INTEGER PRIMARY KEY,aa2); + INSERT INTO linkA_ipk(aa1,aa2) SELECT aa1, aa2 FROM linkA; + CREATE TABLE linkB_ipk(bb1 INTEGER PRIMARY KEY,bb2); + INSERT INTO linkB_ipk(bb1,bb2) SELECT bb1, bb2 FROM linkB; + CREATE TABLE linkC_ipk(cc1 INTEGER PRIMARY KEY,cc2); + INSERT INTO linkC_ipk(cc1,cc2) SELECT cc1, cc2 FROM linkC; + CREATE TABLE linkD_ipk(dd1 INTEGER PRIMARY KEY,dd2); + INSERT INTO linkD_ipk(dd1,dd2) SELECT dd1, dd2 FROM linkD; + WITH RECURSIVE closure(x) AS ( + VALUES(1) + UNION ALL + SELECT aa2 FROM linkA_ipk JOIN closure ON x=aa1 + UNION ALL + SELECT bb2 FROM linkB_ipk JOIN closure ON x=bb1 + UNION ALL + SELECT cc2 FROM linkC_ipk JOIN closure ON x=cc1 + UNION ALL + SELECT dd2 FROM linkD_ipk JOIN closure ON x=dd1 + ) + SELECT x FROM closure ORDER BY +x; +} {1 2 3 4 5 6 7 8 9 11 13} + + +finish_test diff -Nru sqlite3-3.33.0/test/without_rowid1.test sqlite3-3.34.0/test/without_rowid1.test --- sqlite3-3.33.0/test/without_rowid1.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/without_rowid1.test 2020-12-01 16:36:02.000000000 +0000 @@ -341,7 +341,7 @@ } {} do_catchsql_test 7.2 { INSERT INTO t70a(rowid,a,b) VALUES(33,99,'xyzzy'); -} {1 {CHECK constraint failed: t70a}} +} {1 {CHECK constraint failed: rowid!=33}} do_catchsql_test 7.3 { CREATE TABLE t70b( a INT CHECK( rowid!=33 ), diff -Nru sqlite3-3.33.0/test/without_rowid3.test sqlite3-3.34.0/test/without_rowid3.test --- sqlite3-3.33.0/test/without_rowid3.test 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/test/without_rowid3.test 2020-12-01 16:36:02.000000000 +0000 @@ -417,14 +417,14 @@ } {} do_test without_rowid3-3.1.3 { catchsql { UPDATE ab SET a = 5 } -} {1 {CHECK constraint failed: ef}} +} {1 {CHECK constraint failed: e!=5}} do_test without_rowid3-3.1.4 { execsql { SELECT * FROM ab } } {1 b} do_test without_rowid3-3.1.4 { execsql BEGIN; catchsql { UPDATE ab SET a = 5 } -} {1 {CHECK constraint failed: ef}} +} {1 {CHECK constraint failed: e!=5}} do_test without_rowid3-3.1.5 { execsql COMMIT; execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef } diff -Nru sqlite3-3.33.0/tool/GetTclKit.bat sqlite3-3.34.0/tool/GetTclKit.bat --- sqlite3-3.33.0/tool/GetTclKit.bat 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/tool/GetTclKit.bat 2020-12-01 16:36:02.000000000 +0000 @@ -39,10 +39,11 @@ GOTO usage ) -SET ROOT=%~dp0\.. -SET ROOT=%ROOT:\\=\% +IF NOT DEFINED ENVDIR ( + SET ENVDIR=%CD% +) -%_VECHO% Root = '%ROOT%' +%_VECHO% EnvDir = '%ENVDIR%' SET TOOLS=%~dp0 SET TOOLS=%TOOLS:~0,-1% @@ -64,21 +65,42 @@ %_VECHO% Temp = '%TEMP%' IF NOT DEFINED TCLKIT_URI ( - SET TCLKIT_URI=https://tclsh.com/ + SET TCLKIT_URI=https://urn.to/r/tclsh/ ) %_VECHO% TclKitUri = '%TCLKIT_URI%' +IF NOT DEFINED TCLKIT_PATCHLEVEL ( + SET TCLKIT_PATCHLEVEL=8.6.6 +) + +%_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%' + +IF NOT DEFINED TCLKIT_EXE_PATCHLEVEL ( + SET TCLKIT_EXE_PATCHLEVEL=8.6.4 +) + +%_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%' + IF /I "%PROCESSOR%" == "x86" ( CALL :fn_TclKitX86Variables + + IF ERRORLEVEL 1 ( + GOTO errors + ) ) ELSE IF /I "%PROCESSOR%" == "x64" ( CALL :fn_TclKitX64Variables + + IF ERRORLEVEL 1 ( + GOTO errors + ) ) ELSE ( GOTO usage ) %_VECHO% TclKitVersion = '%TCLKIT_VERSION%' %_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%' +%_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%' %_VECHO% TclKitNoEnv = '%TCLKIT_NOENV%' %_VECHO% TclKitNoSdk = '%TCLKIT_NOSDK%' %_VECHO% TclKitExe = '%TCLKIT_EXE%' @@ -173,20 +195,20 @@ IF DEFINED TCLKIT_NOENV GOTO skip_sdkEnvironment -%__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ROOT%\SetTclKitEnv.bat" +%__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ENVDIR%\SetTclKitEnv.bat" IF DEFINED TCLKIT_NOSDK GOTO skip_sdkVariables -%__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ROOT%\SetTclKitEnv.bat" -%__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ROOT%\SetTclKitEnv.bat" -%__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ROOT%\SetTclKitEnv.bat" -%__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ROOT%\SetTclKitEnv.bat" -%__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ROOT%\SetTclKitEnv.bat" +%__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ENVDIR%\SetTclKitEnv.bat" +%__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat" +%__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat" +%__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat" +%__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat" :skip_sdkVariables ECHO. -ECHO Wrote "%ROOT%\SetTclKitEnv.bat". +ECHO Wrote "%ENVDIR%\SetTclKitEnv.bat". ECHO Please run it to set the necessary Tcl environment variables. ECHO. @@ -202,12 +224,17 @@ REM to be available for download. REM IF NOT DEFINED TCLKIT_PATCHLEVEL ( - SET TCLKIT_PATCHLEVEL=8.6.6 + ECHO The TCLKIT_PATCHLEVEL environment variable must be set first. + CALL :fn_SetErrorLevel + GOTO :EOF ) SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=% SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2% - REM SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe - SET TCLKIT_EXE=tclkit-8.6.4.exe + IF DEFINED TCLKIT_EXE_PATCHLEVEL ( + SET TCLKIT_EXE=tclkit-%TCLKIT_EXE_PATCHLEVEL%.exe + ) ELSE ( + SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe + ) SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a SET TCLKIT_SDK=libtclkit-sdk-x86-%TCLKIT_PATCHLEVEL% @@ -226,12 +253,17 @@ REM to be available for download. REM IF NOT DEFINED TCLKIT_PATCHLEVEL ( - SET TCLKIT_PATCHLEVEL=8.6.6 + ECHO The TCLKIT_PATCHLEVEL environment variable must be set first. + CALL :fn_SetErrorLevel + GOTO :EOF ) SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=% SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2% - REM SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe - SET TCLKIT_EXE=tclkit-8.6.4.exe + IF DEFINED TCLKIT_EXE_PATCHLEVEL ( + SET TCLKIT_EXE=tclkit-%TCLKIT_EXE_PATCHLEVEL%.exe + ) ELSE ( + SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe + ) SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a SET TCLKIT_SDK=libtclkit-sdk-x64-%TCLKIT_PATCHLEVEL% diff -Nru sqlite3-3.33.0/tool/lemon.c sqlite3-3.34.0/tool/lemon.c --- sqlite3-3.33.0/tool/lemon.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/tool/lemon.c 2020-12-01 16:36:02.000000000 +0000 @@ -1591,14 +1591,14 @@ ** Sort a list of rules in order of increasing iRule value */ static struct rule *Rule_sort(struct rule *rp){ - int i; + unsigned int i; struct rule *pNext; struct rule *x[32]; memset(x, 0, sizeof(x)); while( rp ){ pNext = rp->next; rp->next = 0; - for(i=0; ipreccounter = 0; psp->firstrule = psp->lastrule = 0; psp->gp->nrule = 0; - /* Fall thru to next case */ + /* fall through */ case WAITING_FOR_DECL_OR_RULE: if( x[0]=='%' ){ psp->state = WAITING_FOR_DECL_KEYWORD; @@ -2426,7 +2426,7 @@ psp->alias[psp->nrhs] = 0; psp->nrhs++; } - }else if( (x[0]=='|' || x[0]=='/') && psp->nrhs>0 ){ + }else if( (x[0]=='|' || x[0]=='/') && psp->nrhs>0 && ISUPPER(x[1]) ){ struct symbol *msp = psp->rhs[psp->nrhs-1]; if( msp->type!=MULTITERMINAL ){ struct symbol *origsp = msp; @@ -2638,8 +2638,10 @@ } nOld = lemonStrlen(zOld); n = nOld + nNew + 20; - addLineMacro = !psp->gp->nolinenosflag && psp->insertLineMacro && - (psp->decllinenoslot==0 || psp->decllinenoslot[0]!=0); + addLineMacro = !psp->gp->nolinenosflag + && psp->insertLineMacro + && psp->tokenlineno>1 + && (psp->decllinenoslot==0 || psp->decllinenoslot[0]!=0); if( addLineMacro ){ for(z=psp->filename, nBack=0; *z; z++){ if( *z=='\\' ) nBack++; @@ -3515,8 +3517,8 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask) { const char *pathlist; - char *pathbufptr; - char *pathbuf; + char *pathbufptr = 0; + char *pathbuf = 0; char *path,*cp; char c; @@ -3550,8 +3552,8 @@ else pathbuf = &cp[1]; if( access(path,modemask)==0 ) break; } - free(pathbufptr); } + free(pathbufptr); } return path; } @@ -3617,6 +3619,16 @@ } } +/* Skip forward past the header of the template file to the first "%%" +*/ +PRIVATE void tplt_skip_header(FILE *in, int *lineno) +{ + char line[LINESIZE]; + while( fgets(line,LINESIZE,in) && (line[0]!='%' || line[1]!='%') ){ + (*lineno)++; + } +} + /* The next function finds the template file and opens it, returning ** a pointer to the opened file. */ PRIVATE FILE *tplt_open(struct lemon *lemp) @@ -3625,6 +3637,7 @@ char buf[1000]; FILE *in; char *tpltname; + char *toFree = 0; char *cp; /* first, see if user specified a template filename on the command line. */ @@ -3656,7 +3669,7 @@ }else if( access(templatename,004)==0 ){ tpltname = templatename; }else{ - tpltname = pathsearch(lemp->argv0,templatename,0); + toFree = tpltname = pathsearch(lemp->argv0,templatename,0); } if( tpltname==0 ){ fprintf(stderr,"Can't find the parser driver template file \"%s\".\n", @@ -3666,10 +3679,10 @@ } in = fopen(tpltname,"rb"); if( in==0 ){ - fprintf(stderr,"Can't open the template file \"%s\".\n",templatename); + fprintf(stderr,"Can't open the template file \"%s\".\n",tpltname); lemp->errorcnt++; - return 0; } + free(toFree); return in; } @@ -4287,6 +4300,7 @@ int mnTknOfst, mxTknOfst; int mnNtOfst, mxNtOfst; struct axset *ax; + char *prefix; lemp->minShiftReduce = lemp->nstate; lemp->errAction = lemp->minShiftReduce + lemp->nrule; @@ -4375,7 +4389,26 @@ fprintf(sql, "COMMIT;\n"); } lineno = 1; - tplt_xfer(lemp->name,in,out,&lineno); + + fprintf(out, + "/* This file is automatically generated by Lemon from input grammar\n" + "** source file \"%s\". */\n", lemp->filename); lineno += 2; + + /* The first %include directive begins with a C-language comment, + ** then skip over the header comment of the template file + */ + if( lemp->include==0 ) lemp->include = ""; + for(i=0; ISSPACE(lemp->include[i]); i++){ + if( lemp->include[i]=='\n' ){ + lemp->include += i+1; + i = -1; + } + } + if( lemp->include[0]=='/' ){ + tplt_skip_header(in,&lineno); + }else{ + tplt_xfer(lemp->name,in,out,&lineno); + } /* Generate the include code, if any */ tplt_print(out,lemp,lemp->include,&lineno); @@ -4387,17 +4420,18 @@ tplt_xfer(lemp->name,in,out,&lineno); /* Generate #defines for all tokens */ + if( lemp->tokenprefix ) prefix = lemp->tokenprefix; + else prefix = ""; if( mhflag ){ - const char *prefix; fprintf(out,"#if INTERFACE\n"); lineno++; - if( lemp->tokenprefix ) prefix = lemp->tokenprefix; - else prefix = ""; - for(i=1; interminal; i++){ - fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); - lineno++; - } - fprintf(out,"#endif\n"); lineno++; + }else{ + fprintf(out,"#ifndef %s%s\n", prefix, lemp->symbols[1]->name); + } + for(i=1; interminal; i++){ + fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); + lineno++; } + fprintf(out,"#endif\n"); lineno++; tplt_xfer(lemp->name,in,out,&lineno); /* Generate the defines */ diff -Nru sqlite3-3.33.0/tool/lempar.c sqlite3-3.34.0/tool/lempar.c --- sqlite3-3.33.0/tool/lempar.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/tool/lempar.c 2020-12-01 16:36:02.000000000 +0000 @@ -22,17 +22,13 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ %% /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols -** in a format understandable to "makeheaders". This section is blank unless -** "lemon" is run with the "-m" command-line option. -***************** Begin makeheaders token definitions *************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ %% -/**************** End makeheaders token definitions ***************************/ +/**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -229,6 +225,7 @@ #ifndef NDEBUG #include +#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -562,7 +559,7 @@ #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); @@ -721,8 +718,9 @@ (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); #ifndef NDEBUG - if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ + if( yyTraceFILE ){ yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", diff -Nru sqlite3-3.33.0/tool/mksqlite3c.tcl sqlite3-3.34.0/tool/mksqlite3c.tcl --- sqlite3-3.33.0/tool/mksqlite3c.tcl 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/tool/mksqlite3c.tcl 2020-12-01 16:36:02.000000000 +0000 @@ -88,6 +88,18 @@ #endif} } +# Examine the parse.c file. If it contains lines of the form: +# +# "#ifndef SQLITE_ENABLE_UPDATE_LIMIT +# +# then set the SQLITE_UDL_CAPABLE_PARSER flag in the amalgamation. +# +set in [open tsrc/parse.c] +if {[regexp {ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT} [read $in]]} { + puts $out "#define SQLITE_UDL_CAPABLE_PARSER 1" +} +close $in + # These are the header files used by SQLite. The first time any of these # files are seen in a #include statement in the C code, include the complete # text of the file in-line. The file only needs to be included once. diff -Nru sqlite3-3.33.0/tool/sqldiff.c sqlite3-3.34.0/tool/sqldiff.c --- sqlite3-3.33.0/tool/sqldiff.c 2020-08-14 13:42:41.000000000 +0000 +++ sqlite3-3.34.0/tool/sqldiff.c 2020-12-01 16:36:02.000000000 +0000 @@ -473,6 +473,7 @@ fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0)); } sqlite3_finalize(pStmt); + sqlite3_free(zId); } @@ -1544,6 +1545,7 @@ /* Check that the schemas of the two tables match. Exit early otherwise. */ checkSchemasMatch(zTab); + strInit(&sql); pStmt = db_prepare("PRAGMA main.table_info=%Q", zTab); while( SQLITE_ROW==sqlite3_step(pStmt) ){ @@ -1565,7 +1567,6 @@ } sqlite3_finalize(pStmt); if( nPk==0 ) goto end_changeset_one_table; - strInit(&sql); if( nCol>nPk ){ strPrintf(&sql, "SELECT %d", SQLITE_UPDATE); for(i=0; in++; } } @@ -457,7 +457,7 @@ int argc, sqlite3_value **argv ){ - const char *zCmd = (const char*)sqlite3_value_text(argv}; hd_resolve_one {0}; hd_puts {); + const char *zCmd = (const char*)sqlite3_value_text(argv[0]); if( zCmd!=0 ){ int rc = system(zCmd); sqlite3_result_int(context, rc); diff -Nru sqlite3-3.33.0/www/arch.html sqlite3-3.34.0/www/arch.html --- sqlite3-3.33.0/www/arch.html 2020-08-14 13:38:22.000000000 +0000 +++ sqlite3-3.34.0/www/arch.html 2020-12-01 16:31:32.000000000 +0000 @@ -109,8 +109,60 @@ modify the inner workings of SQLite.

    - - +

    SQLite C Interface

    Extended Result Codes

    @@ -132,6 +132,7 @@ #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8)) #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) +#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) diff -Nru sqlite3-3.33.0/www/c3ref/constlist.html sqlite3-3.34.0/www/c3ref/constlist.html --- sqlite3-3.33.0/www/c3ref/constlist.html 2020-08-14 13:38:22.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/constlist.html 2020-12-01 16:31:32.000000000 +0000 @@ -112,14 +112,14 @@
  • SQLITE_BUSY
  • SQLITE_BUSY_RECOVERY
  • SQLITE_BUSY_SNAPSHOT
  • -
  • SQLITE_BUSY_TIMEOUT
  • +
  • SQLITE_BUSY_TIMEOUT
  • SQLITE_CANTOPEN
  • SQLITE_CANTOPEN_CONVPATH
  • SQLITE_CANTOPEN_DIRTYWAL
  • SQLITE_CANTOPEN_FULLPATH
  • SQLITE_CANTOPEN_ISDIR
  • SQLITE_CANTOPEN_NOTEMPDIR
  • -
  • SQLITE_CANTOPEN_SYMLINK
  • +
  • SQLITE_CANTOPEN_SYMLINK
  • SQLITE_CHECKPOINT_FULL
  • SQLITE_CHECKPOINT_PASSIVE
  • SQLITE_CHECKPOINT_RESTART
  • @@ -158,7 +158,7 @@
  • SQLITE_CONSTRAINT_FOREIGNKEY
  • SQLITE_CONSTRAINT_FUNCTION
  • SQLITE_CONSTRAINT_NOTNULL
  • -
  • SQLITE_CONSTRAINT_PINNED
  • +
  • SQLITE_CONSTRAINT_PINNED
  • SQLITE_CONSTRAINT_PRIMARYKEY
  • SQLITE_CONSTRAINT_ROWID
  • SQLITE_CONSTRAINT_TRIGGER
  • @@ -166,7 +166,7 @@
  • SQLITE_CONSTRAINT_VTAB
  • SQLITE_COPY
  • SQLITE_CORRUPT
  • -
  • SQLITE_CORRUPT_INDEX
  • +
  • SQLITE_CORRUPT_INDEX
  • SQLITE_CORRUPT_SEQUENCE
  • SQLITE_CORRUPT_VTAB
  • SQLITE_CREATE_INDEX
  • @@ -316,14 +316,15 @@
  • SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
  • SQLITE_IOERR
  • SQLITE_IOERR_ACCESS
  • -
  • SQLITE_IOERR_AUTH
  • -
  • SQLITE_IOERR_BEGIN_ATOMIC
  • +
  • SQLITE_IOERR_AUTH
  • +
  • SQLITE_IOERR_BEGIN_ATOMIC
  • SQLITE_IOERR_BLOCKED
  • SQLITE_IOERR_CHECKRESERVEDLOCK
  • SQLITE_IOERR_CLOSE
  • -
  • SQLITE_IOERR_COMMIT_ATOMIC
  • +
  • SQLITE_IOERR_COMMIT_ATOMIC
  • SQLITE_IOERR_CONVPATH
  • -
  • SQLITE_IOERR_DATA
  • +
  • SQLITE_IOERR_CORRUPTFS
  • +
  • SQLITE_IOERR_DATA
  • SQLITE_IOERR_DELETE
  • SQLITE_IOERR_DELETE_NOENT
  • SQLITE_IOERR_DIR_CLOSE
  • @@ -336,7 +337,7 @@
  • SQLITE_IOERR_NOMEM
  • SQLITE_IOERR_RDLOCK
  • SQLITE_IOERR_READ
  • -
  • SQLITE_IOERR_ROLLBACK_ATOMIC
  • +
  • SQLITE_IOERR_ROLLBACK_ATOMIC
  • SQLITE_IOERR_SEEK
  • SQLITE_IOERR_SHMLOCK
  • SQLITE_IOERR_SHMMAP
  • @@ -345,7 +346,7 @@
  • SQLITE_IOERR_SHORT_READ
  • SQLITE_IOERR_TRUNCATE
  • SQLITE_IOERR_UNLOCK
  • -
  • SQLITE_IOERR_VNODE
  • +
  • SQLITE_IOERR_VNODE
  • SQLITE_IOERR_WRITE
  • SQLITE_LIMIT_ATTACHED
  • SQLITE_LIMIT_COLUMN
  • @@ -502,6 +503,7 @@
  • SQLITE_TESTCTRL_RESERVE
  • SQLITE_TESTCTRL_RESULT_INTREAL
  • SQLITE_TESTCTRL_SCRATCHMALLOC
  • +
  • SQLITE_TESTCTRL_SEEK_COUNT
  • SQLITE_TESTCTRL_SORTER_MMAP
  • SQLITE_TESTCTRL_VDBE_COVERAGE
  • SQLITE_TEXT
  • @@ -513,6 +515,9 @@
  • SQLITE_TRACE_STMT
  • SQLITE_TRANSACTION
  • SQLITE_TRANSIENT
  • +
  • SQLITE_TXN_NONE
  • +
  • SQLITE_TXN_READ
  • +
  • SQLITE_TXN_WRITE
  • SQLITE_UPDATE
  • SQLITE_UTF16
  • SQLITE_UTF16BE
  • diff -Nru sqlite3-3.33.0/www/c3ref/context.html sqlite3-3.34.0/www/c3ref/context.html --- sqlite3-3.33.0/www/c3ref/context.html 2020-08-14 13:38:22.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/context.html 2020-12-01 16:31:32.000000000 +0000 @@ -108,7 +108,8 @@ sqlite3_aggregate_context(), sqlite3_user_data(), sqlite3_context_db_handle(), sqlite3_get_auxdata(), and/or sqlite3_set_auxdata(). -

    +

    26 Methods: +

    • sqlite3_aggregate_context
    • sqlite3_context_db_handle
    • diff -Nru sqlite3-3.33.0/www/c3ref/c_source_id.html sqlite3-3.34.0/www/c3ref/c_source_id.html --- sqlite3-3.33.0/www/c3ref/c_source_id.html 2020-08-14 13:38:22.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/c_source_id.html 2020-12-01 16:31:32.000000000 +0000 @@ -97,9 +97,9 @@

      Compile-Time Library Version Numbers

    -#define SQLITE_VERSION        "3.33.0"
    -#define SQLITE_VERSION_NUMBER 3033000
    -#define SQLITE_SOURCE_ID      "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f"
    +#define SQLITE_VERSION        "3.34.0"
    +#define SQLITE_VERSION_NUMBER 3034000
    +#define SQLITE_SOURCE_ID      "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b"
     

    The SQLITE_VERSION C preprocessor macro in the sqlite3.h header diff -Nru sqlite3-3.33.0/www/c3ref/c_testctrl_always.html sqlite3-3.34.0/www/c3ref/c_testctrl_always.html --- sqlite3-3.33.0/www/c3ref/c_testctrl_always.html 2020-08-14 13:38:22.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/c_testctrl_always.html 2020-12-01 16:31:32.000000000 +0000 @@ -91,7 +91,7 @@ }

    - +

    SQLite C Interface

    Testing Interface Operation Codes

    @@ -125,7 +125,8 @@ #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 -#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */ +#define SQLITE_TESTCTRL_SEEK_COUNT 30 +#define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */

    These constants are the valid operation code parameters used diff -Nru sqlite3-3.33.0/www/c3ref/c_txn_none.html sqlite3-3.34.0/www/c3ref/c_txn_none.html --- sqlite3-3.33.0/www/c3ref/c_txn_none.html 1970-01-01 00:00:00.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/c_txn_none.html 2020-12-01 16:31:32.000000000 +0000 @@ -0,0 +1,135 @@ + + + + + +Allowed return values from [sqlite3_txn_state()] + + + +

    + + + +
    +
    +Small. Fast. Reliable.
    Choose any three. +
    + + +
    +
    + + + +
    +
    +
    + + + +
    +

    SQLite C Interface

    +

    Allowed return values from [sqlite3_txn_state()]

    +
    +
    +#define SQLITE_TXN_NONE  0
    +#define SQLITE_TXN_READ  1
    +#define SQLITE_TXN_WRITE 2
    +
    +

    +These constants define the current transaction state of a database file. +The sqlite3_txn_state(D,S) interface returns one of these +constants in order to describe the transaction state of schema S +in database connection D.

    + +

    + +
    SQLITE_TXN_NONE
    +
    The SQLITE_TXN_NONE state means that no transaction is currently +pending.

    + +

    +

    SQLITE_TXN_READ
    +
    The SQLITE_TXN_READ state means that the database is currently +in a read transaction. Content has been read from the database file +but nothing in the database file has changed. The transaction state +will advanced to SQLITE_TXN_WRITE if any changes occur and there are +no other conflicting concurrent write transactions. The transaction +state will revert to SQLITE_TXN_NONE following a ROLLBACK or +COMMIT.

    + +

    +

    SQLITE_TXN_WRITE
    +
    The SQLITE_TXN_WRITE state means that the database is currently +in a write transaction. Content has been written to the database file +but has not yet committed. The transaction state will change to +to SQLITE_TXN_NONE at the next ROLLBACK or COMMIT.
    +

    See also lists of + Objects, + Constants, and + Functions.

    diff -Nru sqlite3-3.33.0/www/c3ref/funclist.html sqlite3-3.34.0/www/c3ref/funclist.html --- sqlite3-3.33.0/www/c3ref/funclist.html 2020-08-14 13:38:23.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/funclist.html 2020-12-01 16:31:32.000000000 +0000 @@ -97,7 +97,7 @@

    Note: Functions marked with "(exp)" are experimental and functions whose names are struck through are deprecated.

    - +
    @@ -339,6 +339,7 @@
  • sqlite3_trace
  • sqlite3_trace_v2
  • sqlite3_transfer_bindings
  • +
  • sqlite3_txn_state
  • sqlite3_unlock_notify
  • sqlite3_update_hook
  • sqlite3_uri_boolean
  • diff -Nru sqlite3-3.33.0/www/c3ref/preupdate_count.html sqlite3-3.34.0/www/c3ref/preupdate_count.html --- sqlite3-3.33.0/www/c3ref/preupdate_count.html 2020-08-14 13:38:23.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/preupdate_count.html 2020-12-01 16:31:32.000000000 +0000 @@ -157,7 +157,7 @@ seventh parameter is the final rowid value of the row being inserted or updated. The value of the seventh parameter passed to the callback function is not defined for operations on WITHOUT ROWID tables, or for -INSERT operations on rowid tables.

    +DELETE operations on rowid tables.

    The sqlite3_preupdate_old(), sqlite3_preupdate_new(), sqlite3_preupdate_count(), and sqlite3_preupdate_depth() interfaces diff -Nru sqlite3-3.33.0/www/c3ref/snapshot.html sqlite3-3.34.0/www/c3ref/snapshot.html --- sqlite3-3.33.0/www/c3ref/snapshot.html 2020-08-14 13:38:23.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/snapshot.html 2020-12-01 16:31:32.000000000 +0000 @@ -117,9 +117,9 @@ version of the database file so that it is possible to later open a new read transaction that sees that historical version of the database rather than the most recent version. -

    Constructor: sqlite3_snapshot_get()

    -

    Destructor: sqlite3_snapshot_free()

    -

    Methods: +

    1 Constructor: sqlite3_snapshot_get()

    +

    1 Destructor: sqlite3_snapshot_free()

    +

    3 Methods: sqlite3_snapshot_cmp(), sqlite3_snapshot_open(), sqlite3_snapshot_recover()

    diff -Nru sqlite3-3.33.0/www/c3ref/sqlite3.html sqlite3-3.34.0/www/c3ref/sqlite3.html --- sqlite3-3.33.0/www/c3ref/sqlite3.html 2020-08-14 13:38:23.000000000 +0000 +++ sqlite3-3.34.0/www/c3ref/sqlite3.html 2020-12-01 16:31:32.000000000 +0000 @@ -109,13 +109,14 @@ sqlite3_prepare_v2(), sqlite3_create_function(), and sqlite3_busy_timeout() to name but three) that are methods on an sqlite3 object. -

    Constructors: +

    3 Constructors: sqlite3_open(), sqlite3_open16(), sqlite3_open_v2()

    -

    Destructors: +

    2 Destructors: sqlite3_close(), sqlite3_close_v2()

    +

    70 Methods:

    +


    +

    Allowed return values from [sqlite3_txn_state()]

    + +
    +#define SQLITE_TXN_NONE  0
    +#define SQLITE_TXN_READ  1
    +#define SQLITE_TXN_WRITE 2
    +
    +

    +These constants define the current transaction state of a database file. +The sqlite3_txn_state(D,S) interface returns one of these +constants in order to describe the transaction state of schema S +in database connection D.

    + +

    + +
    SQLITE_TXN_NONE
    +
    The SQLITE_TXN_NONE state means that no transaction is currently +pending.

    + +

    +

    SQLITE_TXN_READ
    +
    The SQLITE_TXN_READ state means that the database is currently +in a read transaction. Content has been read from the database file +but nothing in the database file has changed. The transaction state +will advanced to SQLITE_TXN_WRITE if any changes occur and there are +no other conflicting concurrent write transactions. The transaction +state will revert to SQLITE_TXN_NONE following a ROLLBACK or +COMMIT.

    + +

    +

    SQLITE_TXN_WRITE
    +
    The SQLITE_TXN_WRITE state means that the database is currently +in a write transaction. Content has been written to the database file +but has not yet committed. The transaction state will change to +to SQLITE_TXN_NONE at the next ROLLBACK or COMMIT.


    Virtual Table Configuration Options

    @@ -7049,9 +7119,9 @@ The sqlite3_blob_read() and sqlite3_blob_write() interfaces can be used to read or write small subsections of the BLOB. The sqlite3_blob_bytes() interface returns the size of the BLOB in bytes. -

    Constructor: sqlite3_blob_open()

    -

    Destructor: sqlite3_blob_close()

    -

    Methods: +

    1 Constructor: sqlite3_blob_open()

    +

    1 Destructor: sqlite3_blob_close()

    +

    4 Methods: sqlite3_blob_bytes(), sqlite3_blob_read(), sqlite3_blob_reopen(), @@ -7072,13 +7142,14 @@ sqlite3_prepare_v2(), sqlite3_create_function(), and sqlite3_busy_timeout() to name but three) that are methods on an sqlite3 object. -

    Constructors: +

    3 Constructors: sqlite3_open(), sqlite3_open16(), sqlite3_open_v2()

    -

    Destructors: +

    2 Destructors: sqlite3_close(), sqlite3_close_v2()

    +

    70 Methods: