/ Check-in [e2d38d51]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge 3.19.3 changes with this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256: e2d38d51a9cf1c3dfef742507ec76e3d35853bd09b0d09bf2d404c4b036a184d
User & Date: dan 2017-06-08 16:10:41
Wiki:begin-concurrent
Context
2017-06-08
16:23
Update the recent auto-vacuum fix so that it works for the in-memory pointer-map structure used by this branch. check-in: 8e311a6d user: dan tags: begin-concurrent
16:10
Merge 3.19.3 changes with this branch. check-in: e2d38d51 user: dan tags: begin-concurrent
15:54
Merge changes for version 3.19.0 with this branch. check-in: 0f59bb94 user: dan tags: begin-concurrent
14:26
Version 3.19.3 check-in: 0ee482a1 user: drh tags: release, version-3.19.3, branch-3.19
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to VERSION.

     1         -3.19.0
            1  +3.19.3

Changes to configure.

     1      1   #! /bin/sh
     2      2   # Guess values for system-dependent variables and create Makefiles.
     3         -# Generated by GNU Autoconf 2.69 for sqlite 3.19.0.
            3  +# Generated by GNU Autoconf 2.69 for sqlite 3.19.3.
     4      4   #
     5      5   #
     6      6   # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
     7      7   #
     8      8   #
     9      9   # This configure script is free software; the Free Software Foundation
    10     10   # gives unlimited permission to copy, distribute and modify it.
................................................................................
   722    722   subdirs=
   723    723   MFLAGS=
   724    724   MAKEFLAGS=
   725    725   
   726    726   # Identity of this package.
   727    727   PACKAGE_NAME='sqlite'
   728    728   PACKAGE_TARNAME='sqlite'
   729         -PACKAGE_VERSION='3.19.0'
   730         -PACKAGE_STRING='sqlite 3.19.0'
          729  +PACKAGE_VERSION='3.19.3'
          730  +PACKAGE_STRING='sqlite 3.19.3'
   731    731   PACKAGE_BUGREPORT=''
   732    732   PACKAGE_URL=''
   733    733   
   734    734   # Factoring default headers for most tests.
   735    735   ac_includes_default="\
   736    736   #include <stdio.h>
   737    737   #ifdef HAVE_SYS_TYPES_H
................................................................................
  1459   1459   #
  1460   1460   # Report the --help message.
  1461   1461   #
  1462   1462   if test "$ac_init_help" = "long"; then
  1463   1463     # Omit some internal or obsolete options to make the list less imposing.
  1464   1464     # This message is too long to be a string in the A/UX 3.1 sh.
  1465   1465     cat <<_ACEOF
  1466         -\`configure' configures sqlite 3.19.0 to adapt to many kinds of systems.
         1466  +\`configure' configures sqlite 3.19.3 to adapt to many kinds of systems.
  1467   1467   
  1468   1468   Usage: $0 [OPTION]... [VAR=VALUE]...
  1469   1469   
  1470   1470   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1471   1471   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1472   1472   
  1473   1473   Defaults for the options are specified in brackets.
................................................................................
  1524   1524     --build=BUILD     configure for building on BUILD [guessed]
  1525   1525     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1526   1526   _ACEOF
  1527   1527   fi
  1528   1528   
  1529   1529   if test -n "$ac_init_help"; then
  1530   1530     case $ac_init_help in
  1531         -     short | recursive ) echo "Configuration of sqlite 3.19.0:";;
         1531  +     short | recursive ) echo "Configuration of sqlite 3.19.3:";;
  1532   1532      esac
  1533   1533     cat <<\_ACEOF
  1534   1534   
  1535   1535   Optional Features:
  1536   1536     --disable-option-checking  ignore unrecognized --enable/--with options
  1537   1537     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1538   1538     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1648   1648       cd "$ac_pwd" || { ac_status=$?; break; }
  1649   1649     done
  1650   1650   fi
  1651   1651   
  1652   1652   test -n "$ac_init_help" && exit $ac_status
  1653   1653   if $ac_init_version; then
  1654   1654     cat <<\_ACEOF
  1655         -sqlite configure 3.19.0
         1655  +sqlite configure 3.19.3
  1656   1656   generated by GNU Autoconf 2.69
  1657   1657   
  1658   1658   Copyright (C) 2012 Free Software Foundation, Inc.
  1659   1659   This configure script is free software; the Free Software Foundation
  1660   1660   gives unlimited permission to copy, distribute and modify it.
  1661   1661   _ACEOF
  1662   1662     exit
................................................................................
  2067   2067     eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  2068   2068   
  2069   2069   } # ac_fn_c_check_header_mongrel
  2070   2070   cat >config.log <<_ACEOF
  2071   2071   This file contains any messages produced by compilers while
  2072   2072   running configure, to aid debugging if configure makes a mistake.
  2073   2073   
  2074         -It was created by sqlite $as_me 3.19.0, which was
         2074  +It was created by sqlite $as_me 3.19.3, which was
  2075   2075   generated by GNU Autoconf 2.69.  Invocation command line was
  2076   2076   
  2077   2077     $ $0 $@
  2078   2078   
  2079   2079   _ACEOF
  2080   2080   exec 5>>config.log
  2081   2081   {
................................................................................
 11352  11352   else
 11353  11353     enable_memsys5=no
 11354  11354   fi
 11355  11355   
 11356  11356   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5
 11357  11357   $as_echo_n "checking whether to support MEMSYS5... " >&6; }
 11358  11358   if test "${enable_memsys5}" = "yes"; then
 11359         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MEMSYS5"
        11359  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
 11360  11360     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 11361  11361   $as_echo "yes" >&6; }
 11362  11362   else
 11363  11363     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 11364  11364   $as_echo "no" >&6; }
 11365  11365   fi
 11366  11366   # Check whether --enable-memsys3 was given.
................................................................................
 11369  11369   else
 11370  11370     enable_memsys3=no
 11371  11371   fi
 11372  11372   
 11373  11373   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5
 11374  11374   $as_echo_n "checking whether to support MEMSYS3... " >&6; }
 11375  11375   if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
 11376         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MEMSYS3"
        11376  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
 11377  11377     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 11378  11378   $as_echo "yes" >&6; }
 11379  11379   else
 11380  11380     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 11381  11381   $as_echo "no" >&6; }
 11382  11382   fi
 11383  11383   
................................................................................
 11387  11387   if test "${enable_fts3+set}" = set; then :
 11388  11388     enableval=$enable_fts3; enable_fts3=yes
 11389  11389   else
 11390  11390     enable_fts3=no
 11391  11391   fi
 11392  11392   
 11393  11393   if test "${enable_fts3}" = "yes" ; then
 11394         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3"
        11394  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
 11395  11395   fi
 11396  11396   # Check whether --enable-fts4 was given.
 11397  11397   if test "${enable_fts4+set}" = set; then :
 11398  11398     enableval=$enable_fts4; enable_fts4=yes
 11399  11399   else
 11400  11400     enable_fts4=no
 11401  11401   fi
 11402  11402   
 11403  11403   if test "${enable_fts4}" = "yes" ; then
 11404         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4"
        11404  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
 11405  11405     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing log" >&5
 11406  11406   $as_echo_n "checking for library containing log... " >&6; }
 11407  11407   if ${ac_cv_search_log+:} false; then :
 11408  11408     $as_echo_n "(cached) " >&6
 11409  11409   else
 11410  11410     ac_func_search_save_LIBS=$LIBS
 11411  11411   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
................................................................................
 11463  11463   if test "${enable_fts5+set}" = set; then :
 11464  11464     enableval=$enable_fts5; enable_fts5=yes
 11465  11465   else
 11466  11466     enable_fts5=no
 11467  11467   fi
 11468  11468   
 11469  11469   if test "${enable_fts5}" = "yes" ; then
 11470         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS5"
        11470  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
 11471  11471     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing log" >&5
 11472  11472   $as_echo_n "checking for library containing log... " >&6; }
 11473  11473   if ${ac_cv_search_log+:} false; then :
 11474  11474     $as_echo_n "(cached) " >&6
 11475  11475   else
 11476  11476     ac_func_search_save_LIBS=$LIBS
 11477  11477   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
................................................................................
 11532  11532   if test "${enable_json1+set}" = set; then :
 11533  11533     enableval=$enable_json1; enable_json1=yes
 11534  11534   else
 11535  11535     enable_json1=no
 11536  11536   fi
 11537  11537   
 11538  11538   if test "${enable_json1}" = "yes" ; then
 11539         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_JSON1"
        11539  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
 11540  11540   fi
 11541  11541   
 11542  11542   #########
 11543  11543   # See whether we should enable RTREE
 11544  11544   # Check whether --enable-rtree was given.
 11545  11545   if test "${enable_rtree+set}" = set; then :
 11546  11546     enableval=$enable_rtree; enable_rtree=yes
 11547  11547   else
 11548  11548     enable_rtree=no
 11549  11549   fi
 11550  11550   
 11551  11551   if test "${enable_rtree}" = "yes" ; then
 11552         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE"
        11552  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
 11553  11553   fi
 11554  11554   
 11555  11555   #########
 11556  11556   # See whether we should enable the SESSION extension
 11557  11557   # Check whether --enable-session was given.
 11558  11558   if test "${enable_session+set}" = set; then :
 11559  11559     enableval=$enable_session; enable_session=yes
 11560  11560   else
 11561  11561     enable_session=no
 11562  11562   fi
 11563  11563   
 11564  11564   if test "${enable_session}" = "yes" ; then
 11565         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION"
 11566         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK"
        11565  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
        11566  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
 11567  11567   fi
 11568  11568   
 11569  11569   #########
 11570         -# attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter
        11570  +# attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
 11571  11571   for option in $CFLAGS $CPPFLAGS
 11572  11572   do
 11573  11573     case $option in
 11574  11574       -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
 11575  11575       -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
 11576  11576     esac
 11577  11577   done
................................................................................
 12147  12147   test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 12148  12148   
 12149  12149   cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 12150  12150   # Save the log message, to keep $0 and so on meaningful, and to
 12151  12151   # report actual input values of CONFIG_FILES etc. instead of their
 12152  12152   # values after options handling.
 12153  12153   ac_log="
 12154         -This file was extended by sqlite $as_me 3.19.0, which was
        12154  +This file was extended by sqlite $as_me 3.19.3, which was
 12155  12155   generated by GNU Autoconf 2.69.  Invocation command line was
 12156  12156   
 12157  12157     CONFIG_FILES    = $CONFIG_FILES
 12158  12158     CONFIG_HEADERS  = $CONFIG_HEADERS
 12159  12159     CONFIG_LINKS    = $CONFIG_LINKS
 12160  12160     CONFIG_COMMANDS = $CONFIG_COMMANDS
 12161  12161     $ $0 $@
................................................................................
 12213  12213   
 12214  12214   Report bugs to the package provider."
 12215  12215   
 12216  12216   _ACEOF
 12217  12217   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 12218  12218   ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 12219  12219   ac_cs_version="\\
 12220         -sqlite config.status 3.19.0
        12220  +sqlite config.status 3.19.3
 12221  12221   configured by $0, generated by GNU Autoconf 2.69,
 12222  12222     with options \\"\$ac_cs_config\\"
 12223  12223   
 12224  12224   Copyright (C) 2012 Free Software Foundation, Inc.
 12225  12225   This config.status script is free software; the Free Software Foundation
 12226  12226   gives unlimited permission to copy, distribute and modify it."
 12227  12227   

Changes to configure.ac.

   592    592   # Do we want to support memsys3 and/or memsys5
   593    593   #
   594    594   AC_ARG_ENABLE(memsys5, 
   595    595     AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),
   596    596     [enable_memsys5=yes],[enable_memsys5=no])
   597    597   AC_MSG_CHECKING([whether to support MEMSYS5])
   598    598   if test "${enable_memsys5}" = "yes"; then
   599         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MEMSYS5"
          599  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5"
   600    600     AC_MSG_RESULT([yes])
   601    601   else
   602    602     AC_MSG_RESULT([no])
   603    603   fi
   604    604   AC_ARG_ENABLE(memsys3, 
   605    605     AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),
   606    606     [enable_memsys3=yes],[enable_memsys3=no])
   607    607   AC_MSG_CHECKING([whether to support MEMSYS3])
   608    608   if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then
   609         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MEMSYS3"
          609  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3"
   610    610     AC_MSG_RESULT([yes])
   611    611   else
   612    612     AC_MSG_RESULT([no])
   613    613   fi
   614    614   
   615    615   #########
   616    616   # See whether we should enable Full Text Search extensions
   617    617   AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3],
   618    618         [Enable the FTS3 extension]),
   619    619         [enable_fts3=yes],[enable_fts3=no])
   620    620   if test "${enable_fts3}" = "yes" ; then
   621         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3"
          621  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3"
   622    622   fi
   623    623   AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4],
   624    624         [Enable the FTS4 extension]),
   625    625         [enable_fts4=yes],[enable_fts4=no])
   626    626   if test "${enable_fts4}" = "yes" ; then
   627         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4"
          627  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4"
   628    628     AC_SEARCH_LIBS([log],[m])
   629    629   fi
   630    630   AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5],
   631    631         [Enable the FTS5 extension]),
   632    632         [enable_fts5=yes],[enable_fts5=no])
   633    633   if test "${enable_fts5}" = "yes" ; then
   634         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS5"
          634  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5"
   635    635     AC_SEARCH_LIBS([log],[m])
   636    636   fi
   637    637   
   638    638   #########
   639    639   # See whether we should enable JSON1
   640    640   AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],
   641    641         [Enable the JSON1 extension]),
   642    642         [enable_json1=yes],[enable_json1=no])
   643    643   if test "${enable_json1}" = "yes" ; then
   644         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_JSON1"
          644  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
   645    645   fi
   646    646   
   647    647   #########
   648    648   # See whether we should enable RTREE
   649    649   AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree],
   650    650         [Enable the RTREE extension]),
   651    651         [enable_rtree=yes],[enable_rtree=no])
   652    652   if test "${enable_rtree}" = "yes" ; then
   653         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE"
          653  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE"
   654    654   fi
   655    655   
   656    656   #########
   657    657   # See whether we should enable the SESSION extension
   658    658   AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session],
   659    659         [Enable the SESSION extension]),
   660    660         [enable_session=yes],[enable_session=no])
   661    661   if test "${enable_session}" = "yes" ; then
   662         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION"
   663         -  OPT_FEATURE_FLAGS="$(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK"
          662  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION"
          663  +  OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK"
   664    664   fi
   665    665   
   666    666   #########
   667         -# attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter
          667  +# attempt to duplicate any OMITS and ENABLES into the ${OPT_FEATURE_FLAGS} parameter
   668    668   for option in $CFLAGS $CPPFLAGS
   669    669   do
   670    670     case $option in
   671    671       -DSQLITE_OMIT*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
   672    672       -DSQLITE_ENABLE*) OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS $option";;
   673    673     esac
   674    674   done

Changes to src/btree.c.

  8633   8633         goto end_insert;
  8634   8634       }
  8635   8635       oldCell = findCell(pPage, idx);
  8636   8636       if( !pPage->leaf ){
  8637   8637         memcpy(newCell, oldCell, 4);
  8638   8638       }
  8639   8639       rc = clearCell(pPage, oldCell, &info);
  8640         -    if( info.nSize==szNew && info.nLocal==info.nPayload ){
         8640  +    if( info.nSize==szNew && info.nLocal==info.nPayload 
         8641  +     && (!ISAUTOVACUUM || szNew<pPage->minLocal)
         8642  +    ){
  8641   8643         /* Overwrite the old cell with the new if they are the same size.
  8642   8644         ** We could also try to do this if the old cell is smaller, then add
  8643   8645         ** the leftover space to the free list.  But experiments show that
  8644   8646         ** doing that is no faster then skipping this optimization and just
  8645         -      ** calling dropCell() and insertCell(). */
         8647  +      ** calling dropCell() and insertCell(). 
         8648  +      **
         8649  +      ** This optimization cannot be used on an autovacuum database if the
         8650  +      ** new entry uses overflow pages, as the insertCell() call below is
         8651  +      ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry.  */
  8646   8652         assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
  8647   8653         if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
  8648   8654         memcpy(oldCell, newCell, szNew);
  8649   8655         return SQLITE_OK;
  8650   8656       }
  8651   8657       dropCell(pPage, idx, info.nSize, &rc);
  8652   8658       if( rc ) goto end_insert;

Changes to src/expr.c.

  1736   1736       case TK_AGG_COLUMN:
  1737   1737         testcase( pExpr->op==TK_ID );
  1738   1738         testcase( pExpr->op==TK_COLUMN );
  1739   1739         testcase( pExpr->op==TK_AGG_FUNCTION );
  1740   1740         testcase( pExpr->op==TK_AGG_COLUMN );
  1741   1741         if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
  1742   1742           return WRC_Continue;
  1743         -      }else{
  1744         -        pWalker->eCode = 0;
  1745         -        return WRC_Abort;
  1746   1743         }
         1744  +      /* Fall through */
         1745  +    case TK_IF_NULL_ROW:
         1746  +      testcase( pExpr->op==TK_IF_NULL_ROW );
         1747  +      pWalker->eCode = 0;
         1748  +      return WRC_Abort;
  1747   1749       case TK_VARIABLE:
  1748   1750         if( pWalker->eCode==5 ){
  1749   1751           /* Silently convert bound parameters that appear inside of CREATE
  1750   1752           ** statements into a NULL when parsing the CREATE statement text out
  1751   1753           ** of the sqlite_master table */
  1752   1754           pExpr->op = TK_NULL;
  1753   1755         }else if( pWalker->eCode==4 ){

Changes to src/main.c.

  3092   3092       void *pArg = sqlite3GlobalConfig.pSqllogArg;
  3093   3093       sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
  3094   3094     }
  3095   3095   #endif
  3096   3096   #if defined(SQLITE_HAS_CODEC)
  3097   3097     if( rc==SQLITE_OK ){
  3098   3098       const char *zKey;
  3099         -    if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){;
         3099  +    if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){
  3100   3100         u8 iByte;
  3101   3101         int i;
  3102   3102         char zDecoded[40];
  3103   3103         for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
  3104   3104           iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
  3105   3105           if( (i&1)!=0 ) zDecoded[i/2] = iByte;
  3106   3106         }

Changes to src/select.c.

  3210   3210             pNew->flags |= EP_FromJoin;
  3211   3211           }
  3212   3212           sqlite3ExprDelete(db, pExpr);
  3213   3213           pExpr = pNew;
  3214   3214         }
  3215   3215       }
  3216   3216     }else{
         3217  +    if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
         3218  +      pExpr->iTable = pSubst->iNewTable;
         3219  +    }
  3217   3220       pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
  3218   3221       pExpr->pRight = substExpr(pSubst, pExpr->pRight);
  3219   3222       if( ExprHasProperty(pExpr, EP_xIsSelect) ){
  3220   3223         substSelect(pSubst, pExpr->x.pSelect, 1);
  3221   3224       }else{
  3222   3225         substExprList(pSubst, pExpr->x.pList);
  3223   3226       }
................................................................................
  3294   3297   **
  3295   3298   **   (2)  The subquery is not an aggregate or (2a) the outer query is not a join
  3296   3299   **        and (2b) the outer query does not use subqueries other than the one
  3297   3300   **        FROM-clause subquery that is a candidate for flattening.  (2b is
  3298   3301   **        due to ticket [2f7170d73bf9abf80] from 2015-02-09.)
  3299   3302   **
  3300   3303   **   (3)  The subquery is not the right operand of a LEFT JOIN
  3301         -**        or the subquery is not itself a join.
         3304  +**        or the subquery is not itself a join and the outer query is not
         3305  +**        an aggregate.
  3302   3306   **
  3303   3307   **   (4)  The subquery is not DISTINCT.
  3304   3308   **
  3305   3309   **  (**)  At one point restrictions (4) and (5) defined a subset of DISTINCT
  3306   3310   **        sub-queries that were excluded from this optimization. Restriction 
  3307   3311   **        (4) has since been expanded to exclude all DISTINCT subqueries.
  3308   3312   **
................................................................................
  3489   3493     **         t1 LEFT OUTER JOIN (t2 JOIN t3)
  3490   3494     **
  3491   3495     ** If we flatten the above, we would get
  3492   3496     **
  3493   3497     **         (t1 LEFT OUTER JOIN t2) JOIN t3
  3494   3498     **
  3495   3499     ** which is not at all the same thing.
         3500  +  **
         3501  +  ** If the subquery is the right operand of a LEFT JOIN, then the outer
         3502  +  ** query cannot be an aggregate.  This is an artifact of the way aggregates
         3503  +  ** are processed - there is not mechanism to determine if the LEFT JOIN
         3504  +  ** table should be all-NULL.
  3496   3505     **
  3497   3506     ** See also tickets #306, #350, and #3300.
  3498   3507     */
  3499   3508     if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
  3500   3509       isLeftJoin = 1;
  3501         -    if( pSubSrc->nSrc>1 ){
         3510  +    if( pSubSrc->nSrc>1 || isAgg ){
  3502   3511         return 0; /* Restriction (3) */
  3503   3512       }
  3504   3513     }
         3514  +#ifdef SQLITE_EXTRA_IFNULLROW
         3515  +  else if( iFrom>0 && !isAgg ){
         3516  +    /* Setting isLeftJoin to -1 causes OP_IfNullRow opcodes to be generated for
         3517  +    ** every reference to any result column from subquery in a join, even though
         3518  +    ** they are not necessary.  This will stress-test the OP_IfNullRow opcode. */
         3519  +    isLeftJoin = -1;
         3520  +  }
         3521  +#endif
  3505   3522   
  3506   3523     /* Restriction 17: If the sub-query is a compound SELECT, then it must
  3507   3524     ** use only the UNION ALL operator. And none of the simple select queries
  3508   3525     ** that make up the compound SELECT are allowed to be aggregate or distinct
  3509   3526     ** queries.
  3510   3527     */
  3511   3528     if( pSub->pPrior ){
................................................................................
  3751   3768         }
  3752   3769         assert( pParent->pOrderBy==0 );
  3753   3770         assert( pSub->pPrior==0 );
  3754   3771         pParent->pOrderBy = pOrderBy;
  3755   3772         pSub->pOrderBy = 0;
  3756   3773       }
  3757   3774       pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);
  3758         -    if( isLeftJoin ){
         3775  +    if( isLeftJoin>0 ){
  3759   3776         setJoinExpr(pWhere, iNewParent);
  3760   3777       }
  3761   3778       if( subqueryIsAgg ){
  3762   3779         assert( pParent->pHaving==0 );
  3763   3780         pParent->pHaving = pParent->pWhere;
  3764   3781         pParent->pWhere = pWhere;
  3765   3782         pParent->pHaving = sqlite3ExprAnd(db, 

Changes to src/vdbe.c.

  2437   2437   ** Check the cursor P1 to see if it is currently pointing at a NULL row.
  2438   2438   ** If it is, then set register P3 to NULL and jump immediately to P2.
  2439   2439   ** If P1 is not on a NULL row, then fall through without making any
  2440   2440   ** changes.
  2441   2441   */
  2442   2442   case OP_IfNullRow: {         /* jump */
  2443   2443     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
         2444  +  assert( p->apCsr[pOp->p1]!=0 );
  2444   2445     if( p->apCsr[pOp->p1]->nullRow ){
  2445   2446       sqlite3VdbeMemSetNull(aMem + pOp->p3);
  2446   2447       goto jump_to_p2;
  2447   2448     }
  2448   2449     break;
  2449   2450   }
  2450   2451   

Changes to src/whereexpr.c.

  1371   1371   ** a bitmask indicating which tables are used in that expression
  1372   1372   ** tree.
  1373   1373   */
  1374   1374   Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
  1375   1375     Bitmask mask;
  1376   1376     if( p==0 ) return 0;
  1377   1377     if( p->op==TK_COLUMN ){
  1378         -    mask = sqlite3WhereGetMask(pMaskSet, p->iTable);
  1379         -    return mask;
         1378  +    return sqlite3WhereGetMask(pMaskSet, p->iTable);
  1380   1379     }
         1380  +  mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
  1381   1381     assert( !ExprHasProperty(p, EP_TokenOnly) );
  1382         -  mask = p->pRight ? sqlite3WhereExprUsage(pMaskSet, p->pRight) : 0;
         1382  +  if( p->pRight ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
  1383   1383     if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
  1384   1384     if( ExprHasProperty(p, EP_xIsSelect) ){
  1385   1385       mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
  1386   1386     }else if( p->x.pList ){
  1387   1387       mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
  1388   1388     }
  1389   1389     return mask;

Changes to test/autovacuum.test.

   701    701     execsql { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }
   702    702   } {}
   703    703   do_test autovacuum-9.5 {
   704    704     execsql { DELETE FROM t1 WHERE rowid > (SELECT max(a)/2 FROM t1) }
   705    705     file size test.db
   706    706   } $::sqlite_pending_byte
   707    707    
          708  +do_execsql_test autovacuum-10.1 {
          709  +  DROP TABLE t1;
          710  +  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
          711  +  INSERT INTO t1 VALUES(25, randomblob(104));
          712  +  REPLACE INTO t1 VALUES(25, randomblob(1117));
          713  +  PRAGMA integrity_check;
          714  +} {ok}
   708    715   
   709    716   finish_test

Changes to test/join.test.

     1         -# 2002 May 24
            1  +# 2002-05-24
     2      2   #
     3      3   # The author disclaims copyright to this source code.  In place of
     4      4   # a legal notice, here is a blessing:
     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for joins, including outer joins.
    14     14   #
    15         -# $Id: join.test,v 1.27 2009/07/01 16:12:08 danielk1977 Exp $
    16     15   
    17     16   set testdir [file dirname $argv0]
    18     17   source $testdir/tester.tcl
    19     18   
    20     19   do_test join-1.1 {
    21     20     execsql {
    22     21       CREATE TABLE t1(a,b,c);
................................................................................
   708    707   # In the following, the order of [cc] and [bb] must not be exchanged, even
   709    708   # though this would be helpful if the query used an inner join.
   710    709   do_execsql_test join-13.2 {
   711    710     CREATE INDEX ccc ON cc(c);
   712    711     SELECT * FROM aa LEFT JOIN bb, cc WHERE cc.c=aa.a;
   713    712   } {45 {} 45 45 {} 45}
   714    713   
          714  +# Verify that that iTable attributes the TK_IF_NULL_ROW operators in the
          715  +# expression tree are correctly updated by the query flattener.  This was
          716  +# a bug discovered on 2017-05-22 by Mark Brand.
          717  +#
          718  +do_execsql_test join-14.1 {
          719  +  SELECT *
          720  +    FROM (SELECT 1 a) AS x 
          721  +         LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT 1)));
          722  +} {1 1 1}
          723  +do_execsql_test join-14.2 {
          724  +  SELECT *
          725  +  FROM (SELECT 1 a) AS x
          726  +    LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT * FROM (SELECT 1)))) AS y
          727  +    JOIN (SELECT * FROM (SELECT 9)) AS z;
          728  +} {1 1 1 9}
          729  +do_execsql_test join-14.3 {
          730  +  SELECT *
          731  +  FROM (SELECT 111)
          732  +  LEFT JOIN (SELECT cc+222, * FROM (SELECT * FROM (SELECT 333 cc)));
          733  +} {111 555 333}
          734  +
          735  +do_execsql_test join-14.4 {
          736  +  DROP TABLE IF EXISTS t1;
          737  +  CREATE TABLE t1(c PRIMARY KEY, a TEXT(10000), b TEXT(10000));
          738  +  SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;
          739  +} {111 {}}
          740  +do_execsql_test join-14.5 {
          741  +  DROP TABLE IF EXISTS t1;
          742  +  CREATE TABLE t1(c PRIMARY KEY) WITHOUT ROWID;
          743  +  SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;
          744  +} {111 {}}
          745  +
          746  +# Verify the fix to ticket 
          747  +# https://www.sqlite.org/src/tktview/7fde638e94287d2c948cd9389
          748  +#
          749  +db close
          750  +sqlite3 db :memory:
          751  +do_execsql_test join-14.10 {
          752  +  CREATE TABLE t1(a);
          753  +  INSERT INTO t1 VALUES(1),(2),(3);
          754  +  CREATE VIEW v2 AS SELECT a, 1 AS b FROM t1;
          755  +  CREATE TABLE t3(x);
          756  +  INSERT INTO t3 VALUES(2),(4);
          757  +  SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b=1;
          758  +} {2 2 1 |}
          759  +do_execsql_test join-14.11 {
          760  +  SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b+1=x;
          761  +} {2 2 1 |}
          762  +do_execsql_test join-14.12 {
          763  +  SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x ORDER BY b;
          764  +} {4 {} {} | 2 2 1 |}
   715    765   
   716    766   finish_test

Changes to test/releasetest.tcl.

  1032   1032              && $target!="fuzzoomtest" && !$::BUILDONLY && $::QUICK<2} {
  1033   1033         set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
  1034   1034         set xtarget $target
  1035   1035         regsub -all {fulltest[a-z]*} $xtarget test xtarget
  1036   1036         regsub -all {fuzzoomtest} $xtarget fuzztest xtarget
  1037   1037         if {$debug_idx < 0} {
  1038   1038           incr NTEST
  1039         -        append config_options " -DSQLITE_DEBUG=1"
         1039  +        append config_options " -DSQLITE_DEBUG=1 -DSQLITE_EXTRA_IFNULLROW=1"
  1040   1040           add_test_suite all "${zConfig}_debug" $xtarget $config_options
  1041   1041         } else {
  1042   1042           incr NTEST
  1043   1043           regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
  1044   1044           regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
  1045   1045           add_test_suite all "${zConfig}_ndebug" $xtarget $config_options
  1046   1046         }