/ Check-in [bf20d4ff]
Login

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

Overview
Comment:Merge the latest enhancements and fixes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal2
Files: files | file ages | folders
SHA3-256:bf20d4ffcb7b27b519502e2986cd0eb1d34d5fd273752fb27de9cdab75772acd
User & Date: drh 2019-03-08 15:57:31
Wiki:wal2
Context
2019-03-26
12:22
Merge enhancements from trunk. check-in: a0e2e902 user: drh tags: wal2
2019-03-08
16:06
Merge the latest enhancements and fixes from trunk. check-in: 543ecb30 user: drh tags: begin-concurrent-pnu-wal2
15:57
Merge the latest enhancements and fixes from trunk. check-in: bf20d4ff user: drh tags: wal2
15:39
Add the bgckpt.c extension to Makefile.in and Makefile.msc. check-in: 3712d625 user: drh tags: wal2
14:07
Add new test cases in test/fuzzdata8.db check-in: 97bdc090 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   449    449     $(TOP)/ext/fts5/fts5_test_mi.c \
   450    450     $(TOP)/ext/fts5/fts5_test_tok.c \
   451    451     $(TOP)/ext/misc/ieee754.c \
   452    452     $(TOP)/ext/misc/mmapwarm.c \
   453    453     $(TOP)/ext/misc/nextchar.c \
   454    454     $(TOP)/ext/misc/normalize.c \
   455    455     $(TOP)/ext/misc/percentile.c \
          456  +  $(TOP)/ext/misc/prefixes.c \
   456    457     $(TOP)/ext/misc/regexp.c \
   457    458     $(TOP)/ext/misc/remember.c \
   458    459     $(TOP)/ext/misc/series.c \
   459    460     $(TOP)/ext/misc/spellfix.c \
   460    461     $(TOP)/ext/misc/totype.c \
   461    462     $(TOP)/ext/misc/unionvtab.c \
   462    463     $(TOP)/ext/misc/wholenumber.c \
................................................................................
   585    586   FUZZDATA = \
   586    587     $(TOP)/test/fuzzdata1.db \
   587    588     $(TOP)/test/fuzzdata2.db \
   588    589     $(TOP)/test/fuzzdata3.db \
   589    590     $(TOP)/test/fuzzdata4.db \
   590    591     $(TOP)/test/fuzzdata5.db \
   591    592     $(TOP)/test/fuzzdata6.db \
   592         -  $(TOP)/test/fuzzdata7.db
          593  +  $(TOP)/test/fuzzdata7.db \
          594  +  $(TOP)/test/fuzzdata8.db
   593    595   
   594    596   # Standard options to testfixture
   595    597   #
   596    598   TESTOPTS = --verbose=file --output=test-out.txt
   597    599   
   598    600   # Extra compiler options for various shell tools
   599    601   #
................................................................................
   608    610   SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
   609    611   SHELL_OPT += -DSQLITE_ENABLE_DESERIALIZE
   610    612   SHELL_OPT += -DSQLITE_INTROSPECTION_PRAGMAS
   611    613   FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
   612    614   FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
   613    615   FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
   614    616   FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
          617  +FUZZCHECK_OPT += -DSQLITE_ENABLE_DESERIALIZE
          618  +FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
          619  +#FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS5
          620  +FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
          621  +FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
          622  +FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
   615    623   FUZZCHECK_SRC = $(TOP)/test/fuzzcheck.c $(TOP)/test/ossfuzz.c
   616    624   DBFUZZ_OPT =
   617    625   
   618    626   # This is the default Makefile target.  The objects listed here
   619    627   # are what get build when you type just "make" with no arguments.
   620    628   #
   621    629   all:	sqlite3.h libsqlite3.la sqlite3$(TEXE) $(HAVE_TCL:1=libtclsqlite3.la)
................................................................................
   679    687     -DSQLITE_THREADSAFE=0 \
   680    688     -DSQLITE_OMIT_LOAD_EXTENSION \
   681    689     -DSQLITE_ENABLE_DESERIALIZE \
   682    690     -DSQLITE_DEBUG \
   683    691     -DSQLITE_ENABLE_DBSTAT_VTAB \
   684    692     -DSQLITE_ENABLE_RTREE \
   685    693     -DSQLITE_ENABLE_FTS4 \
   686         -  -DSQLITE_EANBLE_FTS5
          694  +  -DSQLITE_ENABLE_FTS5
   687    695   
   688         -dbfuzz2:	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
          696  +dbfuzz2$(TEXE):	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
          697  +	$(CC) $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
          698  +		-DSTANDALONE -o dbfuzz2 \
          699  +		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
          700  +	mkdir -p dbfuzz2-dir
          701  +	cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
          702  +
          703  +dbfuzz2-asan:	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
          704  +	clang-6.0 $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
          705  +		-fsanitize=fuzzer,undefined,address -o dbfuzz2-asan \
          706  +		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
          707  +	mkdir -p dbfuzz2-dir
          708  +	cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
          709  +
          710  +dbfuzz2-msan:	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
   689    711   	clang-6.0 $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
   690         -		-fsanitize=fuzzer,undefined,address -o dbfuzz2 \
   691         -		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c
          712  +		-fsanitize=fuzzer,undefined,memory -o dbfuzz2-msan \
          713  +		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
   692    714   	mkdir -p dbfuzz2-dir
   693    715   	cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
   694    716   
   695    717   mptester$(TEXE):	sqlite3.lo $(TOP)/mptest/mptest.c
   696    718   	$(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.lo \
   697    719   		$(TLIBS) -rpath "$(libdir)"
   698    720   
................................................................................
  1050   1072   	$(TOP)/ext/misc/shathree.c \
  1051   1073   	$(TOP)/ext/misc/fileio.c \
  1052   1074   	$(TOP)/ext/misc/completion.c \
  1053   1075   	$(TOP)/ext/misc/sqlar.c \
  1054   1076   	$(TOP)/ext/expert/sqlite3expert.c \
  1055   1077   	$(TOP)/ext/expert/sqlite3expert.h \
  1056   1078   	$(TOP)/ext/misc/zipfile.c \
         1079  +	$(TOP)/ext/misc/memtrace.c \
  1057   1080           $(TOP)/src/test_windirent.c
  1058   1081   
  1059   1082   shell.c:	$(SHELL_SRC) $(TOP)/tool/mkshellc.tcl
  1060   1083   	$(TCLSH_CMD) $(TOP)/tool/mkshellc.tcl >shell.c
  1061   1084   
  1062   1085   
  1063   1086   
................................................................................
  1309   1332   showwal$(TEXE):	$(TOP)/tool/showwal.c sqlite3.lo
  1310   1333   	$(LTLINK) -o $@ $(TOP)/tool/showwal.c sqlite3.lo $(TLIBS)
  1311   1334   
  1312   1335   showshm$(TEXE):	$(TOP)/tool/showshm.c
  1313   1336   	$(LTLINK) -o $@ $(TOP)/tool/showshm.c
  1314   1337   
  1315   1338   index_usage$(TEXE): $(TOP)/tool/index_usage.c sqlite3.lo
  1316         -	$(LTLINK) -o $@ $(TOP)/tool/index_usage.c sqlite3.lo $(TLIBS)
         1339  +	$(LTLINK) $(SHELL_OPT) -o $@ $(TOP)/tool/index_usage.c sqlite3.lo $(TLIBS)
  1317   1340   
  1318   1341   changeset$(TEXE):	$(TOP)/ext/session/changeset.c sqlite3.lo
  1319   1342   	$(LTLINK) -o $@ $(TOP)/ext/session/changeset.c sqlite3.lo $(TLIBS)
  1320   1343   
  1321   1344   changesetfuzz$(TEXE):	$(TOP)/ext/session/changesetfuzz.c sqlite3.lo
  1322   1345   	$(LTLINK) -o $@ $(TOP)/ext/session/changesetfuzz.c sqlite3.lo $(TLIBS)
  1323   1346   
................................................................................
  1398   1421   	$(INSTALL) -d $(DESTDIR)$(includedir)
  1399   1422   	$(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(includedir)
  1400   1423   	$(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(includedir)
  1401   1424   	$(INSTALL) -d $(DESTDIR)$(pkgconfigdir)
  1402   1425   	$(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir)
  1403   1426   
  1404   1427   pkgIndex.tcl:
  1405         -	echo 'package ifneeded sqlite3 $(RELEASE) [list load $(TCLLIBDIR)/libtclsqlite3$(SHLIB_SUFFIX) sqlite3]' > $@
         1428  +	echo 'package ifneeded sqlite3 $(RELEASE) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] sqlite3]' > $@
  1406   1429   tcl_install:	lib_install libtclsqlite3.la pkgIndex.tcl
  1407   1430   	$(INSTALL) -d $(DESTDIR)$(TCLLIBDIR)
  1408   1431   	$(LTINSTALL) libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)
  1409   1432   	rm -f $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.a
  1410   1433   	$(INSTALL) -m 0644 pkgIndex.tcl $(DESTDIR)$(TCLLIBDIR)
  1411   1434   
  1412   1435   clean:

Changes to Makefile.msc.

  1524   1524     $(TOP)\ext\fts5\fts5_test_mi.c \
  1525   1525     $(TOP)\ext\fts5\fts5_test_tok.c \
  1526   1526     $(TOP)\ext\misc\ieee754.c \
  1527   1527     $(TOP)\ext\misc\mmapwarm.c \
  1528   1528     $(TOP)\ext\misc\nextchar.c \
  1529   1529     $(TOP)\ext\misc\normalize.c \
  1530   1530     $(TOP)\ext\misc\percentile.c \
         1531  +  $(TOP)\ext\misc\prefixes.c \
  1531   1532     $(TOP)\ext\misc\regexp.c \
  1532   1533     $(TOP)\ext\misc\remember.c \
  1533   1534     $(TOP)\ext\misc\series.c \
  1534   1535     $(TOP)\ext\misc\spellfix.c \
  1535   1536     $(TOP)\ext\misc\totype.c \
  1536   1537     $(TOP)\ext\misc\unionvtab.c \
  1537   1538     $(TOP)\ext\misc\wholenumber.c
................................................................................
  1622   1623   FUZZDATA = \
  1623   1624     $(TOP)\test\fuzzdata1.db \
  1624   1625     $(TOP)\test\fuzzdata2.db \
  1625   1626     $(TOP)\test\fuzzdata3.db \
  1626   1627     $(TOP)\test\fuzzdata4.db \
  1627   1628     $(TOP)\test\fuzzdata5.db \
  1628   1629     $(TOP)\test\fuzzdata6.db \
  1629         -  $(TOP)\test\fuzzdata7.db
         1630  +  $(TOP)\test\fuzzdata7.db \
         1631  +  $(TOP)\test\fuzzdata8.db
  1630   1632   # <</mark>>
  1631   1633   
  1632   1634   # Additional compiler options for the shell.  These are only effective
  1633   1635   # when the shell is not being dynamically linked.
  1634   1636   #
  1635   1637   !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
  1636   1638   SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
................................................................................
  1640   1642   !ENDIF
  1641   1643   
  1642   1644   # <<mark>>
  1643   1645   # Extra compiler options for various test tools.
  1644   1646   #
  1645   1647   MPTESTER_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
  1646   1648   FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1
  1647         -FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ -DSQLITE_MAX_MEMORY=50000000 -DSQLITE_PRINTF_PRECISION_LIMIT=1000
         1649  +FUZZCHECK_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ -DSQLITE_MAX_MEMORY=50000000 -DSQLITE_PRINTF_PRECISION_LIMIT=1000
         1650  +FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_DESERIALIZE
         1651  +FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_FTS4
         1652  +FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_RTREE
         1653  +FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_GEOPOLY
         1654  +FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_DBSTAT_VTAB
         1655  +
  1648   1656   FUZZCHECK_SRC = $(TOP)\test\fuzzcheck.c $(TOP)\test\ossfuzz.c
  1649   1657   OSSSHELL_SRC = $(TOP)\test\ossshell.c $(TOP)\test\ossfuzz.c
  1650   1658   DBFUZZ_COMPILE_OPTS = -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION
  1651   1659   KV_COMPILE_OPTS = -DSQLITE_THREADSAFE=0 -DSQLITE_DIRECT_OVERFLOW_READ
  1652   1660   ST_COMPILE_OPTS = -DSQLITE_THREADSAFE=0
  1653   1661   
  1654   1662   # Standard options to testfixture.
................................................................................
  1727   1735   fuzzershell.exe:	$(TOP)\tool\fuzzershell.c $(SQLITE3C) $(SQLITE3H)
  1728   1736   	$(LTLINK) $(NO_WARN) $(FUZZERSHELL_COMPILE_OPTS) $(TOP)\tool\fuzzershell.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  1729   1737   
  1730   1738   dbfuzz.exe:	$(TOP)\test\dbfuzz.c $(SQLITE3C) $(SQLITE3H)
  1731   1739   	$(LTLINK) $(NO_WARN) $(DBFUZZ_COMPILE_OPTS) $(TOP)\test\dbfuzz.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  1732   1740   
  1733   1741   fuzzcheck.exe:	$(FUZZCHECK_SRC) $(SQLITE3C) $(SQLITE3H)
  1734         -	$(LTLINK) $(NO_WARN) $(FUZZCHECK_COMPILE_OPTS) $(FUZZCHECK_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
         1742  +	$(LTLINK) $(NO_WARN) $(FUZZCHECK_OPTS) $(FUZZCHECK_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  1735   1743   
  1736   1744   ossshell.exe:	$(OSSSHELL_SRC) $(SQLITE3C) $(SQLITE3H)
  1737         -	$(LTLINK) $(NO_WARN) $(FUZZCHECK_COMPILE_OPTS) $(OSSSHELL_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
         1745  +	$(LTLINK) $(NO_WARN) $(FUZZCHECK_OPTS) $(OSSSHELL_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  1738   1746   
  1739   1747   sessionfuzz.exe:	zlib $(TOP)\test\sessionfuzz.c $(SQLITE3C) $(SQLITE3H)
  1740   1748   	$(LTLINK) $(NO_WARN) -I$(ZLIBINCDIR) $(TOP)\test\sessionfuzz.c /link $(LDFLAGS) $(LTLINKOPTS) /LIBPATH:$(ZLIBLIBDIR) $(ZLIBLIB)
  1741   1749   
  1742   1750   mptester.exe:	$(TOP)\mptest\mptest.c $(SQLITE3C) $(SQLITE3H)
  1743   1751   	$(LTLINK) $(NO_WARN) $(MPTESTER_COMPILE_OPTS) $(TOP)\mptest\mptest.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  1744   1752   
................................................................................
  2127   2135   	$(TOP)\src\shell.c.in \
  2128   2136   	$(TOP)\ext\misc\appendvfs.c \
  2129   2137   	$(TOP)\ext\misc\shathree.c \
  2130   2138   	$(TOP)\ext\misc\fileio.c \
  2131   2139   	$(TOP)\ext\misc\completion.c \
  2132   2140   	$(TOP)\ext\expert\sqlite3expert.c \
  2133   2141   	$(TOP)\ext\expert\sqlite3expert.h \
         2142  +	$(TOP)\ext\misc\memtrace.c \
  2134   2143   	$(TOP)\src\test_windirent.c
  2135   2144   
  2136   2145   # If use of zlib is enabled, add the "zipfile.c" source file.
  2137   2146   #
  2138   2147   !IF $(USE_ZLIB)!=0
  2139   2148   SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\sqlar.c
  2140   2149   SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\zipfile.c

Changes to VERSION.

     1         -3.27.0
            1  +3.28.0

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.27.0.
            3  +# Generated by GNU Autoconf 2.69 for sqlite 3.28.0.
     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.27.0'
   730         -PACKAGE_STRING='sqlite 3.27.0'
          729  +PACKAGE_VERSION='3.28.0'
          730  +PACKAGE_STRING='sqlite 3.28.0'
   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
................................................................................
  1462   1462   #
  1463   1463   # Report the --help message.
  1464   1464   #
  1465   1465   if test "$ac_init_help" = "long"; then
  1466   1466     # Omit some internal or obsolete options to make the list less imposing.
  1467   1467     # This message is too long to be a string in the A/UX 3.1 sh.
  1468   1468     cat <<_ACEOF
  1469         -\`configure' configures sqlite 3.27.0 to adapt to many kinds of systems.
         1469  +\`configure' configures sqlite 3.28.0 to adapt to many kinds of systems.
  1470   1470   
  1471   1471   Usage: $0 [OPTION]... [VAR=VALUE]...
  1472   1472   
  1473   1473   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1474   1474   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1475   1475   
  1476   1476   Defaults for the options are specified in brackets.
................................................................................
  1527   1527     --build=BUILD     configure for building on BUILD [guessed]
  1528   1528     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1529   1529   _ACEOF
  1530   1530   fi
  1531   1531   
  1532   1532   if test -n "$ac_init_help"; then
  1533   1533     case $ac_init_help in
  1534         -     short | recursive ) echo "Configuration of sqlite 3.27.0:";;
         1534  +     short | recursive ) echo "Configuration of sqlite 3.28.0:";;
  1535   1535      esac
  1536   1536     cat <<\_ACEOF
  1537   1537   
  1538   1538   Optional Features:
  1539   1539     --disable-option-checking  ignore unrecognized --enable/--with options
  1540   1540     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1541   1541     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1653   1653       cd "$ac_pwd" || { ac_status=$?; break; }
  1654   1654     done
  1655   1655   fi
  1656   1656   
  1657   1657   test -n "$ac_init_help" && exit $ac_status
  1658   1658   if $ac_init_version; then
  1659   1659     cat <<\_ACEOF
  1660         -sqlite configure 3.27.0
         1660  +sqlite configure 3.28.0
  1661   1661   generated by GNU Autoconf 2.69
  1662   1662   
  1663   1663   Copyright (C) 2012 Free Software Foundation, Inc.
  1664   1664   This configure script is free software; the Free Software Foundation
  1665   1665   gives unlimited permission to copy, distribute and modify it.
  1666   1666   _ACEOF
  1667   1667     exit
................................................................................
  2072   2072     eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  2073   2073   
  2074   2074   } # ac_fn_c_check_header_mongrel
  2075   2075   cat >config.log <<_ACEOF
  2076   2076   This file contains any messages produced by compilers while
  2077   2077   running configure, to aid debugging if configure makes a mistake.
  2078   2078   
  2079         -It was created by sqlite $as_me 3.27.0, which was
         2079  +It was created by sqlite $as_me 3.28.0, which was
  2080   2080   generated by GNU Autoconf 2.69.  Invocation command line was
  2081   2081   
  2082   2082     $ $0 $@
  2083   2083   
  2084   2084   _ACEOF
  2085   2085   exec 5>>config.log
  2086   2086   {
................................................................................
 12228  12228   test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 12229  12229   
 12230  12230   cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 12231  12231   # Save the log message, to keep $0 and so on meaningful, and to
 12232  12232   # report actual input values of CONFIG_FILES etc. instead of their
 12233  12233   # values after options handling.
 12234  12234   ac_log="
 12235         -This file was extended by sqlite $as_me 3.27.0, which was
        12235  +This file was extended by sqlite $as_me 3.28.0, which was
 12236  12236   generated by GNU Autoconf 2.69.  Invocation command line was
 12237  12237   
 12238  12238     CONFIG_FILES    = $CONFIG_FILES
 12239  12239     CONFIG_HEADERS  = $CONFIG_HEADERS
 12240  12240     CONFIG_LINKS    = $CONFIG_LINKS
 12241  12241     CONFIG_COMMANDS = $CONFIG_COMMANDS
 12242  12242     $ $0 $@
................................................................................
 12294  12294   
 12295  12295   Report bugs to the package provider."
 12296  12296   
 12297  12297   _ACEOF
 12298  12298   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 12299  12299   ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 12300  12300   ac_cs_version="\\
 12301         -sqlite config.status 3.27.0
        12301  +sqlite config.status 3.28.0
 12302  12302   configured by $0, generated by GNU Autoconf 2.69,
 12303  12303     with options \\"\$ac_cs_config\\"
 12304  12304   
 12305  12305   Copyright (C) 2012 Free Software Foundation, Inc.
 12306  12306   This config.status script is free software; the Free Software Foundation
 12307  12307   gives unlimited permission to copy, distribute and modify it."
 12308  12308   

Changes to ext/fts3/README.tokenizers.

    48     48     returned. If only one argument is passed, a pointer to the tokenizer
    49     49     implementation currently registered as <tokenizer-name> is returned,
    50     50     encoded as a blob. Or, if no such tokenizer exists, an SQL exception
    51     51     (error) is raised.
    52     52   
    53     53     SECURITY: If the fts3 extension is used in an environment where potentially
    54     54       malicious users may execute arbitrary SQL (i.e. gears), they should be
    55         -    prevented from invoking the fts3_tokenizer() function, possibly using the
    56         -    authorisation callback.
           55  +    prevented from invoking the fts3_tokenizer() function.  The
           56  +    fts3_tokenizer() function is disabled by default. It is only enabled
           57  +    by SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER. Do not enable it in
           58  +    security sensitive environments.
    57     59   
    58     60     See "Sample code" below for an example of calling the fts3_tokenizer()
    59     61     function from C code.
    60     62   
    61     63   3. ICU Library Tokenizers
    62     64   
    63     65     If this extension is compiled with the SQLITE_ENABLE_ICU pre-processor 

Changes to ext/fts3/fts3.c.

   316    316   #ifndef SQLITE_AMALGAMATION
   317    317   # if defined(SQLITE_DEBUG)
   318    318   int sqlite3Fts3Always(int b) { assert( b ); return b; }
   319    319   int sqlite3Fts3Never(int b)  { assert( !b ); return b; }
   320    320   # endif
   321    321   #endif
   322    322   
          323  +/*
          324  +** This variable is set to false when running tests for which the on disk
          325  +** structures should not be corrupt. Otherwise, true. If it is false, extra
          326  +** assert() conditions in the fts3 code are activated - conditions that are
          327  +** only true if it is guaranteed that the fts3 database is not corrupt.
          328  +*/
          329  +int sqlite3_fts3_may_be_corrupt = 1;
          330  +
   323    331   /* 
   324    332   ** Write a 64-bit variable-length integer to memory starting at p[0].
   325    333   ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
   326    334   ** The number of bytes written is returned.
   327    335   */
   328    336   int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){
   329    337     unsigned char *q = (unsigned char *) p;
................................................................................
   334    342     }while( vu!=0 );
   335    343     q[-1] &= 0x7f;  /* turn off high bit in final byte */
   336    344     assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );
   337    345     return (int) (q - (unsigned char *)p);
   338    346   }
   339    347   
   340    348   #define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \
   341         -  v = (v & mask1) | ( (*(ptr++)) << shift );  \
          349  +  v = (v & mask1) | ( (*(const unsigned char*)(ptr++)) << shift );  \
   342    350     if( (v & mask2)==0 ){ var = v; return ret; }
   343    351   #define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
   344    352     v = (*ptr++);                                               \
   345    353     if( (v & mask2)==0 ){ var = v; return ret; }
   346    354   
   347    355   /* 
   348    356   ** Read a 64-bit variable-length integer from memory starting at p[0].
................................................................................
   557    565   static int fts3DestroyMethod(sqlite3_vtab *pVtab){
   558    566     Fts3Table *p = (Fts3Table *)pVtab;
   559    567     int rc = SQLITE_OK;              /* Return code */
   560    568     const char *zDb = p->zDb;        /* Name of database (e.g. "main", "temp") */
   561    569     sqlite3 *db = p->db;             /* Database handle */
   562    570   
   563    571     /* Drop the shadow tables */
   564         -  if( p->zContentTbl==0 ){
   565         -    fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
   566         -  }
   567         -  fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
   568         -  fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
   569         -  fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
   570         -  fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
          572  +  fts3DbExec(&rc, db, 
          573  +    "DROP TABLE IF EXISTS %Q.'%q_segments';"
          574  +    "DROP TABLE IF EXISTS %Q.'%q_segdir';"
          575  +    "DROP TABLE IF EXISTS %Q.'%q_docsize';"
          576  +    "DROP TABLE IF EXISTS %Q.'%q_stat';"
          577  +    "%s DROP TABLE IF EXISTS %Q.'%q_content';",
          578  +    zDb, p->zName,
          579  +    zDb, p->zName,
          580  +    zDb, p->zName,
          581  +    zDb, p->zName,
          582  +    (p->zContentTbl ? "--" : ""), zDb,p->zName
          583  +  );
   571    584   
   572    585     /* If everything has worked, invoke fts3DisconnectMethod() to free the
   573    586     ** memory associated with the Fts3Table structure and return SQLITE_OK.
   574    587     ** Otherwise, return an SQLite error code.
   575    588     */
   576    589     return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);
   577    590   }
................................................................................
   795    808   **     fts3QuoteId("un \"zip\"")   ->    "un \"\"zip\"\""
   796    809   **
   797    810   ** The pointer returned points to memory obtained from sqlite3_malloc(). It
   798    811   ** is the callers responsibility to call sqlite3_free() to release this
   799    812   ** memory.
   800    813   */
   801    814   static char *fts3QuoteId(char const *zInput){
   802         -  int nRet;
          815  +  sqlite3_int64 nRet;
   803    816     char *zRet;
   804    817     nRet = 2 + (int)strlen(zInput)*2 + 1;
   805         -  zRet = sqlite3_malloc(nRet);
          818  +  zRet = sqlite3_malloc64(nRet);
   806    819     if( zRet ){
   807    820       int i;
   808    821       char *z = zRet;
   809    822       *(z++) = '"';
   810    823       for(i=0; zInput[i]; i++){
   811    824         if( zInput[i]=='"' ) *(z++) = '"';
   812    825         *(z++) = zInput[i];
................................................................................
   979    992       const char *p;
   980    993       nIndex++;
   981    994       for(p=zParam; *p; p++){
   982    995         if( *p==',' ) nIndex++;
   983    996       }
   984    997     }
   985    998   
   986         -  aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
          999  +  aIndex = sqlite3_malloc64(sizeof(struct Fts3Index) * nIndex);
   987   1000     *apIndex = aIndex;
   988   1001     if( !aIndex ){
   989   1002       return SQLITE_NOMEM;
   990   1003     }
   991   1004   
   992   1005     memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);
   993   1006     if( zParam ){
................................................................................
  1058   1071         sqlite3Fts3ErrMsg(pzErr, "%s", sqlite3_errmsg(db));
  1059   1072       }
  1060   1073     }
  1061   1074     sqlite3_free(zSql);
  1062   1075   
  1063   1076     if( rc==SQLITE_OK ){
  1064   1077       const char **azCol;           /* Output array */
  1065         -    int nStr = 0;                 /* Size of all column names (incl. 0x00) */
         1078  +    sqlite3_int64 nStr = 0;       /* Size of all column names (incl. 0x00) */
  1066   1079       int nCol;                     /* Number of table columns */
  1067   1080       int i;                        /* Used to iterate through columns */
  1068   1081   
  1069   1082       /* Loop through the returned columns. Set nStr to the number of bytes of
  1070   1083       ** space required to store a copy of each column name, including the
  1071   1084       ** nul-terminator byte.  */
  1072   1085       nCol = sqlite3_column_count(pStmt);
  1073   1086       for(i=0; i<nCol; i++){
  1074   1087         const char *zCol = sqlite3_column_name(pStmt, i);
  1075         -      nStr += (int)strlen(zCol) + 1;
         1088  +      nStr += strlen(zCol) + 1;
  1076   1089       }
  1077   1090   
  1078   1091       /* Allocate and populate the array to return. */
  1079         -    azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
         1092  +    azCol = (const char **)sqlite3_malloc64(sizeof(char *) * nCol + nStr);
  1080   1093       if( azCol==0 ){
  1081   1094         rc = SQLITE_NOMEM;
  1082   1095       }else{
  1083   1096         char *p = (char *)&azCol[nCol];
  1084   1097         for(i=0; i<nCol; i++){
  1085   1098           const char *zCol = sqlite3_column_name(pStmt, i);
  1086   1099           int n = (int)strlen(zCol)+1;
................................................................................
  1120   1133     sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */
  1121   1134     char **pzErr                    /* Write any error message here */
  1122   1135   ){
  1123   1136     Fts3Hash *pHash = (Fts3Hash *)pAux;
  1124   1137     Fts3Table *p = 0;               /* Pointer to allocated vtab */
  1125   1138     int rc = SQLITE_OK;             /* Return code */
  1126   1139     int i;                          /* Iterator variable */
  1127         -  int nByte;                      /* Size of allocation used for *p */
         1140  +  sqlite3_int64 nByte;            /* Size of allocation used for *p */
  1128   1141     int iCol;                       /* Column index */
  1129   1142     int nString = 0;                /* Bytes required to hold all column names */
  1130   1143     int nCol = 0;                   /* Number of columns in the FTS table */
  1131   1144     char *zCsr;                     /* Space for holding column names */
  1132   1145     int nDb;                        /* Bytes required to hold database name */
  1133   1146     int nName;                      /* Bytes required to hold table name */
  1134   1147     int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
................................................................................
  1154   1167          || (sqlite3_strnicmp(argv[0], "fts3", 4)==0 && !isFts4)
  1155   1168     );
  1156   1169   
  1157   1170     nDb = (int)strlen(argv[1]) + 1;
  1158   1171     nName = (int)strlen(argv[2]) + 1;
  1159   1172   
  1160   1173     nByte = sizeof(const char *) * (argc-2);
  1161         -  aCol = (const char **)sqlite3_malloc(nByte);
         1174  +  aCol = (const char **)sqlite3_malloc64(nByte);
  1162   1175     if( aCol ){
  1163   1176       memset((void*)aCol, 0, nByte);
  1164         -    azNotindexed = (char **)sqlite3_malloc(nByte);
         1177  +    azNotindexed = (char **)sqlite3_malloc64(nByte);
  1165   1178     }
  1166   1179     if( azNotindexed ){
  1167   1180       memset(azNotindexed, 0, nByte);
  1168   1181     }
  1169   1182     if( !aCol || !azNotindexed ){
  1170   1183       rc = SQLITE_NOMEM;
  1171   1184       goto fts3_init_out;
................................................................................
  1352   1365     nByte = sizeof(Fts3Table) +                  /* Fts3Table */
  1353   1366             nCol * sizeof(char *) +              /* azColumn */
  1354   1367             nIndex * sizeof(struct Fts3Index) +  /* aIndex */
  1355   1368             nCol * sizeof(u8) +                  /* abNotindexed */
  1356   1369             nName +                              /* zName */
  1357   1370             nDb +                                /* zDb */
  1358   1371             nString;                             /* Space for azColumn strings */
  1359         -  p = (Fts3Table*)sqlite3_malloc(nByte);
         1372  +  p = (Fts3Table*)sqlite3_malloc64(nByte);
  1360   1373     if( p==0 ){
  1361   1374       rc = SQLITE_NOMEM;
  1362   1375       goto fts3_init_out;
  1363   1376     }
  1364   1377     memset(p, 0, nByte);
  1365   1378     p->db = db;
  1366   1379     p->nColumn = nCol;
................................................................................
  1856   1869       if( !isFirstTerm ){
  1857   1870         zCsr += fts3GetVarint32(zCsr, &nPrefix);
  1858   1871       }
  1859   1872       isFirstTerm = 0;
  1860   1873       zCsr += fts3GetVarint32(zCsr, &nSuffix);
  1861   1874       
  1862   1875       assert( nPrefix>=0 && nSuffix>=0 );
  1863         -    if( nPrefix>zCsr-zNode || nSuffix>zEnd-zCsr ){
         1876  +    if( nPrefix>zCsr-zNode || nSuffix>zEnd-zCsr || nSuffix==0 ){
  1864   1877         rc = FTS_CORRUPT_VTAB;
  1865   1878         goto finish_scan;
  1866   1879       }
  1867   1880       if( (i64)nPrefix+nSuffix>nAlloc ){
  1868   1881         char *zNew;
  1869   1882         nAlloc = ((i64)nPrefix+nSuffix) * 2;
  1870   1883         zNew = (char *)sqlite3_realloc64(zBuffer, nAlloc);
................................................................................
  2131   2144   /*
  2132   2145   ** Compute the union of two position lists.  The output written
  2133   2146   ** into *pp contains all positions of both *pp1 and *pp2 in sorted
  2134   2147   ** order and with any duplicates removed.  All pointers are
  2135   2148   ** updated appropriately.   The caller is responsible for insuring
  2136   2149   ** that there is enough space in *pp to hold the complete output.
  2137   2150   */
  2138         -static void fts3PoslistMerge(
         2151  +static int fts3PoslistMerge(
  2139   2152     char **pp,                      /* Output buffer */
  2140   2153     char **pp1,                     /* Left input list */
  2141   2154     char **pp2                      /* Right input list */
  2142   2155   ){
  2143   2156     char *p = *pp;
  2144   2157     char *p1 = *pp1;
  2145   2158     char *p2 = *pp2;
  2146   2159   
  2147   2160     while( *p1 || *p2 ){
  2148   2161       int iCol1;         /* The current column index in pp1 */
  2149   2162       int iCol2;         /* The current column index in pp2 */
  2150   2163   
  2151         -    if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);
         2164  +    if( *p1==POS_COLUMN ){ 
         2165  +      fts3GetVarint32(&p1[1], &iCol1);
         2166  +      if( iCol1==0 ) return FTS_CORRUPT_VTAB;
         2167  +    }
  2152   2168       else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
  2153   2169       else iCol1 = 0;
  2154   2170   
  2155         -    if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);
         2171  +    if( *p2==POS_COLUMN ){
         2172  +      fts3GetVarint32(&p2[1], &iCol2);
         2173  +      if( iCol2==0 ) return FTS_CORRUPT_VTAB;
         2174  +    }
  2156   2175       else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
  2157   2176       else iCol2 = 0;
  2158   2177   
  2159   2178       if( iCol1==iCol2 ){
  2160   2179         sqlite3_int64 i1 = 0;       /* Last position from pp1 */
  2161   2180         sqlite3_int64 i2 = 0;       /* Last position from pp2 */
  2162   2181         sqlite3_int64 iPrev = 0;
................................................................................
  2196   2215       }
  2197   2216     }
  2198   2217   
  2199   2218     *p++ = POS_END;
  2200   2219     *pp = p;
  2201   2220     *pp1 = p1 + 1;
  2202   2221     *pp2 = p2 + 1;
         2222  +  return SQLITE_OK;
  2203   2223   }
  2204   2224   
  2205   2225   /*
  2206   2226   ** This function is used to merge two position lists into one. When it is
  2207   2227   ** called, *pp1 and *pp2 must both point to position lists. A position-list is
  2208   2228   ** the part of a doclist that follows each document id. For example, if a row
  2209   2229   ** contains:
................................................................................
  2260   2280         sqlite3_int64 iPos2 = 0;
  2261   2281   
  2262   2282         if( iCol1 ){
  2263   2283           *p++ = POS_COLUMN;
  2264   2284           p += sqlite3Fts3PutVarint(p, iCol1);
  2265   2285         }
  2266   2286   
  2267         -      assert( *p1!=POS_END && *p1!=POS_COLUMN );
  2268         -      assert( *p2!=POS_END && *p2!=POS_COLUMN );
  2269   2287         fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
  2270   2288         fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
         2289  +      if( iPos1<0 || iPos2<0 ) break;
  2271   2290   
  2272   2291         while( 1 ){
  2273   2292           if( iPos2==iPos1+nToken 
  2274   2293            || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) 
  2275   2294           ){
  2276   2295             sqlite3_int64 iSave;
  2277   2296             iSave = isSaveLeft ? iPos1 : iPos2;
................................................................................
  2489   2508   */
  2490   2509   static int fts3DoclistOrMerge(
  2491   2510     int bDescDoclist,               /* True if arguments are desc */
  2492   2511     char *a1, int n1,               /* First doclist */
  2493   2512     char *a2, int n2,               /* Second doclist */
  2494   2513     char **paOut, int *pnOut        /* OUT: Malloc'd doclist */
  2495   2514   ){
         2515  +  int rc = SQLITE_OK;
  2496   2516     sqlite3_int64 i1 = 0;
  2497   2517     sqlite3_int64 i2 = 0;
  2498   2518     sqlite3_int64 iPrev = 0;
  2499   2519     char *pEnd1 = &a1[n1];
  2500   2520     char *pEnd2 = &a2[n2];
  2501   2521     char *p1 = a1;
  2502   2522     char *p2 = a2;
................................................................................
  2532   2552     ** The space required to store the output is therefore the sum of the
  2533   2553     ** sizes of the two inputs, plus enough space for exactly one of the input
  2534   2554     ** docids to grow. 
  2535   2555     **
  2536   2556     ** A symetric argument may be made if the doclists are in descending 
  2537   2557     ** order.
  2538   2558     */
  2539         -  aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);
         2559  +  aOut = sqlite3_malloc64((i64)n1+n2+FTS3_VARINT_MAX-1+FTS3_BUFFER_PADDING);
  2540   2560     if( !aOut ) return SQLITE_NOMEM;
  2541   2561   
  2542   2562     p = aOut;
  2543   2563     fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
  2544   2564     fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
  2545   2565     while( p1 || p2 ){
  2546   2566       sqlite3_int64 iDiff = DOCID_CMP(i1, i2);
  2547   2567   
  2548   2568       if( p2 && p1 && iDiff==0 ){
  2549   2569         fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);
  2550         -      fts3PoslistMerge(&p, &p1, &p2);
         2570  +      rc = fts3PoslistMerge(&p, &p1, &p2);
         2571  +      if( rc ) break;
  2551   2572         fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);
  2552   2573         fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
  2553   2574       }else if( !p2 || (p1 && iDiff<0) ){
  2554   2575         fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);
  2555   2576         fts3PoslistCopy(&p, &p1);
  2556   2577         fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);
  2557   2578       }else{
  2558   2579         fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i2);
  2559   2580         fts3PoslistCopy(&p, &p2);
  2560   2581         fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
  2561   2582       }
  2562   2583     }
  2563   2584   
         2585  +  if( rc!=SQLITE_OK ){
         2586  +    sqlite3_free(aOut);
         2587  +    p = aOut = 0;
         2588  +  }else{
         2589  +    assert( (p-aOut)<=n1+n2+FTS3_VARINT_MAX-1 );
         2590  +    memset(&aOut[(p-aOut)], 0, FTS3_BUFFER_PADDING);
         2591  +  }
  2564   2592     *paOut = aOut;
  2565   2593     *pnOut = (int)(p-aOut);
  2566         -  assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
  2567         -  return SQLITE_OK;
         2594  +  return rc;
  2568   2595   }
  2569   2596   
  2570   2597   /*
  2571   2598   ** This function does a "phrase" merge of two doclists. In a phrase merge,
  2572   2599   ** the output contains a copy of each position from the right-hand input
  2573   2600   ** doclist for which there is a position in the left-hand input doclist
  2574   2601   ** exactly nDist tokens before it.
................................................................................
  2595   2622     char *p2 = aRight;
  2596   2623     char *p;
  2597   2624     int bFirstOut = 0;
  2598   2625     char *aOut;
  2599   2626   
  2600   2627     assert( nDist>0 );
  2601   2628     if( bDescDoclist ){
  2602         -    aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
         2629  +    aOut = sqlite3_malloc64((sqlite3_int64)*pnRight + FTS3_VARINT_MAX);
  2603   2630       if( aOut==0 ) return SQLITE_NOMEM;
  2604   2631     }else{
  2605   2632       aOut = aRight;
  2606   2633     }
  2607   2634     p = aOut;
  2608   2635   
  2609   2636     fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
................................................................................
  2779   2806       **
  2780   2807       ** Similar padding is added in the fts3DoclistOrMerge() function.
  2781   2808       */
  2782   2809       pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);
  2783   2810       pTS->anOutput[0] = nDoclist;
  2784   2811       if( pTS->aaOutput[0] ){
  2785   2812         memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
         2813  +      memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX);
  2786   2814       }else{
  2787   2815         return SQLITE_NOMEM;
  2788   2816       }
  2789   2817     }else{
  2790   2818       char *aMerge = aDoclist;
  2791   2819       int nMerge = nDoclist;
  2792   2820       int iOut;
................................................................................
  2830   2858   */
  2831   2859   static int fts3SegReaderCursorAppend(
  2832   2860     Fts3MultiSegReader *pCsr, 
  2833   2861     Fts3SegReader *pNew
  2834   2862   ){
  2835   2863     if( (pCsr->nSegment%16)==0 ){
  2836   2864       Fts3SegReader **apNew;
  2837         -    int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
  2838         -    apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);
         2865  +    sqlite3_int64 nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
         2866  +    apNew = (Fts3SegReader **)sqlite3_realloc64(pCsr->apSegment, nByte);
  2839   2867       if( !apNew ){
  2840   2868         sqlite3Fts3SegReaderFree(pNew);
  2841   2869         return SQLITE_NOMEM;
  2842   2870       }
  2843   2871       pCsr->apSegment = apNew;
  2844   2872     }
  2845   2873     pCsr->apSegment[pCsr->nSegment++] = pNew;
................................................................................
  2895   2923         sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);
  2896   2924         sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);
  2897   2925         int nRoot = sqlite3_column_bytes(pStmt, 4);
  2898   2926         char const *zRoot = sqlite3_column_blob(pStmt, 4);
  2899   2927   
  2900   2928         /* If zTerm is not NULL, and this segment is not stored entirely on its
  2901   2929         ** root node, the range of leaves scanned can be reduced. Do this. */
  2902         -      if( iStartBlock && zTerm ){
         2930  +      if( iStartBlock && zTerm && zRoot ){
  2903   2931           sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
  2904   2932           rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
  2905   2933           if( rc!=SQLITE_OK ) goto finished;
  2906   2934           if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;
  2907   2935         }
  2908   2936    
  2909   2937         rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, 
................................................................................
  3837   3865   **
  3838   3866   ** Discard the contents of the pending terms table.
  3839   3867   */
  3840   3868   static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
  3841   3869     Fts3Table *p = (Fts3Table*)pVtab;
  3842   3870     UNUSED_PARAMETER(iSavepoint);
  3843   3871     assert( p->inTransaction );
  3844         -  assert( p->mxSavepoint >= iSavepoint );
  3845   3872     TESTONLY( p->mxSavepoint = iSavepoint );
  3846   3873     sqlite3Fts3PendingTermsClear(p);
  3847   3874     return SQLITE_OK;
  3848   3875   }
  3849   3876   
  3850   3877   /*
  3851   3878   ** Return true if zName is the extension on one of the shadow tables used
................................................................................
  4612   4639           }
  4613   4640         }
  4614   4641   
  4615   4642         /* Check if the current entries really are a phrase match */
  4616   4643         if( bEof==0 ){
  4617   4644           int nList = 0;
  4618   4645           int nByte = a[p->nToken-1].nList;
  4619         -        char *aDoclist = sqlite3_malloc(nByte+1);
         4646  +        char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING);
  4620   4647           if( !aDoclist ) return SQLITE_NOMEM;
  4621   4648           memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);
         4649  +        memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING);
  4622   4650   
  4623   4651           for(i=0; i<(p->nToken-1); i++){
  4624   4652             if( a[i].bIgnore==0 ){
  4625   4653               char *pL = a[i].pList;
  4626   4654               char *pR = aDoclist;
  4627   4655               char *pOut = aDoclist;
  4628   4656               int nDist = p->nToken-1-i;
................................................................................
  5005   5033     fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
  5006   5034   
  5007   5035     /* Determine which, if any, tokens in the expression should be deferred. */
  5008   5036   #ifndef SQLITE_DISABLE_FTS4_DEFERRED
  5009   5037     if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
  5010   5038       Fts3TokenAndCost *aTC;
  5011   5039       Fts3Expr **apOr;
  5012         -    aTC = (Fts3TokenAndCost *)sqlite3_malloc(
         5040  +    aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
  5013   5041           sizeof(Fts3TokenAndCost) * nToken
  5014   5042         + sizeof(Fts3Expr *) * nOr * 2
  5015   5043       );
  5016   5044       apOr = (Fts3Expr **)&aTC[nToken];
  5017   5045   
  5018   5046       if( !aTC ){
  5019   5047         rc = SQLITE_NOMEM;
................................................................................
  5316   5344     ** no exceptions to this - it's the way the parser in fts3_expr.c works.
  5317   5345     */
  5318   5346     if( *pRc==SQLITE_OK 
  5319   5347      && pExpr->eType==FTSQUERY_NEAR 
  5320   5348      && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
  5321   5349     ){
  5322   5350       Fts3Expr *p; 
  5323         -    int nTmp = 0;                 /* Bytes of temp space */
         5351  +    sqlite3_int64 nTmp = 0;       /* Bytes of temp space */
  5324   5352       char *aTmp;                   /* Temp space for PoslistNearMerge() */
  5325   5353   
  5326   5354       /* Allocate temporary working space. */
  5327   5355       for(p=pExpr; p->pLeft; p=p->pLeft){
  5328   5356         assert( p->pRight->pPhrase->doclist.nList>0 );
  5329   5357         nTmp += p->pRight->pPhrase->doclist.nList;
  5330   5358       }
  5331   5359       nTmp += p->pPhrase->doclist.nList;
  5332         -    aTmp = sqlite3_malloc(nTmp*2);
         5360  +    aTmp = sqlite3_malloc64(nTmp*2);
  5333   5361       if( !aTmp ){
  5334   5362         *pRc = SQLITE_NOMEM;
  5335   5363         res = 0;
  5336   5364       }else{
  5337   5365         char *aPoslist = p->pPhrase->doclist.pList;
  5338   5366         int nToken = p->pPhrase->nToken;
  5339   5367   
................................................................................
  5595   5623   ** After allocating the Fts3Expr.aMI[] array for each phrase in the 
  5596   5624   ** expression rooted at pExpr, the cursor iterates through all rows matched
  5597   5625   ** by pExpr, calling this function for each row. This function increments
  5598   5626   ** the values in Fts3Expr.aMI[] according to the position-list currently
  5599   5627   ** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase 
  5600   5628   ** expression nodes.
  5601   5629   */
  5602         -static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
         5630  +static void fts3EvalUpdateCounts(Fts3Expr *pExpr, int nCol){
  5603   5631     if( pExpr ){
  5604   5632       Fts3Phrase *pPhrase = pExpr->pPhrase;
  5605   5633       if( pPhrase && pPhrase->doclist.pList ){
  5606   5634         int iCol = 0;
  5607   5635         char *p = pPhrase->doclist.pList;
  5608   5636   
  5609         -      assert( *p );
  5610         -      while( 1 ){
         5637  +      do{
  5611   5638           u8 c = 0;
  5612   5639           int iCnt = 0;
  5613   5640           while( 0xFE & (*p | c) ){
  5614   5641             if( (c&0x80)==0 ) iCnt++;
  5615   5642             c = *p++ & 0x80;
  5616   5643           }
  5617   5644   
................................................................................
  5619   5646           ** aMI[iCol*3 + 2] = Number of rows containing at least one instance
  5620   5647           */
  5621   5648           pExpr->aMI[iCol*3 + 1] += iCnt;
  5622   5649           pExpr->aMI[iCol*3 + 2] += (iCnt>0);
  5623   5650           if( *p==0x00 ) break;
  5624   5651           p++;
  5625   5652           p += fts3GetVarint32(p, &iCol);
  5626         -      }
         5653  +      }while( iCol<nCol );
  5627   5654       }
  5628   5655   
  5629         -    fts3EvalUpdateCounts(pExpr->pLeft);
  5630         -    fts3EvalUpdateCounts(pExpr->pRight);
         5656  +    fts3EvalUpdateCounts(pExpr->pLeft, nCol);
         5657  +    fts3EvalUpdateCounts(pExpr->pRight, nCol);
  5631   5658     }
  5632   5659   }
  5633   5660   
  5634   5661   /*
  5635   5662   ** Expression pExpr must be of type FTSQUERY_PHRASE.
  5636   5663   **
  5637   5664   ** If it is not already allocated and populated, this function allocates and
................................................................................
  5667   5694       bEof = pRoot->bEof;
  5668   5695       assert( pRoot->bStart );
  5669   5696   
  5670   5697       /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */
  5671   5698       for(p=pRoot; p; p=p->pLeft){
  5672   5699         Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);
  5673   5700         assert( pE->aMI==0 );
  5674         -      pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));
         5701  +      pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
  5675   5702         if( !pE->aMI ) return SQLITE_NOMEM;
  5676   5703         memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
  5677   5704       }
  5678   5705   
  5679   5706       fts3EvalRestart(pCsr, pRoot, &rc);
  5680   5707   
  5681   5708       while( pCsr->isEof==0 && rc==SQLITE_OK ){
................................................................................
  5693   5720           pCsr->iPrevId = pRoot->iDocid;
  5694   5721         }while( pCsr->isEof==0 
  5695   5722              && pRoot->eType==FTSQUERY_NEAR 
  5696   5723              && sqlite3Fts3EvalTestDeferred(pCsr, &rc) 
  5697   5724         );
  5698   5725   
  5699   5726         if( rc==SQLITE_OK && pCsr->isEof==0 ){
  5700         -        fts3EvalUpdateCounts(pRoot);
         5727  +        fts3EvalUpdateCounts(pRoot, pTab->nColumn);
  5701   5728         }
  5702   5729       }
  5703   5730   
  5704   5731       pCsr->isEof = 0;
  5705   5732       pCsr->iPrevId = iPrevId;
  5706   5733   
  5707   5734       if( bEof ){

Changes to ext/fts3/fts3Int.h.

    91     91   
    92     92   /*
    93     93   ** Maximum length of a varint encoded integer. The varint format is different
    94     94   ** from that used by SQLite, so the maximum length is 10, not 9.
    95     95   */
    96     96   #define FTS3_VARINT_MAX 10
    97     97   
           98  +#define FTS3_BUFFER_PADDING 8
           99  +
    98    100   /*
    99    101   ** FTS4 virtual tables may maintain multiple indexes - one index of all terms
   100    102   ** in the document set and zero or more prefix indexes. All indexes are stored
   101    103   ** as one or more b+-trees in the %_segments and %_segdir tables. 
   102    104   **
   103    105   ** It is possible to determine which index a b+-tree belongs to based on the
   104    106   ** value stored in the "%_segdir.level" column. Given this value L, the index
................................................................................
   123    125   
   124    126   /*
   125    127   ** Terminator values for position-lists and column-lists.
   126    128   */
   127    129   #define POS_COLUMN  (1)     /* Column-list terminator */
   128    130   #define POS_END     (0)     /* Position-list terminator */ 
   129    131   
          132  +/*
          133  +** The assert_fts3_nc() macro is similar to the assert() macro, except that it
          134  +** is used for assert() conditions that are true only if it can be 
          135  +** guranteed that the database is not corrupt.
          136  +*/
          137  +#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
          138  +extern int sqlite3_fts3_may_be_corrupt;
          139  +# define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x))
          140  +#else
          141  +# define assert_fts3_nc(x) assert(x)
          142  +#endif
          143  +
   130    144   /*
   131    145   ** This section provides definitions to allow the
   132    146   ** FTS3 extension to be compiled outside of the 
   133    147   ** amalgamation.
   134    148   */
   135    149   #ifndef SQLITE_AMALGAMATION
   136    150   /*

Changes to ext/fts3/fts3_aux.c.

    62     62     sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */
    63     63     char **pzErr                    /* OUT: sqlite3_malloc'd error message */
    64     64   ){
    65     65     char const *zDb;                /* Name of database (e.g. "main") */
    66     66     char const *zFts3;              /* Name of fts3 table */
    67     67     int nDb;                        /* Result of strlen(zDb) */
    68     68     int nFts3;                      /* Result of strlen(zFts3) */
    69         -  int nByte;                      /* Bytes of space to allocate here */
           69  +  sqlite3_int64 nByte;            /* Bytes of space to allocate here */
    70     70     int rc;                         /* value returned by declare_vtab() */
    71     71     Fts3auxTable *p;                /* Virtual table object to return */
    72     72   
    73     73     UNUSED_PARAMETER(pUnused);
    74     74   
    75     75     /* The user should invoke this in one of two forms:
    76     76     **
................................................................................
    94     94     }
    95     95     nFts3 = (int)strlen(zFts3);
    96     96   
    97     97     rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);
    98     98     if( rc!=SQLITE_OK ) return rc;
    99     99   
   100    100     nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
   101         -  p = (Fts3auxTable *)sqlite3_malloc(nByte);
          101  +  p = (Fts3auxTable *)sqlite3_malloc64(nByte);
   102    102     if( !p ) return SQLITE_NOMEM;
   103    103     memset(p, 0, nByte);
   104    104   
   105    105     p->pFts3Tab = (Fts3Table *)&p[1];
   106    106     p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];
   107    107     p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];
   108    108     p->pFts3Tab->db = db;
................................................................................
   244    244     sqlite3_free(pCsr);
   245    245     return SQLITE_OK;
   246    246   }
   247    247   
   248    248   static int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){
   249    249     if( nSize>pCsr->nStat ){
   250    250       struct Fts3auxColstats *aNew;
   251         -    aNew = (struct Fts3auxColstats *)sqlite3_realloc(pCsr->aStat, 
          251  +    aNew = (struct Fts3auxColstats *)sqlite3_realloc64(pCsr->aStat, 
   252    252           sizeof(struct Fts3auxColstats) * nSize
   253    253       );
   254    254       if( aNew==0 ) return SQLITE_NOMEM;
   255    255       memset(&aNew[pCsr->nStat], 0, 
   256    256           sizeof(struct Fts3auxColstats) * (nSize - pCsr->nStat)
   257    257       );
   258    258       pCsr->aStat = aNew;
................................................................................
   412    412     if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
   413    413   
   414    414     if( iEq>=0 || iGe>=0 ){
   415    415       const unsigned char *zStr = sqlite3_value_text(apVal[0]);
   416    416       assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );
   417    417       if( zStr ){
   418    418         pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
   419         -      pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
   420    419         if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
          420  +      pCsr->filter.nTerm = (int)strlen(pCsr->filter.zTerm);
   421    421       }
   422    422     }
   423    423   
   424    424     if( iLe>=0 ){
   425    425       pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iLe]));
   426         -    pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);
   427    426       if( pCsr->zStop==0 ) return SQLITE_NOMEM;
          427  +    pCsr->nStop = (int)strlen(pCsr->zStop);
   428    428     }
   429    429     
   430    430     if( iLangid>=0 ){
   431    431       iLangVal = sqlite3_value_int(apVal[iLangid]);
   432    432   
   433    433       /* If the user specified a negative value for the languageid, use zero
   434    434       ** instead. This works, as the "languageid=?" constraint will also

Changes to ext/fts3/fts3_expr.c.

   118    118   }
   119    119   
   120    120   /*
   121    121   ** Allocate nByte bytes of memory using sqlite3_malloc(). If successful,
   122    122   ** zero the memory before returning a pointer to it. If unsuccessful, 
   123    123   ** return NULL.
   124    124   */
   125         -static void *fts3MallocZero(int nByte){
   126         -  void *pRet = sqlite3_malloc(nByte);
          125  +static void *fts3MallocZero(sqlite3_int64 nByte){
          126  +  void *pRet = sqlite3_malloc64(nByte);
   127    127     if( pRet ) memset(pRet, 0, nByte);
   128    128     return pRet;
   129    129   }
   130    130   
   131    131   int sqlite3Fts3OpenTokenizer(
   132    132     sqlite3_tokenizer *pTokenizer,
   133    133     int iLangid,
................................................................................
   194    194     }
   195    195   
   196    196     *pnConsumed = i;
   197    197     rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, i, &pCursor);
   198    198     if( rc==SQLITE_OK ){
   199    199       const char *zToken;
   200    200       int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;
   201         -    int nByte;                               /* total space to allocate */
          201  +    sqlite3_int64 nByte;                    /* total space to allocate */
   202    202   
   203    203       rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
   204    204       if( rc==SQLITE_OK ){
   205    205         nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;
   206    206         pRet = (Fts3Expr *)fts3MallocZero(nByte);
   207    207         if( !pRet ){
   208    208           rc = SQLITE_NOMEM;
................................................................................
   248    248   }
   249    249   
   250    250   
   251    251   /*
   252    252   ** Enlarge a memory allocation.  If an out-of-memory allocation occurs,
   253    253   ** then free the old allocation.
   254    254   */
   255         -static void *fts3ReallocOrFree(void *pOrig, int nNew){
   256         -  void *pRet = sqlite3_realloc(pOrig, nNew);
          255  +static void *fts3ReallocOrFree(void *pOrig, sqlite3_int64 nNew){
          256  +  void *pRet = sqlite3_realloc64(pOrig, nNew);
   257    257     if( !pRet ){
   258    258       sqlite3_free(pOrig);
   259    259     }
   260    260     return pRet;
   261    261   }
   262    262   
   263    263   /*
................................................................................
   493    493     }
   494    494   
   495    495     if( sqlite3_fts3_enable_parentheses ){
   496    496       if( *zInput=='(' ){
   497    497         int nConsumed = 0;
   498    498         pParse->nNest++;
   499    499         rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);
   500         -      if( rc==SQLITE_OK && !*ppExpr ){ rc = SQLITE_DONE; }
   501    500         *pnConsumed = (int)(zInput - z) + 1 + nConsumed;
   502    501         return rc;
   503    502       }else if( *zInput==')' ){
   504    503         pParse->nNest--;
   505    504         *pnConsumed = (int)((zInput - z) + 1);
   506    505         *ppExpr = 0;
   507    506         return SQLITE_DONE;
................................................................................
   792    791     if( nMaxDepth==0 ){
   793    792       rc = SQLITE_ERROR;
   794    793     }
   795    794   
   796    795     if( rc==SQLITE_OK ){
   797    796       if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){
   798    797         Fts3Expr **apLeaf;
   799         -      apLeaf = (Fts3Expr **)sqlite3_malloc(sizeof(Fts3Expr *) * nMaxDepth);
          798  +      apLeaf = (Fts3Expr **)sqlite3_malloc64(sizeof(Fts3Expr *) * nMaxDepth);
   800    799         if( 0==apLeaf ){
   801    800           rc = SQLITE_NOMEM;
   802    801         }else{
   803    802           memset(apLeaf, 0, sizeof(Fts3Expr *) * nMaxDepth);
   804    803         }
   805    804   
   806    805         if( rc==SQLITE_OK ){
................................................................................
  1212   1211       sqlite3_free(zErr);
  1213   1212       return;
  1214   1213     }
  1215   1214   
  1216   1215     zExpr = (const char *)sqlite3_value_text(argv[1]);
  1217   1216     nExpr = sqlite3_value_bytes(argv[1]);
  1218   1217     nCol = argc-2;
  1219         -  azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));
         1218  +  azCol = (char **)sqlite3_malloc64(nCol*sizeof(char *));
  1220   1219     if( !azCol ){
  1221   1220       sqlite3_result_error_nomem(context);
  1222   1221       goto exprtest_out;
  1223   1222     }
  1224   1223     for(ii=0; ii<nCol; ii++){
  1225   1224       azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);
  1226   1225     }

Changes to ext/fts3/fts3_hash.c.

    31     31   #include <string.h>
    32     32   
    33     33   #include "fts3_hash.h"
    34     34   
    35     35   /*
    36     36   ** Malloc and Free functions
    37     37   */
    38         -static void *fts3HashMalloc(int n){
    39         -  void *p = sqlite3_malloc(n);
           38  +static void *fts3HashMalloc(sqlite3_int64 n){
           39  +  void *p = sqlite3_malloc64(n);
    40     40     if( p ){
    41     41       memset(p, 0, n);
    42     42     }
    43     43     return p;
    44     44   }
    45     45   static void fts3HashFree(void *p){
    46     46     sqlite3_free(p);

Changes to ext/fts3/fts3_icu.c.

    56     56   ){
    57     57     IcuTokenizer *p;
    58     58     int n = 0;
    59     59   
    60     60     if( argc>0 ){
    61     61       n = strlen(argv[0])+1;
    62     62     }
    63         -  p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);
           63  +  p = (IcuTokenizer *)sqlite3_malloc64(sizeof(IcuTokenizer)+n);
    64     64     if( !p ){
    65     65       return SQLITE_NOMEM;
    66     66     }
    67     67     memset(p, 0, sizeof(IcuTokenizer));
    68     68   
    69     69     if( n ){
    70     70       p->zLocale = (char *)&p[1];
................................................................................
   113    113     if( zInput==0 ){
   114    114       nInput = 0;
   115    115       zInput = "";
   116    116     }else if( nInput<0 ){
   117    117       nInput = strlen(zInput);
   118    118     }
   119    119     nChar = nInput+1;
   120         -  pCsr = (IcuCursor *)sqlite3_malloc(
          120  +  pCsr = (IcuCursor *)sqlite3_malloc64(
   121    121         sizeof(IcuCursor) +                /* IcuCursor */
   122    122         ((nChar+3)&~3) * sizeof(UChar) +   /* IcuCursor.aChar[] */
   123    123         (nChar+1) * sizeof(int)            /* IcuCursor.aOffset[] */
   124    124     );
   125    125     if( !pCsr ){
   126    126       return SQLITE_NOMEM;
   127    127     }

Changes to ext/fts3/fts3_snippet.c.

   174    174       xRet = fts3MIBufferFree;
   175    175     }
   176    176     else if( p->aRef[2]==0 ){
   177    177       p->aRef[2] = 1;
   178    178       aOut = &p->aMatchinfo[p->nElem+2];
   179    179       xRet = fts3MIBufferFree;
   180    180     }else{
   181         -    aOut = (u32*)sqlite3_malloc(p->nElem * sizeof(u32));
          181  +    aOut = (u32*)sqlite3_malloc64(p->nElem * sizeof(u32));
   182    182       if( aOut ){
   183    183         xRet = sqlite3_free;
   184    184         if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32));
   185    185       }
   186    186     }
   187    187   
   188    188     *paOut = aOut;
................................................................................
   425    425   
   426    426     for(i=0; i<pIter->nPhrase; i++){
   427    427       SnippetPhrase *pPhrase = &pIter->aPhrase[i];
   428    428       if( pPhrase->pTail ){
   429    429         char *pCsr = pPhrase->pTail;
   430    430         int iCsr = pPhrase->iTail;
   431    431   
   432         -      while( iCsr<(iStart+pIter->nSnippet) ){
          432  +      while( iCsr<(iStart+pIter->nSnippet) && iCsr>=iStart ){
   433    433           int j;
   434    434           u64 mPhrase = (u64)1 << i;
   435    435           u64 mPos = (u64)1 << (iCsr - iStart);
   436         -        assert( iCsr>=iStart );
          436  +        assert( iCsr>=iStart && (iCsr - iStart)<=64 );
          437  +        assert( i>=0 && i<=64 );
   437    438           if( (mCover|mCovered)&mPhrase ){
   438    439             iScore++;
   439    440           }else{
   440    441             iScore += 1000;
   441    442           }
   442    443           mCover |= mPhrase;
   443    444   
................................................................................
   471    472     pPhrase->nToken = pExpr->pPhrase->nToken;
   472    473     rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);
   473    474     assert( rc==SQLITE_OK || pCsr==0 );
   474    475     if( pCsr ){
   475    476       int iFirst = 0;
   476    477       pPhrase->pList = pCsr;
   477    478       fts3GetDeltaPosition(&pCsr, &iFirst);
   478         -    assert( iFirst>=0 );
   479         -    pPhrase->pHead = pCsr;
   480         -    pPhrase->pTail = pCsr;
   481         -    pPhrase->iHead = iFirst;
   482         -    pPhrase->iTail = iFirst;
          479  +    if( iFirst<0 ){
          480  +      rc = FTS_CORRUPT_VTAB;
          481  +    }else{
          482  +      pPhrase->pHead = pCsr;
          483  +      pPhrase->pTail = pCsr;
          484  +      pPhrase->iHead = iFirst;
          485  +      pPhrase->iTail = iFirst;
          486  +    }
   483    487     }else{
   484    488       assert( rc!=SQLITE_OK || (
   485    489          pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0 
   486    490       ));
   487    491     }
   488    492   
   489    493     return rc;
................................................................................
   512    516     u64 *pmSeen,                    /* IN/OUT: Mask of phrases seen */
   513    517     SnippetFragment *pFragment,     /* OUT: Best snippet found */
   514    518     int *piScore                    /* OUT: Score of snippet pFragment */
   515    519   ){
   516    520     int rc;                         /* Return Code */
   517    521     int nList;                      /* Number of phrases in expression */
   518    522     SnippetIter sIter;              /* Iterates through snippet candidates */
   519         -  int nByte;                      /* Number of bytes of space to allocate */
          523  +  sqlite3_int64 nByte;            /* Number of bytes of space to allocate */
   520    524     int iBestScore = -1;            /* Best snippet score found so far */
   521    525     int i;                          /* Loop counter */
   522    526   
   523    527     memset(&sIter, 0, sizeof(sIter));
   524    528   
   525    529     /* Iterate through the phrases in the expression to count them. The same
   526    530     ** callback makes sure the doclists are loaded for each phrase.
................................................................................
   530    534       return rc;
   531    535     }
   532    536   
   533    537     /* Now that it is known how many phrases there are, allocate and zero
   534    538     ** the required space using malloc().
   535    539     */
   536    540     nByte = sizeof(SnippetPhrase) * nList;
   537         -  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);
          541  +  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc64(nByte);
   538    542     if( !sIter.aPhrase ){
   539    543       return SQLITE_NOMEM;
   540    544     }
   541    545     memset(sIter.aPhrase, 0, nByte);
   542    546   
   543    547     /* Initialize the contents of the SnippetIter object. Then iterate through
   544    548     ** the set of phrases in the expression to populate the aPhrase[] array.
................................................................................
   600    604     }
   601    605   
   602    606     /* If there is insufficient space allocated at StrBuffer.z, use realloc()
   603    607     ** to grow the buffer until so that it is big enough to accomadate the
   604    608     ** appended data.
   605    609     */
   606    610     if( pStr->n+nAppend+1>=pStr->nAlloc ){
   607         -    int nAlloc = pStr->nAlloc+nAppend+100;
   608         -    char *zNew = sqlite3_realloc(pStr->z, nAlloc);
          611  +    sqlite3_int64 nAlloc = pStr->nAlloc+(sqlite3_int64)nAppend+100;
          612  +    char *zNew = sqlite3_realloc64(pStr->z, nAlloc);
   609    613       if( !zNew ){
   610    614         return SQLITE_NOMEM;
   611    615       }
   612    616       pStr->z = zNew;
   613    617       pStr->nAlloc = nAlloc;
   614    618     }
   615    619     assert( pStr->z!=0 && (pStr->nAlloc >= pStr->n+nAppend+1) );
................................................................................
   656    660     if( hlmask ){
   657    661       int nLeft;                    /* Tokens to the left of first highlight */
   658    662       int nRight;                   /* Tokens to the right of last highlight */
   659    663       int nDesired;                 /* Ideal number of tokens to shift forward */
   660    664   
   661    665       for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);
   662    666       for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);
          667  +    assert( (nSnippet-1-nRight)<=63 && (nSnippet-1-nRight)>=0 );
   663    668       nDesired = (nLeft-nRight)/2;
   664    669   
   665    670       /* Ideally, the start of the snippet should be pushed forward in the
   666    671       ** document nDesired tokens. This block checks if there are actually
   667    672       ** nDesired tokens to the right of the snippet. If so, *piPos and
   668    673       ** *pHlMask are updated to shift the snippet nDesired tokens to the
   669    674       ** right. Otherwise, the snippet is shifted by the number of tokens
................................................................................
   848    853     *ppCollist = pEnd;
   849    854     return nEntry;
   850    855   }
   851    856   
   852    857   /*
   853    858   ** This function gathers 'y' or 'b' data for a single phrase.
   854    859   */
   855         -static void fts3ExprLHits(
          860  +static int fts3ExprLHits(
   856    861     Fts3Expr *pExpr,                /* Phrase expression node */
   857    862     MatchInfo *p                    /* Matchinfo context */
   858    863   ){
   859    864     Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;
   860    865     int iStart;
   861    866     Fts3Phrase *pPhrase = pExpr->pPhrase;
   862    867     char *pIter = pPhrase->doclist.pList;
................................................................................
   878    883           p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));
   879    884         }
   880    885       }
   881    886       assert( *pIter==0x00 || *pIter==0x01 );
   882    887       if( *pIter!=0x01 ) break;
   883    888       pIter++;
   884    889       pIter += fts3GetVarint32(pIter, &iCol);
          890  +    if( iCol>=p->nCol ) return FTS_CORRUPT_VTAB;
   885    891     }
          892  +  return SQLITE_OK;
   886    893   }
   887    894   
   888    895   /*
   889    896   ** Gather the results for matchinfo directives 'y' and 'b'.
   890    897   */
   891         -static void fts3ExprLHitGather(
          898  +static int fts3ExprLHitGather(
   892    899     Fts3Expr *pExpr,
   893    900     MatchInfo *p
   894    901   ){
          902  +  int rc = SQLITE_OK;
   895    903     assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );
   896    904     if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
   897    905       if( pExpr->pLeft ){
   898         -      fts3ExprLHitGather(pExpr->pLeft, p);
   899         -      fts3ExprLHitGather(pExpr->pRight, p);
          906  +      rc = fts3ExprLHitGather(pExpr->pLeft, p);
          907  +      if( rc==SQLITE_OK ) rc = fts3ExprLHitGather(pExpr->pRight, p);
   900    908       }else{
   901         -      fts3ExprLHits(pExpr, p);
          909  +      rc = fts3ExprLHits(pExpr, p);
   902    910       }
   903    911     }
          912  +  return rc;
   904    913   }
   905    914   
   906    915   /*
   907    916   ** fts3ExprIterate() callback used to collect the "global" matchinfo stats
   908    917   ** for a single query. 
   909    918   **
   910    919   ** fts3ExprIterate() callback to load the 'global' elements of a
................................................................................
  1113   1122   ** undefined.
  1114   1123   */
  1115   1124   static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
  1116   1125     LcsIterator *aIter;
  1117   1126     int i;
  1118   1127     int iCol;
  1119   1128     int nToken = 0;
         1129  +  int rc = SQLITE_OK;
  1120   1130   
  1121   1131     /* Allocate and populate the array of LcsIterator objects. The array
  1122   1132     ** contains one element for each matchable phrase in the query.
  1123   1133     **/
  1124         -  aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);
         1134  +  aIter = sqlite3_malloc64(sizeof(LcsIterator) * pCsr->nPhrase);
  1125   1135     if( !aIter ) return SQLITE_NOMEM;
  1126   1136     memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);
  1127   1137     (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
  1128   1138   
  1129   1139     for(i=0; i<pInfo->nPhrase; i++){
  1130   1140       LcsIterator *pIter = &aIter[i];
  1131   1141       nToken -= pIter->pExpr->pPhrase->nToken;
................................................................................
  1133   1143     }
  1134   1144   
  1135   1145     for(iCol=0; iCol<pInfo->nCol; iCol++){
  1136   1146       int nLcs = 0;                 /* LCS value for this column */
  1137   1147       int nLive = 0;                /* Number of iterators in aIter not at EOF */
  1138   1148   
  1139   1149       for(i=0; i<pInfo->nPhrase; i++){
  1140         -      int rc;
  1141   1150         LcsIterator *pIt = &aIter[i];
  1142   1151         rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
  1143         -      if( rc!=SQLITE_OK ) return rc;
         1152  +      if( rc!=SQLITE_OK ) goto matchinfo_lcs_out;
  1144   1153         if( pIt->pRead ){
  1145   1154           pIt->iPos = pIt->iPosOffset;
  1146         -        fts3LcsIteratorAdvance(&aIter[i]);
         1155  +        fts3LcsIteratorAdvance(pIt);
         1156  +        if( pIt->pRead==0 ){
         1157  +          rc = FTS_CORRUPT_VTAB;
         1158  +          goto matchinfo_lcs_out;
         1159  +        }
  1147   1160           nLive++;
  1148   1161         }
  1149   1162       }
  1150   1163   
  1151   1164       while( nLive>0 ){
  1152   1165         LcsIterator *pAdv = 0;      /* The iterator to advance by one position */
  1153   1166         int nThisLcs = 0;           /* LCS for the current iterator positions */
................................................................................
  1171   1184         }
  1172   1185         if( fts3LcsIteratorAdvance(pAdv) ) nLive--;
  1173   1186       }
  1174   1187   
  1175   1188       pInfo->aMatchinfo[iCol] = nLcs;
  1176   1189     }
  1177   1190   
         1191  + matchinfo_lcs_out:
  1178   1192     sqlite3_free(aIter);
  1179         -  return SQLITE_OK;
         1193  +  return rc;
  1180   1194   }
  1181   1195   
  1182   1196   /*
  1183   1197   ** Populate the buffer pInfo->aMatchinfo[] with an array of integers to
  1184   1198   ** be returned by the matchinfo() function. Argument zArg contains the 
  1185   1199   ** format string passed as the second argument to matchinfo (or the
  1186   1200   ** default value "pcx" if no second argument was specified). The format
................................................................................
  1268   1282           }
  1269   1283           break;
  1270   1284   
  1271   1285         case FTS3_MATCHINFO_LHITS_BM:
  1272   1286         case FTS3_MATCHINFO_LHITS: {
  1273   1287           int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);
  1274   1288           memset(pInfo->aMatchinfo, 0, nZero);
  1275         -        fts3ExprLHitGather(pCsr->pExpr, pInfo);
         1289  +        rc = fts3ExprLHitGather(pCsr->pExpr, pInfo);
  1276   1290           break;
  1277   1291         }
  1278   1292   
  1279   1293         default: {
  1280   1294           Fts3Expr *pExpr;
  1281   1295           assert( zArg[i]==FTS3_MATCHINFO_HITS );
  1282   1296           pExpr = pCsr->pExpr;
................................................................................
  1419   1433     SnippetFragment aSnippet[4];    /* Maximum of 4 fragments per snippet */
  1420   1434     int nFToken = -1;               /* Number of tokens in each fragment */
  1421   1435   
  1422   1436     if( !pCsr->pExpr ){
  1423   1437       sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
  1424   1438       return;
  1425   1439     }
         1440  +
         1441  +  /* Limit the snippet length to 64 tokens. */
         1442  +  if( nToken<-64 ) nToken = -64;
         1443  +  if( nToken>+64 ) nToken = +64;
  1426   1444   
  1427   1445     for(nSnippet=1; 1; nSnippet++){
  1428   1446   
  1429   1447       int iSnip;                    /* Loop counter 0..nSnippet-1 */
  1430   1448       u64 mCovered = 0;             /* Bitmask of phrases covered by snippet */
  1431   1449       u64 mSeen = 0;                /* Bitmask of phrases seen by BestSnippet() */
  1432   1450   
................................................................................
  1521   1539     int rc;
  1522   1540   
  1523   1541     UNUSED_PARAMETER(iPhrase);
  1524   1542     rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);
  1525   1543     nTerm = pExpr->pPhrase->nToken;
  1526   1544     if( pList ){
  1527   1545       fts3GetDeltaPosition(&pList, &iPos);
  1528         -    assert( iPos>=0 );
         1546  +    assert_fts3_nc( iPos>=0 );
  1529   1547     }
  1530   1548   
  1531   1549     for(iTerm=0; iTerm<nTerm; iTerm++){
  1532   1550       TermOffset *pT = &p->aTerm[p->iTerm++];
  1533   1551       pT->iOff = nTerm-iTerm-1;
  1534   1552       pT->pList = pList;
  1535   1553       pT->iPos = iPos;
................................................................................
  1562   1580     assert( pCsr->isRequireSeek==0 );
  1563   1581   
  1564   1582     /* Count the number of terms in the query */
  1565   1583     rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);
  1566   1584     if( rc!=SQLITE_OK ) goto offsets_out;
  1567   1585   
  1568   1586     /* Allocate the array of TermOffset iterators. */
  1569         -  sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);
         1587  +  sCtx.aTerm = (TermOffset *)sqlite3_malloc64(sizeof(TermOffset)*nToken);
  1570   1588     if( 0==sCtx.aTerm ){
  1571   1589       rc = SQLITE_NOMEM;
  1572   1590       goto offsets_out;
  1573   1591     }
  1574   1592     sCtx.iDocid = pCsr->iPrevId;
  1575   1593     sCtx.pCsr = pCsr;
  1576   1594   
................................................................................
  1631   1649           }
  1632   1650         }
  1633   1651   
  1634   1652         if( !pTerm ){
  1635   1653           /* All offsets for this column have been gathered. */
  1636   1654           rc = SQLITE_DONE;
  1637   1655         }else{
  1638         -        assert( iCurrent<=iMinPos );
         1656  +        assert_fts3_nc( iCurrent<=iMinPos );
  1639   1657           if( 0==(0xFE&*pTerm->pList) ){
  1640   1658             pTerm->pList = 0;
  1641   1659           }else{
  1642   1660             fts3GetDeltaPosition(&pTerm->pList, &pTerm->iPos);
  1643   1661           }
  1644   1662           while( rc==SQLITE_OK && iCurrent<iMinPos ){
  1645   1663             rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);

Changes to ext/fts3/fts3_term.c.

    64     64     sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */
    65     65     char **pzErr                    /* OUT: sqlite3_malloc'd error message */
    66     66   ){
    67     67     char const *zDb;                /* Name of database (e.g. "main") */
    68     68     char const *zFts3;              /* Name of fts3 table */
    69     69     int nDb;                        /* Result of strlen(zDb) */
    70     70     int nFts3;                      /* Result of strlen(zFts3) */
    71         -  int nByte;                      /* Bytes of space to allocate here */
           71  +  sqlite3_int64 nByte;            /* Bytes of space to allocate here */
    72     72     int rc;                         /* value returned by declare_vtab() */
    73         -  Fts3termTable *p;                /* Virtual table object to return */
           73  +  Fts3termTable *p;               /* Virtual table object to return */
    74     74     int iIndex = 0;
    75     75   
    76     76     UNUSED_PARAMETER(pCtx);
    77     77     if( argc==5 ){
    78     78       iIndex = atoi(argv[4]);
    79     79       argc--;
    80     80     }
................................................................................
    92     92     zFts3 = argv[3];
    93     93     nFts3 = (int)strlen(zFts3);
    94     94   
    95     95     rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
    96     96     if( rc!=SQLITE_OK ) return rc;
    97     97   
    98     98     nByte = sizeof(Fts3termTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
    99         -  p = (Fts3termTable *)sqlite3_malloc(nByte);
           99  +  p = (Fts3termTable *)sqlite3_malloc64(nByte);
   100    100     if( !p ) return SQLITE_NOMEM;
   101    101     memset(p, 0, nByte);
   102    102   
   103    103     p->pFts3Tab = (Fts3Table *)&p[1];
   104    104     p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];
   105    105     p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];
   106    106     p->pFts3Tab->db = db;

Changes to ext/fts3/fts3_test.c.

   569    569     UNUSED_PARAMETER(clientData);
   570    570     return TCL_OK;
   571    571   }
   572    572   
   573    573   /* 
   574    574   ** End of tokenizer code.
   575    575   **************************************************************************/ 
          576  +
          577  +/*
          578  +**      sqlite3_fts3_may_be_corrupt BOOLEAN
          579  +**
          580  +** Set or clear the global "may-be-corrupt" flag. Return the old value.
          581  +*/
          582  +static int SQLITE_TCLAPI fts3_may_be_corrupt(
          583  +  void * clientData,
          584  +  Tcl_Interp *interp,
          585  +  int objc,
          586  +  Tcl_Obj *CONST objv[]
          587  +){
          588  +  int bOld = sqlite3_fts3_may_be_corrupt;
          589  +
          590  +  if( objc!=2 && objc!=1 ){
          591  +    Tcl_WrongNumArgs(interp, 1, objv, "?BOOLEAN?");
          592  +    return TCL_ERROR;
          593  +  }
          594  +  if( objc==2 ){
          595  +    int bNew;
          596  +    if( Tcl_GetBooleanFromObj(interp, objv[1], &bNew) ) return TCL_ERROR;
          597  +    sqlite3_fts3_may_be_corrupt = bNew;
          598  +  }
          599  +
          600  +  Tcl_SetObjResult(interp, Tcl_NewIntObj(bOld));
          601  +  return TCL_OK;
          602  +}
   576    603   
   577    604   int Sqlitetestfts3_Init(Tcl_Interp *interp){
   578    605     Tcl_CreateObjCommand(interp, "fts3_near_match", fts3_near_match_cmd, 0, 0);
   579    606     Tcl_CreateObjCommand(interp, 
   580    607         "fts3_configure_incr_load", fts3_configure_incr_load_cmd, 0, 0
   581    608     );
   582    609     Tcl_CreateObjCommand(
   583    610         interp, "fts3_test_tokenizer", fts3_test_tokenizer_cmd, 0, 0
   584    611     );
   585         -
   586    612     Tcl_CreateObjCommand(
   587    613         interp, "fts3_test_varint", fts3_test_varint_cmd, 0, 0
   588    614     );
          615  +  Tcl_CreateObjCommand(
          616  +      interp, "sqlite3_fts3_may_be_corrupt", fts3_may_be_corrupt, 0, 0
          617  +  );
   589    618     return TCL_OK;
   590    619   }
   591    620   #endif                  /* SQLITE_ENABLE_FTS3 || SQLITE_ENABLE_FTS4 */
   592    621   #endif                  /* ifdef SQLITE_TEST */

Changes to ext/fts3/fts3_tokenize_vtab.c.

   118    118       int nByte = 0;
   119    119       char **azDequote;
   120    120   
   121    121       for(i=0; i<argc; i++){
   122    122         nByte += (int)(strlen(argv[i]) + 1);
   123    123       }
   124    124   
   125         -    *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);
          125  +    *pazDequote = azDequote = sqlite3_malloc64(sizeof(char *)*argc + nByte);
   126    126       if( azDequote==0 ){
   127    127         rc = SQLITE_NOMEM;
   128    128       }else{
   129    129         char *pSpace = (char *)&azDequote[argc];
   130    130         for(i=0; i<argc; i++){
   131    131           int n = (int)strlen(argv[i]);
   132    132           azDequote[i] = pSpace;

Changes to ext/fts3/fts3_tokenizer.c.

   102    102       if( !pPtr ){
   103    103         char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
   104    104         sqlite3_result_error(context, zErr, -1);
   105    105         sqlite3_free(zErr);
   106    106         return;
   107    107       }
   108    108     }
   109         -  sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
          109  +  if( fts3TokenizerEnabled(context) ){
          110  +    sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
          111  +  }
   110    112   }
   111    113   
   112    114   int sqlite3Fts3IsIdChar(char c){
   113    115     static const char isFtsIdChar[] = {
   114    116         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 0x */
   115    117         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 1x */
   116    118         0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */

Changes to ext/fts3/fts3_unicode.c.

   151    151       }
   152    152     }
   153    153   
   154    154     if( nEntry ){
   155    155       int *aNew;                    /* New aiException[] array */
   156    156       int nNew;                     /* Number of valid entries in array aNew[] */
   157    157   
   158         -    aNew = sqlite3_realloc(p->aiException, (p->nException+nEntry)*sizeof(int));
          158  +    aNew = sqlite3_realloc64(p->aiException,(p->nException+nEntry)*sizeof(int));
   159    159       if( aNew==0 ) return SQLITE_NOMEM;
   160    160       nNew = p->nException;
   161    161   
   162    162       z = (const unsigned char *)zIn;
   163    163       while( z<zTerm ){
   164    164         READ_UTF8(z, zTerm, iCode);
   165    165         if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum 
................................................................................
   340    340   
   341    341     zOut = pCsr->zToken;
   342    342     do {
   343    343       int iOut;
   344    344   
   345    345       /* Grow the output buffer if required. */
   346    346       if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){
   347         -      char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64);
          347  +      char *zNew = sqlite3_realloc64(pCsr->zToken, pCsr->nAlloc+64);
   348    348         if( !zNew ) return SQLITE_NOMEM;
   349    349         zOut = &zNew[zOut - pCsr->zToken];
   350    350         pCsr->zToken = zNew;
   351    351         pCsr->nAlloc += 64;
   352    352       }
   353    353   
   354    354       /* Write the folded case of the last character read to the output */

Changes to ext/fts3/fts3_unicode2.c.

     1      1   /*
     2         -** 2012 May 25
            2  +** 2012-05-25
     3      3   **
     4      4   ** The author disclaims copyright to this source code.  In place of
     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
................................................................................
   174    174       61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914, 
   175    175       61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218, 
   176    176       62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554, 
   177    177       62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766, 
   178    178       62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118, 
   179    179       63182, 63242, 63274, 63310, 63368, 63390, 
   180    180     };
   181         -#define HIBIT ((char)0x80)
   182         -  char aChar[] = {
          181  +#define HIBIT ((unsigned char)0x80)
          182  +  unsigned char aChar[] = {
   183    183       '\0',      'a',       'c',       'e',       'i',       'n',       
   184    184       'o',       'u',       'y',       'y',       'a',       'c',       
   185    185       'd',       'e',       'e',       'g',       'h',       'i',       
   186    186       'j',       'k',       'l',       'n',       'o',       'r',       
   187    187       's',       't',       'u',       'u',       'w',       'y',       
   188    188       'z',       'o',       'u',       'a',       'i',       'o',       
   189    189       'u',       'u'|HIBIT, 'a'|HIBIT, 'g',       'k',       'o',       

Changes to ext/fts3/fts3_write.c.

   563    563   static sqlite3_int64 getAbsoluteLevel(
   564    564     Fts3Table *p,                   /* FTS3 table handle */
   565    565     int iLangid,                    /* Language id */
   566    566     int iIndex,                     /* Index in p->aIndex[] */
   567    567     int iLevel                      /* Level of segments */
   568    568   ){
   569    569     sqlite3_int64 iBase;            /* First absolute level for iLangid/iIndex */
   570         -  assert( iLangid>=0 );
          570  +  assert_fts3_nc( iLangid>=0 );
   571    571     assert( p->nIndex>0 );
   572    572     assert( iIndex>=0 && iIndex<p->nIndex );
   573    573   
   574    574     iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;
   575    575     return iBase + iLevel;
   576    576   }
   577    577   
................................................................................
  1344   1344         return SQLITE_OK;
  1345   1345       }
  1346   1346   
  1347   1347       fts3SegReaderSetEof(pReader);
  1348   1348   
  1349   1349       /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf 
  1350   1350       ** blocks have already been traversed.  */
  1351         -    assert( pReader->iCurrentBlock<=pReader->iLeafEndBlock );
         1351  +#ifdef CORRUPT_DB
         1352  +    assert( pReader->iCurrentBlock<=pReader->iLeafEndBlock || CORRUPT_DB );
         1353  +#endif
  1352   1354       if( pReader->iCurrentBlock>=pReader->iLeafEndBlock ){
  1353   1355         return SQLITE_OK;
  1354   1356       }
  1355   1357   
  1356   1358       rc = sqlite3Fts3ReadBlock(
  1357   1359           p, ++pReader->iCurrentBlock, &pReader->aNode, &pReader->nNode, 
  1358   1360           (bIncr ? &pReader->nPopulate : 0)
................................................................................
  1611   1613   
  1612   1614     assert( zRoot!=0 || nRoot==0 );
  1613   1615   #ifdef CORRUPT_DB
  1614   1616     assert( zRoot!=0 || CORRUPT_DB );
  1615   1617   #endif
  1616   1618   
  1617   1619     if( iStartLeaf==0 ){
         1620  +    if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB;
  1618   1621       nExtra = nRoot + FTS3_NODE_PADDING;
  1619   1622     }
  1620   1623   
  1621   1624     pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);
  1622   1625     if( !pReader ){
  1623   1626       return SQLITE_NOMEM;
  1624   1627     }
................................................................................
  2249   2252       rc = sqlite3_reset(pStmt);
  2250   2253       if( rc!=SQLITE_OK ) return rc;
  2251   2254     }
  2252   2255     nData = pWriter->nData;
  2253   2256   
  2254   2257     nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);
  2255   2258     nSuffix = nTerm-nPrefix;
         2259  +
         2260  +  /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of 
         2261  +  ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when
         2262  +  ** compared with BINARY collation. This indicates corruption.  */
         2263  +  if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
  2256   2264   
  2257   2265     /* Figure out how many bytes are required by this new entry */
  2258   2266     nReq = sqlite3Fts3VarintLen(nPrefix) +    /* varint containing prefix size */
  2259   2267       sqlite3Fts3VarintLen(nSuffix) +         /* varint containing suffix size */
  2260   2268       nSuffix +                               /* Term suffix */
  2261   2269       sqlite3Fts3VarintLen(nDoclist) +        /* Size of doclist */
  2262   2270       nDoclist;                               /* Doclist data */
................................................................................
  2957   2965             ** doclist. */
  2958   2966             sqlite3_int64 iDelta;
  2959   2967             if( p->bDescIdx && nDoclist>0 ){
  2960   2968               iDelta = iPrev - iDocid;
  2961   2969             }else{
  2962   2970               iDelta = iDocid - iPrev;
  2963   2971             }
  2964         -          assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );
         2972  +          if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){
         2973  +            return FTS_CORRUPT_VTAB;
         2974  +          }
  2965   2975             assert( nDoclist>0 || iDelta==iDocid );
  2966   2976   
  2967   2977             nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
  2968   2978             if( nDoclist+nByte>pCsr->nBuffer ){
  2969   2979               char *aNew;
  2970   2980               pCsr->nBuffer = (nDoclist+nByte)*2;
  2971   2981               aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer);
................................................................................
  3223   3233       iNewLevel = getAbsoluteLevel(p, iLangid, iIndex, iLevel+1);
  3224   3234       rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, iLevel+1, &iIdx);
  3225   3235       bIgnoreEmpty = (iLevel!=FTS3_SEGCURSOR_PENDING) && (iNewLevel>iMaxLevel);
  3226   3236     }
  3227   3237     if( rc!=SQLITE_OK ) goto finished;
  3228   3238   
  3229   3239     assert( csr.nSegment>0 );
  3230         -  assert( iNewLevel>=getAbsoluteLevel(p, iLangid, iIndex, 0) );
  3231         -  assert( iNewLevel<getAbsoluteLevel(p, iLangid, iIndex,FTS3_SEGDIR_MAXLEVEL) );
         3240  +  assert_fts3_nc( iNewLevel>=getAbsoluteLevel(p, iLangid, iIndex, 0) );
         3241  +  assert_fts3_nc( 
         3242  +    iNewLevel<getAbsoluteLevel(p, iLangid, iIndex,FTS3_SEGDIR_MAXLEVEL) 
         3243  +  );
  3232   3244   
  3233   3245     memset(&filter, 0, sizeof(Fts3SegFilter));
  3234   3246     filter.flags = FTS3_SEGMENT_REQUIRE_POS;
  3235   3247     filter.flags |= (bIgnoreEmpty ? FTS3_SEGMENT_IGNORE_EMPTY : 0);
  3236   3248   
  3237   3249     rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
  3238   3250     while( SQLITE_OK==rc ){
................................................................................
  3323   3335   */
  3324   3336   static void fts3DecodeIntArray(
  3325   3337     int N,             /* The number of integers to decode */
  3326   3338     u32 *a,            /* Write the integer values */
  3327   3339     const char *zBuf,  /* The BLOB containing the varints */
  3328   3340     int nBuf           /* size of the BLOB */
  3329   3341   ){
  3330         -  int i, j;
  3331         -  UNUSED_PARAMETER(nBuf);
  3332         -  for(i=j=0; i<N; i++){
  3333         -    sqlite3_int64 x;
  3334         -    j += sqlite3Fts3GetVarint(&zBuf[j], &x);
  3335         -    assert(j<=nBuf);
  3336         -    a[i] = (u32)(x & 0xffffffff);
         3342  +  int i = 0;
         3343  +  if( nBuf && (zBuf[nBuf-1]&0x80)==0 ){
         3344  +    int j;
         3345  +    for(i=j=0; i<N && j<nBuf; i++){
         3346  +      sqlite3_int64 x;
         3347  +      j += sqlite3Fts3GetVarint(&zBuf[j], &x);
         3348  +      a[i] = (u32)(x & 0xffffffff);
         3349  +    }
  3337   3350     }
         3351  +  while( i<N ) a[i++] = 0;
  3338   3352   }
  3339   3353   
  3340   3354   /*
  3341   3355   ** Insert the sizes (in tokens) for each column of the document
  3342   3356   ** with docid equal to p->iPrevDocid.  The sizes are encoded as
  3343   3357   ** a blob of varints.
  3344   3358   */
................................................................................
  3736   3750     }else{
  3737   3751       if( bFirst==0 ){
  3738   3752         p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
  3739   3753       }
  3740   3754       p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
  3741   3755   
  3742   3756       if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){
  3743         -      return SQLITE_CORRUPT_VTAB;
         3757  +      return FTS_CORRUPT_VTAB;
  3744   3758       }
  3745   3759       blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
  3746   3760       if( rc==SQLITE_OK ){
  3747   3761         memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
  3748   3762         p->term.n = nPrefix+nSuffix;
  3749   3763         p->iOff += nSuffix;
  3750   3764         if( p->iChild==0 ){
  3751   3765           p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
  3752   3766           if( (p->nNode-p->iOff)<p->nDoclist ){
  3753         -          return SQLITE_CORRUPT_VTAB;
         3767  +          return FTS_CORRUPT_VTAB;
  3754   3768           }
  3755   3769           p->aDoclist = &p->aNode[p->iOff];
  3756   3770           p->iOff += p->nDoclist;
  3757   3771         }
  3758   3772       }
  3759   3773     }
  3760   3774   

Changes to ext/fts3/unicode/mkunicode.tcl.

    59     59       incr i
    60     60   
    61     61       puts -nonewline [format "%5d" [expr ($iCode<<3) + $nRange-1]]
    62     62       puts -nonewline ", "
    63     63     }
    64     64     puts ""
    65     65     puts "  \};"
    66         -  puts "#define HIBIT ((char)0x80)"
    67         -  puts "  char aChar\[\] = \{"
           66  +  puts "#define HIBIT ((unsigned char)0x80)"
           67  +  puts "  unsigned char aChar\[\] = \{"
    68     68     puts -nonewline "    '\\0',      "
    69     69     set i 1
    70     70     foreach c $aChar f $aFlag {
    71     71       if { $f } {
    72     72         set str "'$c'|HIBIT, "
    73     73       } else {
    74     74         set str "'$c',       "
................................................................................
   834    834     puts "\}"
   835    835   }
   836    836   
   837    837   
   838    838   proc print_fileheader {} {
   839    839     puts [string trim {
   840    840   /*
   841         -** 2012 May 25
          841  +** 2012-05-25
   842    842   **
   843    843   ** The author disclaims copyright to this source code.  In place of
   844    844   ** a legal notice, here is a blessing:
   845    845   **
   846    846   **    May you do good and not evil.
   847    847   **    May you find forgiveness for yourself and forgive others.
   848    848   **    May you share freely, never taking more than you give.

Changes to ext/fts5/fts5.h.

   116    116   **   Query for the details of phrase match iIdx within the current row.
   117    117   **   Phrase matches are numbered starting from zero, so the iIdx argument
   118    118   **   should be greater than or equal to zero and smaller than the value
   119    119   **   output by xInstCount().
   120    120   **
   121    121   **   Usually, output parameter *piPhrase is set to the phrase number, *piCol
   122    122   **   to the column in which it occurs and *piOff the token offset of the
   123         -**   first token of the phrase. The exception is if the table was created
   124         -**   with the offsets=0 option specified. In this case *piOff is always
   125         -**   set to -1.
   126         -**
   127         -**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) 
   128         -**   if an error occurs.
          123  +**   first token of the phrase. Returns SQLITE_OK if successful, or an error
          124  +**   code (i.e. SQLITE_NOMEM) if an error occurs.
   129    125   **
   130    126   **   This API can be quite slow if used with an FTS5 table created with the
   131    127   **   "detail=none" or "detail=column" option. 
   132    128   **
   133    129   ** xRowid:
   134    130   **   Returns the rowid of the current row.
   135    131   **
................................................................................
   162    158   **
   163    159   **
   164    160   ** xSetAuxdata(pFts5, pAux, xDelete)
   165    161   **
   166    162   **   Save the pointer passed as the second argument as the extension functions 
   167    163   **   "auxiliary data". The pointer may then be retrieved by the current or any
   168    164   **   future invocation of the same fts5 extension function made as part of
   169         -**   of the same MATCH query using the xGetAuxdata() API.
          165  +**   the same MATCH query using the xGetAuxdata() API.
   170    166   **
   171    167   **   Each extension function is allocated a single auxiliary data slot for
   172    168   **   each FTS query (MATCH expression). If the extension function is invoked 
   173    169   **   more than once for a single FTS query, then all invocations share a 
   174    170   **   single auxiliary data context.
   175    171   **
   176    172   **   If there is already an auxiliary data pointer when this function is
................................................................................
   177    173   **   invoked, then it is replaced by the new pointer. If an xDelete callback
   178    174   **   was specified along with the original pointer, it is invoked at this
   179    175   **   point.
   180    176   **
   181    177   **   The xDelete callback, if one is specified, is also invoked on the
   182    178   **   auxiliary data pointer after the FTS5 query has finished.
   183    179   **
   184         -**   If an error (e.g. an OOM condition) occurs within this function, an
          180  +**   If an error (e.g. an OOM condition) occurs within this function,
   185    181   **   the auxiliary data is set to NULL and an error code returned. If the
   186    182   **   xDelete parameter was not NULL, it is invoked on the auxiliary data
   187    183   **   pointer before returning.
   188    184   **
   189    185   **
   190    186   ** xGetAuxdata(pFts5, bClear)
   191    187   **

Changes to ext/fts5/fts5Int.h.

    83     83   #ifdef SQLITE_DEBUG
    84     84   extern int sqlite3_fts5_may_be_corrupt;
    85     85   # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))
    86     86   #else
    87     87   # define assert_nc(x) assert(x)
    88     88   #endif
    89     89   
           90  +/*
           91  +** A version of memcmp() that does not cause asan errors if one of the pointer
           92  +** parameters is NULL and the number of bytes to compare is zero.
           93  +*/
           94  +#define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n)))
           95  +
    90     96   /* Mark a function parameter as unused, to suppress nuisance compiler
    91     97   ** warnings. */
    92     98   #ifndef UNUSED_PARAM
    93     99   # define UNUSED_PARAM(X)  (void)(X)
    94    100   #endif
    95    101   
    96    102   #ifndef UNUSED_PARAM2
................................................................................
   270    276   )
   271    277   
   272    278   /* Write and decode big-endian 32-bit integer values */
   273    279   void sqlite3Fts5Put32(u8*, int);
   274    280   int sqlite3Fts5Get32(const u8*);
   275    281   
   276    282   #define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)
   277         -#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF)
          283  +#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0x7FFFFFFF)
   278    284   
   279    285   typedef struct Fts5PoslistReader Fts5PoslistReader;
   280    286   struct Fts5PoslistReader {
   281    287     /* Variables used only by sqlite3Fts5PoslistIterXXX() functions. */
   282    288     const u8 *a;                    /* Position list to iterate through */
   283    289     int n;                          /* Size of buffer at a[] in bytes */
   284    290     int i;                          /* Current offset in a[] */
................................................................................
   305    311   int sqlite3Fts5PoslistNext64(
   306    312     const u8 *a, int n,             /* Buffer containing poslist */
   307    313     int *pi,                        /* IN/OUT: Offset within a[] */
   308    314     i64 *piOff                      /* IN/OUT: Current offset */
   309    315   );
   310    316   
   311    317   /* Malloc utility */
   312         -void *sqlite3Fts5MallocZero(int *pRc, int nByte);
          318  +void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte);
   313    319   char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);
   314    320   
   315    321   /* Character set tests (like isspace(), isalpha() etc.) */
   316    322   int sqlite3Fts5IsBareword(char t);
   317    323   
   318    324   
   319    325   /* Bucket of terms object used by the integrity-check in offsets=0 mode. */
................................................................................
   516    522   
   517    523   /*
   518    524   ** End of interface to code in fts5_varint.c.
   519    525   **************************************************************************/
   520    526   
   521    527   
   522    528   /**************************************************************************
   523         -** Interface to code in fts5.c. 
          529  +** Interface to code in fts5_main.c. 
          530  +*/
          531  +
          532  +/*
          533  +** Virtual-table object.
   524    534   */
          535  +typedef struct Fts5Table Fts5Table;
          536  +struct Fts5Table {
          537  +  sqlite3_vtab base;              /* Base class used by SQLite core */
          538  +  Fts5Config *pConfig;            /* Virtual table configuration */
          539  +  Fts5Index *pIndex;              /* Full-text index */
          540  +};
   525    541   
   526    542   int sqlite3Fts5GetTokenizer(
   527    543     Fts5Global*, 
   528    544     const char **azArg,
   529    545     int nArg,
   530    546     Fts5Tokenizer**,
   531    547     fts5_tokenizer**,
   532    548     char **pzErr
   533    549   );
   534    550   
   535         -Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **);
          551  +Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64);
          552  +
          553  +int sqlite3Fts5FlushToDisk(Fts5Table*);
   536    554   
   537    555   /*
   538    556   ** End of interface to code in fts5.c.
   539    557   **************************************************************************/
   540    558   
   541    559   /**************************************************************************
   542    560   ** Interface to code in fts5_hash.c. 

Changes to ext/fts5/fts5_aux.c.

   132    132   ** *pRc is set to an error code before returning. 
   133    133   */
   134    134   static void fts5HighlightAppend(
   135    135     int *pRc, 
   136    136     HighlightContext *p, 
   137    137     const char *z, int n
   138    138   ){
   139         -  if( *pRc==SQLITE_OK ){
          139  +  if( *pRc==SQLITE_OK && z ){
   140    140       if( n<0 ) n = (int)strlen(z);
   141    141       p->zOut = sqlite3_mprintf("%z%.*s", p->zOut, n, z);
   142    142       if( p->zOut==0 ) *pRc = SQLITE_NOMEM;
   143    143     }
   144    144   }
   145    145   
   146    146   /*
................................................................................
   264    264   ** error occurs.
   265    265   */
   266    266   static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){
   267    267     if( p->nFirstAlloc==p->nFirst ){
   268    268       int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;
   269    269       int *aNew;
   270    270   
   271         -    aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));
          271  +    aNew = (int*)sqlite3_realloc64(p->aFirst, nNew*sizeof(int));
   272    272       if( aNew==0 ) return SQLITE_NOMEM;
   273    273       p->aFirst = aNew;
   274    274       p->nFirstAlloc = nNew;
   275    275     }
   276    276     p->aFirst[p->nFirst++] = iAdd;
   277    277     return SQLITE_OK;
   278    278   }
................................................................................
   331    331     int ip = 0;
   332    332     int ic = 0;
   333    333     int iOff = 0;
   334    334     int iFirst = -1;
   335    335     int nInst;
   336    336     int nScore = 0;
   337    337     int iLast = 0;
          338  +  sqlite3_int64 iEnd = (sqlite3_int64)iPos + nToken;
   338    339   
   339    340     rc = pApi->xInstCount(pFts, &nInst);
   340    341     for(i=0; i<nInst && rc==SQLITE_OK; i++){
   341    342       rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);
   342         -    if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){
          343  +    if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<iEnd ){
   343    344         nScore += (aSeen[ip] ? 1 : 1000);
   344    345         aSeen[ip] = 1;
   345    346         if( iFirst<0 ) iFirst = iOff;
   346    347         iLast = iOff + pApi->xPhraseSize(pFts, ip);
   347    348       }
   348    349     }
   349    350   
   350    351     *pnScore = nScore;
   351    352     if( piPos ){
   352         -    int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
          353  +    sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
   353    354       if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
   354    355       if( iAdj<0 ) iAdj = 0;
   355    356       *piPos = iAdj;
   356    357     }
   357    358   
   358    359     return rc;
   359    360   }
................................................................................
   438    439         for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){
   439    440           int ip, ic, io;
   440    441           int iAdj;
   441    442           int nScore;
   442    443           int jj;
   443    444   
   444    445           rc = pApi->xInst(pFts, ii, &ip, &ic, &io);
   445         -        if( ic!=i || rc!=SQLITE_OK ) continue;
          446  +        if( ic!=i ) continue;
          447  +        if( io>nDocsize ) rc = FTS5_CORRUPT;
          448  +        if( rc!=SQLITE_OK ) continue;
   446    449           memset(aSeen, 0, nPhrase);
   447    450           rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
   448    451               io, nToken, &nScore, &iAdj
   449    452           );
   450    453           if( rc==SQLITE_OK && nScore>nBestScore ){
   451    454             nBestScore = nScore;
   452    455             iBestCol = i;
................................................................................
   564    567     Fts5Bm25Data *p;                /* Object to return */
   565    568   
   566    569     p = pApi->xGetAuxdata(pFts, 0);
   567    570     if( p==0 ){
   568    571       int nPhrase;                  /* Number of phrases in query */
   569    572       sqlite3_int64 nRow = 0;       /* Number of rows in table */
   570    573       sqlite3_int64 nToken = 0;     /* Number of tokens in table */
   571         -    int nByte;                    /* Bytes of space to allocate */
          574  +    sqlite3_int64 nByte;          /* Bytes of space to allocate */
   572    575       int i;
   573    576   
   574    577       /* Allocate the Fts5Bm25Data object */
   575    578       nPhrase = pApi->xPhraseCount(pFts);
   576    579       nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
   577         -    p = (Fts5Bm25Data*)sqlite3_malloc(nByte);
          580  +    p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
   578    581       if( p==0 ){
   579    582         rc = SQLITE_NOMEM;
   580    583       }else{
   581    584         memset(p, 0, nByte);
   582    585         p->nPhrase = nPhrase;
   583    586         p->aIDF = (double*)&p[1];
   584    587         p->aFreq = &p->aIDF[nPhrase];
   585    588       }
   586    589   
   587    590       /* Calculate the average document length for this FTS5 table */
   588    591       if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);
          592  +    assert( rc!=SQLITE_OK || nRow>0 );
   589    593       if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);
   590    594       if( rc==SQLITE_OK ) p->avgdl = (double)nToken  / (double)nRow;
   591    595   
   592    596       /* Calculate an IDF for each phrase in the query */
   593    597       for(i=0; rc==SQLITE_OK && i<nPhrase; i++){
   594    598         sqlite3_int64 nHit = 0;
   595    599         rc = pApi->xQueryPhrase(pFts, i, (void*)&nHit, fts5CountCb);
................................................................................
   706    710           aBuiltin[i].xFunc,
   707    711           aBuiltin[i].xDestroy
   708    712       );
   709    713     }
   710    714   
   711    715     return rc;
   712    716   }
   713         -
   714         -

Changes to ext/fts5/fts5_buffer.c.

    13     13   
    14     14   
    15     15   
    16     16   #include "fts5Int.h"
    17     17   
    18     18   int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){
    19     19     if( (u32)pBuf->nSpace<nByte ){
    20         -    u32 nNew = pBuf->nSpace ? pBuf->nSpace : 64;
           20  +    u64 nNew = pBuf->nSpace ? pBuf->nSpace : 64;
    21     21       u8 *pNew;
    22     22       while( nNew<nByte ){
    23     23         nNew = nNew * 2;
    24     24       }
    25         -    pNew = sqlite3_realloc(pBuf->p, nNew);
           25  +    pNew = sqlite3_realloc64(pBuf->p, nNew);
    26     26       if( pNew==0 ){
    27     27         *pRc = SQLITE_NOMEM;
    28     28         return 1;
    29     29       }else{
    30     30         pBuf->nSpace = nNew;
    31     31         pBuf->p = pNew;
    32     32       }
................................................................................
    48     48     aBuf[0] = (iVal>>24) & 0x00FF;
    49     49     aBuf[1] = (iVal>>16) & 0x00FF;
    50     50     aBuf[2] = (iVal>> 8) & 0x00FF;
    51     51     aBuf[3] = (iVal>> 0) & 0x00FF;
    52     52   }
    53     53   
    54     54   int sqlite3Fts5Get32(const u8 *aBuf){
    55         -  return (aBuf[0] << 24) + (aBuf[1] << 16) + (aBuf[2] << 8) + aBuf[3];
           55  +  return (int)((((u32)aBuf[0])<<24) + (aBuf[1]<<16) + (aBuf[2]<<8) + aBuf[3]);
    56     56   }
    57     57   
    58     58   /*
    59     59   ** Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set 
    60     60   ** the error code in p. If an error has already occurred when this function
    61     61   ** is called, it is a no-op.
    62     62   */
................................................................................
   179    179       int iVal;
   180    180       fts5FastGetVarint32(a, i, iVal);
   181    181       if( iVal==1 ){
   182    182         fts5FastGetVarint32(a, i, iVal);
   183    183         iOff = ((i64)iVal) << 32;
   184    184         fts5FastGetVarint32(a, i, iVal);
   185    185       }
   186         -    *piOff = iOff + (iVal-2);
          186  +    *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
   187    187       *pi = i;
   188    188       return 0;
   189    189     }
   190    190   }
   191    191   
   192    192   
   193    193   /*
................................................................................
   240    240   ){
   241    241     int rc = 0;   /* Initialized only to suppress erroneous warning from Clang */
   242    242     if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;
   243    243     sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);
   244    244     return SQLITE_OK;
   245    245   }
   246    246   
   247         -void *sqlite3Fts5MallocZero(int *pRc, int nByte){
          247  +void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte){
   248    248     void *pRet = 0;
   249    249     if( *pRc==SQLITE_OK ){
   250         -    pRet = sqlite3_malloc(nByte);
          250  +    pRet = sqlite3_malloc64(nByte);
   251    251       if( pRet==0 ){
   252    252         if( nByte>0 ) *pRc = SQLITE_NOMEM;
   253    253       }else{
   254    254         memset(pRet, 0, nByte);
   255    255       }
   256    256     }
   257    257     return pRet;

Changes to ext/fts5/fts5_config.c.

   291    291       }
   292    292       assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES );
   293    293       return rc;
   294    294     }
   295    295   
   296    296     if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){
   297    297       const char *p = (const char*)zArg;
   298         -    int nArg = (int)strlen(zArg) + 1;
          298  +    sqlite3_int64 nArg = strlen(zArg) + 1;
   299    299       char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);
   300    300       char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);
   301    301       char *pSpace = pDel;
   302    302   
   303    303       if( azArg && pSpace ){
   304    304         if( pConfig->pTok ){
   305    305           *pzErr = sqlite3_mprintf("multiple tokenize=... directives");
................................................................................
   421    421     int *pRc,                       /* IN/OUT: Error code */
   422    422     const char *zIn,                /* Buffer to gobble string/bareword from */
   423    423     char **pzOut,                   /* OUT: malloc'd buffer containing str/bw */
   424    424     int *pbQuoted                   /* OUT: Set to true if dequoting required */
   425    425   ){
   426    426     const char *zRet = 0;
   427    427   
   428         -  int nIn = (int)strlen(zIn);
   429         -  char *zOut = sqlite3_malloc(nIn+1);
          428  +  sqlite3_int64 nIn = strlen(zIn);
          429  +  char *zOut = sqlite3_malloc64(nIn+1);
   430    430   
   431    431     assert( *pRc==SQLITE_OK );
   432    432     *pbQuoted = 0;
   433    433     *pzOut = 0;
   434    434   
   435    435     if( zOut==0 ){
   436    436       *pRc = SQLITE_NOMEM;
................................................................................
   525    525     const char **azArg,             /* Array of nArg CREATE VIRTUAL TABLE args */
   526    526     Fts5Config **ppOut,             /* OUT: Results of parse */
   527    527     char **pzErr                    /* OUT: Error message */
   528    528   ){
   529    529     int rc = SQLITE_OK;             /* Return code */
   530    530     Fts5Config *pRet;               /* New object to return */
   531    531     int i;
   532         -  int nByte;
          532  +  sqlite3_int64 nByte;
   533    533   
   534    534     *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));
   535    535     if( pRet==0 ) return SQLITE_NOMEM;
   536    536     memset(pRet, 0, sizeof(Fts5Config));
   537    537     pRet->db = db;
   538    538     pRet->iCookie = -1;
   539    539   

Changes to ext/fts5/fts5_expr.c.

   207    207       }
   208    208     }
   209    209   
   210    210     *pz = &pToken->p[pToken->n];
   211    211     return tok;
   212    212   }
   213    213   
   214         -static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); }
          214  +static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc64((sqlite3_int64)t);}
   215    215   static void fts5ParseFree(void *p){ sqlite3_free(p); }
   216    216   
   217    217   int sqlite3Fts5ExprNew(
   218    218     Fts5Config *pConfig,            /* FTS5 Configuration */
   219    219     int iCol,
   220    220     const char *zExpr,              /* Expression text */
   221    221     Fts5Expr **ppNew, 
................................................................................
   352    352   
   353    353     assert( pTerm->pSynonym );
   354    354     for(p=pTerm; p; p=p->pSynonym){
   355    355       Fts5IndexIter *pIter = p->pIter;
   356    356       if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){
   357    357         if( pIter->nData==0 ) continue;
   358    358         if( nIter==nAlloc ){
   359         -        int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;
   360         -        Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte);
          359  +        sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;
          360  +        Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc64(nByte);
   361    361           if( aNew==0 ){
   362    362             rc = SQLITE_NOMEM;
   363    363             goto synonym_poslist_out;
   364    364           }
   365    365           memcpy(aNew, aIter, sizeof(Fts5PoslistReader) * nIter);
   366    366           nAlloc = nAlloc*2;
   367    367           if( aIter!=aStatic ) sqlite3_free(aIter);
................................................................................
   433    433     int bFirst = pPhrase->aTerm[0].bFirst;
   434    434     
   435    435     fts5BufferZero(&pPhrase->poslist);
   436    436   
   437    437     /* If the aStatic[] array is not large enough, allocate a large array
   438    438     ** using sqlite3_malloc(). This approach could be improved upon. */
   439    439     if( pPhrase->nTerm>ArraySize(aStatic) ){
   440         -    int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;
   441         -    aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte);
          440  +    sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;
          441  +    aIter = (Fts5PoslistReader*)sqlite3_malloc64(nByte);
   442    442       if( !aIter ) return SQLITE_NOMEM;
   443    443     }
   444    444     memset(aIter, 0, sizeof(Fts5PoslistReader) * pPhrase->nTerm);
   445    445   
   446    446     /* Initialize a term iterator for each term in the phrase */
   447    447     for(i=0; i<pPhrase->nTerm; i++){
   448    448       Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];
................................................................................
   568    568     int bMatch;
   569    569   
   570    570     assert( pNear->nPhrase>1 );
   571    571   
   572    572     /* If the aStatic[] array is not large enough, allocate a large array
   573    573     ** using sqlite3_malloc(). This approach could be improved upon. */
   574    574     if( pNear->nPhrase>ArraySize(aStatic) ){
   575         -    int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;
          575  +    sqlite3_int64 nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;
   576    576       a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);
   577    577     }else{
   578    578       memset(aStatic, 0, sizeof(aStatic));
   579    579     }
   580    580     if( rc!=SQLITE_OK ){
   581    581       *pRc = rc;
   582    582       return 0;
................................................................................
  1477   1477     Fts5ExprNearset *pRet = 0;
  1478   1478   
  1479   1479     if( pParse->rc==SQLITE_OK ){
  1480   1480       if( pPhrase==0 ){
  1481   1481         return pNear;
  1482   1482       }
  1483   1483       if( pNear==0 ){
  1484         -      int nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
  1485         -      pRet = sqlite3_malloc(nByte);
         1484  +      sqlite3_int64 nByte;
         1485  +      nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
         1486  +      pRet = sqlite3_malloc64(nByte);
  1486   1487         if( pRet==0 ){
  1487   1488           pParse->rc = SQLITE_NOMEM;
  1488   1489         }else{
  1489   1490           memset(pRet, 0, nByte);
  1490   1491         }
  1491   1492       }else if( (pNear->nPhrase % SZALLOC)==0 ){
  1492   1493         int nNew = pNear->nPhrase + SZALLOC;
  1493         -      int nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);
         1494  +      sqlite3_int64 nByte;
  1494   1495   
  1495         -      pRet = (Fts5ExprNearset*)sqlite3_realloc(pNear, nByte);
         1496  +      nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);
         1497  +      pRet = (Fts5ExprNearset*)sqlite3_realloc64(pNear, nByte);
  1496   1498         if( pRet==0 ){
  1497   1499           pParse->rc = SQLITE_NOMEM;
  1498   1500         }
  1499   1501       }else{
  1500   1502         pRet = pNear;
  1501   1503       }
  1502   1504     }
................................................................................
  1552   1554   
  1553   1555     /* If an error has already occurred, this is a no-op */
  1554   1556     if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;
  1555   1557     if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;
  1556   1558   
  1557   1559     if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){
  1558   1560       Fts5ExprTerm *pSyn;
  1559         -    int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
  1560         -    pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte);
         1561  +    sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
         1562  +    pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);
  1561   1563       if( pSyn==0 ){
  1562   1564         rc = SQLITE_NOMEM;
  1563   1565       }else{
  1564   1566         memset(pSyn, 0, nByte);
  1565   1567         pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);
  1566   1568         memcpy(pSyn->zTerm, pToken, nToken);
  1567   1569         pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;
................................................................................
  1569   1571       }
  1570   1572     }else{
  1571   1573       Fts5ExprTerm *pTerm;
  1572   1574       if( pPhrase==0 || (pPhrase->nTerm % SZALLOC)==0 ){
  1573   1575         Fts5ExprPhrase *pNew;
  1574   1576         int nNew = SZALLOC + (pPhrase ? pPhrase->nTerm : 0);
  1575   1577   
  1576         -      pNew = (Fts5ExprPhrase*)sqlite3_realloc(pPhrase, 
         1578  +      pNew = (Fts5ExprPhrase*)sqlite3_realloc64(pPhrase, 
  1577   1579             sizeof(Fts5ExprPhrase) + sizeof(Fts5ExprTerm) * nNew
  1578   1580         );
  1579   1581         if( pNew==0 ){
  1580   1582           rc = SQLITE_NOMEM;
  1581   1583         }else{
  1582   1584           if( pPhrase==0 ) memset(pNew, 0, sizeof(Fts5ExprPhrase));
  1583   1585           pCtx->pPhrase = pPhrase = pNew;
................................................................................
  1655   1657       pParse->rc = rc;
  1656   1658       fts5ExprPhraseFree(sCtx.pPhrase);
  1657   1659       sCtx.pPhrase = 0;
  1658   1660     }else{
  1659   1661   
  1660   1662       if( pAppend==0 ){
  1661   1663         if( (pParse->nPhrase % 8)==0 ){
  1662         -        int nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);
         1664  +        sqlite3_int64 nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);
  1663   1665           Fts5ExprPhrase **apNew;
  1664         -        apNew = (Fts5ExprPhrase**)sqlite3_realloc(pParse->apPhrase, nByte);
         1666  +        apNew = (Fts5ExprPhrase**)sqlite3_realloc64(pParse->apPhrase, nByte);
  1665   1667           if( apNew==0 ){
  1666   1668             pParse->rc = SQLITE_NOMEM;
  1667   1669             fts5ExprPhraseFree(sCtx.pPhrase);
  1668   1670             return 0;
  1669   1671           }
  1670   1672           pParse->apPhrase = apNew;
  1671   1673         }
................................................................................
  1712   1714     if( rc==SQLITE_OK ){
  1713   1715       pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, 
  1714   1716           sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*));
  1715   1717     }
  1716   1718     if( rc==SQLITE_OK ){
  1717   1719       Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset;
  1718   1720       if( pColsetOrig ){
  1719         -      int nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
  1720         -      Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
         1721  +      sqlite3_int64 nByte;
         1722  +      Fts5Colset *pColset;
         1723  +      nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
         1724  +      pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
  1721   1725         if( pColset ){ 
  1722   1726           memcpy(pColset, pColsetOrig, nByte);
  1723   1727         }
  1724   1728         pNew->pRoot->pNear->pColset = pColset;
  1725   1729       }
  1726   1730     }
  1727   1731   
................................................................................
  1833   1837   ){
  1834   1838     int nCol = p ? p->nCol : 0;     /* Num. columns already in colset object */
  1835   1839     Fts5Colset *pNew;               /* New colset object to return */
  1836   1840   
  1837   1841     assert( pParse->rc==SQLITE_OK );
  1838   1842     assert( iCol>=0 && iCol<pParse->pConfig->nCol );
  1839   1843   
  1840         -  pNew = sqlite3_realloc(p, sizeof(Fts5Colset) + sizeof(int)*nCol);
         1844  +  pNew = sqlite3_realloc64(p, sizeof(Fts5Colset) + sizeof(int)*nCol);
  1841   1845     if( pNew==0 ){
  1842   1846       pParse->rc = SQLITE_NOMEM;
  1843   1847     }else{
  1844   1848       int *aiCol = pNew->aiCol;
  1845   1849       int i, j;
  1846   1850       for(i=0; i<nCol; i++){
  1847   1851         if( aiCol[i]==iCol ) return pNew;
................................................................................
  1929   1933   ** Otherwise, a copy of (*pOrig) is made into memory obtained from
  1930   1934   ** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation
  1931   1935   ** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned.
  1932   1936   */
  1933   1937   static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){
  1934   1938     Fts5Colset *pRet;
  1935   1939     if( pOrig ){
  1936         -    int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
         1940  +    sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
  1937   1941       pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);
  1938   1942       if( pRet ){ 
  1939   1943         memcpy(pRet, pOrig, nByte);
  1940   1944       }
  1941   1945     }else{
  1942   1946       pRet = 0;
  1943   1947     }
................................................................................
  2083   2087     Fts5ExprNode *pRight,           /* Right hand child expression */
  2084   2088     Fts5ExprNearset *pNear          /* For STRING expressions, the near cluster */
  2085   2089   ){
  2086   2090     Fts5ExprNode *pRet = 0;
  2087   2091   
  2088   2092     if( pParse->rc==SQLITE_OK ){
  2089   2093       int nChild = 0;               /* Number of children of returned node */
  2090         -    int nByte;                    /* Bytes of space to allocate for this node */
         2094  +    sqlite3_int64 nByte;          /* Bytes of space to allocate for this node */
  2091   2095    
  2092   2096       assert( (eType!=FTS5_STRING && !pNear)
  2093   2097            || (eType==FTS5_STRING && !pLeft && !pRight)
  2094   2098       );
  2095   2099       if( eType==FTS5_STRING && pNear==0 ) return 0;
  2096   2100       if( eType!=FTS5_STRING && pLeft==0 ) return pRight;
  2097   2101       if( eType!=FTS5_STRING && pRight==0 ) return pLeft;
................................................................................
  2215   2219       }
  2216   2220     }
  2217   2221   
  2218   2222     return pRet;
  2219   2223   }
  2220   2224   
  2221   2225   static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
  2222         -  int nByte = 0;
         2226  +  sqlite3_int64 nByte = 0;
  2223   2227     Fts5ExprTerm *p;
  2224   2228     char *zQuoted;
  2225   2229   
  2226   2230     /* Determine the maximum amount of space required. */
  2227   2231     for(p=pTerm; p; p=p->pSynonym){
  2228   2232       nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2;
  2229   2233     }
  2230         -  zQuoted = sqlite3_malloc(nByte);
         2234  +  zQuoted = sqlite3_malloc64(nByte);
  2231   2235   
  2232   2236     if( zQuoted ){
  2233   2237       int i = 0;
  2234   2238       for(p=pTerm; p; p=p->pSynonym){
  2235   2239         char *zIn = p->zTerm;
  2236   2240         zQuoted[i++] = '"';
  2237   2241         while( *zIn ){
................................................................................
  2463   2467   
  2464   2468     if( bTcl && nArg>1 ){
  2465   2469       zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]);
  2466   2470       iArg = 2;
  2467   2471     }
  2468   2472   
  2469   2473     nConfig = 3 + (nArg-iArg);
  2470         -  azConfig = (const char**)sqlite3_malloc(sizeof(char*) * nConfig);
         2474  +  azConfig = (const char**)sqlite3_malloc64(sizeof(char*) * nConfig);
  2471   2475     if( azConfig==0 ){
  2472   2476       sqlite3_result_error_nomem(pCtx);
  2473   2477       return;
  2474   2478     }
  2475   2479     azConfig[0] = 0;
  2476   2480     azConfig[1] = "main";
  2477   2481     azConfig[2] = "tbl";
................................................................................
  2644   2648     Fts5PoslistWriter writer;
  2645   2649     int bOk;                        /* True if ok to populate */
  2646   2650     int bMiss;
  2647   2651   };
  2648   2652   
  2649   2653   Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){
  2650   2654     Fts5PoslistPopulator *pRet;
  2651         -  pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
         2655  +  pRet = sqlite3_malloc64(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
  2652   2656     if( pRet ){
  2653   2657       int i;
  2654   2658       memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
  2655   2659       for(i=0; i<pExpr->nPhrase; i++){
  2656   2660         Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist;
  2657   2661         Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;
  2658   2662         assert( pExpr->apExprPhrase[i]->nTerm==1 );
................................................................................
  2843   2847     }else{
  2844   2848       *ppCollist = 0;
  2845   2849       *pnCollist = 0;
  2846   2850     }
  2847   2851   
  2848   2852     return rc;
  2849   2853   }
  2850         -

Changes to ext/fts5/fts5_hash.c.

    86     86     int rc = SQLITE_OK;
    87     87     Fts5Hash *pNew;
    88     88   
    89     89     *ppNew = pNew = (Fts5Hash*)sqlite3_malloc(sizeof(Fts5Hash));
    90     90     if( pNew==0 ){
    91     91       rc = SQLITE_NOMEM;
    92     92     }else{
    93         -    int nByte;
           93  +    sqlite3_int64 nByte;
    94     94       memset(pNew, 0, sizeof(Fts5Hash));
    95     95       pNew->pnByte = pnByte;
    96     96       pNew->eDetail = pConfig->eDetail;
    97     97   
    98     98       pNew->nSlot = 1024;
    99     99       nByte = sizeof(Fts5HashEntry*) * pNew->nSlot;
   100         -    pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc(nByte);
          100  +    pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc64(nByte);
   101    101       if( pNew->aSlot==0 ){
   102    102         sqlite3_free(pNew);
   103    103         *ppNew = 0;
   104    104         rc = SQLITE_NOMEM;
   105    105       }else{
   106    106         memset(pNew->aSlot, 0, nByte);
   107    107       }
................................................................................
   161    161   */
   162    162   static int fts5HashResize(Fts5Hash *pHash){
   163    163     int nNew = pHash->nSlot*2;
   164    164     int i;
   165    165     Fts5HashEntry **apNew;
   166    166     Fts5HashEntry **apOld = pHash->aSlot;
   167    167   
   168         -  apNew = (Fts5HashEntry**)sqlite3_malloc(nNew*sizeof(Fts5HashEntry*));
          168  +  apNew = (Fts5HashEntry**)sqlite3_malloc64(nNew*sizeof(Fts5HashEntry*));
   169    169     if( !apNew ) return SQLITE_NOMEM;
   170    170     memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
   171    171   
   172    172     for(i=0; i<pHash->nSlot; i++){
   173    173       while( apOld[i] ){
   174    174         unsigned int iHash;
   175    175         Fts5HashEntry *p = apOld[i];
................................................................................
   255    255       }
   256    256     }
   257    257   
   258    258     /* If an existing hash entry cannot be found, create a new one. */
   259    259     if( p==0 ){
   260    260       /* Figure out how much space to allocate */
   261    261       char *zKey;
   262         -    int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
          262  +    sqlite3_int64 nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
   263    263       if( nByte<128 ) nByte = 128;
   264    264   
   265    265       /* Grow the Fts5Hash.aSlot[] array if necessary. */
   266    266       if( (pHash->nEntry*2)>=pHash->nSlot ){
   267    267         int rc = fts5HashResize(pHash);
   268    268         if( rc!=SQLITE_OK ) return rc;
   269    269         iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);
   270    270       }
   271    271   
   272    272       /* Allocate new Fts5HashEntry and add it to the hash table. */
   273         -    p = (Fts5HashEntry*)sqlite3_malloc(nByte);
          273  +    p = (Fts5HashEntry*)sqlite3_malloc64(nByte);
   274    274       if( !p ) return SQLITE_NOMEM;
   275    275       memset(p, 0, sizeof(Fts5HashEntry));
   276    276       p->nAlloc = nByte;
   277    277       zKey = fts5EntryKey(p);
   278    278       zKey[0] = bByte;
   279    279       memcpy(&zKey[1], pToken, nToken);
   280    280       assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
................................................................................
   305    305       **     + 9 bytes for a new rowid,
   306    306       **     + 4 byte reserved for the "poslist size" varint.
   307    307       **     + 1 byte for a "new column" byte,
   308    308       **     + 3 bytes for a new column number (16-bit max) as a varint,
   309    309       **     + 5 bytes for the new position offset (32-bit max).
   310    310       */
   311    311       if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){
   312         -      int nNew = p->nAlloc * 2;
          312  +      sqlite3_int64 nNew = p->nAlloc * 2;
   313    313         Fts5HashEntry *pNew;
   314    314         Fts5HashEntry **pp;
   315         -      pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew);
          315  +      pNew = (Fts5HashEntry*)sqlite3_realloc64(p, nNew);
   316    316         if( pNew==0 ) return SQLITE_NOMEM;
   317         -      pNew->nAlloc = nNew;
          317  +      pNew->nAlloc = (int)nNew;
   318    318         for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext);
   319    319         *pp = pNew;
   320    320         p = pNew;
   321    321       }
   322    322       nIncr -= p->nData;
   323    323     }
   324    324     assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) );
................................................................................
   434    434     const int nMergeSlot = 32;
   435    435     Fts5HashEntry **ap;
   436    436     Fts5HashEntry *pList;
   437    437     int iSlot;
   438    438     int i;
   439    439   
   440    440     *ppSorted = 0;
   441         -  ap = sqlite3_malloc(sizeof(Fts5HashEntry*) * nMergeSlot);
          441  +  ap = sqlite3_malloc64(sizeof(Fts5HashEntry*) * nMergeSlot);
   442    442     if( !ap ) return SQLITE_NOMEM;
   443    443     memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
   444    444   
   445    445     for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
   446    446       Fts5HashEntry *pIter;
   447    447       for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
   448    448         if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
................................................................................
   479    479   ){
   480    480     unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
   481    481     char *zKey = 0;
   482    482     Fts5HashEntry *p;
   483    483   
   484    484     for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
   485    485       zKey = fts5EntryKey(p);
   486         -    if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
          486  +    assert( p->nKey+1==(int)strlen(zKey) );
          487  +    if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;
   487    488     }
   488    489   
   489    490     if( p ){
   490    491       fts5HashAddPoslistSize(pHash, p);
   491    492       *ppDoclist = (const u8*)&zKey[nTerm+1];
   492    493       *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
   493    494     }else{
................................................................................
   530    531       *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
   531    532     }else{
   532    533       *pzTerm = 0;
   533    534       *ppDoclist = 0;
   534    535       *pnDoclist = 0;
   535    536     }
   536    537   }
   537         -

Changes to ext/fts5/fts5_index.c.

   508    508   **   Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered.
   509    509   **   There is no way to tell if this is populated or not.
   510    510   */
   511    511   struct Fts5Iter {
   512    512     Fts5IndexIter base;             /* Base class containing output vars */
   513    513   
   514    514     Fts5Index *pIndex;              /* Index that owns this iterator */
   515         -  Fts5Structure *pStruct;         /* Database structure for this iterator */
   516    515     Fts5Buffer poslist;             /* Buffer containing current poslist */
   517    516     Fts5Colset *pColset;            /* Restrict matches to these columns */
   518    517   
   519    518     /* Invoked to set output variables. */
   520    519     void (*xSetOutputs)(Fts5Iter*, Fts5SegIter*);
   521    520   
   522    521     int nSeg;                       /* Size of aSeg[] array */
................................................................................
   569    568   
   570    569   /*
   571    570   ** Allocate and return a buffer at least nByte bytes in size.
   572    571   **
   573    572   ** If an OOM error is encountered, return NULL and set the error code in
   574    573   ** the Fts5Index handle passed as the first argument.
   575    574   */
   576         -static void *fts5IdxMalloc(Fts5Index *p, int nByte){
          575  +static void *fts5IdxMalloc(Fts5Index *p, sqlite3_int64 nByte){
   577    576     return sqlite3Fts5MallocZero(&p->rc, nByte);
   578    577   }
   579    578   
   580    579   /*
   581    580   ** Compare the contents of the pLeft buffer with the pRight/nRight blob.
   582    581   **
   583    582   ** Return -ve if pLeft is smaller than pRight, 0 if they are equal or
................................................................................
   603    602   ** Return -ve if pLeft is smaller than pRight, 0 if they are equal or
   604    603   ** +ve if pRight is smaller than pLeft. In other words:
   605    604   **
   606    605   **     res = *pLeft - *pRight
   607    606   */
   608    607   static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){
   609    608     int nCmp = MIN(pLeft->n, pRight->n);
   610         -  int res = memcmp(pLeft->p, pRight->p, nCmp);
          609  +  int res = fts5Memcmp(pLeft->p, pRight->p, nCmp);
   611    610     return (res==0 ? (pLeft->n - pRight->n) : res);
   612    611   }
   613    612   
   614    613   static int fts5LeafFirstTermOff(Fts5Data *pLeaf){
   615    614     int ret;
   616    615     fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);
   617    616     return ret;
................................................................................
   669    668       ** table, missing row, non-blob/text in block column - indicate 
   670    669       ** backing store corruption.  */
   671    670       if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT;
   672    671   
   673    672       if( rc==SQLITE_OK ){
   674    673         u8 *aOut = 0;               /* Read blob data into this buffer */
   675    674         int nByte = sqlite3_blob_bytes(p->pReader);
   676         -      int nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;
   677         -      pRet = (Fts5Data*)sqlite3_malloc(nAlloc);
          675  +      sqlite3_int64 nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;
          676  +      pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);
   678    677         if( pRet ){
   679    678           pRet->nn = nByte;
   680    679           aOut = pRet->p = (u8*)&pRet[1];
   681    680         }else{
   682    681           rc = SQLITE_NOMEM;
   683    682         }
   684    683   
................................................................................
   845    844     Fts5Structure **ppOut           /* OUT: Deserialized object */
   846    845   ){
   847    846     int rc = SQLITE_OK;
   848    847     int i = 0;
   849    848     int iLvl;
   850    849     int nLevel = 0;
   851    850     int nSegment = 0;
   852         -  int nByte;                      /* Bytes of space to allocate at pRet */
          851  +  sqlite3_int64 nByte;            /* Bytes of space to allocate at pRet */
   853    852     Fts5Structure *pRet = 0;        /* Structure object to return */
   854    853   
   855    854     /* Grab the cookie value */
   856    855     if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);
   857    856     i = 4;
   858    857   
   859    858     /* Read the total number of levels and segments from the start of the
................................................................................
   929    928   /*
   930    929   **
   931    930   */
   932    931   static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){
   933    932     if( *pRc==SQLITE_OK ){
   934    933       Fts5Structure *pStruct = *ppStruct;
   935    934       int nLevel = pStruct->nLevel;
   936         -    int nByte = (
          935  +    sqlite3_int64 nByte = (
   937    936           sizeof(Fts5Structure) +                  /* Main structure */
   938    937           sizeof(Fts5StructureLevel) * (nLevel+1)  /* aLevel[] array */
   939    938       );
   940    939   
   941         -    pStruct = sqlite3_realloc(pStruct, nByte);
          940  +    pStruct = sqlite3_realloc64(pStruct, nByte);
   942    941       if( pStruct ){
   943    942         memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));
   944    943         pStruct->nLevel++;
   945    944         *ppStruct = pStruct;
   946    945       }else{
   947    946         *pRc = SQLITE_NOMEM;
   948    947       }
................................................................................
   959    958     int iLvl, 
   960    959     int nExtra, 
   961    960     int bInsert
   962    961   ){
   963    962     if( *pRc==SQLITE_OK ){
   964    963       Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];
   965    964       Fts5StructureSegment *aNew;
   966         -    int nByte;
          965  +    sqlite3_int64 nByte;
   967    966   
   968    967       nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);
   969         -    aNew = sqlite3_realloc(pLvl->aSeg, nByte);
          968  +    aNew = sqlite3_realloc64(pLvl->aSeg, nByte);
   970    969       if( aNew ){
   971    970         if( bInsert==0 ){
   972    971           memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);
   973    972         }else{
   974    973           int nMove = pLvl->nSeg * sizeof(Fts5StructureSegment);
   975    974           memmove(&aNew[nExtra], aNew, nMove);
   976    975           memset(aNew, 0, sizeof(Fts5StructureSegment) * nExtra);
................................................................................
  1476   1475     int iLeafPg                     /* Leaf page number to load dlidx for */
  1477   1476   ){
  1478   1477     Fts5DlidxIter *pIter = 0;
  1479   1478     int i;
  1480   1479     int bDone = 0;
  1481   1480   
  1482   1481     for(i=0; p->rc==SQLITE_OK && bDone==0; i++){
  1483         -    int nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
         1482  +    sqlite3_int64 nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
  1484   1483       Fts5DlidxIter *pNew;
  1485   1484   
  1486         -    pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);
         1485  +    pNew = (Fts5DlidxIter*)sqlite3_realloc64(pIter, nByte);
  1487   1486       if( pNew==0 ){
  1488   1487         p->rc = SQLITE_NOMEM;
  1489   1488       }else{
  1490   1489         i64 iRowid = FTS5_DLIDX_ROWID(iSegid, i, iLeafPg);
  1491   1490         Fts5DlidxLvl *pLvl = &pNew->aLvl[i];
  1492   1491         pIter = pNew;
  1493   1492         memset(pLvl, 0, sizeof(Fts5DlidxLvl));
................................................................................
  1649   1648   */
  1650   1649   static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
  1651   1650     u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */
  1652   1651     int iOff = pIter->iLeafOffset;  /* Offset to read at */
  1653   1652     int nNew;                       /* Bytes of new data */
  1654   1653   
  1655   1654     iOff += fts5GetVarint32(&a[iOff], nNew);
  1656         -  if( iOff+nNew>pIter->pLeaf->nn || nKeep>pIter->term.n ){
         1655  +  if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
  1657   1656       p->rc = FTS5_CORRUPT;
  1658   1657       return;
  1659   1658     }
  1660   1659     pIter->term.n = nKeep;
  1661   1660     fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
  1662   1661     assert( pIter->term.n<=pIter->term.nSpace );
  1663   1662     iOff += nNew;
................................................................................
  1776   1775       if( i>=n ) break;
  1777   1776       i += fts5GetVarint(&a[i], (u64*)&iDelta);
  1778   1777       pIter->iRowid += iDelta;
  1779   1778   
  1780   1779       /* If necessary, grow the pIter->aRowidOffset[] array. */
  1781   1780       if( iRowidOffset>=pIter->nRowidOffset ){
  1782   1781         int nNew = pIter->nRowidOffset + 8;
  1783         -      int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));
         1782  +      int *aNew = (int*)sqlite3_realloc64(pIter->aRowidOffset,nNew*sizeof(int));
  1784   1783         if( aNew==0 ){
  1785   1784           p->rc = SQLITE_NOMEM;
  1786   1785           break;
  1787   1786         }
  1788   1787         pIter->aRowidOffset = aNew;
  1789   1788         pIter->nRowidOffset = nNew;
  1790   1789       }
................................................................................
  2230   2229     const u8 *pTerm, int nTerm      /* Term to search for */
  2231   2230   ){
  2232   2231     int iOff;
  2233   2232     const u8 *a = pIter->pLeaf->p;
  2234   2233     int szLeaf = pIter->pLeaf->szLeaf;
  2235   2234     int n = pIter->pLeaf->nn;
  2236   2235   
  2237         -  int nMatch = 0;
  2238         -  int nKeep = 0;
  2239         -  int nNew = 0;
  2240         -  int iTermOff;
         2236  +  u32 nMatch = 0;
         2237  +  u32 nKeep = 0;
         2238  +  u32 nNew = 0;
         2239  +  u32 iTermOff;
  2241   2240     int iPgidx;                     /* Current offset in pgidx */
  2242   2241     int bEndOfPage = 0;
  2243   2242   
  2244   2243     assert( p->rc==SQLITE_OK );
  2245   2244   
  2246   2245     iPgidx = szLeaf;
  2247   2246     iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff);
................................................................................
  2257   2256       fts5FastGetVarint32(a, iOff, nNew);
  2258   2257       if( nKeep<nMatch ){
  2259   2258         goto search_failed;
  2260   2259       }
  2261   2260   
  2262   2261       assert( nKeep>=nMatch );
  2263   2262       if( nKeep==nMatch ){
  2264         -      int nCmp;
  2265         -      int i;
  2266         -      nCmp = MIN(nNew, nTerm-nMatch);
         2263  +      u32 nCmp;
         2264  +      u32 i;
         2265  +      nCmp = (u32)MIN(nNew, nTerm-nMatch);
  2267   2266         for(i=0; i<nCmp; i++){
  2268   2267           if( a[iOff+i]!=pTerm[nMatch+i] ) break;
  2269   2268         }
  2270   2269         nMatch += i;
  2271   2270   
  2272         -      if( nTerm==nMatch ){
         2271  +      if( (u32)nTerm==nMatch ){
  2273   2272           if( i==nNew ){
  2274   2273             goto search_success;
  2275   2274           }else{
  2276   2275             goto search_failed;
  2277   2276           }
  2278   2277         }else if( i<nNew && a[iOff+i]>pTerm[nMatch] ){
  2279   2278           goto search_failed;
................................................................................
  2323   2322           }
  2324   2323         }
  2325   2324       }while( 1 );
  2326   2325     }
  2327   2326   
  2328   2327    search_success:
  2329   2328     pIter->iLeafOffset = iOff + nNew;
  2330         -  if( pIter->iLeafOffset>n ){
         2329  +  if( pIter->iLeafOffset>n || nNew<1 ){
  2331   2330       p->rc = FTS5_CORRUPT;
  2332   2331       return;
  2333   2332     }
  2334   2333     pIter->iTermLeafOffset = pIter->iLeafOffset;
  2335   2334     pIter->iTermLeafPgno = pIter->iLeafPgno;
  2336   2335   
  2337   2336     fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);
................................................................................
  2433   2432     **
  2434   2433     **   1) an error has occurred, or
  2435   2434     **   2) the iterator points to EOF, or
  2436   2435     **   3) the iterator points to an entry with term (pTerm/nTerm), or
  2437   2436     **   4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points
  2438   2437     **      to an entry with a term greater than or equal to (pTerm/nTerm).
  2439   2438     */
  2440         -  assert( p->rc!=SQLITE_OK                                          /* 1 */
         2439  +  assert_nc( p->rc!=SQLITE_OK                                       /* 1 */
  2441   2440      || pIter->pLeaf==0                                               /* 2 */
  2442   2441      || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0          /* 3 */
  2443   2442      || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0)  /* 4 */
  2444   2443     );
  2445   2444   }
  2446   2445   
  2447   2446   /*
................................................................................
  2531   2530     if( p1->pLeaf || p2->pLeaf ){
  2532   2531       if( p1->pLeaf==0 ){
  2533   2532         assert( pRes->iFirst==i2 );
  2534   2533       }else if( p2->pLeaf==0 ){
  2535   2534         assert( pRes->iFirst==i1 );
  2536   2535       }else{
  2537   2536         int nMin = MIN(p1->term.n, p2->term.n);
  2538         -      int res = memcmp(p1->term.p, p2->term.p, nMin);
         2537  +      int res = fts5Memcmp(p1->term.p, p2->term.p, nMin);
  2539   2538         if( res==0 ) res = p1->term.n - p2->term.n;
  2540   2539   
  2541   2540         if( res==0 ){
  2542   2541           assert( pRes->bTermEq==1 );
  2543   2542           assert( p1->iRowid!=p2->iRowid );
  2544   2543           res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : 1;
  2545   2544         }else{
................................................................................
  2754   2753   */
  2755   2754   static void fts5MultiIterFree(Fts5Iter *pIter){
  2756   2755     if( pIter ){
  2757   2756       int i;
  2758   2757       for(i=0; i<pIter->nSeg; i++){
  2759   2758         fts5SegIterClear(&pIter->aSeg[i]);
  2760   2759       }
  2761         -    fts5StructureRelease(pIter->pStruct);
  2762   2760       fts5BufferFree(&pIter->poslist);
  2763   2761       sqlite3_free(pIter);
  2764   2762     }
  2765   2763   }
  2766   2764   
  2767   2765   static void fts5MultiIterAdvanced(
  2768   2766     Fts5Index *p,                   /* FTS5 backend to iterate within */
................................................................................
  3102   3100   */
  3103   3101   static void fts5SegiterPoslist(
  3104   3102     Fts5Index *p,
  3105   3103     Fts5SegIter *pSeg,
  3106   3104     Fts5Colset *pColset,
  3107   3105     Fts5Buffer *pBuf
  3108   3106   ){
  3109         -  if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos) ){
         3107  +  if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
         3108  +    memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);
  3110   3109       if( pColset==0 ){
  3111   3110         fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);
  3112   3111       }else{
  3113   3112         if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){
  3114   3113           PoslistCallbackCtx sCtx;
  3115   3114           sCtx.pBuf = pBuf;
  3116   3115           sCtx.pColset = pColset;
................................................................................
  3400   3399         nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);
  3401   3400       }
  3402   3401     }
  3403   3402     *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
  3404   3403     if( pNew==0 ) return;
  3405   3404     pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
  3406   3405     pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
  3407         -  pNew->pStruct = pStruct;
  3408   3406     pNew->pColset = pColset;
  3409         -  fts5StructureRef(pStruct);
  3410   3407     if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
  3411   3408       fts5IterSetOutputCb(&p->rc, pNew);
  3412   3409     }
  3413   3410   
  3414   3411     /* Initialize each of the component segment iterators. */
  3415   3412     if( p->rc==SQLITE_OK ){
  3416   3413       if( iLevel<0 ){
................................................................................
  3580   3577         int iLvl, iSeg;
  3581   3578         int i;
  3582   3579         u32 mask;
  3583   3580         memset(aUsed, 0, sizeof(aUsed));
  3584   3581         for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
  3585   3582           for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
  3586   3583             int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;
  3587         -          if( iId<=FTS5_MAX_SEGMENT ){
         3584  +          if( iId<=FTS5_MAX_SEGMENT && iId>0 ){
  3588   3585               aUsed[(iId-1) / 32] |= (u32)1 << ((iId-1) % 32);
  3589   3586             }
  3590   3587           }
  3591   3588         }
  3592   3589   
  3593   3590         for(i=0; aUsed[i]==0xFFFFFFFF; i++);
  3594   3591         mask = aUsed[i];
................................................................................
  3675   3672   */
  3676   3673   static int fts5WriteDlidxGrow(
  3677   3674     Fts5Index *p,
  3678   3675     Fts5SegWriter *pWriter,
  3679   3676     int nLvl
  3680   3677   ){
  3681   3678     if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
  3682         -    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc(
         3679  +    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc64(
  3683   3680           pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl
  3684   3681       );
  3685   3682       if( aDlidx==0 ){
  3686   3683         p->rc = SQLITE_NOMEM;
  3687   3684       }else{
  3688   3685         int nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);
  3689   3686         memset(&aDlidx[pWriter->nDlidx], 0, nByte);
................................................................................
  3754   3751   */
  3755   3752   static void fts5WriteBtreeTerm(
  3756   3753     Fts5Index *p,                   /* FTS5 backend object */
  3757   3754     Fts5SegWriter *pWriter,         /* Writer object */
  3758   3755     int nTerm, const u8 *pTerm      /* First term on new page */
  3759   3756   ){
  3760   3757     fts5WriteFlushBtree(p, pWriter);
  3761         -  fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
  3762         -  pWriter->iBtPage = pWriter->writer.pgno;
         3758  +  if( p->rc==SQLITE_OK ){
         3759  +    fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
         3760  +    pWriter->iBtPage = pWriter->writer.pgno;
         3761  +  }
  3763   3762   }
  3764   3763   
  3765   3764   /*
  3766   3765   ** This function is called when flushing a leaf page that contains no
  3767   3766   ** terms at all to disk.
  3768   3767   */
  3769   3768   static void fts5WriteBtreeNoTerm(
................................................................................
  3916   3915     assert( pPage->buf.n>=4 );
  3917   3916     assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );
  3918   3917   
  3919   3918     /* If the current leaf page is full, flush it to disk. */
  3920   3919     if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){
  3921   3920       if( pPage->buf.n>4 ){
  3922   3921         fts5WriteFlushLeaf(p, pWriter);
         3922  +      if( p->rc!=SQLITE_OK ) return;
  3923   3923       }
  3924   3924       fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);
  3925   3925     }
  3926   3926     
  3927   3927     /* TODO1: Updating pgidx here. */
  3928   3928     pPgidx->n += sqlite3Fts5PutVarint(
  3929   3929         &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx
................................................................................
  3951   3951         ** copy of (pTerm/nTerm) into the parent node. This is slightly
  3952   3952         ** inefficient, but still correct.  */
  3953   3953         int n = nTerm;
  3954   3954         if( pPage->term.n ){
  3955   3955           n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);
  3956   3956         }
  3957   3957         fts5WriteBtreeTerm(p, pWriter, n, pTerm);
         3958  +      if( p->rc!=SQLITE_OK ) return;
  3958   3959         pPage = &pWriter->writer;
  3959   3960       }
  3960   3961     }else{
  3961   3962       nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);
  3962   3963       fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
  3963   3964     }
  3964   3965   
................................................................................
  4001   4002         fts5WriteDlidxAppend(p, pWriter, iRowid);
  4002   4003       }
  4003   4004   
  4004   4005       /* Write the rowid. */
  4005   4006       if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
  4006   4007         fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);
  4007   4008       }else{
  4008         -      assert( p->rc || iRowid>pWriter->iPrevRowid );
         4009  +      assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
  4009   4010         fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
  4010   4011       }
  4011   4012       pWriter->iPrevRowid = iRowid;
  4012   4013       pWriter->bFirstRowidInDoclist = 0;
  4013   4014       pWriter->bFirstRowidInPage = 0;
  4014   4015     }
  4015   4016   }
................................................................................
  4123   4124   ** incremental merge operation. This function is called if the incremental
  4124   4125   ** merge step has finished but the input has not been completely exhausted.
  4125   4126   */
  4126   4127   static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){
  4127   4128     int i;
  4128   4129     Fts5Buffer buf;
  4129   4130     memset(&buf, 0, sizeof(Fts5Buffer));
  4130         -  for(i=0; i<pIter->nSeg; i++){
         4131  +  for(i=0; i<pIter->nSeg && p->rc==SQLITE_OK; i++){
  4131   4132       Fts5SegIter *pSeg = &pIter->aSeg[i];
  4132   4133       if( pSeg->pSeg==0 ){
  4133   4134         /* no-op */
  4134   4135       }else if( pSeg->pLeaf==0 ){
  4135   4136         /* All keys from this input segment have been transfered to the output.
  4136   4137         ** Set both the first and last page-numbers to 0 to indicate that the
  4137   4138         ** segment is now empty. */
................................................................................
  4141   4142         int iOff = pSeg->iTermLeafOffset;     /* Offset on new first leaf page */
  4142   4143         i64 iLeafRowid;
  4143   4144         Fts5Data *pData;
  4144   4145         int iId = pSeg->pSeg->iSegid;
  4145   4146         u8 aHdr[4] = {0x00, 0x00, 0x00, 0x00};
  4146   4147   
  4147   4148         iLeafRowid = FTS5_SEGMENT_ROWID(iId, pSeg->iTermLeafPgno);
  4148         -      pData = fts5DataRead(p, iLeafRowid);
         4149  +      pData = fts5LeafRead(p, iLeafRowid);
  4149   4150         if( pData ){
  4150         -        fts5BufferZero(&buf);
  4151         -        fts5BufferGrow(&p->rc, &buf, pData->nn);
  4152         -        fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
  4153         -        fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
  4154         -        fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
  4155         -        fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);
  4156         -        if( p->rc==SQLITE_OK ){
  4157         -          /* Set the szLeaf field */
  4158         -          fts5PutU16(&buf.p[2], (u16)buf.n);
  4159         -        }
  4160         -
  4161         -        /* Set up the new page-index array */
  4162         -        fts5BufferAppendVarint(&p->rc, &buf, 4);
  4163         -        if( pSeg->iLeafPgno==pSeg->iTermLeafPgno 
  4164         -         && pSeg->iEndofDoclist<pData->szLeaf 
  4165         -        ){
  4166         -          int nDiff = pData->szLeaf - pSeg->iEndofDoclist;
  4167         -          fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
  4168         -          fts5BufferAppendBlob(&p->rc, &buf, 
  4169         -              pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]
  4170         -          );
  4171         -        }
  4172         -
  4173         -        fts5DataRelease(pData);
  4174         -        pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;
  4175         -        fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);
  4176         -        fts5DataWrite(p, iLeafRowid, buf.p, buf.n);
         4151  +        if( iOff>pData->szLeaf ){
         4152  +          /* This can occur if the pages that the segments occupy overlap - if
         4153  +          ** a single page has been assigned to more than one segment. In
         4154  +          ** this case a prior iteration of this loop may have corrupted the
         4155  +          ** segment currently being trimmed.  */
         4156  +          p->rc = FTS5_CORRUPT;
         4157  +        }else{
         4158  +          fts5BufferZero(&buf);
         4159  +          fts5BufferGrow(&p->rc, &buf, pData->nn);
         4160  +          fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
         4161  +          fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
         4162  +          fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
         4163  +          fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff,&pData->p[iOff]);
         4164  +          if( p->rc==SQLITE_OK ){
         4165  +            /* Set the szLeaf field */
         4166  +            fts5PutU16(&buf.p[2], (u16)buf.n);
         4167  +          }
         4168  +
         4169  +          /* Set up the new page-index array */
         4170  +          fts5BufferAppendVarint(&p->rc, &buf, 4);
         4171  +          if( pSeg->iLeafPgno==pSeg->iTermLeafPgno 
         4172  +           && pSeg->iEndofDoclist<pData->szLeaf
         4173  +           && pSeg->iPgidxOff<=pData->nn
         4174  +          ){
         4175  +            int nDiff = pData->szLeaf - pSeg->iEndofDoclist;
         4176  +            fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
         4177  +            fts5BufferAppendBlob(&p->rc, &buf, 
         4178  +                pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]
         4179  +            );
         4180  +          }
         4181  +
         4182  +          pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;
         4183  +          fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);
         4184  +          fts5DataWrite(p, iLeafRowid, buf.p, buf.n);
         4185  +        }
         4186  +        fts5DataRelease(pData);
  4177   4187         }
  4178   4188       }
  4179   4189     }
  4180   4190     fts5BufferFree(&buf);
  4181   4191   }
  4182   4192   
  4183   4193   static void fts5MergeChunkCallback(
................................................................................
  4261   4271     ){
  4262   4272       Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
  4263   4273       int nPos;                     /* position-list size field value */
  4264   4274       int nTerm;
  4265   4275       const u8 *pTerm;
  4266   4276   
  4267   4277       pTerm = fts5MultiIterTerm(pIter, &nTerm);
  4268         -    if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){
         4278  +    if( nTerm!=term.n || fts5Memcmp(pTerm, term.p, nTerm) ){
  4269   4279         if( pnRem && writer.nLeafWritten>nRem ){
  4270   4280           break;
  4271   4281         }
  4272   4282         fts5BufferSet(&p->rc, &term, nTerm, pTerm);
  4273   4283         bTermWritten =0;
  4274   4284       }
  4275   4285   
................................................................................
  4516   4526         const char *zTerm;          /* Buffer containing term */
  4517   4527         const u8 *pDoclist;         /* Pointer to doclist for this term */
  4518   4528         int nDoclist;               /* Size of doclist in bytes */
  4519   4529   
  4520   4530         /* Write the term for this entry to disk. */
  4521   4531         sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);
  4522   4532         fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);
         4533  +      if( p->rc!=SQLITE_OK ) break;
  4523   4534   
  4524   4535         assert( writer.bFirstRowidInPage==0 );
  4525   4536         if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
  4526   4537           /* The entire doclist will fit on the current leaf. */
  4527   4538           fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);
  4528   4539         }else{
  4529   4540           i64 iRowid = 0;
................................................................................
  4538   4549             iRowid += iDelta;
  4539   4550             
  4540   4551             if( writer.bFirstRowidInPage ){
  4541   4552               fts5PutU16(&pBuf->p[0], (u16)pBuf->n);   /* first rowid on page */
  4542   4553               pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
  4543   4554               writer.bFirstRowidInPage = 0;
  4544   4555               fts5WriteDlidxAppend(p, &writer, iRowid);
         4556  +            if( p->rc!=SQLITE_OK ) break;
  4545   4557             }else{
  4546   4558               pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
  4547   4559             }
  4548   4560             assert( pBuf->n<=pBuf->nSpace );
  4549   4561   
  4550   4562             if( eDetail==FTS5_DETAIL_NONE ){
  4551   4563               if( iOff<nDoclist && pDoclist[iOff]==0 ){
................................................................................
  4595   4607             }
  4596   4608           }
  4597   4609         }
  4598   4610   
  4599   4611         /* TODO2: Doclist terminator written here. */
  4600   4612         /* pBuf->p[pBuf->n++] = '\0'; */
  4601   4613         assert( pBuf->n<=pBuf->nSpace );
  4602         -      sqlite3Fts5HashScanNext(pHash);
         4614  +      if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);
  4603   4615       }
  4604   4616       sqlite3Fts5HashClear(pHash);
  4605   4617       fts5WriteFinish(p, &writer, &pgnoLast);
  4606   4618   
  4607   4619       /* Update the Fts5Structure. It is written back to the database by the
  4608   4620       ** fts5StructureRelease() call below.  */
  4609   4621       if( pStruct->nLevel==0 ){
................................................................................
  4639   4651   }
  4640   4652   
  4641   4653   static Fts5Structure *fts5IndexOptimizeStruct(
  4642   4654     Fts5Index *p, 
  4643   4655     Fts5Structure *pStruct
  4644   4656   ){
  4645   4657     Fts5Structure *pNew = 0;
  4646         -  int nByte = sizeof(Fts5Structure);
         4658  +  sqlite3_int64 nByte = sizeof(Fts5Structure);
  4647   4659     int nSeg = pStruct->nSegment;
  4648   4660     int i;
  4649   4661   
  4650   4662     /* Figure out if this structure requires optimization. A structure does
  4651   4663     ** not require optimization if either:
  4652   4664     **
  4653   4665     **  + it consists of fewer than two segments, or 
................................................................................
  4769   4781   static void fts5AppendPoslist(
  4770   4782     Fts5Index *p,
  4771   4783     i64 iDelta,
  4772   4784     Fts5Iter *pMulti,
  4773   4785     Fts5Buffer *pBuf
  4774   4786   ){
  4775   4787     int nData = pMulti->base.nData;
         4788  +  int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING;
  4776   4789     assert( nData>0 );
  4777         -  if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){
         4790  +  if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){
  4778   4791       fts5BufferSafeAppendVarint(pBuf, iDelta);
  4779   4792       fts5BufferSafeAppendVarint(pBuf, nData*2);
  4780   4793       fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);
         4794  +    memset(&pBuf->p[pBuf->n], 0, FTS5_DATA_ZERO_PADDING);
  4781   4795     }
  4782   4796   }
  4783   4797   
  4784   4798   
  4785   4799   static void fts5DoclistIterNext(Fts5DoclistIter *pIter){
  4786   4800     u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist;
  4787   4801   
................................................................................
  4954   4968           /* Merge the two position lists. */ 
  4955   4969           i64 iPos1 = 0;
  4956   4970           i64 iPos2 = 0;
  4957   4971           int iOff1 = 0;
  4958   4972           int iOff2 = 0;
  4959   4973           u8 *a1 = &i1.aPoslist[i1.nSize];
  4960   4974           u8 *a2 = &i2.aPoslist[i2.nSize];
         4975  +        int nCopy;
         4976  +        u8 *aCopy;
  4961   4977   
  4962   4978           i64 iPrev = 0;
  4963   4979           Fts5PoslistWriter writer;
  4964   4980           memset(&writer, 0, sizeof(writer));
  4965   4981   
  4966   4982           fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
  4967   4983           fts5BufferZero(&tmp);
................................................................................
  4985   5001               if( iPos1<iPos2 ){
  4986   5002                 if( iPos1!=iPrev ){
  4987   5003                   sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);
  4988   5004                 }
  4989   5005                 sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
  4990   5006                 if( iPos1<0 ) break;
  4991   5007               }else{
  4992         -              assert( iPos2!=iPrev );
         5008  +              assert_nc( iPos2!=iPrev );
  4993   5009                 sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);
  4994   5010                 sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
  4995   5011                 if( iPos2<0 ) break;
  4996   5012               }
  4997   5013             }
  4998   5014           }
  4999   5015   
  5000   5016           if( iPos1>=0 ){
  5001   5017             if( iPos1!=iPrev ){
  5002   5018               sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);
  5003   5019             }
  5004         -          fts5BufferSafeAppendBlob(&tmp, &a1[iOff1], i1.nPoslist-iOff1);
         5020  +          aCopy = &a1[iOff1];
         5021  +          nCopy = i1.nPoslist - iOff1;
  5005   5022           }else{
  5006   5023             assert( iPos2>=0 && iPos2!=iPrev );
  5007   5024             sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);
  5008         -          fts5BufferSafeAppendBlob(&tmp, &a2[iOff2], i2.nPoslist-iOff2);
         5025  +          aCopy = &a2[iOff2];
         5026  +          nCopy = i2.nPoslist - iOff2;
         5027  +        }
         5028  +        if( nCopy>0 ){
         5029  +          fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);
  5009   5030           }
  5010   5031   
  5011   5032           /* WRITEPOSLISTSIZE */
  5012   5033           fts5BufferSafeAppendVarint(&out, tmp.n * 2);
  5013   5034           fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);
  5014   5035           fts5DoclistIterNext(&i1);
  5015   5036           fts5DoclistIterNext(&i2);
         5037  +        assert( out.n<=(p1->n+p2->n+9) );
  5016   5038           if( i1.aPoslist==0 || i2.aPoslist==0 ) break;
  5017   5039         }
  5018   5040       }
  5019   5041   
  5020   5042       if( i1.aPoslist ){
  5021   5043         fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);
  5022   5044         fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.aEof - i1.aPoslist);
................................................................................
  5110   5132         if( p->rc==SQLITE_OK ){
  5111   5133           xMerge(p, &doclist, &aBuf[i]);
  5112   5134         }
  5113   5135         fts5BufferFree(&aBuf[i]);
  5114   5136       }
  5115   5137       fts5MultiIterFree(p1);
  5116   5138   
  5117         -    pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
         5139  +    pData = fts5IdxMalloc(p, sizeof(Fts5Data)+doclist.n+FTS5_DATA_ZERO_PADDING);
  5118   5140       if( pData ){
  5119   5141         pData->p = (u8*)&pData[1];
  5120   5142         pData->nn = pData->szLeaf = doclist.n;
  5121   5143         if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);
  5122   5144         fts5MultiIterNew2(p, pData, bDesc, ppIter);
  5123   5145       }
  5124   5146       fts5BufferFree(&doclist);
................................................................................
  5876   5898   
  5877   5899         iOff = fts5LeafFirstTermOff(pLeaf);
  5878   5900         iRowidOff = fts5LeafFirstRowidOff(pLeaf);
  5879   5901         if( iRowidOff>=iOff || iOff>=pLeaf->szLeaf ){
  5880   5902           p->rc = FTS5_CORRUPT;
  5881   5903         }else{
  5882   5904           iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);
  5883         -        res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
         5905  +        res = fts5Memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
  5884   5906           if( res==0 ) res = nTerm - nIdxTerm;
  5885   5907           if( res<0 ) p->rc = FTS5_CORRUPT;
  5886   5908         }
  5887   5909   
  5888   5910         fts5IntegrityCheckPgidx(p, pLeaf);
  5889   5911       }
  5890   5912       fts5DataRelease(pLeaf);
................................................................................
  6271   6293   ){
  6272   6294     i64 iRowid;                     /* Rowid for record being decoded */
  6273   6295     int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */
  6274   6296     const u8 *aBlob; int n;         /* Record to decode */
  6275   6297     u8 *a = 0;
  6276   6298     Fts5Buffer s;                   /* Build up text to return here */
  6277   6299     int rc = SQLITE_OK;             /* Return code */
  6278         -  int nSpace = 0;
         6300  +  sqlite3_int64 nSpace = 0;
  6279   6301     int eDetailNone = (sqlite3_user_data(pCtx)!=0);
  6280   6302   
  6281   6303     assert( nArg==2 );
  6282   6304     UNUSED_PARAM(nArg);
  6283   6305     memset(&s, 0, sizeof(Fts5Buffer));
  6284   6306     iRowid = sqlite3_value_int64(apVal[0]);
  6285   6307   
................................................................................
  6382   6404         sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)"corrupt");
  6383   6405         goto decode_out;
  6384   6406       }else{
  6385   6407         iRowidOff = fts5GetU16(&a[0]);
  6386   6408         iPgidxOff = szLeaf = fts5GetU16(&a[2]);
  6387   6409         if( iPgidxOff<n ){
  6388   6410           fts5GetVarint32(&a[iPgidxOff], iTermOff);
         6411  +      }else if( iPgidxOff>n ){
         6412  +        rc = FTS5_CORRUPT;
         6413  +        goto decode_out;
  6389   6414         }
  6390   6415       }
  6391   6416   
  6392   6417       /* Decode the position list tail at the start of the page */
  6393   6418       if( iRowidOff!=0 ){
  6394   6419         iOff = iRowidOff;
  6395   6420       }else if( iTermOff!=0 ){
  6396   6421         iOff = iTermOff;
  6397   6422       }else{
  6398   6423         iOff = szLeaf;
  6399   6424       }
         6425  +    if( iOff>n ){
         6426  +      rc = FTS5_CORRUPT;
         6427  +      goto decode_out;
         6428  +    }
  6400   6429       fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
  6401   6430   
  6402   6431       /* Decode any more doclist data that appears on the page before the
  6403   6432       ** first term. */
  6404   6433       nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
         6434  +    if( nDoclist+iOff>n ){
         6435  +      rc = FTS5_CORRUPT;
         6436  +      goto decode_out;
         6437  +    }
  6405   6438       fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
  6406   6439   
  6407         -    while( iPgidxOff<n ){
         6440  +    while( iPgidxOff<n && rc==SQLITE_OK ){
  6408   6441         int bFirst = (iPgidxOff==szLeaf);     /* True for first term on page */
  6409   6442         int nByte;                            /* Bytes of data */
  6410   6443         int iEnd;
  6411   6444         
  6412   6445         iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nByte);
  6413   6446         iPgidxPrev += nByte;
  6414   6447         iOff = iPgidxPrev;
................................................................................
  6415   6448   
  6416   6449         if( iPgidxOff<n ){
  6417   6450           fts5GetVarint32(&a[iPgidxOff], nByte);
  6418   6451           iEnd = iPgidxPrev + nByte;
  6419   6452         }else{
  6420   6453           iEnd = szLeaf;
  6421   6454         }
         6455  +      if( iEnd>szLeaf ){
         6456  +        rc = FTS5_CORRUPT;
         6457  +        break;
         6458  +      }
  6422   6459   
  6423   6460         if( bFirst==0 ){
  6424   6461           iOff += fts5GetVarint32(&a[iOff], nByte);
         6462  +        if( nByte>term.n ){
         6463  +          rc = FTS5_CORRUPT;
         6464  +          break;
         6465  +        }
  6425   6466           term.n = nByte;
  6426   6467         }
  6427   6468         iOff += fts5GetVarint32(&a[iOff], nByte);
         6469  +      if( iOff+nByte>n ){
         6470  +        rc = FTS5_CORRUPT;
         6471  +        break;
         6472  +      }
  6428   6473         fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);
  6429   6474         iOff += nByte;
  6430   6475   
  6431   6476         sqlite3Fts5BufferAppendPrintf(
  6432   6477             &rc, &s, " term=%.*s", term.n, (const char*)term.p
  6433   6478         );
  6434   6479         iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff);

Changes to ext/fts5/fts5_main.c.

    24     24   */
    25     25   int sqlite3_fts5_may_be_corrupt = 1;
    26     26   
    27     27   
    28     28   typedef struct Fts5Auxdata Fts5Auxdata;
    29     29   typedef struct Fts5Auxiliary Fts5Auxiliary;
    30     30   typedef struct Fts5Cursor Fts5Cursor;
           31  +typedef struct Fts5FullTable Fts5FullTable;
    31     32   typedef struct Fts5Sorter Fts5Sorter;
    32         -typedef struct Fts5Table Fts5Table;
    33     33   typedef struct Fts5TokenizerModule Fts5TokenizerModule;
    34     34   
    35     35   /*
    36     36   ** NOTES ON TRANSACTIONS: 
    37     37   **
    38     38   ** SQLite invokes the following virtual table methods as transactions are 
    39     39   ** opened and closed by the user:
................................................................................
   106    106     char *zName;                    /* Name of tokenizer */
   107    107     void *pUserData;                /* User pointer passed to xCreate() */
   108    108     fts5_tokenizer x;               /* Tokenizer functions */
   109    109     void (*xDestroy)(void*);        /* Destructor function */
   110    110     Fts5TokenizerModule *pNext;     /* Next registered tokenizer module */
   111    111   };
   112    112   
   113         -/*
   114         -** Virtual-table object.
   115         -*/
   116         -struct Fts5Table {
   117         -  sqlite3_vtab base;              /* Base class used by SQLite core */
   118         -  Fts5Config *pConfig;            /* Virtual table configuration */
   119         -  Fts5Index *pIndex;              /* Full-text index */
          113  +struct Fts5FullTable {
          114  +  Fts5Table p;                    /* Public class members from fts5Int.h */
   120    115     Fts5Storage *pStorage;          /* Document store */
   121    116     Fts5Global *pGlobal;            /* Global (connection wide) data */
   122    117     Fts5Cursor *pSortCsr;           /* Sort data from this cursor */
   123    118   #ifdef SQLITE_DEBUG
   124    119     struct Fts5TransactionState ts;
   125    120   #endif
   126    121   };
................................................................................
   250    245   #define FTS5_BEGIN      1
   251    246   #define FTS5_SYNC       2
   252    247   #define FTS5_COMMIT     3
   253    248   #define FTS5_ROLLBACK   4
   254    249   #define FTS5_SAVEPOINT  5
   255    250   #define FTS5_RELEASE    6
   256    251   #define FTS5_ROLLBACKTO 7
   257         -static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
          252  +static void fts5CheckTransactionState(Fts5FullTable *p, int op, int iSavepoint){
   258    253     switch( op ){
   259    254       case FTS5_BEGIN:
   260    255         assert( p->ts.eState==0 );
   261    256         p->ts.eState = 1;
   262    257         p->ts.iSavepoint = -1;
   263    258         break;
   264    259   
................................................................................
   289    284         assert( iSavepoint>=0 );
   290    285         assert( iSavepoint<=p->ts.iSavepoint );
   291    286         p->ts.iSavepoint = iSavepoint-1;
   292    287         break;
   293    288   
   294    289       case FTS5_ROLLBACKTO:
   295    290         assert( p->ts.eState==1 );
   296         -      assert( iSavepoint>=0 );
          291  +      assert( iSavepoint>=-1 );
   297    292         assert( iSavepoint<=p->ts.iSavepoint );
   298    293         p->ts.iSavepoint = iSavepoint;
   299    294         break;
   300    295     }
   301    296   }
   302    297   #else
   303    298   # define fts5CheckTransactionState(x,y,z)
   304    299   #endif
   305    300   
   306    301   /*
   307    302   ** Return true if pTab is a contentless table.
   308    303   */
   309         -static int fts5IsContentless(Fts5Table *pTab){
   310         -  return pTab->pConfig->eContent==FTS5_CONTENT_NONE;
          304  +static int fts5IsContentless(Fts5FullTable *pTab){
          305  +  return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE;
   311    306   }
   312    307   
   313    308   /*
   314    309   ** Delete a virtual table handle allocated by fts5InitVtab(). 
   315    310   */
   316         -static void fts5FreeVtab(Fts5Table *pTab){
          311  +static void fts5FreeVtab(Fts5FullTable *pTab){
   317    312     if( pTab ){
   318         -    sqlite3Fts5IndexClose(pTab->pIndex);
          313  +    sqlite3Fts5IndexClose(pTab->p.pIndex);
   319    314       sqlite3Fts5StorageClose(pTab->pStorage);
   320         -    sqlite3Fts5ConfigFree(pTab->pConfig);
          315  +    sqlite3Fts5ConfigFree(pTab->p.pConfig);
   321    316       sqlite3_free(pTab);
   322    317     }
   323    318   }
   324    319   
   325    320   /*
   326    321   ** The xDisconnect() virtual table method.
   327    322   */
   328    323   static int fts5DisconnectMethod(sqlite3_vtab *pVtab){
   329         -  fts5FreeVtab((Fts5Table*)pVtab);
          324  +  fts5FreeVtab((Fts5FullTable*)pVtab);
   330    325     return SQLITE_OK;
   331    326   }
   332    327   
   333    328   /*
   334    329   ** The xDestroy() virtual table method.
   335    330   */
   336    331   static int fts5DestroyMethod(sqlite3_vtab *pVtab){
   337    332     Fts5Table *pTab = (Fts5Table*)pVtab;
   338    333     int rc = sqlite3Fts5DropAll(pTab->pConfig);
   339    334     if( rc==SQLITE_OK ){
   340         -    fts5FreeVtab((Fts5Table*)pVtab);
          335  +    fts5FreeVtab((Fts5FullTable*)pVtab);
   341    336     }
   342    337     return rc;
   343    338   }
   344    339   
   345    340   /*
   346    341   ** This function is the implementation of both the xConnect and xCreate
   347    342   ** methods of the FTS3 virtual table.
................................................................................
   362    357     sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */
   363    358     char **pzErr                    /* Write any error message here */
   364    359   ){
   365    360     Fts5Global *pGlobal = (Fts5Global*)pAux;
   366    361     const char **azConfig = (const char**)argv;
   367    362     int rc = SQLITE_OK;             /* Return code */
   368    363     Fts5Config *pConfig = 0;        /* Results of parsing argc/argv */
   369         -  Fts5Table *pTab = 0;            /* New virtual table object */
          364  +  Fts5FullTable *pTab = 0;        /* New virtual table object */
   370    365   
   371    366     /* Allocate the new vtab object and parse the configuration */
   372         -  pTab = (Fts5Table*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Table));
          367  +  pTab = (Fts5FullTable*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5FullTable));
   373    368     if( rc==SQLITE_OK ){
   374    369       rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);
   375    370       assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );
   376    371     }
   377    372     if( rc==SQLITE_OK ){
   378         -    pTab->pConfig = pConfig;
          373  +    pTab->p.pConfig = pConfig;
   379    374       pTab->pGlobal = pGlobal;
   380    375     }
   381    376   
   382    377     /* Open the index sub-system */
   383    378     if( rc==SQLITE_OK ){
   384         -    rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->pIndex, pzErr);
          379  +    rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->p.pIndex, pzErr);
   385    380     }
   386    381   
   387    382     /* Open the storage sub-system */
   388    383     if( rc==SQLITE_OK ){
   389    384       rc = sqlite3Fts5StorageOpen(
   390         -        pConfig, pTab->pIndex, bCreate, &pTab->pStorage, pzErr
          385  +        pConfig, pTab->p.pIndex, bCreate, &pTab->pStorage, pzErr
   391    386       );
   392    387     }
   393    388   
   394    389     /* Call sqlite3_declare_vtab() */
   395    390     if( rc==SQLITE_OK ){
   396    391       rc = sqlite3Fts5ConfigDeclareVtab(pConfig);
   397    392     }
   398    393   
   399    394     /* Load the initial configuration */
   400    395     if( rc==SQLITE_OK ){
   401    396       assert( pConfig->pzErrmsg==0 );
   402    397       pConfig->pzErrmsg = pzErr;
   403         -    rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);
   404         -    sqlite3Fts5IndexRollback(pTab->pIndex);
          398  +    rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
          399  +    sqlite3Fts5IndexRollback(pTab->p.pIndex);
   405    400       pConfig->pzErrmsg = 0;
   406    401     }
   407    402   
   408    403     if( rc!=SQLITE_OK ){
   409    404       fts5FreeVtab(pTab);
   410    405       pTab = 0;
   411    406     }else if( bCreate ){
................................................................................
   610    605       }
   611    606     }
   612    607   
   613    608     pInfo->idxNum = idxFlags;
   614    609     return SQLITE_OK;
   615    610   }
   616    611   
   617         -static int fts5NewTransaction(Fts5Table *pTab){
          612  +static int fts5NewTransaction(Fts5FullTable *pTab){
   618    613     Fts5Cursor *pCsr;
   619    614     for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
   620    615       if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;
   621    616     }
   622    617     return sqlite3Fts5StorageReset(pTab->pStorage);
   623    618   }
   624    619   
   625    620   /*
   626    621   ** Implementation of xOpen method.
   627    622   */
   628    623   static int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){
   629         -  Fts5Table *pTab = (Fts5Table*)pVTab;
   630         -  Fts5Config *pConfig = pTab->pConfig;
          624  +  Fts5FullTable *pTab = (Fts5FullTable*)pVTab;
          625  +  Fts5Config *pConfig = pTab->p.pConfig;
   631    626     Fts5Cursor *pCsr = 0;           /* New cursor object */
   632         -  int nByte;                      /* Bytes of space to allocate */
          627  +  sqlite3_int64 nByte;            /* Bytes of space to allocate */
   633    628     int rc;                         /* Return code */
   634    629   
   635    630     rc = fts5NewTransaction(pTab);
   636    631     if( rc==SQLITE_OK ){
   637    632       nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
   638         -    pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);
          633  +    pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
   639    634       if( pCsr ){
   640    635         Fts5Global *pGlobal = pTab->pGlobal;
   641    636         memset(pCsr, 0, nByte);
   642    637         pCsr->aColumnSize = (int*)&pCsr[1];
   643    638         pCsr->pNext = pGlobal->pCsr;
   644    639         pGlobal->pCsr = pCsr;
   645    640         pCsr->iCsrId = ++pGlobal->iNextId;
................................................................................
   669    664       | FTS5CSR_REQUIRE_DOCSIZE 
   670    665       | FTS5CSR_REQUIRE_INST 
   671    666       | FTS5CSR_REQUIRE_POSLIST 
   672    667     );
   673    668   }
   674    669   
   675    670   static void fts5FreeCursorComponents(Fts5Cursor *pCsr){
   676         -  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
          671  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
   677    672     Fts5Auxdata *pData;
   678    673     Fts5Auxdata *pNext;
   679    674   
   680    675     sqlite3_free(pCsr->aInstIter);
   681    676     sqlite3_free(pCsr->aInst);
   682    677     if( pCsr->pStmt ){
   683    678       int eStmt = fts5StmtType(pCsr);
................................................................................
   713    708   
   714    709   /*
   715    710   ** Close the cursor.  For additional information see the documentation
   716    711   ** on the xClose method of the virtual table interface.
   717    712   */
   718    713   static int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){
   719    714     if( pCursor ){
   720         -    Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
          715  +    Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
   721    716       Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
   722    717       Fts5Cursor **pp;
   723    718   
   724    719       fts5FreeCursorComponents(pCsr);
   725    720       /* Remove the cursor from the Fts5Global.pCsr list */
   726    721       for(pp=&pTab->pGlobal->pCsr; (*pp)!=pCsr; pp=&(*pp)->pNext);
   727    722       *pp = pCsr->pNext;
................................................................................
   770    765   }
   771    766   
   772    767   
   773    768   /*
   774    769   ** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors 
   775    770   ** open on table pTab.
   776    771   */
   777         -static void fts5TripCursors(Fts5Table *pTab){
          772  +static void fts5TripCursors(Fts5FullTable *pTab){
   778    773     Fts5Cursor *pCsr;
   779    774     for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
   780    775       if( pCsr->ePlan==FTS5_PLAN_MATCH
   781    776        && pCsr->base.pVtab==(sqlite3_vtab*)pTab 
   782    777       ){
   783    778         CsrFlagSet(pCsr, FTS5CSR_REQUIRE_RESEEK);
   784    779       }
................................................................................
   797    792   ** Return SQLITE_OK if successful or if no reseek was required, or an 
   798    793   ** error code if an error occurred.
   799    794   */
   800    795   static int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){
   801    796     int rc = SQLITE_OK;
   802    797     assert( *pbSkip==0 );
   803    798     if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){
   804         -    Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
          799  +    Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
   805    800       int bDesc = pCsr->bDesc;
   806    801       i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);
   807    802   
   808         -    rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->pIndex, iRowid, bDesc);
          803  +    rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->p.pIndex, iRowid, bDesc);
   809    804       if( rc==SQLITE_OK &&  iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){
   810    805         *pbSkip = 1;
   811    806       }
   812    807   
   813    808       CsrFlagClear(pCsr, FTS5CSR_REQUIRE_RESEEK);
   814    809       fts5CsrNewrow(pCsr);
   815    810       if( sqlite3Fts5ExprEof(pCsr->pExpr) ){
................................................................................
   898    893     }
   899    894   
   900    895     va_end(ap);
   901    896     *ppStmt = pRet;
   902    897     return rc;
   903    898   } 
   904    899   
   905         -static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
   906         -  Fts5Config *pConfig = pTab->pConfig;
          900  +static int fts5CursorFirstSorted(
          901  +  Fts5FullTable *pTab, 
          902  +  Fts5Cursor *pCsr, 
          903  +  int bDesc
          904  +){
          905  +  Fts5Config *pConfig = pTab->p.pConfig;
   907    906     Fts5Sorter *pSorter;
   908    907     int nPhrase;
   909         -  int nByte;
          908  +  sqlite3_int64 nByte;
   910    909     int rc;
   911    910     const char *zRank = pCsr->zRank;
   912    911     const char *zRankArgs = pCsr->zRankArgs;
   913    912     
   914    913     nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
   915    914     nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
   916         -  pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);
          915  +  pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
   917    916     if( pSorter==0 ) return SQLITE_NOMEM;
   918    917     memset(pSorter, 0, nByte);
   919    918     pSorter->nIdx = nPhrase;
   920    919   
   921    920     /* TODO: It would be better to have some system for reusing statement
   922    921     ** handles here, rather than preparing a new one for each query. But that
   923    922     ** is not possible as SQLite reference counts the virtual table objects.
................................................................................
   946    945       sqlite3_free(pSorter);
   947    946       pCsr->pSorter = 0;
   948    947     }
   949    948   
   950    949     return rc;
   951    950   }
   952    951   
   953         -static int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
          952  +static int fts5CursorFirst(Fts5FullTable *pTab, Fts5Cursor *pCsr, int bDesc){
   954    953     int rc;
   955    954     Fts5Expr *pExpr = pCsr->pExpr;
   956         -  rc = sqlite3Fts5ExprFirst(pExpr, pTab->pIndex, pCsr->iFirstRowid, bDesc);
          955  +  rc = sqlite3Fts5ExprFirst(pExpr, pTab->p.pIndex, pCsr->iFirstRowid, bDesc);
   957    956     if( sqlite3Fts5ExprEof(pExpr) ){
   958    957       CsrFlagSet(pCsr, FTS5CSR_EOF);
   959    958     }
   960    959     fts5CsrNewrow(pCsr);
   961    960     return rc;
   962    961   }
   963    962   
................................................................................
   964    963   /*
   965    964   ** Process a "special" query. A special query is identified as one with a
   966    965   ** MATCH expression that begins with a '*' character. The remainder of
   967    966   ** the text passed to the MATCH operator are used as  the special query
   968    967   ** parameters.
   969    968   */
   970    969   static int fts5SpecialMatch(
   971         -  Fts5Table *pTab, 
          970  +  Fts5FullTable *pTab, 
   972    971     Fts5Cursor *pCsr, 
   973    972     const char *zQuery
   974    973   ){
   975    974     int rc = SQLITE_OK;             /* Return code */
   976    975     const char *z = zQuery;         /* Special query text */
   977    976     int n;                          /* Number of bytes in text at z */
   978    977   
   979    978     while( z[0]==' ' ) z++;
   980    979     for(n=0; z[n] && z[n]!=' '; n++);
   981    980   
   982         -  assert( pTab->base.zErrMsg==0 );
          981  +  assert( pTab->p.base.zErrMsg==0 );
   983    982     pCsr->ePlan = FTS5_PLAN_SPECIAL;
   984    983   
   985    984     if( 0==sqlite3_strnicmp("reads", z, n) ){
   986         -    pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->pIndex);
          985  +    pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);
   987    986     }
   988    987     else if( 0==sqlite3_strnicmp("id", z, n) ){
   989    988       pCsr->iSpecial = pCsr->iCsrId;
   990    989     }
   991    990     else{
   992    991       /* An unrecognized directive. Return an error message. */
   993         -    pTab->base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
          992  +    pTab->p.base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
   994    993       rc = SQLITE_ERROR;
   995    994     }
   996    995   
   997    996     return rc;
   998    997   }
   999    998   
  1000    999   /*
  1001   1000   ** Search for an auxiliary function named zName that can be used with table
  1002   1001   ** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary
  1003   1002   ** structure. Otherwise, if no such function exists, return NULL.
  1004   1003   */
  1005         -static Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){
         1004  +static Fts5Auxiliary *fts5FindAuxiliary(Fts5FullTable *pTab, const char *zName){
  1006   1005     Fts5Auxiliary *pAux;
  1007   1006   
  1008   1007     for(pAux=pTab->pGlobal->pAux; pAux; pAux=pAux->pNext){
  1009   1008       if( sqlite3_stricmp(zName, pAux->zFunc)==0 ) return pAux;
  1010   1009     }
  1011   1010   
  1012   1011     /* No function of the specified name was found. Return 0. */
  1013   1012     return 0;
  1014   1013   }
  1015   1014   
  1016   1015   
  1017   1016   static int fts5FindRankFunction(Fts5Cursor *pCsr){
  1018         -  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
  1019         -  Fts5Config *pConfig = pTab->pConfig;
         1017  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
         1018  +  Fts5Config *pConfig = pTab->p.pConfig;
  1020   1019     int rc = SQLITE_OK;
  1021   1020     Fts5Auxiliary *pAux = 0;
  1022   1021     const char *zRank = pCsr->zRank;
  1023   1022     const char *zRankArgs = pCsr->zRankArgs;
  1024   1023   
  1025   1024     if( zRankArgs ){
  1026   1025       char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
................................................................................
  1028   1027         sqlite3_stmt *pStmt = 0;
  1029   1028         rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
  1030   1029                                 SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
  1031   1030         sqlite3_free(zSql);
  1032   1031         assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
  1033   1032         if( rc==SQLITE_OK ){
  1034   1033           if( SQLITE_ROW==sqlite3_step(pStmt) ){
  1035         -          int nByte;
         1034  +          sqlite3_int64 nByte;
  1036   1035             pCsr->nRankArg = sqlite3_column_count(pStmt);
  1037   1036             nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;
  1038   1037             pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);
  1039   1038             if( rc==SQLITE_OK ){
  1040   1039               int i;
  1041   1040               for(i=0; i<pCsr->nRankArg; i++){
  1042   1041                 pCsr->apRankArg[i] = sqlite3_column_value(pStmt, i);
................................................................................
  1050   1049         }
  1051   1050       }
  1052   1051     }
  1053   1052   
  1054   1053     if( rc==SQLITE_OK ){
  1055   1054       pAux = fts5FindAuxiliary(pTab, zRank);
  1056   1055       if( pAux==0 ){
  1057         -      assert( pTab->base.zErrMsg==0 );
  1058         -      pTab->base.zErrMsg = sqlite3_mprintf("no such function: %s", zRank);
         1056  +      assert( pTab->p.base.zErrMsg==0 );
         1057  +      pTab->p.base.zErrMsg = sqlite3_mprintf("no such function: %s", zRank);
  1059   1058         rc = SQLITE_ERROR;
  1060   1059       }
  1061   1060     }
  1062   1061   
  1063   1062     pCsr->pRank = pAux;
  1064   1063     return rc;
  1065   1064   }
................................................................................
  1126   1125   static int fts5FilterMethod(
  1127   1126     sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */
  1128   1127     int idxNum,                     /* Strategy index */
  1129   1128     const char *zUnused,            /* Unused */
  1130   1129     int nVal,                       /* Number of elements in apVal */
  1131   1130     sqlite3_value **apVal           /* Arguments for the indexing scheme */
  1132   1131   ){
  1133         -  Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
  1134         -  Fts5Config *pConfig = pTab->pConfig;
         1132  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
         1133  +  Fts5Config *pConfig = pTab->p.pConfig;
  1135   1134     Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
  1136   1135     int rc = SQLITE_OK;             /* Error code */
  1137   1136     int iVal = 0;                   /* Counter for apVal[] */
  1138   1137     int bDesc;                      /* True if ORDER BY [rank|rowid] DESC */
  1139   1138     int bOrderByRank;               /* True if ORDER BY rank */
  1140   1139     sqlite3_value *pMatch = 0;      /* <tbl> MATCH ? expression (or NULL) */
  1141   1140     sqlite3_value *pRank = 0;       /* rank MATCH ? expression (or NULL) */
................................................................................
  1156   1155     assert( pCsr->pStmt==0 );
  1157   1156     assert( pCsr->pExpr==0 );
  1158   1157     assert( pCsr->csrflags==0 );
  1159   1158     assert( pCsr->pRank==0 );
  1160   1159     assert( pCsr->zRank==0 );
  1161   1160     assert( pCsr->zRankArgs==0 );
  1162   1161   
  1163         -  assert( pzErrmsg==0 || pzErrmsg==&pTab->base.zErrMsg );
  1164         -  pConfig->pzErrmsg = &pTab->base.zErrMsg;
         1162  +  assert( pzErrmsg==0 || pzErrmsg==&pTab->p.base.zErrMsg );
         1163  +  pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
  1165   1164   
  1166   1165     /* Decode the arguments passed through to this function.
  1167   1166     **
  1168   1167     ** Note: The following set of if(...) statements must be in the same
  1169   1168     ** order as the corresponding entries in the struct at the top of
  1170   1169     ** fts5BestIndexMethod().  */
  1171   1170     if( BitFlagTest(idxNum, FTS5_BI_MATCH) ) pMatch = apVal[iVal++];
................................................................................
  1223   1222       if( rc==SQLITE_OK ){
  1224   1223         if( zExpr[0]=='*' ){
  1225   1224           /* The user has issued a query of the form "MATCH '*...'". This
  1226   1225           ** indicates that the MATCH expression is not a full text query,
  1227   1226           ** but a request for an internal parameter.  */
  1228   1227           rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);
  1229   1228         }else{
  1230         -        char **pzErr = &pTab->base.zErrMsg;
         1229  +        char **pzErr = &pTab->p.base.zErrMsg;
  1231   1230           rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);
  1232   1231           if( rc==SQLITE_OK ){
  1233   1232             if( bOrderByRank ){
  1234   1233               pCsr->ePlan = FTS5_PLAN_SORTED_MATCH;
  1235   1234               rc = fts5CursorFirstSorted(pTab, pCsr, bDesc);
  1236   1235             }else{
  1237   1236               pCsr->ePlan = FTS5_PLAN_MATCH;
................................................................................
  1246   1245       );
  1247   1246       rc = SQLITE_ERROR;
  1248   1247     }else{
  1249   1248       /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup
  1250   1249       ** by rowid (ePlan==FTS5_PLAN_ROWID).  */
  1251   1250       pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);
  1252   1251       rc = sqlite3Fts5StorageStmt(
  1253         -        pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->base.zErrMsg
         1252  +        pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg
  1254   1253       );
  1255   1254       if( rc==SQLITE_OK ){
  1256   1255         if( pCsr->ePlan==FTS5_PLAN_ROWID ){
  1257   1256           sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);
  1258   1257         }else{
  1259   1258           sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);
  1260   1259           sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);
................................................................................
  1329   1328   ** be left in sqlite3_vtab.zErrMsg.
  1330   1329   */
  1331   1330   static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){
  1332   1331     int rc = SQLITE_OK;
  1333   1332   
  1334   1333     /* If the cursor does not yet have a statement handle, obtain one now. */ 
  1335   1334     if( pCsr->pStmt==0 ){
  1336         -    Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
         1335  +    Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
  1337   1336       int eStmt = fts5StmtType(pCsr);
  1338   1337       rc = sqlite3Fts5StorageStmt(
  1339         -        pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->base.zErrMsg:0)
         1338  +        pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->p.base.zErrMsg:0)
  1340   1339       );
  1341         -    assert( rc!=SQLITE_OK || pTab->base.zErrMsg==0 );
         1340  +    assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
  1342   1341       assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );
  1343   1342     }
  1344   1343   
  1345   1344     if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){
  1346   1345       assert( pCsr->pExpr );
  1347   1346       sqlite3_reset(pCsr->pStmt);
  1348   1347       sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));
................................................................................
  1356   1355           rc = FTS5_CORRUPT;
  1357   1356         }
  1358   1357       }
  1359   1358     }
  1360   1359     return rc;
  1361   1360   }
  1362   1361   
  1363         -static void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){
         1362  +static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){
  1364   1363     va_list ap;                     /* ... printf arguments */
  1365   1364     va_start(ap, zFormat);
  1366         -  assert( p->base.zErrMsg==0 );
  1367         -  p->base.zErrMsg = sqlite3_vmprintf(zFormat, ap);
         1365  +  assert( p->p.base.zErrMsg==0 );
         1366  +  p->p.base.zErrMsg = sqlite3_vmprintf(zFormat, ap);
  1368   1367     va_end(ap);
  1369   1368   }
  1370   1369   
  1371   1370   /*
  1372   1371   ** This function is called to handle an FTS INSERT command. In other words,
  1373   1372   ** an INSERT statement of the form:
  1374   1373   **
................................................................................
  1380   1379   ** error code if an error occurs.
  1381   1380   **
  1382   1381   ** The commands implemented by this function are documented in the "Special
  1383   1382   ** INSERT Directives" section of the documentation. It should be updated if
  1384   1383   ** more commands are added to this function.
  1385   1384   */
  1386   1385   static int fts5SpecialInsert(
  1387         -  Fts5Table *pTab,                /* Fts5 table object */
         1386  +  Fts5FullTable *pTab,            /* Fts5 table object */
  1388   1387     const char *zCmd,               /* Text inserted into table-name column */
  1389   1388     sqlite3_value *pVal             /* Value inserted into rank column */
  1390   1389   ){
  1391         -  Fts5Config *pConfig = pTab->pConfig;
         1390  +  Fts5Config *pConfig = pTab->p.pConfig;
  1392   1391     int rc = SQLITE_OK;
  1393   1392     int bError = 0;
  1394   1393   
  1395   1394     if( 0==sqlite3_stricmp("delete-all", zCmd) ){
  1396   1395       if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
  1397   1396         fts5SetVtabError(pTab, 
  1398   1397             "'delete-all' may only be used with a "
................................................................................
  1419   1418     }else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){
  1420   1419       rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);
  1421   1420   #ifdef SQLITE_DEBUG
  1422   1421     }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){
  1423   1422       pConfig->bPrefixIndex = sqlite3_value_int(pVal);
  1424   1423   #endif
  1425   1424     }else{
  1426         -    rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);
         1425  +    rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
  1427   1426       if( rc==SQLITE_OK ){
  1428         -      rc = sqlite3Fts5ConfigSetValue(pTab->pConfig, zCmd, pVal, &bError);
         1427  +      rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError);
  1429   1428       }
  1430   1429       if( rc==SQLITE_OK ){
  1431   1430         if( bError ){
  1432   1431           rc = SQLITE_ERROR;
  1433   1432         }else{
  1434   1433           rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0);
  1435   1434         }
  1436   1435       }
  1437   1436     }
  1438   1437     return rc;
  1439   1438   }
  1440   1439   
  1441   1440   static int fts5SpecialDelete(
  1442         -  Fts5Table *pTab, 
         1441  +  Fts5FullTable *pTab, 
  1443   1442     sqlite3_value **apVal
  1444   1443   ){
  1445   1444     int rc = SQLITE_OK;
  1446   1445     int eType1 = sqlite3_value_type(apVal[1]);
  1447   1446     if( eType1==SQLITE_INTEGER ){
  1448   1447       sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);
  1449   1448       rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]);
  1450   1449     }
  1451   1450     return rc;
  1452   1451   }
  1453   1452   
  1454   1453   static void fts5StorageInsert(
  1455   1454     int *pRc, 
  1456         -  Fts5Table *pTab, 
         1455  +  Fts5FullTable *pTab, 
  1457   1456     sqlite3_value **apVal, 
  1458   1457     i64 *piRowid
  1459   1458   ){
  1460   1459     int rc = *pRc;
  1461   1460     if( rc==SQLITE_OK ){
  1462   1461       rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);
  1463   1462     }
................................................................................
  1483   1482   */
  1484   1483   static int fts5UpdateMethod(
  1485   1484     sqlite3_vtab *pVtab,            /* Virtual table handle */
  1486   1485     int nArg,                       /* Size of argument array */
  1487   1486     sqlite3_value **apVal,          /* Array of arguments */
  1488   1487     sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */
  1489   1488   ){
  1490         -  Fts5Table *pTab = (Fts5Table*)pVtab;
  1491         -  Fts5Config *pConfig = pTab->pConfig;
         1489  +  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
         1490  +  Fts5Config *pConfig = pTab->p.pConfig;
  1492   1491     int eType0;                     /* value_type() of apVal[0] */
  1493   1492     int rc = SQLITE_OK;             /* Return code */
  1494   1493   
  1495   1494     /* A transaction must be open when this is called. */
  1496   1495     assert( pTab->ts.eState==1 );
  1497   1496   
  1498   1497     assert( pVtab->zErrMsg==0 );
  1499   1498     assert( nArg==1 || nArg==(2+pConfig->nCol+2) );
  1500         -  assert( nArg==1 
  1501         -      || sqlite3_value_type(apVal[1])==SQLITE_INTEGER 
  1502         -      || sqlite3_value_type(apVal[1])==SQLITE_NULL 
         1499  +  assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER 
         1500  +       || sqlite3_value_type(apVal[0])==SQLITE_NULL 
  1503   1501     );
  1504         -  assert( pTab->pConfig->pzErrmsg==0 );
  1505         -  pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
         1502  +  assert( pTab->p.pConfig->pzErrmsg==0 );
         1503  +  pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
  1506   1504   
  1507   1505     /* Put any active cursors into REQUIRE_SEEK state. */
  1508   1506     fts5TripCursors(pTab);
  1509   1507   
  1510   1508     eType0 = sqlite3_value_type(apVal[0]);
  1511   1509     if( eType0==SQLITE_NULL 
  1512   1510      && sqlite3_value_type(apVal[2+pConfig->nCol])!=SQLITE_NULL 
................................................................................
  1539   1537   
  1540   1538       assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );
  1541   1539       assert( nArg!=1 || eType0==SQLITE_INTEGER );
  1542   1540   
  1543   1541       /* Filter out attempts to run UPDATE or DELETE on contentless tables.
  1544   1542       ** This is not suported.  */
  1545   1543       if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){
  1546         -      pTab->base.zErrMsg = sqlite3_mprintf(
         1544  +      pTab->p.base.zErrMsg = sqlite3_mprintf(
  1547   1545             "cannot %s contentless fts5 table: %s", 
  1548   1546             (nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName
  1549   1547         );
  1550   1548         rc = SQLITE_ERROR;
  1551   1549       }
  1552   1550   
  1553   1551       /* DELETE */
  1554   1552       else if( nArg==1 ){
  1555   1553         i64 iDel = sqlite3_value_int64(apVal[0]);  /* Rowid to delete */
  1556   1554         rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);
  1557   1555       }
  1558   1556   
  1559         -    /* INSERT */
  1560         -    else if( eType0!=SQLITE_INTEGER ){     
  1561         -      /* If this is a REPLACE, first remove the current entry (if any) */
  1562         -      if( eConflict==SQLITE_REPLACE 
  1563         -       && sqlite3_value_type(apVal[1])==SQLITE_INTEGER 
  1564         -      ){
  1565         -        i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */
  1566         -        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
  1567         -      }
  1568         -      fts5StorageInsert(&rc, pTab, apVal, pRowid);
  1569         -    }
  1570         -
  1571         -    /* UPDATE */
         1557  +    /* INSERT or UPDATE */
  1572   1558       else{
  1573         -      i64 iOld = sqlite3_value_int64(apVal[0]);  /* Old rowid */
  1574         -      i64 iNew = sqlite3_value_int64(apVal[1]);  /* New rowid */
  1575         -      if( iOld!=iNew ){
  1576         -        if( eConflict==SQLITE_REPLACE ){
  1577         -          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
  1578         -          if( rc==SQLITE_OK ){
  1579         -            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
  1580         -          }
  1581         -          fts5StorageInsert(&rc, pTab, apVal, pRowid);
  1582         -        }else{
  1583         -          rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
  1584         -          if( rc==SQLITE_OK ){
  1585         -            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
  1586         -          }
  1587         -          if( rc==SQLITE_OK ){
  1588         -            rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid);
  1589         -          }
         1559  +      int eType1 = sqlite3_value_numeric_type(apVal[1]);
         1560  +
         1561  +      if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){
         1562  +        rc = SQLITE_MISMATCH;
         1563  +      }
         1564  +
         1565  +      else if( eType0!=SQLITE_INTEGER ){     
         1566  +        /* If this is a REPLACE, first remove the current entry (if any) */
         1567  +        if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
         1568  +          i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */
         1569  +          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
  1590   1570           }
  1591         -      }else{
  1592         -        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
  1593   1571           fts5StorageInsert(&rc, pTab, apVal, pRowid);
  1594   1572         }
         1573  +
         1574  +      /* UPDATE */
         1575  +      else{
         1576  +        i64 iOld = sqlite3_value_int64(apVal[0]);  /* Old rowid */
         1577  +        i64 iNew = sqlite3_value_int64(apVal[1]);  /* New rowid */
         1578  +        if( eType1==SQLITE_INTEGER && iOld!=iNew ){
         1579  +          if( eConflict==SQLITE_REPLACE ){
         1580  +            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
         1581  +            if( rc==SQLITE_OK ){
         1582  +              rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
         1583  +            }
         1584  +            fts5StorageInsert(&rc, pTab, apVal, pRowid);
         1585  +          }else{
         1586  +            rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
         1587  +            if( rc==SQLITE_OK ){
         1588  +              rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
         1589  +            }
         1590  +            if( rc==SQLITE_OK ){
         1591  +              rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
         1592  +            }
         1593  +          }
         1594  +        }else{
         1595  +          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
         1596  +          fts5StorageInsert(&rc, pTab, apVal, pRowid);
         1597  +        }
         1598  +      }
  1595   1599       }
  1596   1600     }
  1597   1601   
  1598         -  pTab->pConfig->pzErrmsg = 0;
         1602  +  pTab->p.pConfig->pzErrmsg = 0;
  1599   1603     return rc;
  1600   1604   }
  1601   1605   
  1602   1606   /*
  1603   1607   ** Implementation of xSync() method. 
  1604   1608   */
  1605   1609   static int fts5SyncMethod(sqlite3_vtab *pVtab){
  1606   1610     int rc;
  1607         -  Fts5Table *pTab = (Fts5Table*)pVtab;
         1611  +  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
  1608   1612     fts5CheckTransactionState(pTab, FTS5_SYNC, 0);
  1609         -  pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
         1613  +  pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
  1610   1614     fts5TripCursors(pTab);
  1611   1615     rc = sqlite3Fts5StorageSync(pTab->pStorage);
  1612         -  pTab->pConfig->pzErrmsg = 0;
         1616  +  pTab->p.pConfig->pzErrmsg = 0;
  1613   1617     return rc;
  1614   1618   }
  1615   1619   
  1616   1620   /*
  1617   1621   ** Implementation of xBegin() method. 
  1618   1622   */
  1619   1623   static int fts5BeginMethod(sqlite3_vtab *pVtab){
  1620         -  fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
  1621         -  fts5NewTransaction((Fts5Table*)pVtab);
         1624  +  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_BEGIN, 0);
         1625  +  fts5NewTransaction((Fts5FullTable*)pVtab);
  1622   1626     return SQLITE_OK;
  1623   1627   }
  1624   1628   
  1625   1629   /*
  1626   1630   ** Implementation of xCommit() method. This is a no-op. The contents of
  1627   1631   ** the pending-terms hash-table have already been flushed into the database
  1628   1632   ** by fts5SyncMethod().
  1629   1633   */
  1630   1634   static int fts5CommitMethod(sqlite3_vtab *pVtab){
  1631   1635     UNUSED_PARAM(pVtab);  /* Call below is a no-op for NDEBUG builds */
  1632         -  fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);
         1636  +  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_COMMIT, 0);
  1633   1637     return SQLITE_OK;
  1634   1638   }
  1635   1639   
  1636   1640   /*
  1637   1641   ** Implementation of xRollback(). Discard the contents of the pending-terms
  1638   1642   ** hash-table. Any changes made to the database are reverted by SQLite.
  1639   1643   */
  1640   1644   static int fts5RollbackMethod(sqlite3_vtab *pVtab){
  1641   1645     int rc;
  1642         -  Fts5Table *pTab = (Fts5Table*)pVtab;
         1646  +  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
  1643   1647     fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
  1644   1648     rc = sqlite3Fts5StorageRollback(pTab->pStorage);
  1645   1649     return rc;
  1646   1650   }
  1647   1651   
  1648   1652   static int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);
  1649   1653   
................................................................................
  1659   1663   
  1660   1664   static int fts5ApiColumnTotalSize(
  1661   1665     Fts5Context *pCtx, 
  1662   1666     int iCol, 
  1663   1667     sqlite3_int64 *pnToken
  1664   1668   ){
  1665   1669     Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
  1666         -  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
         1670  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
  1667   1671     return sqlite3Fts5StorageSize(pTab->pStorage, iCol, pnToken);
  1668   1672   }
  1669   1673   
  1670   1674   static int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){
  1671   1675     Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
  1672         -  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
         1676  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
  1673   1677     return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow);
  1674   1678   }
  1675   1679   
  1676   1680   static int fts5ApiTokenize(
  1677   1681     Fts5Context *pCtx, 
  1678   1682     const char *pText, int nText, 
  1679   1683     void *pUserData,
................................................................................
  1700   1704     Fts5Context *pCtx, 
  1701   1705     int iCol, 
  1702   1706     const char **pz, 
  1703   1707     int *pn
  1704   1708   ){
  1705   1709     int rc = SQLITE_OK;
  1706   1710     Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
  1707         -  if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){
         1711  +  if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) 
         1712  +   || pCsr->ePlan==FTS5_PLAN_SPECIAL 
         1713  +  ){
  1708   1714       *pz = 0;
  1709   1715       *pn = 0;
  1710   1716     }else{
  1711   1717       rc = fts5SeekCursor(pCsr, 0);
  1712   1718       if( rc==SQLITE_OK ){
  1713   1719         *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1);
  1714   1720         *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1);
................................................................................
  1769   1775   ** correctly for the current view. Return SQLITE_OK if successful, or an
  1770   1776   ** SQLite error code otherwise.
  1771   1777   */
  1772   1778   static int fts5CacheInstArray(Fts5Cursor *pCsr){
  1773   1779     int rc = SQLITE_OK;
  1774   1780     Fts5PoslistReader *aIter;       /* One iterator for each phrase */
  1775   1781     int nIter;                      /* Number of iterators/phrases */
         1782  +  int nCol = ((Fts5Table*)pCsr->base.pVtab)->pConfig->nCol;
  1776   1783     
  1777   1784     nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
  1778   1785     if( pCsr->aInstIter==0 ){
  1779         -    int nByte = sizeof(Fts5PoslistReader) * nIter;
         1786  +    sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nIter;
  1780   1787       pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);
  1781   1788     }
  1782   1789     aIter = pCsr->aInstIter;
  1783   1790   
  1784   1791     if( aIter ){
  1785   1792       int nInst = 0;                /* Number instances seen so far */
  1786   1793       int i;
................................................................................
  1807   1814             }
  1808   1815           }
  1809   1816           if( iBest<0 ) break;
  1810   1817   
  1811   1818           nInst++;
  1812   1819           if( nInst>=pCsr->nInstAlloc ){
  1813   1820             pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
  1814         -          aInst = (int*)sqlite3_realloc(
         1821  +          aInst = (int*)sqlite3_realloc64(
  1815   1822                 pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3
  1816   1823                 );
  1817   1824             if( aInst ){
  1818   1825               pCsr->aInst = aInst;
  1819   1826             }else{
  1820   1827               rc = SQLITE_NOMEM;
  1821   1828               break;
................................................................................
  1822   1829             }
  1823   1830           }
  1824   1831   
  1825   1832           aInst = &pCsr->aInst[3 * (nInst-1)];
  1826   1833           aInst[0] = iBest;
  1827   1834           aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos);
  1828   1835           aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos);
         1836  +        if( aInst[1]<0 || aInst[1]>=nCol ){
         1837  +          rc = FTS5_CORRUPT;
         1838  +          break;
         1839  +        }
  1829   1840           sqlite3Fts5PoslistReaderNext(&aIter[iBest]);
  1830   1841         }
  1831   1842       }
  1832   1843   
  1833   1844       pCsr->nInstCount = nInst;
  1834   1845       CsrFlagClear(pCsr, FTS5CSR_REQUIRE_INST);
  1835   1846     }
................................................................................
  1894   1905       (*pCnt)++;
  1895   1906     }
  1896   1907     return SQLITE_OK;
  1897   1908   }
  1898   1909   
  1899   1910   static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){
  1900   1911     Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
  1901         -  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
  1902         -  Fts5Config *pConfig = pTab->pConfig;
         1912  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
         1913  +  Fts5Config *pConfig = pTab->p.pConfig;
  1903   1914     int rc = SQLITE_OK;
  1904   1915   
  1905   1916     if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){
  1906   1917       if( pConfig->bColumnsize ){
  1907   1918         i64 iRowid = fts5CursorRowid(pCsr);
  1908   1919         rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);
  1909   1920       }else if( pConfig->zContent==0 ){
................................................................................
  2151   2162   static int fts5ApiQueryPhrase(
  2152   2163     Fts5Context *pCtx, 
  2153   2164     int iPhrase, 
  2154   2165     void *pUserData,
  2155   2166     int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*)
  2156   2167   ){
  2157   2168     Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
  2158         -  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
         2169  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
  2159   2170     int rc;
  2160   2171     Fts5Cursor *pNew = 0;
  2161   2172   
  2162   2173     rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);
  2163   2174     if( rc==SQLITE_OK ){
  2164   2175       pNew->ePlan = FTS5_PLAN_MATCH;
  2165   2176       pNew->iFirstRowid = SMALLEST_INT64;
................................................................................
  2228   2239     }else{
  2229   2240       fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);
  2230   2241     }
  2231   2242   }
  2232   2243   
  2233   2244   
  2234   2245   /*
  2235         -** Given cursor id iId, return a pointer to the corresponding Fts5Index 
         2246  +** Given cursor id iId, return a pointer to the corresponding Fts5Table 
  2236   2247   ** object. Or NULL If the cursor id does not exist.
  2237         -**
  2238         -** If successful, set *ppConfig to point to the associated config object 
  2239         -** before returning.
  2240   2248   */
  2241         -Fts5Index *sqlite3Fts5IndexFromCsrid(
         2249  +Fts5Table *sqlite3Fts5TableFromCsrid(
  2242   2250     Fts5Global *pGlobal,            /* FTS5 global context for db handle */
  2243         -  i64 iCsrId,                     /* Id of cursor to find */
  2244         -  Fts5Config **ppConfig           /* OUT: Configuration object */
         2251  +  i64 iCsrId                      /* Id of cursor to find */
  2245   2252   ){
  2246   2253     Fts5Cursor *pCsr;
  2247         -  Fts5Table *pTab;
  2248         -
  2249   2254     pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);
  2250         -  pTab = (Fts5Table*)pCsr->base.pVtab;
  2251         -  *ppConfig = pTab->pConfig;
  2252         -
  2253         -  return pTab->pIndex;
         2255  +  if( pCsr ){
         2256  +    return (Fts5Table*)pCsr->base.pVtab;
         2257  +  }
         2258  +  return 0;
  2254   2259   }
  2255   2260   
  2256   2261   /*
  2257   2262   ** Return a "position-list blob" corresponding to the current position of
  2258   2263   ** cursor pCsr via sqlite3_result_blob(). A position-list blob contains
  2259   2264   ** the current position-list for each phrase in the query associated with
  2260   2265   ** cursor pCsr.
................................................................................
  2326   2331   ** the row that the supplied cursor currently points to.
  2327   2332   */
  2328   2333   static int fts5ColumnMethod(
  2329   2334     sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */
  2330   2335     sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */
  2331   2336     int iCol                        /* Index of column to read value from */
  2332   2337   ){
  2333         -  Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
  2334         -  Fts5Config *pConfig = pTab->pConfig;
         2338  +  Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
         2339  +  Fts5Config *pConfig = pTab->p.pConfig;
  2335   2340     Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
  2336   2341     int rc = SQLITE_OK;
  2337   2342     
  2338   2343     assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );
  2339   2344   
  2340   2345     if( pCsr->ePlan==FTS5_PLAN_SPECIAL ){
  2341   2346       if( iCol==pConfig->nCol ){
................................................................................
  2379   2384   static int fts5FindFunctionMethod(
  2380   2385     sqlite3_vtab *pVtab,            /* Virtual table handle */
  2381   2386     int nUnused,                    /* Number of SQL function arguments */
  2382   2387     const char *zName,              /* Name of SQL function */
  2383   2388     void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
  2384   2389     void **ppArg                    /* OUT: User data for *pxFunc */
  2385   2390   ){
  2386         -  Fts5Table *pTab = (Fts5Table*)pVtab;
         2391  +  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
  2387   2392     Fts5Auxiliary *pAux;
  2388   2393   
  2389   2394     UNUSED_PARAM(nUnused);
  2390   2395     pAux = fts5FindAuxiliary(pTab, zName);
  2391   2396     if( pAux ){
  2392   2397       *pxFunc = fts5ApiCallback;
  2393   2398       *ppArg = (void*)pAux;
................................................................................
  2401   2406   /*
  2402   2407   ** Implementation of FTS5 xRename method. Rename an fts5 table.
  2403   2408   */
  2404   2409   static int fts5RenameMethod(
  2405   2410     sqlite3_vtab *pVtab,            /* Virtual table handle */
  2406   2411     const char *zName               /* New name of table */
  2407   2412   ){
  2408         -  Fts5Table *pTab = (Fts5Table*)pVtab;
         2413  +  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
  2409   2414     return sqlite3Fts5StorageRename(pTab->pStorage, zName);
  2410   2415   }
         2416  +
         2417  +int sqlite3Fts5FlushToDisk(Fts5Table *pTab){
         2418  +  fts5TripCursors((Fts5FullTable*)pTab);
         2419  +  return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage);
         2420  +}
  2411   2421   
  2412   2422   /*
  2413   2423   ** The xSavepoint() method.
  2414   2424   **
  2415   2425   ** Flush the contents of the pending-terms table to disk.
  2416   2426   */
  2417   2427   static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
  2418         -  Fts5Table *pTab = (Fts5Table*)pVtab;
  2419   2428     UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */
  2420         -  fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
  2421         -  fts5TripCursors(pTab);
  2422         -  return sqlite3Fts5StorageSync(pTab->pStorage);
         2429  +  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint);
         2430  +  return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
  2423   2431   }
  2424   2432   
  2425   2433   /*
  2426   2434   ** The xRelease() method.
  2427   2435   **
  2428   2436   ** This is a no-op.
  2429   2437   */
  2430   2438   static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
  2431         -  Fts5Table *pTab = (Fts5Table*)pVtab;
  2432   2439     UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */
  2433         -  fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
  2434         -  fts5TripCursors(pTab);
  2435         -  return sqlite3Fts5StorageSync(pTab->pStorage);
         2440  +  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint);
         2441  +  return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
  2436   2442   }
  2437   2443   
  2438   2444   /*
  2439   2445   ** The xRollbackTo() method.
  2440   2446   **
  2441   2447   ** Discard the contents of the pending terms table.
  2442   2448   */
  2443   2449   static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
  2444         -  Fts5Table *pTab = (Fts5Table*)pVtab;
         2450  +  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
  2445   2451     UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */
  2446   2452     fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
  2447   2453     fts5TripCursors(pTab);
  2448   2454     return sqlite3Fts5StorageRollback(pTab->pStorage);
  2449   2455   }
  2450   2456   
  2451   2457   /*

Changes to ext/fts5/fts5_storage.c.

   111    111   
   112    112         case FTS5_STMT_INSERT_CONTENT: 
   113    113         case FTS5_STMT_REPLACE_CONTENT: {
   114    114           int nCol = pC->nCol + 1;
   115    115           char *zBind;
   116    116           int i;
   117    117   
   118         -        zBind = sqlite3_malloc(1 + nCol*2);
          118  +        zBind = sqlite3_malloc64(1 + nCol*2);
   119    119           if( zBind ){
   120    120             for(i=0; i<nCol; i++){
   121    121               zBind[i*2] = '?';
   122    122               zBind[i*2 + 1] = ',';
   123    123             }
   124    124             zBind[i*2-1] = '\0';
   125    125             zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind);
................................................................................
   278    278     Fts5Index *pIndex, 
   279    279     int bCreate, 
   280    280     Fts5Storage **pp,
   281    281     char **pzErr                    /* OUT: Error message */
   282    282   ){
   283    283     int rc = SQLITE_OK;
   284    284     Fts5Storage *p;                 /* New object */
   285         -  int nByte;                      /* Bytes of space to allocate */
          285  +  sqlite3_int64 nByte;            /* Bytes of space to allocate */
   286    286   
   287    287     nByte = sizeof(Fts5Storage)               /* Fts5Storage object */
   288    288           + pConfig->nCol * sizeof(i64);      /* Fts5Storage.aTotalSize[] */
   289         -  *pp = p = (Fts5Storage*)sqlite3_malloc(nByte);
          289  +  *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
   290    290     if( !p ) return SQLITE_NOMEM;
   291    291   
   292    292     memset(p, 0, nByte);
   293    293     p->aTotalSize = (i64*)&p[1];
   294    294     p->pConfig = pConfig;
   295    295     p->pIndex = pIndex;
   296    296   
   297    297     if( bCreate ){
   298    298       if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
   299    299         int nDefn = 32 + pConfig->nCol*10;
   300         -      char *zDefn = sqlite3_malloc(32 + pConfig->nCol * 10);
          300  +      char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 10);
   301    301         if( zDefn==0 ){
   302    302           rc = SQLITE_NOMEM;
   303    303         }else{
   304    304           int i;
   305    305           int iOff;
   306    306           sqlite3_snprintf(nDefn, zDefn, "id INTEGER PRIMARY KEY");
   307    307           iOff = (int)strlen(zDefn);
................................................................................
   584    584   }
   585    585   
   586    586   int sqlite3Fts5StorageRebuild(Fts5Storage *p){
   587    587     Fts5Buffer buf = {0,0,0};
   588    588     Fts5Config *pConfig = p->pConfig;
   589    589     sqlite3_stmt *pScan = 0;
   590    590     Fts5InsertCtx ctx;
   591         -  int rc;
          591  +  int rc, rc2;
   592    592   
   593    593     memset(&ctx, 0, sizeof(Fts5InsertCtx));
   594    594     ctx.pStorage = p;
   595    595     rc = sqlite3Fts5StorageDeleteAll(p);
   596    596     if( rc==SQLITE_OK ){
   597    597       rc = fts5StorageLoadTotals(p, 1);
   598    598     }
................................................................................
   623    623       p->nTotalRow++;
   624    624   
   625    625       if( rc==SQLITE_OK ){
   626    626         rc = fts5StorageInsertDocsize(p, iRowid, &buf);
   627    627       }
   628    628     }
   629    629     sqlite3_free(buf.p);
          630  +  rc2 = sqlite3_reset(pScan);
          631  +  if( rc==SQLITE_OK ) rc = rc2;
   630    632   
   631    633     /* Write the averages record */
   632    634     if( rc==SQLITE_OK ){
   633    635       rc = fts5StorageSaveTotals(p);
   634    636     }
   635    637     return rc;
   636    638   }
................................................................................
   872    874     int *aColSize;                  /* Array of size pConfig->nCol */
   873    875     i64 *aTotalSize;                /* Array of size pConfig->nCol */
   874    876     Fts5IntegrityCtx ctx;
   875    877     sqlite3_stmt *pScan;
   876    878   
   877    879     memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
   878    880     ctx.pConfig = p->pConfig;
   879         -  aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64)));
          881  +  aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
   880    882     if( !aTotalSize ) return SQLITE_NOMEM;
   881    883     aColSize = (int*)&aTotalSize[pConfig->nCol];
   882    884     memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
   883    885   
   884    886     /* Generate the expected index checksum based on the contents of the
   885    887     ** %_content table. This block stores the checksum in ctx.cksum. */
   886    888     rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
................................................................................
  1072   1074     }
  1073   1075     return rc;
  1074   1076   }
  1075   1077   
  1076   1078   int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){
  1077   1079     int rc = fts5StorageLoadTotals(p, 0);
  1078   1080     if( rc==SQLITE_OK ){
         1081  +    /* nTotalRow being zero does not necessarily indicate a corrupt 
         1082  +    ** database - it might be that the FTS5 table really does contain zero
         1083  +    ** rows. However this function is only called from the xRowCount() API,
         1084  +    ** and there is no way for that API to be invoked if the table contains
         1085  +    ** no rows. Hence the FTS5_CORRUPT return.  */
  1079   1086       *pnRow = p->nTotalRow;
         1087  +    if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT;
  1080   1088     }
  1081   1089     return rc;
  1082   1090   }
  1083   1091   
  1084   1092   /*
  1085   1093   ** Flush any data currently held in-memory to disk.
  1086   1094   */

Changes to ext/fts5/fts5_test_mi.c.

   305    305     const char *zArg                /* Matchinfo flag string */
   306    306   ){
   307    307     Fts5MatchinfoCtx *p;
   308    308     int nCol;
   309    309     int nPhrase;
   310    310     int i;
   311    311     int nInt;
   312         -  int nByte;
          312  +  sqlite3_int64 nByte;
   313    313     int rc;
   314    314   
   315    315     nCol = pApi->xColumnCount(pFts);
   316    316     nPhrase = pApi->xPhraseCount(pFts);
   317    317   
   318    318     nInt = 0;
   319    319     for(i=0; zArg[i]; i++){
................................................................................
   326    326       }
   327    327       nInt += n;
   328    328     }
   329    329   
   330    330     nByte = sizeof(Fts5MatchinfoCtx)          /* The struct itself */
   331    331            + sizeof(u32) * nInt               /* The p->aRet[] array */
   332    332            + (i+1);                           /* The p->zArg string */
   333         -  p = (Fts5MatchinfoCtx*)sqlite3_malloc(nByte);
          333  +  p = (Fts5MatchinfoCtx*)sqlite3_malloc64(nByte);
   334    334     if( p==0 ){
   335    335       sqlite3_result_error_nomem(pCtx);
   336    336       return 0;
   337    337     }
   338    338     memset(p, 0, nByte);
   339    339   
   340    340     p->nCol = nCol;

Changes to ext/fts5/fts5_test_tok.c.

   133    133       int nByte = 0;
   134    134       char **azDequote;
   135    135   
   136    136       for(i=0; i<argc; i++){
   137    137         nByte += (int)(strlen(argv[i]) + 1);
   138    138       }
   139    139   
   140         -    *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);
          140  +    *pazDequote = azDequote = sqlite3_malloc64(sizeof(char *)*argc + nByte);
   141    141       if( azDequote==0 ){
   142    142         rc = SQLITE_NOMEM;
   143    143       }else{
   144    144         char *pSpace = (char *)&azDequote[argc];
   145    145         for(i=0; i<argc; i++){
   146    146           int n = (int)strlen(argv[i]);
   147    147           azDequote[i] = pSpace;
................................................................................
   331    331   ){
   332    332     Fts5tokCursor *pCsr = (Fts5tokCursor*)pCtx;
   333    333     Fts5tokRow *pRow;
   334    334   
   335    335     if( (pCsr->nRow & (pCsr->nRow-1))==0 ){
   336    336       int nNew = pCsr->nRow ? pCsr->nRow*2 : 32;
   337    337       Fts5tokRow *aNew;
   338         -    aNew = (Fts5tokRow*)sqlite3_realloc(pCsr->aRow, nNew*sizeof(Fts5tokRow));
          338  +    aNew = (Fts5tokRow*)sqlite3_realloc64(pCsr->aRow, nNew*sizeof(Fts5tokRow));
   339    339       if( aNew==0 ) return SQLITE_NOMEM;
   340    340       memset(&aNew[pCsr->nRow], 0, sizeof(Fts5tokRow)*(nNew-pCsr->nRow));
   341    341       pCsr->aRow = aNew;
   342    342     }
   343    343   
   344    344     pRow = &pCsr->aRow[pCsr->nRow];
   345    345     pRow->iStart = iStart;

Changes to ext/fts5/fts5_tokenize.c.

   148    148         ie++;
   149    149       }
   150    150   
   151    151       /* Fold to lower case */
   152    152       nByte = ie-is;
   153    153       if( nByte>nFold ){
   154    154         if( pFold!=aFold ) sqlite3_free(pFold);
   155         -      pFold = sqlite3_malloc(nByte*2);
          155  +      pFold = sqlite3_malloc64((sqlite3_int64)nByte*2);
   156    156         if( pFold==0 ){
   157    157           rc = SQLITE_NOMEM;
   158    158           break;
   159    159         }
   160    160         nFold = nByte*2;
   161    161       }
   162    162       asciiFold(pFold, &pText[is], nByte);
................................................................................
   252    252     int bTokenChars                 /* 1 for 'tokenchars', 0 for 'separators' */
   253    253   ){
   254    254     int rc = SQLITE_OK;
   255    255     int n = (int)strlen(z);
   256    256     int *aNew;
   257    257   
   258    258     if( n>0 ){
   259         -    aNew = (int*)sqlite3_realloc(p->aiException, (n+p->nException)*sizeof(int));
          259  +    aNew = (int*)sqlite3_realloc64(p->aiException,
          260  +                                   (n+p->nException)*sizeof(int));
   260    261       if( aNew ){
   261    262         int nNew = p->nException;
   262    263         const unsigned char *zCsr = (const unsigned char*)z;
   263    264         const unsigned char *zTerm = (const unsigned char*)&z[n];
   264    265         while( zCsr<zTerm ){
   265    266           u32 iCode;
   266    267           int bToken;
................................................................................
   486    487       /* Run through the tokenchars. Fold them into the output buffer along
   487    488       ** the way.  */
   488    489       while( zCsr<zTerm ){
   489    490   
   490    491         /* Grow the output buffer so that there is sufficient space to fit the
   491    492         ** largest possible utf-8 character.  */
   492    493         if( zOut>pEnd ){
   493         -        aFold = sqlite3_malloc(nFold*2);
          494  +        aFold = sqlite3_malloc64((sqlite3_int64)nFold*2);
   494    495           if( aFold==0 ){
   495    496             rc = SQLITE_NOMEM;
   496    497             goto tokenize_done;
   497    498           }
   498    499           zOut = &aFold[zOut - p->aFold];
   499    500           memcpy(aFold, p->aFold, nFold);
   500    501           sqlite3_free(p->aFold);

Changes to ext/fts5/fts5_unicode2.c.

     1      1   /*
     2         -** 2012 May 25
            2  +** 2012-05-25
     3      3   **
     4      4   ** The author disclaims copyright to this source code.  In place of
     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
................................................................................
    43     43       61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914, 
    44     44       61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218, 
    45     45       62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554, 
    46     46       62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766, 
    47     47       62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118, 
    48     48       63182, 63242, 63274, 63310, 63368, 63390, 
    49     49     };
    50         -#define HIBIT ((char)0x80)
    51         -  char aChar[] = {
           50  +#define HIBIT ((unsigned char)0x80)
           51  +  unsigned char aChar[] = {
    52     52       '\0',      'a',       'c',       'e',       'i',       'n',       
    53     53       'o',       'u',       'y',       'y',       'a',       'c',       
    54     54       'd',       'e',       'e',       'g',       'h',       'i',       
    55     55       'j',       'k',       'l',       'n',       'o',       'r',       
    56     56       's',       't',       'u',       'u',       'w',       'y',       
    57     57       'z',       'o',       'u',       'a',       'i',       'o',       
    58     58       'u',       'u'|HIBIT, 'a'|HIBIT, 'g',       'k',       'o',       
................................................................................
   770    770       int n = (aFts5UnicodeData[iTbl] >> 5) + i;
   771    771       for(; i<128 && i<n; i++){
   772    772         aAscii[i] = bToken;
   773    773       }
   774    774       iTbl++;
   775    775     }
   776    776   }
   777         -

Changes to ext/fts5/fts5_varint.c.

    72     72     ** routine.
    73     73     */
    74     74     {
    75     75       u64 v64;
    76     76       u8 n;
    77     77       p -= 2;
    78     78       n = sqlite3Fts5GetVarint(p, &v64);
    79         -    *v = (u32)v64;
           79  +    *v = ((u32)v64) & 0x7FFFFFFF;
    80     80       assert( n>3 && n<=9 );
    81     81       return n;
    82     82     }
    83     83   }
    84     84   
    85     85   
    86     86   /*
................................................................................
   338    338   #endif
   339    339     assert( iVal>=(1 << 7) );
   340    340     if( iVal<(1 << 14) ) return 2;
   341    341     if( iVal<(1 << 21) ) return 3;
   342    342     if( iVal<(1 << 28) ) return 4;
   343    343     return 5;
   344    344   }
   345         -

Changes to ext/fts5/fts5_vocab.c.

    51     51     Fts5Global *pGlobal;            /* FTS5 global object for this database */
    52     52     int eType;                      /* FTS5_VOCAB_COL, ROW or INSTANCE */
    53     53   };
    54     54   
    55     55   struct Fts5VocabCursor {
    56     56     sqlite3_vtab_cursor base;
    57     57     sqlite3_stmt *pStmt;            /* Statement holding lock on pIndex */
    58         -  Fts5Index *pIndex;              /* Associated FTS5 index */
           58  +  Fts5Table *pFts5;               /* Associated FTS5 table */
    59     59   
    60     60     int bEof;                       /* True if this cursor is at EOF */
    61     61     Fts5IndexIter *pIter;           /* Term/rowid iterator object */
    62     62   
    63     63     int nLeTerm;                    /* Size of zLeTerm in bytes */
    64     64     char *zLeTerm;                  /* (term <= $zLeTerm) paramater, or NULL */
    65     65   
    66     66     /* These are used by 'col' tables only */
    67         -  Fts5Config *pConfig;            /* Fts5 table configuration */
    68     67     int iCol;
    69     68     i64 *aCnt;
    70     69     i64 *aDoc;
    71     70   
    72     71     /* Output values used by all tables. */
    73     72     i64 rowid;                      /* This table's current rowid value */
    74     73     Fts5Buffer term;                /* Current value of 'term' column */
................................................................................
   323    322   ** Implementation of xOpen method.
   324    323   */
   325    324   static int fts5VocabOpenMethod(
   326    325     sqlite3_vtab *pVTab, 
   327    326     sqlite3_vtab_cursor **ppCsr
   328    327   ){
   329    328     Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab;
   330         -  Fts5Index *pIndex = 0;
   331         -  Fts5Config *pConfig = 0;
          329  +  Fts5Table *pFts5 = 0;
   332    330     Fts5VocabCursor *pCsr = 0;
   333    331     int rc = SQLITE_OK;
   334    332     sqlite3_stmt *pStmt = 0;
   335    333     char *zSql = 0;
   336    334   
   337    335     zSql = sqlite3Fts5Mprintf(&rc,
   338    336         "SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'",
................................................................................
   343    341     }
   344    342     sqlite3_free(zSql);
   345    343     assert( rc==SQLITE_OK || pStmt==0 );
   346    344     if( rc==SQLITE_ERROR ) rc = SQLITE_OK;
   347    345   
   348    346     if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
   349    347       i64 iId = sqlite3_column_int64(pStmt, 0);
   350         -    pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &pConfig);
          348  +    pFts5 = sqlite3Fts5TableFromCsrid(pTab->pGlobal, iId);
   351    349     }
   352    350   
   353         -  if( rc==SQLITE_OK && pIndex==0 ){
   354         -    rc = sqlite3_finalize(pStmt);
   355         -    pStmt = 0;
   356         -    if( rc==SQLITE_OK ){
   357         -      pVTab->zErrMsg = sqlite3_mprintf(
   358         -          "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
   359         -      );
   360         -      rc = SQLITE_ERROR;
          351  +  if( rc==SQLITE_OK ){
          352  +    if( pFts5==0 ){
          353  +      rc = sqlite3_finalize(pStmt);
          354  +      pStmt = 0;
          355  +      if( rc==SQLITE_OK ){
          356  +        pVTab->zErrMsg = sqlite3_mprintf(
          357  +            "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
          358  +            );
          359  +        rc = SQLITE_ERROR;
          360  +      }
          361  +    }else{
          362  +      rc = sqlite3Fts5FlushToDisk(pFts5);
   361    363       }
   362    364     }
   363    365   
   364    366     if( rc==SQLITE_OK ){
   365         -    int nByte = pConfig->nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor);
          367  +    int nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor);
   366    368       pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);
   367    369     }
   368    370   
   369    371     if( pCsr ){
   370         -    pCsr->pIndex = pIndex;
          372  +    pCsr->pFts5 = pFts5;
   371    373       pCsr->pStmt = pStmt;
   372         -    pCsr->pConfig = pConfig;
   373    374       pCsr->aCnt = (i64*)&pCsr[1];
   374         -    pCsr->aDoc = &pCsr->aCnt[pConfig->nCol];
          375  +    pCsr->aDoc = &pCsr->aCnt[pFts5->pConfig->nCol];
   375    376     }else{
   376    377       sqlite3_finalize(pStmt);
   377    378     }
   378    379   
   379    380     *ppCsr = (sqlite3_vtab_cursor*)pCsr;
   380    381     return rc;
   381    382   }
................................................................................
   383    384   static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){
   384    385     pCsr->rowid = 0;
   385    386     sqlite3Fts5IterClose(pCsr->pIter);
   386    387     pCsr->pIter = 0;
   387    388     sqlite3_free(pCsr->zLeTerm);
   388    389     pCsr->nLeTerm = -1;
   389    390     pCsr->zLeTerm = 0;
          391  +  pCsr->bEof = 0;
   390    392   }
   391    393   
   392    394   /*
   393    395   ** Close the cursor.  For additional information see the documentation
   394    396   ** on the xClose method of the virtual table interface.
   395    397   */
   396    398   static int fts5VocabCloseMethod(sqlite3_vtab_cursor *pCursor){
................................................................................
   421    423   
   422    424       sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);
   423    425     }
   424    426     return rc;
   425    427   }
   426    428   
   427    429   static int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){
   428         -  int eDetail = pCsr->pConfig->eDetail;
          430  +  int eDetail = pCsr->pFts5->pConfig->eDetail;
   429    431     int rc = SQLITE_OK;
   430    432     Fts5IndexIter *pIter = pCsr->pIter;
   431    433     i64 *pp = &pCsr->iInstPos;
   432    434     int *po = &pCsr->iInstOff;
   433    435     
   434    436     assert( sqlite3Fts5IterEof(pIter)==0 );
   435    437     assert( pCsr->bEof==0 );
................................................................................
   456    458   /*
   457    459   ** Advance the cursor to the next row in the table.
   458    460   */
   459    461   static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
   460    462     Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
   461    463     Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;
   462    464     int rc = SQLITE_OK;
   463         -  int nCol = pCsr->pConfig->nCol;
          465  +  int nCol = pCsr->pFts5->pConfig->nCol;
   464    466   
   465    467     pCsr->rowid++;
   466    468   
   467    469     if( pTab->eType==FTS5_VOCAB_INSTANCE ){
   468    470       return fts5VocabInstanceNext(pCsr);
   469    471     }
   470    472   
................................................................................
   478    480       if( sqlite3Fts5IterEof(pCsr->pIter) ){
   479    481         pCsr->bEof = 1;
   480    482       }else{
   481    483         const char *zTerm;
   482    484         int nTerm;
   483    485   
   484    486         zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
          487  +      assert( nTerm>=0 );
   485    488         if( pCsr->nLeTerm>=0 ){
   486    489           int nCmp = MIN(nTerm, pCsr->nLeTerm);
   487    490           int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);
   488    491           if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){
   489    492             pCsr->bEof = 1;
   490    493             return SQLITE_OK;
   491    494           }
................................................................................
   494    497         sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);
   495    498         memset(pCsr->aCnt, 0, nCol * sizeof(i64));
   496    499         memset(pCsr->aDoc, 0, nCol * sizeof(i64));
   497    500         pCsr->iCol = 0;
   498    501   
   499    502         assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW );
   500    503         while( rc==SQLITE_OK ){
   501         -        int eDetail = pCsr->pConfig->eDetail;
          504  +        int eDetail = pCsr->pFts5->pConfig->eDetail;
   502    505           const u8 *pPos; int nPos;   /* Position list */
   503    506           i64 iPos = 0;               /* 64-bit position read from poslist */
   504    507           int iOff = 0;               /* Current offset within position list */
   505    508   
   506    509           pPos = pCsr->pIter->pData;
   507    510           nPos = pCsr->pIter->nData;
   508    511   
................................................................................
   517    520               break;
   518    521   
   519    522             case FTS5_VOCAB_COL:
   520    523               if( eDetail==FTS5_DETAIL_FULL ){
   521    524                 int iCol = -1;
   522    525                 while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){
   523    526                   int ii = FTS5_POS2COLUMN(iPos);
   524         -                pCsr->aCnt[ii]++;
   525    527                   if( iCol!=ii ){
   526    528                     if( ii>=nCol ){
   527    529                       rc = FTS5_CORRUPT;
   528    530                       break;
   529    531                     }
   530    532                     pCsr->aDoc[ii]++;
   531    533                     iCol = ii;
   532    534                   }
          535  +                pCsr->aCnt[ii]++;
   533    536                 }
   534    537               }else if( eDetail==FTS5_DETAIL_COLUMNS ){
   535    538                 while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){
   536    539                   assert_nc( iPos>=0 && iPos<nCol );
   537    540                   if( iPos>=nCol ){
   538    541                     rc = FTS5_CORRUPT;
   539    542                     break;
................................................................................
   554    557           if( rc==SQLITE_OK ){
   555    558             rc = sqlite3Fts5IterNextScan(pCsr->pIter);
   556    559           }
   557    560           if( pTab->eType==FTS5_VOCAB_INSTANCE ) break;
   558    561   
   559    562           if( rc==SQLITE_OK ){
   560    563             zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
   561         -          if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ){
          564  +          if( nTerm!=pCsr->term.n 
          565  +          || (nTerm>0 && memcmp(zTerm, pCsr->term.p, nTerm)) 
          566  +          ){
   562    567               break;
   563    568             }
   564    569             if( sqlite3Fts5IterEof(pCsr->pIter) ) break;
   565    570           }
   566    571         }
   567    572       }
   568    573     }
   569    574   
   570    575     if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){
   571    576       while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++;
   572         -    assert( pCsr->iCol<pCsr->pConfig->nCol );
          577  +    assert( pCsr->iCol<pCsr->pFts5->pConfig->nCol );
   573    578     }
   574    579     return rc;
   575    580   }
   576    581   
   577    582   /*
   578    583   ** This is the xFilter implementation for the virtual table.
   579    584   */
................................................................................
   612    617     }else{
   613    618       if( pGe ){
   614    619         zTerm = (const char *)sqlite3_value_text(pGe);
   615    620         nTerm = sqlite3_value_bytes(pGe);
   616    621       }
   617    622       if( pLe ){
   618    623         const char *zCopy = (const char *)sqlite3_value_text(pLe);
          624  +      if( zCopy==0 ) zCopy = "";
   619    625         pCsr->nLeTerm = sqlite3_value_bytes(pLe);
   620    626         pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1);
   621    627         if( pCsr->zLeTerm==0 ){
   622    628           rc = SQLITE_NOMEM;
   623    629         }else{
   624    630           memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1);
   625    631         }
   626    632       }
   627    633     }
   628    634   
   629    635     if( rc==SQLITE_OK ){
   630         -    rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
          636  +    Fts5Index *pIndex = pCsr->pFts5->pIndex;
          637  +    rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
   631    638     }
   632    639     if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
   633    640       rc = fts5VocabInstanceNewTerm(pCsr);
   634    641     }
   635         -  if( rc==SQLITE_OK 
   636         -   && !pCsr->bEof 
   637         -   && (eType!=FTS5_VOCAB_INSTANCE || pCsr->pConfig->eDetail!=FTS5_DETAIL_NONE)
          642  +  if( rc==SQLITE_OK && !pCsr->bEof 
          643  +   && (eType!=FTS5_VOCAB_INSTANCE 
          644  +    || pCsr->pFts5->pConfig->eDetail!=FTS5_DETAIL_NONE)
   638    645     ){
   639    646       rc = fts5VocabNextMethod(pCursor);
   640    647     }
   641    648   
   642    649     return rc;
   643    650   }
   644    651   
................................................................................
   653    660   
   654    661   static int fts5VocabColumnMethod(
   655    662     sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */
   656    663     sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */
   657    664     int iCol                        /* Index of column to read value from */
   658    665   ){
   659    666     Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
   660         -  int eDetail = pCsr->pConfig->eDetail;
          667  +  int eDetail = pCsr->pFts5->pConfig->eDetail;
   661    668     int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType;
   662    669     i64 iVal = 0;
   663    670   
   664    671     if( iCol==0 ){
   665    672       sqlite3_result_text(
   666    673           pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT
   667    674       );
   668    675     }else if( eType==FTS5_VOCAB_COL ){
   669    676       assert( iCol==1 || iCol==2 || iCol==3 );
   670    677       if( iCol==1 ){
   671    678         if( eDetail!=FTS5_DETAIL_NONE ){
   672         -        const char *z = pCsr->pConfig->azCol[pCsr->iCol];
          679  +        const char *z = pCsr->pFts5->pConfig->azCol[pCsr->iCol];
   673    680           sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);
   674    681         }
   675    682       }else if( iCol==2 ){
   676    683         iVal = pCsr->aDoc[pCsr->iCol];
   677    684       }else{
   678    685         iVal = pCsr->aCnt[pCsr->iCol];
   679    686       }
................................................................................
   693    700         case 2: {
   694    701           int ii = -1;
   695    702           if( eDetail==FTS5_DETAIL_FULL ){
   696    703             ii = FTS5_POS2COLUMN(pCsr->iInstPos);
   697    704           }else if( eDetail==FTS5_DETAIL_COLUMNS ){
   698    705             ii = (int)pCsr->iInstPos;
   699    706           }
   700         -        if( ii>=0 && ii<pCsr->pConfig->nCol ){
   701         -          const char *z = pCsr->pConfig->azCol[ii];
          707  +        if( ii>=0 && ii<pCsr->pFts5->pConfig->nCol ){
          708  +          const char *z = pCsr->pFts5->pConfig->azCol[ii];
   702    709             sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);
   703    710           }
   704    711           break;
   705    712         }
   706    713         default: {
   707    714           assert( iCol==3 );
   708    715           if( eDetail==FTS5_DETAIL_FULL ){

Changes to ext/fts5/test/fts5ai.test.

    47     47       ROLLBACK TO one;
    48     48     COMMIT;
    49     49   }
    50     50   
    51     51   do_execsql_test 1.2 {
    52     52     INSERT INTO t1(t1) VALUES('integrity-check');
    53     53   }
           54  +
           55  +do_execsql_test 1.3 {
           56  +  SAVEPOINT one;
           57  +    INSERT INTO t1 VALUES('v w x');
           58  +  ROLLBACK TO one;
           59  +}
    54     60   }
    55     61   
    56     62   
    57     63   finish_test

Changes to ext/fts5/test/fts5ak.test.

   139    139     --   '[a b c d e]'
   140    140     SELECT highlight(ft, 0, '[', ']') FROM ft WHERE ft MATCH 'a+b+c AND c+d+e';
   141    141   } {
   142    142     {[a b c] x [c d e]}
   143    143     {[a b c] [c d e]}
   144    144     {[a b c d e]}
   145    145   }
          146  +
          147  +do_execsql_test 3.2 {
          148  +  SELECT highlight(ft, 0, NULL, NULL) FROM ft WHERE ft MATCH 'a+b+c AND c+d+e';
          149  +} {
          150  +  {a b c x c d e}
          151  +  {a b c c d e}
          152  +  {a b c d e}
          153  +}
   146    154   
   147    155   }
   148    156   
   149    157   finish_test

Changes to ext/fts5/test/fts5aux.test.

   271    271   
   272    272   do_execsql_test 9.3 {
   273    273     SELECT rowid FROM t1('b:a AND b:b') ORDER BY rank;
   274    274   } {
   275    275     9 10
   276    276   }
   277    277   
          278  +#-------------------------------------------------------------------------
          279  +# Test that aux. functions may not be used in aggregate queries.
          280  +#
          281  +reset_db
          282  +do_execsql_test 10.0 {
          283  +  CREATE VIRTUAL TABLE t1 USING fts5(x, y, z);
          284  +  INSERT INTO t1 VALUES('a', 'one two', 1);
          285  +  INSERT INTO t1 VALUES('b', 'two three', 2);
          286  +  INSERT INTO t1 VALUES('c', 'three four', 1);
          287  +  INSERT INTO t1 VALUES('d', 'four five', 2);
          288  +  INSERT INTO t1 VALUES('e', 'five six', 1);
          289  +  INSERT INTO t1 VALUES('f', 'six seven', 2);
          290  +}
          291  +
          292  +proc firstcol {cmd} { $cmd xColumnText 0 }
          293  +sqlite3_fts5_create_function db firstcol firstcol
          294  +
          295  +do_execsql_test 10.1.1 {
          296  +  SELECT firstcol(t1) FROM t1
          297  +} {a b c d e f}
          298  +do_execsql_test 10.1.2 {
          299  +  SELECT group_concat(x, '.') FROM t1
          300  +} {a.b.c.d.e.f}
          301  +
          302  +do_catchsql_test 10.1.3 {
          303  +  SELECT group_concat(firstcol(t1), '.') FROM t1
          304  +} {1 {unable to use function firstcol in the requested context}}
   278    305   
          306  +do_catchsql_test 10.1.4 {
          307  +  SELECT group_concat(firstcol(t1), '.') FROM t1 GROUP BY rowid
          308  +} {1 {unable to use function firstcol in the requested context}}
   279    309   
   280    310   finish_test
          311  +

Changes to ext/fts5/test/fts5corrupt3.test.

    19     19   
    20     20   # If SQLITE_ENABLE_FTS5 is defined, omit this file.
    21     21   ifcapable !fts5 {
    22     22     finish_test
    23     23     return
    24     24   }
    25     25   sqlite3_fts5_may_be_corrupt 1
           26  +database_may_be_corrupt
    26     27   
    27     28   proc create_t1 {} {
    28     29     expr srand(0)
    29     30     db func rnddoc fts5_rnddoc
    30     31     db eval {
    31     32       CREATE VIRTUAL TABLE t1 USING fts5(x);
    32     33       INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
................................................................................
  2096   2097   | end c22b.db
  2097   2098   }]} {}
  2098   2099   
  2099   2100   
  2100   2101   do_catchsql_test 22.1 {
  2101   2102     INSERT INTO t1(t1) VALUES('optimize');
  2102   2103   } {1 {vtable constructor failed: t1}}
         2104  +
         2105  +#--------------------------------------------------------------------------
         2106  +reset_db
         2107  +do_test 23.0 {
         2108  +  sqlite3 db {}
         2109  +  db deserialize [decode_hexdb {
         2110  +| size 28672 pagesize 4096 filename c24b.db
         2111  +| page 1 offset 0
         2112  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         2113  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
         2114  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04   ................
         2115  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         2116  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         2117  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         2118  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         2119  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         2120  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         2121  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         2122  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         2123  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         2124  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         2125  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         2126  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         2127  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         2128  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         2129  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         2130  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         2131  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         2132  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         2133  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         2134  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         2135  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         2136  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         2137  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         2138  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         2139  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         2140  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         2141  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         2142  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         2143  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         2144  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         2145  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         2146  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         2147  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         2148  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         2149  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         2150  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         2151  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         2152  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         2153  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         2154  +| page 2 offset 4096
         2155  +|      0: 0d 0f 1c 00 05 0e cb 00 0f e8 0e cb 0f bd 0f 30   ...............0
         2156  +|     16: 0e e2 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         2157  +|   3776: 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00 30   ...............0
         2158  +|   3792: 00 00 00 00 01 03 03 00 03 01 01 01 02 01 01 03   ................
         2159  +|   3808: 01 01 33 8c 80 80 80 80 01 03 00 6c 00 00 00 2c   ..3........l...,
         2160  +|   3824: 07 30 62 61 63 6b 75 70 05 02 04 02 05 65 61 6d   .0backup.....eam
         2161  +|   3840: 65 72 05 02 02 02 05 6f 6f 6d 65 72 05 01 02 05   er.....oomer....
         2162  +|   3856: 75 6d 6d 65 72 05 02 03 04 0b 0a 09 0f ef 00 14   ummer...........
         2163  +|   3872: 2a 00 00 00 00 01 02 02 00 02 01 01 01 02 01 01   *...............
         2164  +|   3888: 81 05 88 80 80 80 80 01 04 00 82 0e 00 00 00 76   ...............v
         2165  +|   3904: 06 30 61 62 61 63 6b 08 02 07 04 04 6e 64 6f 6e   .0aback.....ndon
         2166  +|   3920: 08 02 05 02 05 63 74 69 76 65 04 02 02 04 02 0b   .....ctive......
         2167  +|   3936: 02 04 6c 70 68 61 08 02 0a 02 03 74 6f 6d 06 02   ..lpha.....tom..
         2168  +|   3952: 02 02 02 09 05 02 69 63 07 02 02 01 06 62 61 63   ......ic.....bac
         2169  +|   3968: 6b 75 70 08 02 04 02 05 6f 6f 6d 65 72 05 02 02   kup.....oomer...
         2170  +|   3984: 03 02 08 01 07 63 68 61 6e 6e 65 6c 08 02 03 01   .....channel....
         2171  +|   4000: 05 65 6c 70 68 61 08 02 02 01 04 74 65 73 74 08   .elpha.....test.
         2172  +|   4016: 02 06 04 0a 09 0d 09 0b 07 0b 0d 0c 0a 24 84 80   .............$..
         2173  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 02 61 23 25 23   ......N.....a#%#
         2174  +|   4048: 27 2b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   '+.....ft.....nd
         2175  +|   4064: 6f 6e 03 02 00 a0 42 70 05 01 03 00 10 08 13 00   on....Bp........
         2176  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         2177  +| page 3 offset 8192
         2178  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         2179  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         2180  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         2181  +| page 4 offset 12288
         2182  +|      0: 0d 0f ca 00 08 0f 57 00 0f f6 0f ec 0f e0 0f d5   ......W.........
         2183  +|     16: 0f 57 0f c1 0f b6 0f 70 00 00 00 00 00 00 00 00   .W.....p........
         2184  +|   3920: 00 00 00 00 00 00 00 17 05 03 00 35 62 65 61 6d   ...........5beam
         2185  +|   3936: 65 72 20 62 75 6d 6d 65 72 20 62 61 63 6b 75 70   er bummer backup
         2186  +|   3952: 44 08 04 00 81 0d 65 6c 70 68 61 20 63 68 61 6e   D.....elpha chan
         2187  +|   3968: 6e 65 6c 20 62 61 63 6b 75 70 20 61 62 61 6e 64   nel backup aband
         2188  +|   3984: 6f 6e 20 74 65 73 74 20 61 62 61 63 6b 20 62 6f   on test aback bo
         2189  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         2190  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         2191  +|   4032: 63 07 06 03 00 15 61 74 6f 6d 00 00 00 0b 19 62   c.....atom.....b
         2192  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
         2193  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         2194  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         2195  +| page 5 offset 16384
         2196  +|      0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8   ................
         2197  +|     16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00   ................
         2198  +|   4048: 04 08 03 00 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         2199  +|   4064: 0e 01 04 05 03 00 0e 03 04 04 03 00 0e 01 04 03   ................
         2200  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         2201  +| page 6 offset 20480
         2202  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         2203  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         2204  +| page 7 offset 24576
         2205  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         2206  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         2207  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         2208  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         2209  +| end c24b.db
         2210  +}]} {}
         2211  +
         2212  +do_catchsql_test 23.1 {
         2213  +  INSERT INTO t1(t1) VALUES('optimize');
         2214  +} {1 {database disk image is malformed}}
         2215  +
         2216  +#--------------------------------------------------------------------------
         2217  +reset_db
         2218  +do_test 24.0 {
         2219  +  sqlite3 db {}
         2220  +  db deserialize [decode_hexdb {
         2221  +| size 32768 pagesize 4096 filename crash-b87dfef02880fe.db
         2222  +| page 1 offset 0
         2223  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         2224  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08   .....@  ........
         2225  +|     32: 00 00 00 02 00 00 00 01 00 00 00 09 00 00 00 04   ................
         2226  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         2227  +|     96: 00 00 00 00 0d 0f c7 00 07 0d 92 00 0f 8d 0f 36   ...............6
         2228  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d 92 0d 92 00 00 00 00   ...k............
         2229  +|   3472: 00 00 22 08 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         2230  +|   3488: 32 74 32 08 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         2231  +|   3504: 20 74 32 28 78 29 56 07 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         2232  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         2233  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         2234  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         2235  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         2236  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         2237  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         2238  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         2239  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         2240  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         2241  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         2242  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         2243  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         2244  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         2245  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         2246  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         2247  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         2248  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         2249  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         2250  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         2251  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         2252  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         2253  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         2254  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         2255  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         2256  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         2257  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         2258  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         2259  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         2260  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         2261  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         2262  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         2263  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         2264  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         2265  +| page 3 offset 8192
         2266  +|      0: 0d 00 00 00 03 0c 94 00 0f e6 0f ef 0c 94 00 00   ................
         2267  +|   3216: 00 00 00 00 86 4a 84 80 80 80 80 01 04 00 8d 18   .....J..........
         2268  +|   3232: 00 00 03 2b 02 30 30 01 02 06 01 02 06 01 02 06   ...+.00.........
         2269  +|   3248: 1f 02 03 01 02 03 01 02 03 01 08 32 30 31 36 30   ...........20160
         2270  +|   3264: 36 30 39 01 02 07 01 02 07 01 02 07 01 01 34 01   609...........4.
         2271  +|   3280: 02 05 01 02 05 01 02 05 01 01 35 01 02 04 01 02   ..........5.....
         2272  +|   3296: 04 01 02 04 02 07 30 30 30 30 30 30 30 1c 02 04   ......0000000...
         2273  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         2274  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2275  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2276  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         2277  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 08 63 6f 6d 70   ............comp
         2278  +|   3392: 69 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64   iler...........d
         2279  +|   3408: 62 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04   bstat...........
         2280  +|   3424: 65 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65   ebug...........e
         2281  +|   3440: 6e 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02   nable...........
         2282  +|   3456: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         2283  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         2284  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         2285  +|   3504: 02 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02   ......xtension..
         2286  +|   3520: 04 01 02 04 01 02 04 01 04 66 74 73 34 1a 02 03   .........fts4...
         2287  +|   3536: 01 02 03 01 02 03 04 01 35 0d 02 03 01 02 03 01   ........5.......
         2288  +|   3552: 02 03 01 03 67 63 63 01 02 03 01 02 03 01 02 03   ....gcc.........
         2289  +|   3568: 02 06 65 6f 70 6f 6c 79 10 02 03 01 02 03 01 02   ..eopoly........
         2290  +|   3584: 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03 01 02   ...json1........
         2291  +|   3600: 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01 02 03   ...load.........
         2292  +|   3616: 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02 02 05   ..max...........
         2293  +|   3632: 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03 04 04   emory...........
         2294  +|   3648: 73 79 73 35 16 02 03 01 02 03 01 02 03 01 06 6e   sys5...........n
         2295  +|   3664: 6f 63 61 73 65 02 06 01 02 02 03 06 01 02 02 03   ocase...........
         2296  +|   3680: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         2297  +|   3696: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2298  +|   3712: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2299  +|   3728: 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01 02 02   ...omit.........
         2300  +|   3744: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02   ................
         2301  +|   3760: 58 81 96 4d 01 06 01 02 02 03 06 01 02 02 03 06   X..M............
         2302  +|   3776: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2303  +|   3792: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2304  +|   3808: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         2305  +|   3824: 01 0a 74 68 72 65 61 64 73 61 66 65 22 02 02 01   ..threadsafe....
         2306  +|   3840: 02 02 01 02 02 01 04 76 74 61 62 07 02 04 01 02   .......vtab.....
         2307  +|   3856: 04 01 02 04 01 01 78 01 06 01 01 02 01 06 01 01   ......x.........
         2308  +|   3872: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         2309  +|   3888: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         2310  +|   3904: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         2311  +|   3920: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         2312  +|   3936: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         2313  +|   3952: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         2314  +|   3968: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         2315  +|   3984: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         2316  +|   4000: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         2317  +|   4016: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         2318  +|   4032: 02 01 06 01 01 02 01 06 01 01 02 04 15 13 0c 0c   ................
         2319  +|   4048: 12 44 13 11 0f 47 13 0f 0c 0e 11 10 0f 0e 10 0f   .D...G..........
         2320  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 5a 24 24 0f   D..@.......$Z$$.
         2321  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         2322  +| page 4 offset 12288
         2323  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         2324  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         2325  +| page 5 offset 16384
         2326  +|      0: 0d 00 00 00 24 0c 0a 00 0f d8 0f af 0f 86 0f 74   ....$..........t
         2327  +|     16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5   .a.N./..........
         2328  +|     32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5   ...t.[.@.$......
         2329  +|     48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb   .......h.O.5....
         2330  +|     64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a   .......x.W.>.$..
         2331  +|   3072: 00 00 00 00 00 00 00 00 00 00 18 24 05 00 25 0f   ...........$..%.
         2332  +|   3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49   .THREADSAFE=0XBI
         2333  +|   3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41   NARY.#..%..THREA
         2334  +|   3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22   DSAFE=0XNOCASE..
         2335  +|   3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d   ..%..THREADSAFE=
         2336  +|   3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d   0XRTRIM.!..3..OM
         2337  +|   3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f   IT LOAD EXTENSIO
         2338  +|   3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f   NXBINARY. ..3..O
         2339  +|   3200: 4d 49 54 20 4c 4f 41 44 b2 04 55 85 44 54 e5 34   MIT LOAD..U.DT.4
         2340  +|   3216: 94 f4 e5 84 e4 f4 34 15 34 51 e1 f0 50 03 30 f1   ......4.4Q..P.0.
         2341  +|   3232: 74 f4 d4 95 42 04 c4 f4 14 42 04 55 85 44 54 e5   t...B....B.U.DT.
         2342  +|   3248: 34 94 f4 e5 85 25 45 24 94 d1 f1 e0 50 03 30 f1   4....%E$....P.0.
         2343  +|   3264: 94 d4 15 82 04 d4 54 d4 f5 25 93 d3 53 03 03 03   ......T..%..S...
         2344  +|   3280: 03 03 03 05 84 24 94 e4 15 25 91 f1 d0 50 03 30   .....$...%...P.0
         2345  +|   3296: f1 94 d4 15 82 04 d4 54 d4 f5 25 93 d3 53 03 03   .......T..%..S..
         2346  +|   3312: 03 03 03 03 05 84 e4 f4 34 15 34 51 e1 c0 50 03   ........4.4Q..P.
         2347  +|   3328: 30 f1 74 d4 15 82 04 d4 54 d4 f5 25 93 d3 53 03   0.t.....T..%..S.
         2348  +|   3344: 03 03 03 03 03 05 85 25 45 24 94 d1 81 b0 50 02   .......%E$....P.
         2349  +|   3360: 50 f1 94 54 e4 14 24 c4 52 05 25 45 24 54 55 84   P..T..$.R.%E$TU.
         2350  +|   3376: 24 94 e4 15 25 91 81 a0 50 02 50 f1 94 54 e4 14   $...%...P.P..T..
         2351  +|   3392: 24 c4 52 05 25 45 24 54 55 84 e4 f4 34 15 34 51   $.R.%E$TU...4.4Q
         2352  +|   3408: 71 90 50 02 50 f1 74 54 e4 14 24 c4 52 05 25 45   q.P.P.tT..$.R.%E
         2353  +|   3424: 24 54 55 85 25 45 24 94 d1 a1 80 50 02 90 f1 94   $TU.%E$....P....
         2354  +|   3440: 54 e4 14 24 c4 52 04 d4 54 d5 35 95 33 55 84 24   T..$.R..T.5.3U.$
         2355  +|   3456: 94 e4 15 25 91 a1 70 50 02 90 f1 94 54 e4 14 24   ...%..pP....T..$
         2356  +|   3472: c4 52 04 d4 54 d5 35 95 33 55 84 e4 f4 34 15 34   .R..T.5.3U...4.4
         2357  +|   3488: 51 91 60 50 02 90 f1 74 54 e4 14 24 c4 52 04 d4   Q.`P...tT..$.R..
         2358  +|   3504: 54 d5 35 95 33 55 85 25 45 24 94 d1 81 50 50 02   T.5.3U.%E$...PP.
         2359  +|   3520: 50 f1 94 54 e4 14 24 c4 52 04 a5 34 f4 e3 15 84   P..T..$.R..4....
         2360  +|   3536: 24 94 e4 15 25 91 81 40 50 02 50 f1 94 54 e4 14   $...%..@P.P..T..
         2361  +|   3552: 24 c4 52 04 a5 34 f4 e3 15 84 e4 f4 34 15 34 51   $.R..4......4.4Q
         2362  +|   3568: 71 30 50 02 50 f1 74 54 e4 14 24 c4 52 04 a5 34   q0P.P.tT..$.R..4
         2363  +|   3584: f4 e3 15 85 25 45 24 94 d1 a1 20 50 02 90 f1 94   ....%E$... P....
         2364  +|   3600: 54 e4 14 24 c4 52 04 74 54 f5 04 f4 c5 95 84 24   T..$.R.tT......$
         2365  +|   3616: 94 e4 15 25 91 a1 10 50 02 90 f1 94 54 e4 14 24   ...%...P....T..$
         2366  +|   3632: c4 52 04 74 54 f5 04 f4 c5 95 84 e4 f4 34 15 34   .R.tT........4.4
         2367  +|   3648: 51 91 00 50 02 90 f1 74 54 e4 14 24 c4 52 04 74   Q..P...tT..$.R.t
         2368  +|   3664: 54 f5 04 f4 c5 95 85 25 45 24 94 d1 70 f0 50 02   T......%E$..p.P.
         2369  +|   3680: 30 f1 94 54 e4 14 24 c5 20 46 54 53 35 58 42 49   0..T..$. FTS5XBI
         2370  +|   3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c   NARY....#..ENABL
         2371  +|   3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05   E FTS5XNOCASE...
         2372  +|   3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58   .#..ENABLE FTS5X
         2373  +|   3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42   RTRIM....#..ENAB
         2374  +|   3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 97 0b   LE FTS4XBINARY..
         2375  +|   3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34   ..#..ENABLE FTS4
         2376  +|   3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e   XNOCASE....#..EN
         2377  +|   3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e   ABLE FTS4XRTRIM.
         2378  +|   3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         2379  +|   3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e   TAT VTABXBINARY.
         2380  +|   3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         2381  +|   3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d   TAT VTABXNOCASE.
         2382  +|   3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         2383  +|   3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06   TAT VTABXRTRIM..
         2384  +|   3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52   .....DEBUGXBINAR
         2385  +|   3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f   Y.......DEBUGXNO
         2386  +|   3952: 43 41 53 45 10 02 02 50 08 5f 17 44 45 42 55 47   CASE...P._.DEBUG
         2387  +|   3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d   XRTRIM'...C..COM
         2388  +|   3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20   PILER=gcc-5.4.0 
         2389  +|   4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27   20160609XBINARY'
         2390  +|   4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67   ...C..COMPILER=g
         2391  +|   4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30   cc-5.4.0 2016060
         2392  +|   4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43   9XNOCASE&...C..C
         2393  +|   4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e   OMPILER=gcc-5.4.
         2394  +|   4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d   0 20160609XRTRIM
         2395  +| page 6 offset 20480
         2396  +|      0: 0d 00 00 00 24 0e e0 00 0f f8 0f f0 0f e8 0f e0   ....$...........
         2397  +|     16: 0f d8 0f d0 0f c8 0f c0 0f b8 0f b0 0f a8 0f a0   ................
         2398  +|     32: 0f 98 0f 90 0f 88 0f 80 0f 78 0f 70 0f 68 0f 60   .........x.p.h.`
         2399  +|     48: 0f 58 0f 50 0f 48 0f 40 0f 38 0f 30 0f 28 0f 20   .X.P.H.@.8.0.(. 
         2400  +|     64: 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0 0e e8 0e e0   ................
         2401  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         2402  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         2403  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         2404  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         2405  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         2406  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         2407  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         2408  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         2409  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         2410  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         2411  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         2412  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         2413  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         2414  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         2415  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         2416  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         2417  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 06 01 01   ................
         2418  +|   4080: 06 02 03 00 12 06 01 01 06 01 03 00 12 06 01 01   ................
         2419  +| page 7 offset 24576
         2420  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         2421  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         2422  +| page 8 offset 28672
         2423  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e9 0f d6 00 00   ................
         2424  +|   4048: 00 00 00 00 00 00 11 03 02 2b 69 6e 74 65 67 72   .........+integr
         2425  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
         2426  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   uild....optimize
         2427  +| end crash-b87dfef02880fe.db
         2428  +}]} {}
         2429  +
         2430  +do_catchsql_test 24.1 {
         2431  +  UPDATE t1 SET b=quote(zeroblob(200)) WHERE a MATCH 'thread*';
         2432  +} {1 {database disk image is malformed}}
         2433  +
         2434  +do_catchsql_test 24.2 {
         2435  +  INSERT INTO t1(t1) VALUES('integrity-check');
         2436  +} {1 {database disk image is malformed}}
         2437  +
         2438  +#--------------------------------------------------------------------------
         2439  +reset_db
         2440  +do_test 25.0 {
         2441  +  sqlite3 db {}
         2442  +  db deserialize [decode_hexdb {
         2443  +| size 28672 pagesize 4096 filename crash-e3b1b19e4d4bcc.db
         2444  +| page 1 offset 0
         2445  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         2446  +|     16: 10 00 01 01 00 40 20 20 00 00 00 06 00 00 00 00   .....@  ........
         2447  +|     32: 00 00 00 00 00 00 00 06 00 00 00 04 00 00 00 00   ................
         2448  +|     48: 03 20 54 35 24 54 15 44 52 04 94 e4 44 55 82 07   . T5$T.DR...DU..
         2449  +|     64: 43 27 a2 04 f4 e2 07 43 22 87 a2 95 30 30 71 71   C'.....C....00qq
         2450  +|     80: 11 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33   .SQLite format 3
         2451  +|     96: 00 10 00 01 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
         2452  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 03 30 01 00 00 10   .....N.....0....
         2453  +|    128: 10 04 02 02 00 00 00 00 00 00 00 00 30 00 00 00   ............0...
         2454  +|    144: 00 00 00 00 00 00 00 00 20 00 00 00 40 00 00 00   ........ ...@...
         2455  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         2456  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         2457  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         2458  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         2459  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         2460  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         2461  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         2462  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         2463  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         2464  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         2465  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         2466  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         2467  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         2468  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         2469  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         2470  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         2471  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         2472  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         2473  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         2474  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         2475  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         2476  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         2477  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         2478  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         2479  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         2480  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         2481  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         2482  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         2483  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         2484  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 d9 44   (id INTEGER PR.D
         2485  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         2486  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         2487  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         2488  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         2489  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         2490  +| page 2 offset 4096
         2491  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         2492  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         2493  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         2494  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
         2495  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         2496  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         2497  +| page 3 offset 8192
         2498  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         2499  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         2500  +| page 4 offset 12288
         2501  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f e0 fe 00 00 00   ................
         2502  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 00 03   .....abandon....
         2503  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         2504  +| page 5 offset 16384
         2505  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         2506  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         2507  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         2508  +| page 6 offset 20480
         2509  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         2510  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         2511  +| page 7 offset 24576
         2512  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 01 fe 0f d6 00 00   ................
         2513  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         2514  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         2515  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         2516  +| end crash-e3b1b19e4d4bcc.db
         2517  +}]} {}
         2518  +
         2519  +do_catchsql_test 25.1 {
         2520  +  INSERT INTO t1(t1) VALUES('rebuild');
         2521  +} {1 {database disk image is malformed}}
         2522  +
         2523  +do_execsql_test 25.2 {
         2524  +  PRAGMA page_size=512;
         2525  +} 
         2526  +
         2527  +#--------------------------------------------------------------------------
         2528  +reset_db
         2529  +do_test 26.0 {
         2530  +  sqlite3 db {}
         2531  +  db deserialize [decode_hexdb {
         2532  +| size 32768 pagesize 4096 filename c30b.db
         2533  +| page 1 offset 0
         2534  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         2535  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 08   .....@  ........
         2536  +|     32: 00 00 00 02 00 00 00 01 00 00 00 01 00 00 00 04   ................
         2537  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         2538  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         2539  +|     96: 00 2e 30 38 0d 0f c7 00 07 0d 92 00 0f 8d 0f 36   ..08...........6
         2540  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d 92 0d 92 00 00 00 00   ...k............
         2541  +|   3472: 00 00 22 08 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         2542  +|   3488: 32 74 32 08 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         2543  +|   3504: 20 74 32 28 78 29 56 07 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         2544  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         2545  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         2546  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         2547  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         2548  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         2549  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         2550  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         2551  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         2552  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         2553  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         2554  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         2555  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         2556  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         2557  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         2558  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         2559  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         2560  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         2561  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         2562  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         2563  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         2564  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         2565  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         2566  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         2567  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         2568  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         2569  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         2570  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         2571  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         2572  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         2573  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         2574  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         2575  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         2576  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         2577  +| page 3 offset 8192
         2578  +|      0: 0d 0c 0f 00 05 09 fe 00 0f e6 09 fe 0c 94 0c 23   ...............#
         2579  +|     16: 0a 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         2580  +|   2544: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 0a   ................
         2581  +|   2560: 03 00 30 00 00 00 00 01 03 03 00 03 01 01 01 02   ..0.............
         2582  +|   2576: 01 01 03 01 01 83 72 8c 80 80 80 80 01 04 00 87   ......r.........
         2583  +|   2592: 68 00 00 01 e4 02 30 30 03 03 06 02 83 0f 30 30   h.....00......00
         2584  +|   2608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2585  +|   2624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2586  +|   2640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2587  +|   2656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2588  +|   2672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2589  +|   2688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2590  +|   2704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2591  +|   2720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2592  +|   2736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2593  +|   2752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2594  +|   2768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2595  +|   2784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2596  +|   2800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2597  +|   2816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2598  +|   2832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2599  +|   2848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2600  +|   2864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2601  +|   2880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2602  +|   2896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2603  +|   2912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2604  +|   2928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2605  +|   2944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2606  +|   2960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2607  +|   2976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2608  +|   2992: 30 30 30 30 30 30 30 30 30 30 30 30 30 03 06 01   0000000000000...
         2609  +|   3008: 01 03 01 08 32 30 31 36 30 36 30 39 03 03 07 01   ....20160609....
         2610  +|   3024: 01 34 03 03 05 01 01 35 03 03 04 01 06 62 69 6e   .4.....5.....bin
         2611  +|   3040: 61 72 79 03 07 01 02 02 01 08 63 6f 6d 70 69 6c   ary.......compil
         2612  +|   3056: 65 72 03 03 02 01 03 67 63 63 03 03 03 01 01 78   er.....gcc.....x
         2613  +|   3072: 03 07 01 01 02 04 06 83 17 0d 06 06 0d 0d 08 0f   ................
         2614  +|   3088: ef 00 14 2a 00 00 00 00 01 02 02 00 02 01 01 01   ...*............
         2615  +|   3104: 02 01 01 6a 88 80 80 80 80 01 04 00 81 58 00 00   ...j.........X..
         2616  +|   3120: 00 5f 07 30 62 69 6e 61 72 79 0c 01 03 01 01 06   ._.0binary......
         2617  +|   3136: 65 6e 61 62 6c 65 0a 01 01 01 01 01 01 01 01 01   enable..........
         2618  +|   3152: 01 01 01 04 66 74 73 34 0a 01 01 01 01 01 04 01   ....fts4........
         2619  +|   3168: 35 0d 01 01 01 01 01 01 06 6e 6f 63 61 73 65 0b   5........nocase.
         2620  +|   3184: 01 03 01 01 05 72 74 72 69 6d 0a 01 03 01 01 01   .....rtrim......
         2621  +|   3200: 78 0a 01 01 01 01 01 01 01 01 01 01 01 04 0c 14   x...............
         2622  +|   3216: 0c 09 0c 0b 86 4a 84 80 80 80 80 01 04 00 8d 18   .....J..........
         2623  +|   3232: 00 00 03 2b 02 30 30 01 02 06 01 02 06 01 02 06   ...+.00.........
         2624  +|   3248: 1f 02 03 01 02 03 01 02 03 01 08 32 30 31 36 30   ...........20160
         2625  +|   3264: 36 30 39 01 02 07 01 02 07 01 02 07 01 01 34 01   609...........4.
         2626  +|   3280: 02 05 01 02 05 01 02 05 01 01 35 01 02 04 01 02   ..........5.....
         2627  +|   3296: 04 01 02 04 02 07 30 30 30 30 30 30 30 1c 02 04   ......0000000...
         2628  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         2629  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2630  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2631  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         2632  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 08 63 6f 6d 70   ............comp
         2633  +|   3392: 69 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64   iler...........d
         2634  +|   3408: 62 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04   bstat...........
         2635  +|   3424: 65 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65   ebug...........e
         2636  +|   3440: 6e 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02   nable...........
         2637  +|   3456: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         2638  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         2639  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         2640  +|   3504: 02 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02   ......xtension..
         2641  +|   3520: 04 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03   .........fts4...
         2642  +|   3536: 01 02 03 01 02 03 04 01 35 0d 02 03 01 02 03 01   ........5.......
         2643  +|   3552: 02 03 01 03 67 63 63 01 02 03 01 02 03 01 02 03   ....gcc.........
         2644  +|   3568: 02 06 65 6f 70 6f 6c 79 10 02 03 01 02 03 01 02   ..eopoly........
         2645  +|   3584: 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03 01 02   ...json1........
         2646  +|   3600: 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01 02 03   ...load.........
         2647  +|   3616: 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02 02 05   ..max...........
         2648  +|   3632: 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03 04 04   emory...........
         2649  +|   3648: 73 79 73 35 16 02 03 01 02 03 01 02 03 01 06 6e   sys5...........n
         2650  +|   3664: 6f 63 61 73 65 02 06 01 02 02 03 06 01 02 02 03   ocase...........
         2651  +|   3680: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         2652  +|   3696: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2653  +|   3712: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2654  +|   3728: 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01 02 02   ...omit.........
         2655  +|   3744: 01 05 72 74 72 65 65 19 02 03 01 02 03 01 02 03   ..rtree.........
         2656  +|   3760: 04 02 69 6d 01 06 01 02 02 03 06 01 02 02 03 06   ..im............
         2657  +|   3776: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2658  +|   3792: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2659  +|   3808: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         2660  +|   3824: 01 0a 74 68 72 65 61 64 73 61 66 65 03 57 34 56   ..threadsafe.W4V
         2661  +|   3840: 94 64 91 46 85 84 04 76 74 61 62 07 02 04 01 02   .d.F...vtab.....
         2662  +|   3856: 04 01 02 04 01 01 78 01 06 01 01 02 01 06 01 01   ......x.........
         2663  +|   3872: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 10 02   ................
         2664  +|   3888: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         2665  +|   3904: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         2666  +|   3920: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         2667  +|   3936: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         2668  +|   3952: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         2669  +|   3968: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         2670  +|   3984: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         2671  +|   4000: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         2672  +|   4016: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         2673  +|   4032: 02 01 06 01 01 02 01 06 01 01 02 04 15 13 0c 0c   ................
         2674  +|   4048: 12 44 13 11 0f 47 13 0f 0c 0e 11 10 0f 0e 10 0f   .D...G..........
         2675  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 1e 4e 1f 1e 00   D..@........N...
         2676  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         2677  +| page 4 offset 12288
         2678  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         2679  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         2680  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         2681  +| page 5 offset 16384
         2682  +|      0: 0d 0e 5b 00 1e 0a 4d 00 0f d8 0f af 0a 4d 0f 74   ..[...M......M.t
         2683  +|     16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e 40 0e 24 0e 08   .a.N./.....@.$..
         2684  +|     32: 0d ef 0d d5 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35   ...........h.O.5
         2685  +|     48: 0d 1b 0c fb 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e   ...........x.W.>
         2686  +|     64: 0c 24 0c 0a 0c 0a 0c 0a 0c 0a 0c 0a 0c 0a 0c 0a   .$..............
         2687  +|   2624: 00 00 00 00 00 00 00 00 00 00 00 00 00 83 3a 03   ..............:.
         2688  +|   2640: 06 00 43 86 33 19 43 4f 4d 50 49 4c 45 52 3d 67   ..C.3.COMPILER=g
         2689  +|   2656: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30   cc-5.4.0 2016060
         2690  +|   2672: 39 58 27 30 30 30 30 30 30 30 30 30 30 30 30 30   9X'0000000000000
         2691  +|   2688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2692  +|   2704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2693  +|   2720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2694  +|   2736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2695  +|   2752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2696  +|   2768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2697  +|   2784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2698  +|   2800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2699  +|   2816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2700  +|   2832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2701  +|   2848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2702  +|   2864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2703  +|   2880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2704  +|   2896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2705  +|   2912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2706  +|   2928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2707  +|   2944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2708  +|   2960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2709  +|   2976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2710  +|   2992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2711  +|   3008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2712  +|   3024: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2713  +|   3040: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2714  +|   3056: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   0000000000000000
         2715  +|   3072: 30 30 30 27 42 49 4e 41 52 59 18 24 05 00 25 0f   000'BINARY.$..%.
         2716  +|   3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49   .THREADSAFE=0XBI
         2717  +|   3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41   NARY.#..%..THREA
         2718  +|   3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22   DSAFE=0XNOCASE..
         2719  +|   3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d   ..%..THREADSAFE=
         2720  +|   3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d   0XRTRIM.!..3..OM
         2721  +|   3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f   IT LOAD EXTENSIO
         2722  +|   3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f   NXBINARY. ..3..O
         2723  +|   3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49   MIT LOAD EXTENSI
         2724  +|   3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17   ONXNOCASE....3..
         2725  +|   3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53   OMIT LOAD EXTENS
         2726  +|   3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19   IONXRTRIM....3..
         2727  +|   3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30   MAX MEMORY=50000
         2728  +|   3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f   000XBINARY....3.
         2729  +|   3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30   .MAX MEMORY=5000
         2730  +|   3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33   0000XNOCASE....3
         2731  +|   3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30   ..MAX MEMORY=500
         2732  +|   3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25   00000XRTRIM....%
         2733  +|   3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42   ..ENABLE RTREEXB
         2734  +|   3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         2735  +|   3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17   LE RTREEXNOCASE.
         2736  +|   3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52   ...%..ENABLE RTR
         2737  +|   3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45   EEXRTRIM....)..E
         2738  +|   3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49   NABLE MEMSYS5XBI
         2739  +|   3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         2740  +|   3472: 42 60 2d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45   B`-EMSYS5XNOCASE
         2741  +|   3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45   ....)..ENABLE ME
         2742  +|   3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25   MSYS5XRTRIM....%
         2743  +|   3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42   ..ENABLE JSON1XB
         2744  +|   3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         2745  +|   3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17   LE JSON1XNOCASE.
         2746  +|   3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f   ...%..ENABLE JSO
         2747  +|   3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45   N1XRTRIM....)..E
         2748  +|   3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49   NABLE GEOPOLYXBI
         2749  +|   3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         2750  +|   3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45   E GEOPOLYXNOCASE
         2751  +|   3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45   ....)..ENABLE GE
         2752  +|   3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 0f 86 00 94 23   OPOLYXRTRIM....#
         2753  +|   3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49   ..ENABLE FTS5XBI
         2754  +|   3696: 4e 41 52 59 00 00 00 7b 23 0f 19 45 4e 41 42 4c   NARY....#..ENABL
         2755  +|   3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 00 00 00   E FTS5XNOCASE...
         2756  +|   3728: 62 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58   b#..ENABLE FTS5X
         2757  +|   3744: 52 54 52 49 4d 00 00 00 4a 23 0f 19 45 4e 41 42   RTRIM...J#..ENAB
         2758  +|   3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 00 00   LE FTS4XBINARY..
         2759  +|   3776: 00 31 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34   .1#..ENABLE FTS4
         2760  +|   3792: 58 4e 4f 43 41 53 45 00 00 00 18 23 0f 17 45 4e   XNOCASE....#..EN
         2761  +|   3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e   ABLE FTS4XRTRIM.
         2762  +|   3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         2763  +|   3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e   TAT VTABXBINARY.
         2764  +|   3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         2765  +|   3872: 54 41 54 20 56 54 24 15 48 4e 4f 43 41 53 45 1d   TAT VT$.HNOCASE.
         2766  +|   3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         2767  +|   3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06   TAT VTABXRTRIM..
         2768  +|   3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52   .....DEBUGXBINAR
         2769  +|   3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f   Y.......DEBUGXNO
         2770  +|   3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47   CASE.......DEBUG
         2771  +|   3968: 58 52 54 52 49 4d 00 00 00 29 43 0f 19 43 4f 4d   XRTRIM...)C..COM
         2772  +|   3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20   PILER=gcc-5.4.0 
         2773  +|   4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27   20160609XBINARY'
         2774  +|   4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67   ...C..COMPILER=g
         2775  +|   4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30   cc-5.4.0 2016060
         2776  +|   4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43   9XNOCASE&...C..C
         2777  +|   4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e   OMPILER=gcc-5.4.
         2778  +|   4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d   0 20160609XRTRIM
         2779  +| page 6 offset 20480
         2780  +|      0: 0d 0f 88 00 1e 0e e0 00 0f f8 0f f0 0f b0 0f e0   ................
         2781  +|     16: 0f d8 0f d0 0f c8 0f c0 0f b8 0f 80 0f 78 0f 70   .............x.p
         2782  +|     32: 0f 68 0f 60 0f 58 0f 50 0f 48 0f 40 0f 38 0f 30   .h.`.X.P.H.@.8.0
         2783  +|     48: 0f 28 0f 20 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0   .(. ............
         2784  +|     64: 0e e8 0e e0 0e e0 0e e0 0e e0 0e e0 0e e0 0e e0   ................
         2785  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         2786  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         2787  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         2788  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         2789  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         2790  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         2791  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         2792  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         2793  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         2794  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         2795  +|   3968: 06 10 03 00 12 02 01 01 0f e8 00 28 12 02 01 01   ...........(....
         2796  +|   3984: 00 00 00 28 12 02 01 01 00 00 00 20 12 02 01 01   ...(....... ....
         2797  +|   4000: 00 00 00 18 12 02 01 01 00 00 00 10 12 02 01 01   ................
         2798  +|   4016: 06 03 03 00 12 06 02 01 06 09 03 00 12 03 01 01   ................
         2799  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         2800  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         2801  +|   4064: 06 04 03 00 12 01 01 01 00 00 00 08 12 06 01 01   ................
         2802  +|   4080: 06 02 03 00 12 06 01 01 06 01 03 00 12 06 01 01   ................
         2803  +| page 7 offset 24576
         2804  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         2805  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         2806  +| page 8 offset 28672
         2807  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e9 0f d6 00 00   ................
         2808  +|   4048: 00 00 00 00 00 00 11 03 02 2b 69 6e 74 65 67 72   .........+integr
         2809  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
         2810  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   uild....optimize
         2811  +| end c30b.db
         2812  +}]} {}
         2813  +
         2814  +do_catchsql_test 26.1 {
         2815  +  BEGIN;
         2816  +    INSERT INTO t1(t1) VALUES('rebuild');
         2817  +    INSERT INTO t1(t1) VALUES('integrity-check');
         2818  +  COMMIT;
         2819  +} {0 {}}
         2820  +
         2821  +#--------------------------------------------------------------------------
         2822  +reset_db
         2823  +do_test 27.0 {
         2824  +  sqlite3 db {}
         2825  +  db deserialize [decode_hexdb {
         2826  +| size 32768 pagesize 4096 filename timeout-2ca5b0658c98.db
         2827  +| page 1 offset 0
         2828  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         2829  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08   .....@  ........
         2830  +|     32: 00 00 00 02 00 00 00 01 00 00 00 09 00 00 00 04   ................
         2831  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         2832  +|     96: 00 00 00 00 0d 0f c7 00 07 0d 92 00 0f 8d 0f 36   ...............6
         2833  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d 92 0d 92 00 00 00 00   ...k............
         2834  +|   3472: 00 00 22 08 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         2835  +|   3488: 32 74 32 08 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         2836  +|   3504: 20 74 32 28 78 29 56 07 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         2837  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         2838  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         2839  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         2840  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         2841  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         2842  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         2843  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         2844  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         2845  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         2846  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         2847  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         2848  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         2849  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         2850  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         2851  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         2852  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         2853  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         2854  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         2855  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         2856  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         2857  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         2858  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         2859  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         2860  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         2861  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         2862  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         2863  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         2864  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         2865  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         2866  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         2867  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         2868  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         2869  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         2870  +| page 3 offset 8192
         2871  +|      0: 0d 00 00 00 03 0c 94 00 0f e6 0f ef 0c 94 00 00   ................
         2872  +|   3216: 00 00 00 00 86 4a 84 80 80 80 80 01 04 00 8d 18   .....J..........
         2873  +|   3232: 00 00 03 2b 02 30 30 01 02 06 01 02 06 01 02 06   ...+.00.........
         2874  +|   3248: 1f 02 03 01 02 03 01 02 03 01 08 32 30 31 36 30   ...........20160
         2875  +|   3264: 36 30 39 01 02 07 01 02 07 01 02 07 01 01 34 01   609...........4.
         2876  +|   3280: 02 05 01 02 05 01 02 05 01 01 35 01 02 04 01 02   ..........5.....
         2877  +|   3296: 04 01 02 04 02 07 30 30 30 30 30 30 30 1c 02 04   ......0000000...
         2878  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         2879  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2880  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2881  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         2882  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 08 63 6f 6d 70   ............comp
         2883  +|   3392: 69 6c 65 72 01 20 01 02 02 02 01 02 02 01 06 64   iler. .........d
         2884  +|   3408: 62 73 7c cc cc cc cc cc cc cc cc cc cc cc cc cc   bs|.............
         2885  +|   3424: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc   ................
         2886  +|   3440: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc   ................
         2887  +|   3456: cc cc cc cc cc cc c4 61 74 07 02 03 01 02 03 01   .......at.......
         2888  +|   3472: 02 03 02 04 65 62 75 67 04 02 02 01 02 02 01 02   ....ebug........
         2889  +|   3488: 02 01 06 65 6e 61 62 6c 65 07 02 02 01 02 02 01   ...enable.......
         2890  +|   3504: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         2891  +|   3520: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         2892  +|   3536: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 05 23   ...............#
         2893  +|   3552: d6 76 36 32 d3 52 e3 42 e3 02 03 23 03 13 63 03   .v62.R.B...#..c.
         2894  +|   3568: 63 03 95 84 e4 f4 34 15 34 52 60 10 50 04 30 f1   c.....4.4R`.P.0.
         2895  +|   3584: 74 34 f4 d5 04 94 c4 55 23 d6 76 36 32 d3 52 e3   t4.....U#.v62.R.
         2896  +|   3600: 42 e3 02 03 23 03 13 63 03 63 03 95 85 25 45 24   B...#..c.c...%E$
         2897  +|   3616: 94 d0 d0 00 00 02 40 ee 00 00 ff 80 ff 00 fe 80   ......@.........
         2898  +|   3632: fe 00 fd 80 fd 00 fc 80 fc 00 fb 80 fb 00 fa 80   ................
         2899  +|   3648: fa 00 f9 80 f9 00 f8 80 f8 00 f7 80 f7 00 f6 80   ................
         2900  +|   3664: f6 00 f5 80 f5 00 f4 80 f4 00 f8 0f 30 0f 28 0f   ............0.(.
         2901  +|   3680: 20 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0 0e e8 0e    ...............
         2902  +|   3696: e0 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2903  +|   3712: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2904  +|   3728: 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01 02 02   ...omit.........
         2905  +|   3744: 01 05 72 74 72 65 65 19 02 03 01 02 03 01 02 03   ..rtree.........
         2906  +|   3760: 04 02 69 6d 01 06 01 02 02 03 06 01 02 02 03 06   ..im............
         2907  +|   3776: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         2908  +|   3792: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         2909  +|   3808: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         2910  +|   3824: 01 0a 74 68 72 65 61 64 73 61 66 65 22 02 02 01   ..threadsafe....
         2911  +|   3840: 02 02 01 02 02 01 04 76 74 61 62 07 02 04 01 02   .......vtab.....
         2912  +|   3856: 04 01 02 04 01 01 78 01 06 01 01 02 01 06 01 01   ......x.........
         2913  +|   3872: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         2914  +|   3888: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         2915  +|   3904: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         2916  +|   3920: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         2917  +|   3936: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         2918  +|   3952: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         2919  +|   3968: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         2920  +|   3984: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         2921  +|   4000: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         2922  +|   4016: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         2923  +|   4032: 02 01 06 01 01 02 01 06 01 01 02 04 15 13 0c 0c   ................
         2924  +|   4048: 12 44 13 11 0f 47 13 0f 0c 0e 11 10 0f 0e 10 0f   .D...G..........
         2925  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 5a 24 24 0f   D..@.......$Z$$.
         2926  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         2927  +| page 4 offset 12288
         2928  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         2929  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         2930  +| page 5 offset 16384
         2931  +|      0: 0d 00 00 00 24 0c 0a 00 0f d8 0f af 0f 86 0f 74   ....$..........t
         2932  +|     16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5   .a.N./..........
         2933  +|     32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5   ...t.[.@.$......
         2934  +|     48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb   .......h.O.5....
         2935  +|     64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a   .......x.W.>.$..
         2936  +|   3072: 00 00 00 00 00 00 00 00 00 00 18 24 05 00 25 0f   ...........$..%.
         2937  +|   3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49   .THREADSAFE=0XBI
         2938  +|   3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41   NARY.#..%..THREA
         2939  +|   3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22   DSAFE=0XNOCASE..
         2940  +|   3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d   ..%..THREADSAFE=
         2941  +|   3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d   0XRTRIM.!..3..OM
         2942  +|   3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f   IT LOAD EXTENSIO
         2943  +|   3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f   NXBINARY. ..3..O
         2944  +|   3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49   MIT LOAD EXTENSI
         2945  +|   3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17   ONXNOCASE....3..
         2946  +|   3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 5f e8 54 45 4e   OMIT LOAD E_.TEN
         2947  +|   3248: 53 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f   SIONXRTRIM....3.
         2948  +|   3264: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 31 81   .MAX MEMORY=501.
         2949  +|   3280: 40 50 02 50 f1 94 54 e4 14 24 c4 52 04 a5 35 f4   @P.P..T..$.R..5.
         2950  +|   3296: e3 15 84 e4 f4 34 15 34 51 71 30 50 02 50 f1 74   .....4.4Qq0P.P.t
         2951  +|   3312: 54 e4 14 24 c4 52 04 a5 34 f4 e3 15 85 25 45 24   T..$.R..4....%E$
         2952  +|   3328: 94 d1 a1 20 50 02 90 f1 94 54 e4 14 24 c4 52 04   ... P....T..$.R.
         2953  +|   3344: 74 54 f5 04 f4 c5 95 84 24 94 e4 15 25 91 a1 10   tT......$...%...
         2954  +|   3360: 50 02 90 f1 94 54 e4 14 24 c4 52 04 74 54 f5 04   P....T..$.R.tT..
         2955  +|   3376: f4 c5 95 84 e4 f4 34 15 34 51 91 00 50 02 90 f1   ......4.4Q..P...
         2956  +|   3392: 74 54 e4 14 24 c4 52 04 74 54 f5 04 f4 c5 95 85   tT..$.R.tT......
         2957  +|   3408: 25 45 24 94 d1 70 f0 50 02 30 f1 94 54 e4 14 24   %E$..p.P.0..T..$
         2958  +|   3424: c4 52 04 65 45 33 55 84 24 94 e4 15 25 91 70 e0   .R.eE3U.$...%.p.
         2959  +|   3440: 50 02 30 f1 94 54 e4 14 24 c4 52 04 65 45 33 55   P.0..T..$.R.eE3U
         2960  +|   3456: 84 e4 f4 34 15 34 51 60 d0 50 02 30 f1 74 54 e4   ...4.4Q`.P.0.tT.
         2961  +|   3472: 14 24 c4 52 04 65 45 33 55 85 25 45 24 94 d1 70   .$.R.eE3U.%E$..p
         2962  +|   3488: c0 50 02 30 f1 94 54 e4 14 24 c4 52 04 65 45 33   .P.0..T..$.R.eE3
         2963  +|   3504: 45 84 24 94 e4 15 25 91 70 b0 50 02 30 f1 94 54   E.$...%.p.P.0..T
         2964  +|   3520: e4 14 24 c4 52 04 65 45 33 45 84 e4 f4 34 15 34   ..$.R.eE3E...4.4
         2965  +|   3536: 51 60 a0 50 02 30 f1 74 54 e4 14 24 c4 52 04 65   Q`.P.0.tT..$.R.e
         2966  +|   3552: 45 33 45 85 25 45 24 94 d1 e0 90 50 03 10 f1 94   E3E.%E$....P....
         2967  +|   3568: 54 e4 42 4c 45 20 44 42 53 54 41 54 20 56 54 41   T.BLE DBSTAT VTA
         2968  +|   3584: 42 58 42 49 4e 41 52 59 1e 08 05 00 31 0f 19 45   BXBINARY....1..E
         2969  +|   3600: e4 14 24 c4 52 04 44 25 35 44 15 42 05 65 42 41   ..$.R.D%5D.B.eBA
         2970  +|   3616: 54 84 e4 f4 34 15 34 51 d0 70 50 03 10 f1 74 54   T...4.4Q.pP...tT
         2971  +|   3632: e4 14 24 c4 52 04 44 25 35 44 15 42 05 65 44 14   ..$.R.D%5D.B.eD.
         2972  +|   3648: 25 85 25 45 24 94 d1 10 60 50 01 70 f1 94 44 54   %.%E$...`P.p..DT
         2973  +|   3664: 25 54 75 84 24 94 e4 15 25 91 10 50 50 01 70 f1   %Tu.$...%..PP.p.
         2974  +|   3680: 94 44 54 25 54 75 84 e4 f4 34 15 34 51 00 40 50   .DT%Tu...4.4Q.@P
         2975  +|   3696: 01 70 f1 74 44 54 25 54 75 85 25 45 24 94 d2 70   .p.tDT%Tu.%E$..p
         2976  +|   3712: 30 50 04 30 f1 94 34 f4 d5 04 94 c4 55 23 d6 76   0P.0..4.....U#.v
         2977  +|   3728: 36 32 d3 52 e3 42 e3 02 03 23 03 13 63 03 63 03   62.R.B...#..c.c.
         2978  +|   3744: 95 84 24 94 e4 15 25 92 70 20 50 04 30 f1 94 34   ..$...%.p P.0..4
         2979  +|   3760: f4 d5 04 94 c4 53 30 01 00 00 10 10 04 02 02 00   .....S0.........
         2980  +|   3776: 00 00 00 00 00 00 00 80 00 00 00 20 00 00 00 10   ........... ....
         2981  +|   3792: 00 00 00 90 00 00 00 40 00 00 00 00 00 00 00 00   .......@........
         2982  +| page 6 offset 20480
         2983  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         2984  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         2985  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         2986  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         2987  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         2988  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         2989  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         2990  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         2991  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         2992  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         2993  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         2994  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         2995  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         2996  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         2997  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         2998  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         2999  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 06 01 01   ................
         3000  +|   4080: 06 02 03 00 12 06 01 01 06 01 03 00 12 06 01 01   ................
         3001  +| page 7 offset 24576
         3002  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3003  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3004  +| page 8 offset 28672
         3005  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e9 0f d6 00 00   ................
         3006  +|   4048: 00 00 00 00 00 00 11 03 02 2b 69 6e 74 65 67 72   .........+integr
         3007  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
         3008  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   uild....optimize
         3009  +| end timeout-2ca5b0658c98.db
         3010  +}]} {}
         3011  +
         3012  +do_catchsql_test 27.1 {
         3013  +  DELETE FROM t1 WHERE a MATCH 'fts*';
         3014  +} {1 {database disk image is malformed}}
         3015  +
         3016  +#-------------------------------------------------------------------------
         3017  +reset_db
         3018  +do_test 28.0 {
         3019  +  sqlite3 db {}
         3020  +  db deserialize [decode_hexdb {
         3021  +| size 40960 pagesize 4096 filename crash-e2d47e0624a42c.db
         3022  +| page 1 offset 0
         3023  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3024  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a   .....@  ........
         3025  +|     32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04   ................
         3026  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3027  +|     96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c   ..........n....L
         3028  +|    112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50   .....$...r.....P
         3029  +|    128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00   .....n..........
         3030  +|   2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d   ..............C.
         3031  +|   2928: 06 17 11 11 08 75 74 61 62 6c 65 74 34 74 34 43   .....utablet4t4C
         3032  +|   2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
         3033  +|   2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73   BLE t4 USING fts
         3034  +|   2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f   5vocab('t2', 'ro
         3035  +|   2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65   w')C......utable
         3036  +|   3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55   t3t3CREATE VIRTU
         3037  +|   3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e   AL TABLE t3 USIN
         3038  +|   3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27   G fts5vocab('t1'
         3039  +|   3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d   , 'row')V.......
         3040  +|   3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32   tablet2_configt2
         3041  +|   3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54   _config.CREATE T
         3042  +|   3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27   ABLE 't2_config'
         3043  +|   3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   (k PRIMARY KEY, 
         3044  +|   3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   v) WITHOUT ROWID
         3045  +|   3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32   ^...!!...tablet2
         3046  +|   3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65   _contentt2_conte
         3047  +|   3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20   nt.CREATE TABLE 
         3048  +|   3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   't2_content'(id 
         3049  +|   3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         3050  +|   3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29   KEY, c0, c1, c2)
         3051  +|   3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32   i.......-tablet2
         3052  +|   3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54   _idxt2_idx.CREAT
         3053  +|   3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27   E TABLE 't2_idx'
         3054  +|   3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67   (segid, term, pg
         3055  +|   3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28   no, PRIMARY KEY(
         3056  +|   3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49   segid, term)) WI
         3057  +|   3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b   THOUT ROWIDU....
         3058  +|   3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61   ....tablet2_data
         3059  +|   3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54   t2_data.CREATE T
         3060  +|   3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69   ABLE 't2_data'(i
         3061  +|   3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52   d INTEGER PRIMAR
         3062  +|   3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f   Y KEY, block BLO
         3063  +|   3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65   B)X........table
         3064  +|   3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55   t2t2CREATE VIRTU
         3065  +|   3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e   AL TABLE t2 USIN
         3066  +|   3488: 47 20 66 74 73 35 28 27 61 27 2c 5b 62 5d 2c 22   G fts5('a',[b],.
         3067  +|   3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63   c.,detail=none,c
         3068  +|   3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17   olumnsize=0)V...
         3069  +|   3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66   ....tablet1_conf
         3070  +|   3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41   igt1_config.CREA
         3071  +|   3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
         3072  +|   3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b   fig'(k PRIMARY K
         3073  +|   3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52   EY, v) WITHOUT R
         3074  +|   3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62   OWID[...!!...tab
         3075  +|   3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64   let1_docsizet1_d
         3076  +|   3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41   ocsize.CREATE TA
         3077  +|   3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27   BLE 't1_docsize'
         3078  +|   3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         3079  +|   3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42   ARY KEY, sz BLOB
         3080  +|   3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74   )^...!!...tablet
         3081  +|   3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74   1_contentt1_cont
         3082  +|   3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45   ent.CREATE TABLE
         3083  +|   3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64    't1_content'(id
         3084  +|   3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
         3085  +|   3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32    KEY, c0, c1, c2
         3086  +|   3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74   )i.......-tablet
         3087  +|   3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41   1_idxt1_idx.CREA
         3088  +|   3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78   TE TABLE 't1_idx
         3089  +|   3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70   '(segid, term, p
         3090  +|   3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59   gno, PRIMARY KEY
         3091  +|   3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57   (segid, term)) W
         3092  +|   3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17   ITHOUT ROWIDU...
         3093  +|   3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74   .....tablet1_dat
         3094  +|   3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20   at1_data.CREATE 
         3095  +|   3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28   TABLE 't1_data'(
         3096  +|   3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         3097  +|   3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c   RY KEY, block BL
         3098  +|   4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c   OB)[.......#tabl
         3099  +|   4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         3100  +|   4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         3101  +|   4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e   NG fts5(a,b unin
         3102  +|   4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65   dexed,c,tokenize
         3103  +|   4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29   =.porter ascii.)
         3104  +| page 2 offset 4096
         3105  +|      0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c   ..h............|
         3106  +|     16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .*..............
         3107  +|   3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00   .......0........
         3108  +|   3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80   ..........7.....
         3109  +|   3888: 01 03 00 74 00 00 00 2e 02 30 61 03 02 02 01 01   ...t.....0a.....
         3110  +|   3904: 62 03 02 03 01 01 63 03 02 04 01 01 67 03 06 01   b.....c.....g...
         3111  +|   3920: 02 02 01 01 68 03 06 01 02 03 01 01 69 03 06 01   ....h.......i...
         3112  +|   3936: 02 04 04 06 06 06 08 08 0f ef 00 14 2a 00 00 00   ............*...
         3113  +|   3952: 00 01 02 02 00 02 01 01 01 02 01 01 25 88 80 80   ............%...
         3114  +|   3968: 80 80 01 03 00 50 00 00 00 1f 02 30 67 02 08 02   .....P.....0g...
         3115  +|   3984: 01 02 02 01 01 68 02 08 03 01 02 03 01 01 69 02   .....h........i.
         3116  +|   4000: 08 04 01 02 04 04 09 09 37 84 80 80 80 80 01 03   ........7.......
         3117  +|   4016: 00 74 00 00 00 2e 02 30 61 01 02 02 01 01 62 01   .t.....0a.....b.
         3118  +|   4032: 02 03 01 01 63 01 02 04 01 01 67 01 06 01 02 20   ....c.....g.... 
         3119  +|   4048: 10 16 80 10 60 10 20 30 10 16 90 10 60 10 20 40   ....`. 0....`. @
         3120  +|   4064: 40 60 60 60 80 80 70 10 30 01 40 30 90 00 90 00   @```..p.0.@0....
         3121  +|   4080: 00 01 12 40 00 00 00 00 10 10 10 00 10 10 10 10   ...@............
         3122  +| page 3 offset 8192
         3123  +|      0: a0 00 00 00 30 fe c0 00 ff a0 ff 30 fe 00 00 00   ....0......0....
         3124  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         3125  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         3126  +| page 4 offset 12288
         3127  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         3128  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3129  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3130  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3131  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3132  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         3133  +| page 5 offset 16384
         3134  +|      0: 0d 00 00 00 03 0f e8 00 0f f8 0f f0 0f e8 00 00   ................
         3135  +|   4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 03   ................
         3136  +|   4080: 06 02 03 00 12 03 00 03 06 01 03 00 12 03 00 03   ................
         3137  +| page 6 offset 20480
         3138  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3139  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3140  +| page 7 offset 24576
         3141  +|      0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00   ................
         3142  +|   3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84   ..............A.
         3143  +|   4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61   ............4.0a
         3144  +|   4016: 01 01 01 01 01 62 01 01 01 01 01 63 01 01 01 01   .....b.....c....
         3145  +|   4032: 01 64 01 01 01 65 01 01 01 66 01 01 01 01 01 68   .d...e...f.....h
         3146  +|   4048: 01 01 01 01 01 69 01 01 01 04 06 06 06 04 04 04   .....i..........
         3147  +|   4064: 06 06 07 01 03 00 14 03 09 09 09 0f 0a 03 00 24   ...............$
         3148  +|   4080: 00 00 00 00 01 01 01 00 01 01 01 01 0a 00 00 00   ................
         3149  +| page 8 offset 28672
         3150  +|      0: 01 0f fa 00 0f fa 00 00 00 00 00 00 00 00 00 00   ................
         3151  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3152  +| page 9 offset 32768
         3153  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 1f be 00 00   ................
         3154  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3155  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3156  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3157  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3158  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         3159  +| page 10 offset 36864
         3160  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3161  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3162  +| end crash-e2d47e0624a42c.db
         3163  +}]} {}
         3164  +
         3165  +do_catchsql_test 28.1 {
         3166  +  SELECT count( fts5_decode(id, block) ) FROM t2_data;
         3167  +} {1 {database disk image is malformed}}
         3168  +
         3169  +#-------------------------------------------------------------------------
         3170  +reset_db
         3171  +do_test 29.0 {
         3172  +  sqlite3 db {}
         3173  +  db deserialize [decode_hexdb {
         3174  +| size 28672 pagesize 4096 filename crash-e114c036e13dde.db
         3175  +| page 1 offset 0
         3176  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3177  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         3178  +|     32: 00 00 00 02 00 00 00 01 00 00 00 08 00 00 00 04   ................
         3179  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3180  +|     96: 00 00 00 00 0d 0f c7 00 06 0d b6 00 0f 8d 0f 36   ...............6
         3181  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d b6 00 00 00 00 00 00   ...k............
         3182  +|   3504: 00 00 00 00 00 00 56 07 06 17 1f 1f 01 7d 74 61   ......V.......ta
         3183  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         3184  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         3185  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         3186  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         3187  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         3188  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         3189  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         3190  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         3191  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         3192  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         3193  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         3194  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         3195  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         3196  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         3197  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         3198  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         3199  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         3200  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         3201  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         3202  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         3203  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         3204  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         3205  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         3206  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         3207  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         3208  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         3209  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         3210  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         3211  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         3212  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         3213  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         3214  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         3215  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         3216  +| page 3 offset 8192
         3217  +|      0: 0d 00 00 00 03 0c af 00 0f e6 0f ef 0c af 00 00   ................
         3218  +|   3232: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86   ................
         3219  +|   3248: 2f 84 80 80 80 80 01 04 00 8c 62 00 00 03 12 02   /.........b.....
         3220  +|   3264: 30 30 01 04 05 03 01 04 05 03 01 04 05 03 1f 02   00..............
         3221  +|   3280: 03 01 02 03 01 02 03 01 08 35 30 30 30 30 30 30   .........5000000
         3222  +|   3296: 30 1c 02 04 01 02 04 01 02 04 01 01 36 01 02 04   0...........6...
         3223  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         3224  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         3225  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         3226  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         3227  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 05 63 6c 61 6e   ............clan
         3228  +|   3392: 67 01 02 03 01 02 03 01 02 03 02 07 6f 6d 70 69   g...........ompi
         3229  +|   3408: 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64 62   ler...........db
         3230  +|   3424: 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04 65   stat...........e
         3231  +|   3440: 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65 6e   bug...........en
         3232  +|   3456: 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02 02   able............
         3233  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         3234  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         3235  +|   3504: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         3236  +|   3520: 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02 04   .....xtension...
         3237  +|   3536: 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03 03   ........fts4....
         3238  +|   3552: 01 02 01 02 03 04 01 35 0d 02 03 01 02 03 01 02   .......5........
         3239  +|   3568: 03 01 07 67 65 6f 70 6f 6c 79 10 02 03 01 02 03   ...geopoly......
         3240  +|   3584: 01 02 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03   .....json1......
         3241  +|   3600: 01 02 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01   .....load.......
         3242  +|   3616: 02 03 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02   ....max.........
         3243  +|   3632: 02 05 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03   ..emory.........
         3244  +|   3648: 04 04 73 79 73 35 16 02 03 01 02 03 01 02 03 01   ..sys5..........
         3245  +|   3664: 06 6e 6f 63 61 73 65 02 06 01 02 02 03 06 01 02   .nocase.........
         3246  +|   3680: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         3247  +|   3696: 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03   ................
         3248  +|   3712: 06 01 02 02 03 06 01 02 02 03 06 01 12 02 03 06   ................
         3249  +|   3728: 01 02 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01   .....omit.......
         3250  +|   3744: 02 02 01 05 72 74 72 65 65 19 02 03 01 02 03 01   ....rtree.......
         3251  +|   3760: 02 03 04 02 69 6d 01 06 01 02 02 03 06 01 02 02   ....im..........
         3252  +|   3776: 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03   ................
         3253  +|   3792: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         3254  +|   3808: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         3255  +|   3824: 02 02 01 0a 74 68 72 65 61 64 73 61 66 65 22 02   ....threadsafe..
         3256  +|   3840: 02 01 02 02 01 02 02 01 04 76 74 61 62 07 02 04   .........vtab...
         3257  +|   3856: 01 02 04 01 02 04 01 01 78 01 06 01 01 02 01 06   ........x.......
         3258  +|   3872: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         3259  +|   3888: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         3260  +|   3904: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         3261  +|   3920: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         3262  +|   3936: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         3263  +|   3952: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         3264  +|   3968: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         3265  +|   3984: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         3266  +|   4000: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         3267  +|   4016: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         3268  +|   4032: 01 01 02 01 06 01 01 02 01 06 01 01 02 04 18 13   ................
         3269  +|   4048: 0c 44 10 12 11 0f 47 13 0f 0c 12 10 0f 0e 10 0f   .D....G.........
         3270  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 57 24 24 0f   D..@.......$W$$.
         3271  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3272  +| page 4 offset 12288
         3273  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         3274  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3275  +| page 5 offset 16384
         3276  +|      0: 0d 00 00 00 24 0c 1f 00 0f df 0f bd 0f 9b 0f 89   ....$...........
         3277  +|     16: 0f 76 0f 63 0f 44 0f 24 0f 04 0e ec 0e d3 0e ba   .v.c.D.$........
         3278  +|     32: 0e a2 0e 89 0e 70 e5 50 e3 90 e1 d0 e0 40 de a0   .....p.P.....@..
         3279  +|     48: dd 00 db 50 d9 90 d7 ea ca ea be d0 d6 40 d4 a0   ...P.........@..
         3280  +|     64: d3 00 d1 00 ce f0 cc e0 ca e0 c8 d0 c6 c0 c5 30   ...............0
         3281  +|     80: c3 90 c1 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         3282  +|   3088: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18   ................
         3283  +|   3104: 24 05 00 25 0f 19 54 48 52 45 41 44 53 41 46 45   $..%..THREADSAFE
         3284  +|   3120: 3d 30 58 42 49 4e 41 52 59 18 23 05 00 25 0f 19   =0XBINARY.#..%..
         3285  +|   3136: 54 48 52 45 41 44 53 41 46 45 3d 30 58 4e 4f 43   THREADSAFE=0XNOC
         3286  +|   3152: 41 53 45 17 22 05 00 25 0f 17 54 48 52 45 41 44   ASE....%..THREAD
         3287  +|   3168: 53 41 46 45 3d 30 05 00 33 0f 19 4f 4d 49 54 20   SAFE=0..3..OMIT 
         3288  +|   3184: 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 58 42   LOAD EXTENSIONXB
         3289  +|   3200: 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f 4d 49 54   INARY. ..3..OMIT
         3290  +|   3216: 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 58    LOAD EXTENSIONX
         3291  +|   3232: 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 4f 4d 49   NOCASE....3..OMI
         3292  +|   3248: 54 20 4c f4 14 42 04 55 85 44 54 e5 34 94 f4 e5   T L..B.U.DT.4...
         3293  +|   3264: 85 25 45 24 94 d1 f1 e0 50 03 30 f1 94 d4 15 82   .%E$....P.0.....
         3294  +|   3280: 04 d4 54 d4 f5 25 93 d3 53 03 03 03 03 03 03 05   ..T..%..S.......
         3295  +|   3296: 84 24 94 e4 15 25 91 f1 d0 50 03 30 f1 94 d4 15   .$...%...P.0....
         3296  +|   3312: 82 04 d4 54 d4 f5 25 93 d3 53 03 03 03 03 03 03   ...T..%..S......
         3297  +|   3328: 05 84 e4 f4 34 15 34 51 e1 c0 50 03 30 f1 74 d4   ....4.4Q..P.0.t.
         3298  +|   3344: 15 82 04 d4 54 d4 f2 90 f1 74 54 e4 14 24 c4 52   ....T....tT..$.R
         3299  +|   3360: 04 74 54 f5 04 f4 c5 95 85 25 45 24 94 d1 70 f0   .tT......%E$..p.
         3300  +|   3376: 50 02 30 f1 94 54 e4 14 24 c4 52 04 65 45 33 55   P.0..T..$.R.eE3U
         3301  +|   3392: 84 24 94 e4 15 25 91 70 e0 50 02 30 f1 94 54 e4   .$...%.p.P.0..T.
         3302  +|   3408: 14 24 c4 52 04 65 45 33 55 84 e4 f4 34 15 34 51   .$.R.eE3U...4.4Q
         3303  +|   3424: 60 d0 50 02 30 f1 74 54 e4 14 24 c4 52 04 65 45   `.P.0.tT..$.R.eE
         3304  +|   3440: 33 55 85 25 45 24 94 d1 70 c0 50 02 30 f1 94 54   3U.%E$..p.P.0..T
         3305  +|   3456: e4 14 24 c4 52 04 65 45 33 45 84 24 94 e4 15 25   ..$.R.eE3E.$...%
         3306  +|   3472: 91 70 b0 50 02 30 f1 94 54 e4 14 24 c4 52 04 65   .p.P.0..T..$.R.e
         3307  +|   3488: 45 33 45 84 e4 f4 34 15 34 51 60 a0 74 54 e4 14   E3E...4.4Q`.tT..
         3308  +|   3504: 24 c4 52 04 65 45 33 45 85 25 45 24 94 d1 e0 90   $.R.eE3E.%E$....
         3309  +|   3520: 50 03 10 f1 94 54 e4 14 24 c4 52 04 44 25 35 44   P....T..$.R.D%5D
         3310  +|   3536: 15 42 05 65 44 14 25 84 24 94 e4 15 25 91 e0 80   .B.eD.%.$...%...
         3311  +|   3552: 50 03 10 f1 94 54 e4 14 24 c4 52 04 44 25 35 44   P....T..$.R.D%5D
         3312  +|   3568: 15 42 05 65 44 14 25 84 e4 f4 34 15 34 51 d0 70   .B.eD.%...4.4Q.p
         3313  +|   3584: 50 03 10 f1 74 54 e4 14 24 c4 52 04 44 25 35 44   P...tT..$.R.D%5D
         3314  +|   3600: 15 42 05 65 44 14 25 85 25 45 24 94 d1 10 60 50   .B.eD.%.%E$...`P
         3315  +|   3616: 01 70 f1 94 44 54 25 54 75 84 24 94 e4 15 25 91   .p..DT%Tu.$...%.
         3316  +|   3632: 10 50 50 01 70 f1 94 44 54 25 54 75 84 e4 f4 34   .PP.p..DT%Tu...4
         3317  +|   3648: 15 34 51 00 40 50 01 70 f1 74 44 54 25 54 75 85   .4Q.@P.p.tDT%Tu.
         3318  +|   3664: 25 45 24 94 d2 00 30 50 03 50 f1 94 34 f4 d5 04   %E$...0P.P..4...
         3319  +|   3680: 94 c4 55 23 d6 36 c6 16 e6 72 d3 62 e3 02 e3 05   ..U#.6...r.b....
         3320  +|   3696: 84 24 94 e4 15 25 92 00 20 50 03 50 f1 94 34 f4   .$...%.. P.P..4.
         3321  +|   3712: d5 04 94 c4 55 23 d6 36 c6 16 e6 72 d3 62 e3 02   ....U#.6...r.b..
         3322  +|   3728: e3 05 84 e4 f4 34 15 34 51 f0 10 50 03 50 f1 74   .....4.4Q..P.P.t
         3323  +|   3744: 34 f4 d5 04 94 c4 55 23 d6 36 c6 16 e6 72 d3 62   4.....U#.6...r.b
         3324  +|   3760: e3 02 e3 05 85 25 45 24 94 d0 d0 00 00 02 40 ee   .....%E$......@.
         3325  +|   3776: 00 00 ff 80 ff 00 fe 80 fe 00 fd 80 fd 00 fc 80   ................
         3326  +|   3792: fc 00 fb 80 fb 00 fa 80 fa 00 f9 80 f9 00 f8 80   ................
         3327  +|   3808: f8 00 f7 80 f7 00 f6 80 f6 00 f5 80 f5 00 f4 80   ................
         3328  +|   3824: f4 00 f3 80 f3 00 f2 80 f2 00 f1 80 f1 00 f0 80   ................
         3329  +|   3840: f0 00 ef 80 ef 00 ee 80 ee 00 00 00 00 00 00 00   ................
         3330  +| page 6 offset 20480
         3331  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         3332  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         3333  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         3334  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         3335  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         3336  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         3337  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         3338  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         3339  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         3340  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         3341  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         3342  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         3343  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         3344  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         3345  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         3346  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         3347  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 05 01 01   ................
         3348  +|   4080: 06 02 03 00 12 05 01 01 06 01 03 00 12 05 01 01   ................
         3349  +| page 7 offset 24576
         3350  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3351  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3352  +| end crash-e114c036e13dde.db
         3353  +}]} {}
         3354  +
         3355  +do_catchsql_test 29.1 {
         3356  +  CREATE VIRTUAL TABLE t3 USING fts5vocab('t1','col');
         3357  +} {0 {}}
         3358  +do_catchsql_test 29.2 {
         3359  +  SELECT rowid, quote(term), * FROM t3 WHERE term=='nocase';
         3360  +} {1 {database disk image is malformed}}
         3361  +
         3362  +#-------------------------------------------------------------------------
         3363  +reset_db
         3364  +do_test 30.0 {
         3365  +  sqlite3 db {}
         3366  +  db deserialize [decode_hexdb {
         3367  +| size 40960 pagesize 4096 filename crash-eef41e30b388a0.db
         3368  +| page 1 offset 0
         3369  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3370  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a   .....@  ........
         3371  +|     32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04   ................
         3372  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3373  +|     96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c   ..........n....L
         3374  +|    112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50   .....$...r.....P
         3375  +|    128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00   .....n..........
         3376  +|   2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d   ..............C.
         3377  +|   2928: 06 17 11 11 08 75 74 61 62 6c 65 74 34 74 34 43   .....utablet4t4C
         3378  +|   2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
         3379  +|   2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73   BLE t4 USING fts
         3380  +|   2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f   5vocab('t2', 'ro
         3381  +|   2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65   w')C......utable
         3382  +|   3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55   t3t3CREATE VIRTU
         3383  +|   3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e   AL TABLE t3 USIN
         3384  +|   3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27   G fts5vocab('t1'
         3385  +|   3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d   , 'row')V.......
         3386  +|   3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32   tablet2_configt2
         3387  +|   3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54   _config.CREATE T
         3388  +|   3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27   ABLE 't2_config'
         3389  +|   3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   (k PRIMARY KEY, 
         3390  +|   3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   v) WITHOUT ROWID
         3391  +|   3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32   ^...!!...tablet2
         3392  +|   3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65   _contentt2_conte
         3393  +|   3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20   nt.CREATE TABLE 
         3394  +|   3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   't2_content'(id 
         3395  +|   3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         3396  +|   3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29   KEY, c0, c1, c2)
         3397  +|   3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32   i.......-tablet2
         3398  +|   3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54   _idxt2_idx.CREAT
         3399  +|   3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27   E TABLE 't2_idx'
         3400  +|   3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67   (segid, term, pg
         3401  +|   3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28   no, PRIMARY KEY(
         3402  +|   3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49   segid, term)) WI
         3403  +|   3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b   THOUT ROWIDU....
         3404  +|   3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61   ....tablet2_data
         3405  +|   3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54   t2_data.CREATE T
         3406  +|   3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69   ABLE 't2_data'(i
         3407  +|   3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52   d INTEGER PRIMAR
         3408  +|   3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f   Y KEY, block BLO
         3409  +|   3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65   B)X........table
         3410  +|   3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55   t2t2CREATE VIRTU
         3411  +|   3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e   AL TABLE t2 USIN
         3412  +|   3488: 47 20 66 74 73 35 28 27 61 27 2c 5b 62 5d 2c 22   G fts5('a',[b],.
         3413  +|   3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63   c.,detail=none,c
         3414  +|   3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17   olumnsize=0)V...
         3415  +|   3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66   ....tablet1_conf
         3416  +|   3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41   igt1_config.CREA
         3417  +|   3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
         3418  +|   3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b   fig'(k PRIMARY K
         3419  +|   3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52   EY, v) WITHOUT R
         3420  +|   3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62   OWID[...!!...tab
         3421  +|   3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64   let1_docsizet1_d
         3422  +|   3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41   ocsize.CREATE TA
         3423  +|   3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27   BLE 't1_docsize'
         3424  +|   3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         3425  +|   3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42   ARY KEY, sz BLOB
         3426  +|   3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74   )^...!!...tablet
         3427  +|   3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74   1_contentt1_cont
         3428  +|   3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45   ent.CREATE TABLE
         3429  +|   3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64    't1_content'(id
         3430  +|   3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
         3431  +|   3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32    KEY, c0, c1, c2
         3432  +|   3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74   )i.......-tablet
         3433  +|   3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41   1_idxt1_idx.CREA
         3434  +|   3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78   TE TABLE 't1_idx
         3435  +|   3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70   '(segid, term, p
         3436  +|   3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59   gno, PRIMARY KEY
         3437  +|   3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57   (segid, term)) W
         3438  +|   3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17   ITHOUT ROWIDU...
         3439  +|   3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74   .....tablet1_dat
         3440  +|   3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20   at1_data.CREATE 
         3441  +|   3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28   TABLE 't1_data'(
         3442  +|   3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         3443  +|   3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c   RY KEY, block BL
         3444  +|   4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c   OB)[.......#tabl
         3445  +|   4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         3446  +|   4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         3447  +|   4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e   NG fts5(a,b unin
         3448  +|   4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65   dexed,c,tokenize
         3449  +|   4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29   =.porter ascii.)
         3450  +| page 2 offset 4096
         3451  +|      0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c   ..h............|
         3452  +|     16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .*..............
         3453  +|   3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00   .......0........
         3454  +|   3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80   ..........7.....
         3455  +|   3888: 01 03 00 74 00 00 00 2e 02 30 61 03 02 02 01 01   ...t.....0a.....
         3456  +|   3904: 62 03 02 03 01 01 63 03 02 04 01 01 67 03 06 01   b.....c.....g...
         3457  +|   3920: 02 02 01 01 68 03 06 01 02 03 01 01 69 03 06 01   ....h.......i...
         3458  +|   3936: 02 04 00 00 66 46 08 08 0f ef 00 14 2a 00 00 00   ....fF......*...
         3459  +|   3952: 00 01 02 02 00 02 01 01 01 02 01 01 25 88 80 80   ............%...
         3460  +|   3968: 80 80 01 03 00 50 00 00 00 1f 02 30 67 02 08 02   .....P.....0g...
         3461  +|   3984: 01 02 02 01 01 68 02 08 03 01 02 03 01 01 69 02   .....h........i.
         3462  +|   4000: 08 04 01 02 04 04 09 09 37 84 80 80 80 80 01 03   ........7.......
         3463  +|   4016: 00 74 00 00 00 2e 02 30 61 01 02 02 01 01 62 01   .t.....0a.....b.
         3464  +|   4032: 02 03 01 01 63 01 02 04 01 01 67 01 06 01 02 02   ....c.....g.....
         3465  +|   4048: 01 01 68 01 06 01 02 03 01 01 69 01 06 01 02 04   ..h.......i.....
         3466  +|   4064: 04 06 06 06 08 08 07 01 03 00 14 03 09 00 09 00   ................
         3467  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3468  +| page 3 offset 8192
         3469  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         3470  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         3471  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         3472  +| page 4 offset 12288
         3473  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         3474  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3475  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3476  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3477  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3478  +|   4080: 17 61 20 62 20 63 64 20 52 06 66 72 06 82 06 90   .a b cd R.fr....
         3479  +| page 5 offset 16384
         3480  +|      0: d0 00 00 00 30 fe 80 00 ff 80 ff 00 fe 00 00 00   ....0...........
         3481  +|   4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 03   ................
         3482  +|   4080: 06 02 03 00 12 03 00 03 06 01 03 00 12 03 00 03   ................
         3483  +| page 6 offset 20480
         3484  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3485  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3486  +| page 7 offset 24576
         3487  +|      0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00   ................
         3488  +|   3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84   ..............A.
         3489  +|   4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61   ............4.0a
         3490  +|   4016: 01 01 01 01 01 62 01 01 01 01 01 63 01 01 01 01   .....b.....c....
         3491  +|   4032: 01 64 01 01 01 65 01 01 01 66 01 01 01 67 01 01   .d...e...f...g..
         3492  +|   4048: 01 01 01 68 01 01 01 01 01 69 01 01 01 04 06 06   ...h.....i......
         3493  +|   4064: 06 04 04 04 06 06 07 01 03 00 14 03 09 09 09 0f   ................
         3494  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3495  +| page 8 offset 28672
         3496  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         3497  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3498  +| page 9 offset 32768
         3499  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         3500  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3501  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3502  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3503  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3504  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         3505  +| page 10 offset 36864
         3506  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3507  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3508  +| end crash-eef41e30b388a0.db
         3509  +}]} {}
         3510  +
         3511  +do_catchsql_test 30.1 {
         3512  +  SELECT fts5_decode(id, block) FROM t1_data;
         3513  +} {1 {database disk image is malformed}}
         3514  +
         3515  +#-------------------------------------------------------------------------
         3516  +reset_db
         3517  +do_test 31.0 {
         3518  +  sqlite3 db {}
         3519  +  db deserialize [decode_hexdb {
         3520  +| size 8192 pagesize 4096 filename crash-7629f35f11d48e.db
         3521  +| page 1 offset 0
         3522  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3523  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 02   .....@  ........
         3524  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04   ................
         3525  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3526  +|     96: 00 00 00 00 0d 00 00 00 01 0f c7 00 0f c7 00 00   ................
         3527  +|   4032: 00 00 00 00 00 00 00 37 01 06 17 15 15 01 53 74   .......7......St
         3528  +|   4048: 61 62 6c 65 64 75 61 6c 64 75 61 6c 02 43 52 45   abledualdual.CRE
         3529  +|   4064: 41 54 45 20 54 41 42 4c 45 20 64 75 61 6c 28 64   ATE TABLE dual(d
         3530  +|   4080: 75 6d 6d 79 20 76 61 72 28 31 29 29 0d 00 00 00   ummy var(1))....
         3531  +| page 2 offset 4096
         3532  +|      0: 01 0f fb 00 0f fb 00 00 00 00 00 00 00 00 00 00   ................
         3533  +|   4080: 00 00 00 00 00 00 00 00 00 00 00 03 01 02 0f 58   ...............X
         3534  +| end crash-7629f35f11d48e.db
         3535  +}]} {}
         3536  +
         3537  +do_execsql_test 31.1 {
         3538  +  CREATE VIRTUAL TABLE t1 USING fts5(a,b,c);
         3539  +  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<72)
         3540  +    INSERT INTO t1(a) SELECT randomblob(2829) FROM c;
         3541  +  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10)
         3542  +    INSERT INTO t1(a) SELECT randomblob(3000) FROM c;
         3543  +}
         3544  +
         3545  +do_catchsql_test 31.2 {
         3546  +  DELETE FROM t1 WHERE a MATCH X'6620e574f32a';
         3547  +} {0 {}}
         3548  +
         3549  +#-------------------------------------------------------------------------
         3550  +reset_db
         3551  +do_test 32.0 {
         3552  +  sqlite3 db {}
         3553  +  db deserialize [decode_hexdb {
         3554  +| size 40960 pagesize 4096 filename crash-e2d47e0624a42c.db
         3555  +| page 1 offset 0
         3556  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3557  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a   .....@  ........
         3558  +|     32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04   ................
         3559  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3560  +|     96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c   ..........n....L
         3561  +|    112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50   .....$...r.....P
         3562  +|    128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00   .....n..........
         3563  +|   2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d   ..............C.
         3564  +|   2928: 06 17 11 11 08 75 74 61 62 6c 65 74 34 74 34 43   .....utablet4t4C
         3565  +|   2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
         3566  +|   2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73   BLE t4 USING fts
         3567  +|   2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f   5vocab('t2', 'ro
         3568  +|   2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65   w')C......utable
         3569  +|   3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55   t3t3CREATE VIRTU
         3570  +|   3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e   AL TABLE t3 USIN
         3571  +|   3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27   G fts5vocab('t1'
         3572  +|   3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d   , 'row')V.......
         3573  +|   3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32   tablet2_configt2
         3574  +|   3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54   _config.CREATE T
         3575  +|   3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27   ABLE 't2_config'
         3576  +|   3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   (k PRIMARY KEY, 
         3577  +|   3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   v) WITHOUT ROWID
         3578  +|   3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32   ^...!!...tablet2
         3579  +|   3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65   _contentt2_conte
         3580  +|   3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20   nt.CREATE TABLE 
         3581  +|   3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   't2_content'(id 
         3582  +|   3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         3583  +|   3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29   KEY, c0, c1, c2)
         3584  +|   3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32   i.......-tablet2
         3585  +|   3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54   _idxt2_idx.CREAT
         3586  +|   3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27   E TABLE 't2_idx'
         3587  +|   3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67   (segid, term, pg
         3588  +|   3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28   no, PRIMARY KEY(
         3589  +|   3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49   segid, term)) WI
         3590  +|   3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b   THOUT ROWIDU....
         3591  +|   3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61   ....tablet2_data
         3592  +|   3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54   t2_data.CREATE T
         3593  +|   3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69   ABLE 't2_data'(i
         3594  +|   3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52   d INTEGER PRIMAR
         3595  +|   3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f   Y KEY, block BLO
         3596  +|   3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65   B)X........table
         3597  +|   3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55   t2t2CREATE VIRTU
         3598  +|   3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e   AL TABLE t2 USIN
         3599  +|   3488: 47 20 66 74 73 35 28 27 61 27 2c 5b 62 5d 2c 22   G fts5('a',[b],.
         3600  +|   3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63   c.,detail=none,c
         3601  +|   3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17   olumnsize=0)V...
         3602  +|   3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66   ....tablet1_conf
         3603  +|   3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41   igt1_config.CREA
         3604  +|   3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
         3605  +|   3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b   fig'(k PRIMARY K
         3606  +|   3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52   EY, v) WITHOUT R
         3607  +|   3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62   OWID[...!!...tab
         3608  +|   3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64   let1_docsizet1_d
         3609  +|   3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41   ocsize.CREATE TA
         3610  +|   3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27   BLE 't1_docsize'
         3611  +|   3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         3612  +|   3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42   ARY KEY, sz BLOB
         3613  +|   3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74   )^...!!...tablet
         3614  +|   3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74   1_contentt1_cont
         3615  +|   3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45   ent.CREATE TABLE
         3616  +|   3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64    't1_content'(id
         3617  +|   3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
         3618  +|   3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32    KEY, c0, c1, c2
         3619  +|   3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74   )i.......-tablet
         3620  +|   3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41   1_idxt1_idx.CREA
         3621  +|   3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78   TE TABLE 't1_idx
         3622  +|   3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70   '(segid, term, p
         3623  +|   3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59   gno, PRIMARY KEY
         3624  +|   3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57   (segid, term)) W
         3625  +|   3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17   ITHOUT ROWIDU...
         3626  +|   3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74   .....tablet1_dat
         3627  +|   3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20   at1_data.CREATE 
         3628  +|   3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28   TABLE 't1_data'(
         3629  +|   3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         3630  +|   3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c   RY KEY, block BL
         3631  +|   4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c   OB)[.......#tabl
         3632  +|   4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         3633  +|   4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         3634  +|   4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e   NG fts5(a,b unin
         3635  +|   4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65   dexed,c,tokenize
         3636  +|   4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29   =.porter ascii.)
         3637  +| page 2 offset 4096
         3638  +|      0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c   ..h............|
         3639  +|     16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .*..............
         3640  +|   3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00   .......0........
         3641  +|   3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80   ..........7.....
         3642  +|   3888: 01 03 00 74 00 00 00 2e 02 30 61 03 02 02 01 01   ...t.....0a.....
         3643  +|   3904: 62 03 02 03 01 01 63 03 02 04 01 01 67 03 06 01   b.....c.....g...
         3644  +|   3920: 02 02 01 01 68 03 06 01 02 03 01 01 69 03 06 01   ....h.......i...
         3645  +|   3936: 02 04 04 06 06 06 08 08 0f ef 00 14 2a 00 00 00   ............*...
         3646  +|   3952: 00 01 02 02 00 02 01 01 01 02 01 01 25 88 80 80   ............%...
         3647  +|   3968: 80 80 01 03 00 50 00 00 00 1f 02 30 67 02 08 02   .....P.....0g...
         3648  +|   3984: 01 02 02 01 01 68 02 08 03 01 02 03 01 01 69 02   .....h........i.
         3649  +|   4000: 08 04 01 02 04 04 09 09 37 84 80 80 80 80 01 03   ........7.......
         3650  +|   4016: 00 74 00 00 00 2e 02 30 61 01 02 02 01 01 62 01   .t.....0a.....b.
         3651  +|   4032: 02 03 01 01 63 01 02 04 01 01 67 01 06 01 02 20   ....c.....g.... 
         3652  +|   4048: 10 16 80 10 60 10 20 30 10 16 90 10 60 10 20 40   ....`. 0....`. @
         3653  +|   4064: 40 60 60 60 80 80 70 10 30 01 40 30 90 00 90 00   @```..p.0.@0....
         3654  +|   4080: 00 01 12 40 00 00 00 00 10 10 10 00 10 10 10 10   ...@............
         3655  +| page 3 offset 8192
         3656  +|      0: a0 00 00 00 30 fe c0 00 ff a0 ff 30 fe 00 00 00   ....0......0....
         3657  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         3658  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         3659  +| page 4 offset 12288
         3660  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         3661  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3662  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3663  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3664  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3665  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         3666  +| page 5 offset 16384
         3667  +|      0: 0d 00 00 00 03 0f e8 00 0f f8 0f f0 0f e8 00 00   ................
         3668  +|   4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 03   ................
         3669  +|   4080: 06 02 03 00 12 03 00 03 06 01 03 00 12 03 00 03   ................
         3670  +| page 6 offset 20480
         3671  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3672  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3673  +| page 7 offset 24576
         3674  +|      0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00   ................
         3675  +|   3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84   ..............A.
         3676  +|   4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61   ............4.0a
         3677  +|   4016: 01 01 01 01 01 62 01 01 01 01 01 63 01 01 01 01   .....b.....c....
         3678  +|   4032: 01 64 01 01 01 65 01 01 01 66 01 01 01 01 01 68   .d...e...f.....h
         3679  +|   4048: 01 01 01 01 01 69 01 01 01 04 06 06 06 04 04 04   .....i..........
         3680  +|   4064: 06 06 07 01 03 00 14 03 09 09 09 0f 0a 03 00 24   ...............$
         3681  +|   4080: 00 00 00 00 01 01 01 00 01 01 01 01 0a 00 00 00   ................
         3682  +| page 8 offset 28672
         3683  +|      0: 01 0f fa 00 0f fa 00 00 00 00 00 00 00 00 00 00   ................
         3684  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3685  +| page 9 offset 32768
         3686  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 1f be 00 00   ................
         3687  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3688  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3689  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3690  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3691  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         3692  +| page 10 offset 36864
         3693  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3694  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3695  +| end crash-e2d47e0624a42c.db
         3696  +}]} {}
         3697  +
         3698  +do_catchsql_test 32.1 {
         3699  +  SELECT snippet(t1, -1, '.', '..', '[', ']'), 
         3700  +         highlight(t1, 2, '[', ']') 
         3701  +  FROM t1('g + h') 
         3702  +  WHERE rank MATCH 'bm25(1.0, 1.0)' ORDER BY rank;
         3703  +} {1 {vtable constructor failed: t1}}
         3704  +
         3705  +do_catchsql_test 32.2 {
         3706  +  SELECT * FROM t3;
         3707  +} {1 {database disk image is malformed}}
         3708  +
         3709  +do_catchsql_test 32.3 {
         3710  +  SELECT * FROM t4;
         3711  +} {1 {database disk image is malformed}}
         3712  +
         3713  +do_catchsql_test 32.4 {
         3714  +  SELECT fts5_decode(id, block) FROM t1_data;
         3715  +} {1 {database disk image is malformed}}
         3716  +
         3717  +do_catchsql_test 32.5 {
         3718  +  SELECT fts5_decode(id, block) FROM t2_data;
         3719  +} {1 {database disk image is malformed}}
         3720  +
         3721  +#-------------------------------------------------------------------------
         3722  +reset_db
         3723  +do_test 33.0 {
         3724  +  sqlite3 db {}
         3725  +  db deserialize [decode_hexdb {
         3726  +| size 28672 pagesize 4096 filename crash-fed6e90021ba5d.db
         3727  +| page 1 offset 0
         3728  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3729  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         3730  +|     32: 00 00 00 02 00 00 00 01 00 00 00 08 00 00 00 04   ................
         3731  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3732  +|     96: 00 00 00 00 0d 0f c7 00 06 0d b6 00 0f 8d 0f 36   ...............6
         3733  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d b6 00 00 00 00 00 00   ...k............
         3734  +|   3504: 00 00 00 00 00 00 56 07 06 17 1f 1f 01 7d 74 61   ......V.......ta
         3735  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         3736  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         3737  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         3738  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         3739  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         3740  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         3741  +|   3616: 6f 63 73 69 8a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsi.et1_docsize
         3742  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         3743  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         3744  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         3745  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         3746  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         3747  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         3748  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         3749  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         3750  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         3751  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         3752  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         3753  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         3754  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         3755  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         3756  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         3757  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         3758  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         3759  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         3760  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         3761  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         3762  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         3763  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         3764  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         3765  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         3766  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         3767  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         3768  +| page 3 offset 8192
         3769  +|      0: 0d 00 00 00 03 0c af 00 0f e6 0f ef 0c af 00 00   ................
         3770  +|   3232: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86   ................
         3771  +|   3248: 2f 84 80 80 80 80 01 04 00 8c 62 00 00 03 12 02   /.........b.....
         3772  +|   3264: 30 30 01 04 05 03 01 04 05 03 01 04 05 03 1f 02   00..............
         3773  +|   3280: 03 01 02 03 01 02 03 01 08 35 30 30 30 30 30 30   .........5000000
         3774  +|   3296: 30 1c 02 04 01 0e ee ca ec ea ea ab e4 f5 ca b1   0...............
         3775  +|   3312: ac ee ec de ef 3e ee ca ee ec f2 f8 0f f0 0f e8   .....>..........
         3776  +|   3328: 0f e0 0f d8 0f d0 0f c8 0f c0 0f b8 0f b0 0f a8   ................
         3777  +|   3344: 0f a0 0f 98 0f 90 0f 88 0f 80 0f 78 0f 70 0f 68   ...........x.p.h
         3778  +|   3360: 0f 60 0f 58 0f 50 0f 48 0f 40 0f 38 0f 30 0f 28   .`.X.P.H.@.8.0.(
         3779  +|   3376: 0f 20 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0 0e e8   . ..............
         3780  +|   3392: 0e e0 02 03 01 02 03 01 02 03 02 07 6f 6d 70 69   ............ompi
         3781  +|   3408: 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64 62   ler...........db
         3782  +|   3424: 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04 65   stat...........e
         3783  +|   3440: 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65 6e   bug...........en
         3784  +|   3456: 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02 02   able............
         3785  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         3786  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         3787  +|   3504: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         3788  +|   3520: 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02 04   .....xtension...
         3789  +|   3536: 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03 03   ........fts4....
         3790  +|   3552: 01 02 01 02 03 04 01 35 0d 02 03 01 02 03 01 02   .......5........
         3791  +|   3568: 03 01 07 67 65 6f 70 6f 6c 79 10 02 03 01 02 03   ...geopoly......
         3792  +|   3584: 01 02 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03   .....json1......
         3793  +|   3600: 01 02 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01   .....load.......
         3794  +|   3616: 02 03 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02   ....max.........
         3795  +|   3632: 02 05 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03   ..emory.........
         3796  +|   3648: 04 04 73 79 73 35 16 02 03 01 02 03 01 02 03 01   ..sys5..........
         3797  +|   3664: 06 6e 6f 63 61 73 65 02 06 01 02 02 03 06 01 02   .nocase.........
         3798  +|   3680: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         3799  +|   3696: 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03   ................
         3800  +|   3712: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         3801  +|   3728: 01 02 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01   .....omit.......
         3802  +|   3744: 02 02 01 05 72 74 72 65 65 19 02 03 01 02 03 01   ....rtree.......
         3803  +|   3760: 02 03 04 02 69 6d 01 06 01 02 02 03 06 01 02 02   ....im..........
         3804  +|   3776: 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03   ................
         3805  +|   3792: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         3806  +|   3808: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         3807  +|   3824: 02 02 01 0a 74 68 72 65 61 64 73 61 66 65 22 02   ....threadsafe..
         3808  +|   3840: 02 01 02 02 01 02 02 01 04 76 74 61 62 07 02 04   .........vtab...
         3809  +|   3856: 01 02 04 01 02 04 01 01 78 01 06 01 01 02 01 06   ........x.......
         3810  +|   3872: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         3811  +|   3888: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         3812  +|   3904: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         3813  +|   3920: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         3814  +|   3936: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         3815  +|   3952: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         3816  +|   3968: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         3817  +|   3984: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         3818  +|   4000: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         3819  +|   4016: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         3820  +|   4032: 01 01 02 01 06 01 01 02 01 06 01 01 02 04 18 13   ................
         3821  +|   4048: 0c 44 10 12 11 0f 47 13 0f 0c 12 10 0f 0e 10 0f   .D....G.........
         3822  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 57 24 24 0f   D..@.......$W$$.
         3823  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3824  +| page 4 offset 12288
         3825  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         3826  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3827  +| page 5 offset 16384
         3828  +|      0: 0d 00 00 00 24 0c 1f 00 0f df 0f bd 0f 9b 0f 89   ....$...........
         3829  +|     16: 0f 76 0f 63 0f 44 0f 24 0f 04 0e ec 0e d3 0e ba   .v.c.D.$........
         3830  +|     32: 0e a2 0e 89 0e 70 0e 55 0e 39 0e 1d 0e 04 0d ea   .....p.U.9......
         3831  +|     48: 0d d0 0d b5 0d 99 0d 7d 0d 64 0d 4a 0d 30 0d 10   .........d.J.0..
         3832  +|     64: 0c ef 0c ce 0c ae 54 d5 35 95 33 55 84 24 94 e4   ......T.5.3U.$..
         3833  +|     80: 15 25 91 a1 70 50 02 90 f1 94 54 e4 14 24 c4 52   .%..pP....T..$.R
         3834  +|     96: 04 d4 54 d5 35 95 33 55 84 e4 f4 34 15 34 51 91   ..T.5.3U...4.4Q.
         3835  +|    112: 60 50 02 90 f1 74 54 e4 14 24 c4 52 04 d4 54 d5   `P...tT..$.R..T.
         3836  +|    128: 35 95 33 55 85 25 45 24 94 d1 81 50 50 02 50 f1   5.3U.%E$...PP.P.
         3837  +|    144: 94 54 e4 14 24 c4 52 04 a5 34 f4 e3 15 84 24 94   .T..$.R..4....$.
         3838  +|    160: e4 15 25 91 81 40 50 02 50 f1 94 54 e4 14 24 c4   ..%..@P.P..T..$.
         3839  +|    176: 52 04 a5 34 f4 e3 15 84 e4 f4 34 15 34 51 71 30   R..4......4.4Qq0
         3840  +|    192: 50 02 50 f1 74 54 e4 14 24 c4 52 04 ae 4f 41 33   P.P.tT..$.R..OA3
         3841  +|    208: 55 85 25 45 24 94 d1 a1 20 50 02 90 f1 94 54 e4   U.%E$... P....T.
         3842  +|    224: 14 24 c4 52 04 74 54 f5 04 f4 c5 95 84 24 94 e4   .$.R.tT......$..
         3843  +|    240: 15 25 91 a1 10 50 02 90 f1 94 54 e4 14 24 c4 52   .%...P....T..$.R
         3844  +|    256: 04 74 54 f5 04 f4 c5 95 84 e4 f4 34 15 34 51 91   .tT........4.4Q.
         3845  +|    272: 00 50 02 90 f1 74 54 e4 14 24 c4 52 04 74 54 f5   .P...tT..$.R.tT.
         3846  +|    288: 04 f4 c5 95 85 25 45 24 94 d1 70 f0 50 02 30 f1   .....%E$..p.P.0.
         3847  +|    304: 94 54 e4 14 24 c4 52 04 65 45 33 55 84 24 94 e4   .T..$.R.eE3U.$..
         3848  +|    320: 15 25 91 70 e0 50 02 30 f1 94 54 e4 40 0f 38 0f   .%.p.P.0..T.@.8.
         3849  +|    336: 30 0f 28 0f 20 0f 18 0f 10 0f 08 0f 00 0e f8 0e   0.(. ...........
         3850  +|    352: f0 0e e8 0e e0 00 00 00 00 00 00 00 00 00 00 00   ................
         3851  +| page 6 offset 20480
         3852  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         3853  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         3854  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         3855  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         3856  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         3857  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         3858  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         3859  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         3860  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         3861  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         3862  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         3863  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         3864  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         3865  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         3866  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         3867  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         3868  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 05 01 01   ................
         3869  +|   4080: 06 02 03 00 12 05 01 01 06 01 03 00 12 05 01 01   ................
         3870  +| page 7 offset 24576
         3871  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 52 59 11 05 05 00   ..........RY....
         3872  +|     16: 17 0f 19 44 45 42 55 47 58 4e 4f 43 41 53 45 10   ...DEBUGXNOCASE.
         3873  +|     32: 04 05 00 17 0f 17 44 45 42 55 47 58 52 54 52 49   ......DEBUGXRTRI
         3874  +|     48: 4d 20 03 05 00 35 0f 19 43 4f 4d 50 49 4c 45 52   M ...5..COMPILER
         3875  +|     64: 3d 63 6c 61 6e 67 2d 36 2e 30 2e 30 58 42 49 4e   =clang-6.0.0XBIN
         3876  +|     80: 41 52 59 20 02 05 00 35 0f 19 43 4f 4d 50 49 4c   ARY ...5..COMPIL
         3877  +|     96: 45 52 3d 63 6c 61 6e 67 2d 36 2e 30 2e 30 58 4e   ER=clang-6.0.0XN
         3878  +|    112: 4f 43 41 53 45 1f 01 05 00 35 0f 17 43 4f 4d 50   OCASE....5..COMP
         3879  +|    128: 49 4c 45 52 3d 63 6c 61 6e 67 2d 36 2e 30 2e 30   ILER=clang-6.0.0
         3880  +|    144: 58 52 54 52 49 4d 0d 00 00 00 24 0e e0 00 0f 6f   XRTRIM....$....o
         3881  +|    160: 6e 74 65 6e 74 05 43 52 45 41 54 45 20 54 41 42   ntent.CREATE TAB
         3882  +|    176: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28   LE 't1_content'(
         3883  +|    192: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         3884  +|    208: 52 59 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20   RY KEY, c0, c1, 
         3885  +|    224: 63 32 29 69 04 07 17 19 19 01 81 2d 74 61 62 6c   c2)i.......-tabl
         3886  +|    240: 65 74 31 5f 69 64 78 74 31 5f 69 64 78 04 43 52   et1_idxt1_idx.CR
         3887  +|    256: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69   EATE TABLE 't1_i
         3888  +|    272: 64 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c   dx'(segid, term,
         3889  +|    288: 20 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b    pgno, PRIMARY K
         3890  +|    304: 45 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29   EY(segid, term))
         3891  +|    320: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 03    WITHOUT ROWIDU.
         3892  +|    336: 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64   .......tablet1_d
         3893  +|    352: 61 74 61 74 31 5f 64 61 74 61 03 43 52 45 41 54   atat1_data.CREAT
         3894  +|    368: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61   E TABLE 't1_data
         3895  +|    384: 27 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49   '(id INTEGER PRI
         3896  +|    400: 4d 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20   MARY KEY, block 
         3897  +|    416: 42 4c 4f 42 29 38 02 06 17 11 11 08 5f 74 61 62   BLOB)8......_tab
         3898  +|    432: 6c 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52   let1t1CREATE VIR
         3899  +|    448: 54 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53   TUAL TABLE t1 US
         3900  +|    464: 49 4e 47 20 66 74 73 35 28 61 2c 62 2c 63 29 00   ING fts5(a,b,c).
         3901  +|    480: 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00   ..9.............
         3902  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3903  +| end crash-fed6e90021ba5d.db
         3904  +}]} {}
         3905  +
         3906  +do_execsql_test 33.1 {
         3907  +  CREATE VIRTUAL TABLE t2 USING fts5vocab('t1','row');
         3908  +  CREATE VIRTUAL TABLE t3 USING fts5vocab('t1','col');
         3909  +  CREATE VIRTUAL TABLE t4 USING fts5vocab('t1','instance');
         3910  +}
         3911  +
         3912  +do_catchsql_test 33.2 {
         3913  +  SELECT * FROM t2;
         3914  +} {1 {database disk image is malformed}}
         3915  +
         3916  +do_catchsql_test 33.3 {
         3917  +  SELECT * FROM t2, t3, t4 WHERE t2.term=t3.term AND t3.term=t4.term;
         3918  +} {1 {database disk image is malformed}}
         3919  +
         3920  +#-------------------------------------------------------------------------
         3921  +reset_db
         3922  +do_test 34.0 {
         3923  +  sqlite3 db {}
         3924  +  db deserialize [decode_hexdb {
         3925  +| size 40960 pagesize 4096 filename crash-a60a9da4c8932f.db
         3926  +| page 1 offset 0
         3927  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3928  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a   .....@  ........
         3929  +|     32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04   ................
         3930  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3931  +|     96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c   ..........n....L
         3932  +|    112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50   .....$...r.....P
         3933  +|    128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00   .....n..........
         3934  +|   2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d   ..............C.
         3935  +|   2928: 06 17 11 11 08 75 74 61 62 6c 65 74 34 74 34 43   .....utablet4t4C
         3936  +|   2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
         3937  +|   2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73   BLE t4 USING fts
         3938  +|   2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f   5vocab('t2', 'ro
         3939  +|   2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65   w')C......utable
         3940  +|   3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55   t3t3CREATE VIRTU
         3941  +|   3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e   AL TABLE t3 USIN
         3942  +|   3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27   G fts5vocab('t1'
         3943  +|   3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d   , 'row')V.......
         3944  +|   3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32   tablet2_configt2
         3945  +|   3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54   _config.CREATE T
         3946  +|   3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27   ABLE 't2_config'
         3947  +|   3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   (k PRIMARY KEY, 
         3948  +|   3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   v) WITHOUT ROWID
         3949  +|   3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32   ^...!!...tablet2
         3950  +|   3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65   _contentt2_conte
         3951  +|   3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20   nt.CREATE TABLE 
         3952  +|   3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   't2_content'(id 
         3953  +|   3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         3954  +|   3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29   KEY, c0, c1, c2)
         3955  +|   3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32   i.......-tablet2
         3956  +|   3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54   _idxt2_idx.CREAT
         3957  +|   3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27   E TABLE 't2_idx'
         3958  +|   3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67   (segid, term, pg
         3959  +|   3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28   no, PRIMARY KEY(
         3960  +|   3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49   segid, term)) WI
         3961  +|   3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b   THOUT ROWIDU....
         3962  +|   3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61   ....tablet2_data
         3963  +|   3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54   t2_data.CREATE T
         3964  +|   3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69   ABLE 't2_data'(i
         3965  +|   3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52   d INTEGER PRIMAR
         3966  +|   3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f   Y KEY, block BLO
         3967  +|   3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65   B)X........table
         3968  +|   3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55   t2t2CREATE VIRTU
         3969  +|   3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e   AL TABLE t2 USIN
         3970  +|   3488: 47 20 66 74 73 35 28 27 61 27 2c 5b 62 5d 2c 22   G fts5('a',[b],.
         3971  +|   3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63   c.,detail=none,c
         3972  +|   3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17   olumnsize=0)V...
         3973  +|   3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66   ....tablet1_conf
         3974  +|   3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41   igt1_config.CREA
         3975  +|   3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
         3976  +|   3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b   fig'(k PRIMARY K
         3977  +|   3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52   EY, v) WITHOUT R
         3978  +|   3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62   OWID[...!!...tab
         3979  +|   3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64   let1_docsizet1_d
         3980  +|   3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41   ocsize.CREATE TA
         3981  +|   3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27   BLE 't1_docsize'
         3982  +|   3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         3983  +|   3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42   ARY KEY, sz BLOB
         3984  +|   3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74   )^...!!...tablet
         3985  +|   3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74   1_contentt1_cont
         3986  +|   3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45   ent.CREATE TABLE
         3987  +|   3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64    't1_content'(id
         3988  +|   3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
         3989  +|   3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32    KEY, c0, c1, c2
         3990  +|   3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74   )i.......-tablet
         3991  +|   3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41   1_idxt1_idx.CREA
         3992  +|   3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78   TE TABLE 't1_idx
         3993  +|   3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70   '(segid, term, p
         3994  +|   3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59   gno, PRIMARY KEY
         3995  +|   3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57   (segid, term)) W
         3996  +|   3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17   ITHOUT ROWIDU...
         3997  +|   3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74   .....tablet1_dat
         3998  +|   3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20   at1_data.CREATE 
         3999  +|   3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28   TABLE 't1_data'(
         4000  +|   3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         4001  +|   3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c   RY KEY, block BL
         4002  +|   4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c   OB)[.......#tabl
         4003  +|   4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         4004  +|   4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         4005  +|   4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e   NG fts5(a,b unin
         4006  +|   4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65   dexed,c,tokenize
         4007  +|   4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29   =.porter ascii.)
         4008  +| page 2 offset 4096
         4009  +|      0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c   ..h............|
         4010  +|     16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .*..............
         4011  +|   3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00   .......0........
         4012  +|   3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80   ..........7.....
         4013  +|   3888: 01 03 00 74 00 20 68 20 69 0d 00 00 00 03 0f e8   ...t. h i.......
         4014  +|   3904: 00 0f f8 0f f0 0f e8 00 00 00 00 00 00 00 00 00   ................
         4015  +| page 5 offset 16384
         4016  +|   4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 00   ................
         4017  +|   4080: 60 20 30 01 20 30 00 30 60 10 30 01 20 30 00 30   ` 0. 0.0`.0. 0.0
         4018  +| page 6 offset 20480
         4019  +|      0: a0 00 00 00 10 ff 40 00 ff 00 00 00 00 00 00 00   ......@.........
         4020  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         4021  +| page 7 offset 24576
         4022  +|      0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00   ................
         4023  +|   3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84   ..............A.
         4024  +|   4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61   ............4.0a
         4025  +|   4016: 01 01 00 00 00 00 00 00 00 00 00 11 87 89 06 26   ...............&
         4026  +|   4032: 01 64 01 01 01 65 01 01 01 66 01 01 01 67 01 01   .d...e...f...g..
         4027  +|   4048: 01 01 01 68 01 01 01 01 01 69 01 01 01 04 06 06   ...h.....i......
         4028  +|   4064: 06 04 44 00 06 06 07 01 03 00 14 03 09 09 09 0f   ..D.............
         4029  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         4030  +| page 8 offset 28672
         4031  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         4032  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         4033  +| page 9 offset 32768
         4034  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         4035  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         4036  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         4037  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         4038  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         4039  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         4040  +| page 10 offset 36864
         4041  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         4042  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         4043  +| end crash-a60a9da4c8932f.db
         4044  +}]} {}
         4045  +
         4046  +do_catchsql_test 34.1 {
         4047  +  SELECT fts5_decode(id, block) FROM t1_data;
         4048  +} {1 {database disk image is malformed}}
         4049  +
         4050  +do_catchsql_test 34.2 {
         4051  +  SELECT fts5_decode(id, block) FROM t2_data;
         4052  +} {1 {database disk image is malformed}}
         4053  +
         4054  +#-------------------------------------------------------------------------
         4055  +reset_db
         4056  +do_test 35.0 {
         4057  +  sqlite3 db {}
         4058  +  db deserialize [decode_hexdb {
         4059  +| size 32768 pagesize 4096 filename crash-ae135cb10977c7.db
         4060  +| page 1 offset 0
         4061  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         4062  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08   .....@  ........
         4063  +|     32: 00 00 00 02 00 00 00 01 00 00 00 09 00 00 00 04   ................
         4064  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         4065  +|     96: 00 00 00 00 0d 0f c7 00 07 0d 92 00 0f 8d 0f 36   ...............6
         4066  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d 92 0d 92 00 00 00 00   ...k............
         4067  +|   3472: 00 00 22 08 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         4068  +|   3488: 32 74 32 08 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         4069  +|   3504: 20 74 32 28 78 29 56 07 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         4070  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         4071  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         4072  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         4073  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         4074  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         4075  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         4076  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         4077  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         4078  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         4079  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         4080  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         4081  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         4082  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         4083  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         4084  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         4085  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         4086  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         4087  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         4088  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         4089  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         4090  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         4091  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         4092  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         4093  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         4094  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         4095  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         4096  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         4097  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         4098  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         4099  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         4100  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         4101  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         4102  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         4103  +| page 3 offset 8192
         4104  +|      0: 0d 00 00 00 03 0c 94 00 0f e6 0f ef 0c 94 00 00   ................
         4105  +|   3216: 00 00 00 00 86 4a 84 80 80 80 80 01 04 00 8d 18   .....J..........
         4106  +|   3232: 00 00 03 2b 02 30 30 01 02 06 01 02 06 01 02 06   ...+.00.........
         4107  +|   3248: 1f 02 03 01 02 03 01 02 03 01 08 32 30 31 36 30   ...........20160
         4108  +|   3264: 36 30 39 01 02 07 01 02 07 01 02 07 01 01 34 01   609...........4.
         4109  +|   3280: 02 05 01 02 05 01 02 05 01 01 35 01 02 04 01 02   ..........5.....
         4110  +|   3296: 04 01 02 04 02 07 30 30 30 30 30 30 30 1c 02 3d   ......0000000..=
         4111  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         4112  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         4113  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         4114  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         4115  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 08 63 6f 6d 70   ............comp
         4116  +|   3392: 69 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64   iler...........d
         4117  +|   3408: 62 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04   bstat...........
         4118  +|   3424: 65 62 75 67 04 02 02 01 02 02 01 02 02 01 07 65   ebug...........e
         4119  +|   3440: 6e 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02   nable...........
         4120  +|   3456: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         4121  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         4122  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         4123  +|   3504: 02 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02   ......xtension..
         4124  +|   3520: 04 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03   .........fts4...
         4125  +|   3536: 01 02 03 01 02 03 04 01 35 0d 02 03 01 02 03 01   ........5.......
         4126  +|   3552: 02 03 01 03 67 63 63 01 02 03 01 02 03 01 02 03   ....gcc.........
         4127  +|   3568: 02 06 65 6f 70 6f 6c 79 10 02 03 01 02 03 01 02   ..eopoly........
         4128  +|   3584: 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03 01 02   ...json1........
         4129  +|   3600: 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01 02 03   ...load.........
         4130  +|   3616: 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02 02 05   ..max...........
         4131  +|   3632: 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03 04 04   emory...........
         4132  +|   3648: 73 79 73 35 16 02 03 01 02 03 01 02 03 01 06 6e   sys5...........n
         4133  +|   3664: 6f 63 61 73 65 02 06 01 02 02 03 06 01 02 02 03   ocase...........
         4134  +|   3680: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         4135  +|   3696: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         4136  +|   3712: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         4137  +|   3728: 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01 02 02   ...omit.........
         4138  +|   3744: 01 05 72 74 72 65 65 19 02 03 01 02 03 01 02 03   ..rtree.........
         4139  +|   3760: 04 02 69 6d 01 06 01 02 02 03 06 01 02 02 03 06   ..im............
         4140  +|   3776: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         4141  +|   3792: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         4142  +|   3808: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         4143  +|   3824: 01 0a 74 68 72 65 61 64 73 61 66 65 22 02 02 01   ..threadsafe....
         4144  +|   3840: 02 02 01 02 02 01 04 76 74 61 62 07 02 04 01 02   .......vtab.....
         4145  +|   3856: 04 01 02 04 01 01 78 01 06 01 01 02 01 06 01 01   ......x.........
         4146  +|   3872: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         4147  +|   3888: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         4148  +|   3904: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         4149  +|   3920: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         4150  +|   3936: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         4151  +|   3952: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         4152  +|   3968: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         4153  +|   3984: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         4154  +|   4000: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         4155  +|   4016: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         4156  +|   4032: 02 01 06 01 01 02 01 06 01 01 02 04 15 13 0c 0c   ................
         4157  +|   4048: 12 44 13 11 0f 47 13 0e fc 0e 11 10 0f 0e 10 0f   .D...G..........
         4158  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 5a 24 24 0f   D..@.......$Z$$.
         4159  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         4160  +| page 4 offset 12288
         4161  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         4162  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         4163  +| page 5 offset 16384
         4164  +|      0: 0d 00 00 00 24 0c 0a 00 0f d8 0f af 0f 86 0f 74   ....$..........t
         4165  +|     16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5   .a.N./..........
         4166  +|     32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 01 2f 0d d5   ...t.[.@.$.../..
         4167  +|     48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb   .......h.O.5....
         4168  +|     64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a   .......x.W.>.$..
         4169  +|   3072: 00 00 00 00 00 00 00 00 00 00 18 24 05 00 25 0f   ...........$..%.
         4170  +|   3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49   .THREADSAFE=0XBI
         4171  +|   3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41   NARY.#..%..THREA
         4172  +|   3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 8f   DSAFE=0XNOCASE..
         4173  +|   3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d   ..%..THREADSAFE=
         4174  +|   3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d   0XRTRIM.!..3..OM
         4175  +|   3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f   IT LOAD EXTENSIO
         4176  +|   3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f   NXBINARY. ..3..O
         4177  +|   3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49   MIT LOAD EXTENSI
         4178  +|   3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17   ONXNOCASE....3..
         4179  +|   3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53   OMIT LOAD EXTENS
         4180  +|   3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19   IONXRTRIM....3..
         4181  +|   3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30   MAX MEMORY=50000
         4182  +|   3280: 30 30 30 57 42 49 4e 41 52 59 1f 1d 05 00 33 0f   000WBINARY....3.
         4183  +|   3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30   .MAX MEMORY=5000
         4184  +|   3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33   0000XNOCASE....3
         4185  +|   3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30   ..MAX MEMORY=500
         4186  +|   3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25   00000XRTRIM....%
         4187  +|   3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42   ..ENABLE RTREEXB
         4188  +|   3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         4189  +|   3392: 4c 45 20 52 54 52 45 45 59 4e 4f 43 41 53 45 17   LE RTREEYNOCASE.
         4190  +|   3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52   ...%..ENABLE RTR
         4191  +|   3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45   EEXRTRIM....)..E
         4192  +|   3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49   NABLE MEMSYS5XBI
         4193  +|   3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         4194  +|   3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45   E MEMSYS5XNOCASE
         4195  +|   3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45   ....)..ENABLE ME
         4196  +|   3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25   MSYS5XRTRIM....%
         4197  +|   3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42   ..ENABLE JSON1XB
         4198  +|   3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         4199  +|   3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17   LE JSON1XNOCASE.
         4200  +|   3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f   ...%..ENABLE JSO
         4201  +|   3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45   N1XRTRIM....)..E
         4202  +|   3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49   NABLE GEOPOLYXBI
         4203  +|   3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4f 41 42 4c   NARY....)..EOABL
         4204  +|   3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 51 53 45   E GEOPOLYXNOCQSE
         4205  +|   3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45   ....)..ENABLE GE
         4206  +|   3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23   OPOLYXRTRIM....#
         4207  +|   3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49   ..ENABLE FTS5XBI
         4208  +|   3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c   NARY....#..ENABL
         4209  +|   3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 1d 05   E FTS5XNOCASE...
         4210  +|   3728: 00 23 0f a4 45 4e 41 42 4c 45 20 46 54 53 35 58   .#..ENABLE FTS5X
         4211  +|   3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42   RTRIM....#..ENAB
         4212  +|   3760: 4c 45 20 46 55 53 34 58 42 49 4e 41 52 59 17 0b   LE FUS4XBINARY..
         4213  +|   3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34   ..#..ENABLE FTS4
         4214  +|   3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e   XNOCASE....#..EN
         4215  +|   3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e   ABLE FTS4XRTRIM.
         4216  +|   3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         4217  +|   3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e   TAT VTABXBINARY.
         4218  +|   3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         4219  +|   3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d   TAT VTABXNOCASE.
         4220  +|   3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         4221  +|   3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06   TAT VTABXRTRIM..
         4222  +|   3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52   .....DEBUGXBINAR
         4223  +|   3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f   Y.......DEBUGXNO
         4224  +|   3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47   CASE.......DEBUG
         4225  +|   3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d   XRTRIM'...C..COM
         4226  +|   3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20   PILER=gcc-5.4.0 
         4227  +|   4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27   20160609XBINARY'
         4228  +|   4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67   ...C..COMPILER=g
         4229  +|   4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30   cc-5.4.0 2016060
         4230  +|   4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43   9XNOCASE&...C..C
         4231  +|   4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e   OMPILER=gcc-5.4.
         4232  +|   4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d   0 20160609XRTRIM
         4233  +| page 6 offset 20480
         4234  +|      0: 0d 00 00 00 24 0e e0 00 0f f8 0f f0 0f e8 0f e0   ....$...........
         4235  +|     16: 0f d8 0f d0 0f c8 0f c0 0f b8 0f b0 0f a8 0f a0   ................
         4236  +|     32: 0f 98 0f 90 0f 88 0f 80 0f 78 0f 70 0f 68 0f 60   .........x.p.h.`
         4237  +|     48: 0f 58 0f 50 0f 48 0f 40 0f 38 0f 30 0f 28 0f 20   .X.P.H.@.8.0.(. 
         4238  +|     64: 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0 0e e8 0e e0   ................
         4239  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         4240  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         4241  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         4242  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         4243  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         4244  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         4245  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         4246  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         4247  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         4248  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         4249  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         4250  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         4251  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         4252  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         4253  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         4254  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         4255  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 06 01 01   ................
         4256  +|   4080: 06 02 03 00 12 06 01 01 06 01 03 00 12 06 01 01   ................
         4257  +| page 7 offset 24576
         4258  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         4259  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         4260  +| page 8 offset 28672
         4261  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e9 0f d6 00 00   ................
         4262  +|   4048: 00 00 00 00 00 00 11 03 02 2b 69 6e 74 65 67 72   .........+integr
         4263  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
         4264  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   uild....optimize
         4265  +| end crash-ae135cb10977c7.db
         4266  +}]} {}
         4267  +
         4268  +do_catchsql_test 35.1 {
         4269  +  SELECT * FROM t1 WHERE t1 MATCH 'e*';
         4270  +} {1 {database disk image is malformed}}
         4271  +
         4272  +#-------------------------------------------------------------------------
         4273  +reset_db
         4274  +do_test 36.0 {
         4275  +  sqlite3 db {}
         4276  +  db deserialize [decode_hexdb {
         4277  +| size 24576 pagesize 4096 filename crash-a6651222df1bd1.db
         4278  +| page 1 offset 0
         4279  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         4280  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06   .....@  ........
         4281  +|     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
         4282  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         4283  +|     96: 00 00 00 00 0d 00 00 00 06 0e 0f 00 0f aa 0f 53   ...............S
         4284  +|    112: 0e e8 0e 8b 0e 33 0e 0f 00 00 00 00 00 00 00 00   .....3..........
         4285  +|   3584: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22   ................
         4286  +|   3600: 06 06 17 11 11 01 31 74 61 62 6c 65 62 62 62 62   ......1tablebbbb
         4287  +|   3616: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 62 62   .CREATE TABLE bb
         4288  +|   3632: 28 61 29 56 05 06 17 1f 1f 01 7d 74 61 62 6c 65   (a)V.......table
         4289  +|   3648: 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63 6f 6e 66   t1_configt1_conf
         4290  +|   3664: 69 67 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   ig.CREATE TABLE 
         4291  +|   3680: 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b 20 50 52   't1_config'(k PR
         4292  +|   3696: 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 57 49   IMARY KEY, v) WI
         4293  +|   3712: 54 48 4f 55 54 20 52 4f 57 49 44 5b 04 07 17 21   THOUT ROWID[...!
         4294  +|   3728: 21 01 81 01 74 61 62 6c 65 74 31 5f 64 6f 63 73   !...tablet1_docs
         4295  +|   3744: 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65 04 43 52   izet1_docsize.CR
         4296  +|   3760: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 64   EATE TABLE 't1_d
         4297  +|   3776: 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 54 45 47   ocsize'(id INTEG
         4298  +|   3792: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         4299  +|   3808: 73 7a 20 42 4c 4f 42 29 69 03 07 17 19 19 01 81   sz BLOB)i.......
         4300  +|   3824: 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 5f 69   -tablet1_idxt1_i
         4301  +|   3840: 64 78 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   dx.CREATE TABLE 
         4302  +|   3856: 27 74 31 5f 69 64 78 27 28 73 65 67 69 64 2c 20   't1_idx'(segid, 
         4303  +|   3872: 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50 52 49 4d   term, pgno, PRIM
         4304  +|   3888: 41 52 59 20 4b 45 59 28 73 65 67 69 64 2c 20 74   ARY KEY(segid, t
         4305  +|   3904: 65 72 6d 29 29 20 57 49 54 48 4f 55 54 20 52 4f   erm)) WITHOUT RO
         4306  +|   3920: 57 49 44 55 02 07 17 1b 1b 01 81 01 74 61 62 6c   WIDU........tabl
         4307  +|   3936: 65 74 31 5f 64 61 74 61 74 31 5f 64 61 74 61 02   et1_datat1_data.
         4308  +|   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31   CREATE TABLE 't1
         4309  +|   3968: 5f 64 61 74 61 27 28 69 64 20 49 4e 54 45 47 45   _data'(id INTEGE
         4310  +|   3984: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62   R PRIMARY KEY, b
         4311  +|   4000: 6c 6f 63 6b 20 42 4c 4f 42 29 54 01 07 17 11 11   lock BLOB)T.....
         4312  +|   4016: 08 81 15 74 61 62 6c 65 74 31 74 31 43 52 45 41   ...tablet1t1CREA
         4313  +|   4032: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45   TE VIRTUAL TABLE
         4314  +|   4048: 20 74 31 20 55 53 49 4e 47 20 66 74 73 35 28 61    t1 USING fts5(a
         4315  +|   4064: 2c 62 2c 70 72 65 66 69 78 3d 22 31 2c 32 2c 33   ,b,prefix=.1,2,3
         4316  +|   4080: 2c 34 22 2c 20 63 6f 6e 74 65 6e 74 3d 22 22 29   ,4., content=..)
         4317  +| page 2 offset 4096
         4318  +|      0: 0d 0b 6a 00 37 09 4c 02 0f e7 09 4c 0f c6 0f a4   ..j.7.L....L....
         4319  +|     16: 0f 88 0f 6d 0f 4b 0f 2c 0f 0e 0e ec 0e cd 0e ad   ...m.K.,........
         4320  +|     32: 0e 8e 0e 6c 0e 4b 0e 29 0e 08 0d e6 0d c4 0d b5   ...l.K.)........
         4321  +|     48: 0d 97 0d 76 0d 54 0d 31 0d 15 0c f3 0c d3 0c b5   ...v.T.1........
         4322  +|     64: 0c 95 0c 73 0c 54 0c 32 0c 10 0b ee 0b cc 0b b0   ...s.T.2........
         4323  +|     80: 0b 8d 0b 7e 0b 48 0b 2e 0b 0b 0a ef 0a cc 0a ad   ...~.H..........
         4324  +|     96: 0a 8c 0a 6d 0a 4d 0a 2b 0a 0c 09 ec 09 ca 09 a8   ...m.M.+........
         4325  +|    112: 09 86 09 63 0f f1 00 00 00 00 00 00 00 00 00 00   ...c............
         4326  +|   2368: 00 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00   ................
         4327  +|   2384: 30 00 00 00 01 01 03 35 00 03 01 11 12 02 01 12   0......5........
         4328  +|   2400: 03 01 11 1c 8c 80 80 80 80 10 03 00 3e 00 00 00   ............>...
         4329  +|   2416: 17 01 05 05 34 74 61 62 6c 03 02 03 01 04 77 68   ....4tabl.....wh
         4330  +|   2432: 65 72 03 02 06 09 1b 8c 80 80 80 80 0f 03 00 3c   er.............<
         4331  +|   2448: 00 00 00 16 05 34 66 74 73 34 03 02 02 01 04 6e   .....4fts4.....n
         4332  +|   2464: 75 6d 62 03 06 01 04 09 1b 8c 80 80 80 80 0e 03   umb.............
         4333  +|   2480: 00 3c 00 00 00 16 04 33 74 68 65 03 06 01 01 04   .<.....3the.....
         4334  +|   2496: 01 03 77 68 65 03 02 04 04 0a 1b 8c 80 80 80 80   ..whe...........
         4335  +|   2512: 0d 03 00 3c 00 00 00 16 04 33 6e 75 6d 03 06 01   ...<.....3num...
         4336  +|   2528: 01 05 01 03 74 61 62 03 02 03 04 0a 19 8c 80 80   ....tab.........
         4337  +|   2544: 80 80 0c 03 00 38 00 00 00 14 03 32 77 68 03 02   .....8.....2wh..
         4338  +|   2560: 04 00 04 33 66 74 73 03 02 02 04 07 18 8c 80 80   ...3fts.........
         4339  +|   2576: 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 03 02   .....6.....2ta..
         4340  +|   2592: 03 02 01 68 03 06 01 01 04 04 07 1b 8c 80 80 80   ...h............
         4341  +|   2608: 80 0a 03 00 3c 00 00 00 16 03 32 6e 75 03 06 01   ....<.....2nu...
         4342  +|   2624: 01 05 01 02 6f 66 03 06 01 01 06 04 09 19 8c 80   ....of..........
         4343  +|   2640: 80 80 80 09 03 00 38 00 00 00 14 03 32 66 74 03   ......8.....2ft.
         4344  +|   2656: 02 02 01 02 69 73 03 06 01 01 03 04 07 18 8c 80   ....is..........
         4345  +|   2672: 80 80 80 08 03 00 36 00 00 00 13 02 31 74 03 08   ......6.....1t..
         4346  +|   2688: 03 01 01 04 01 01 77 03 02 04 04 09 1a 8c 80 80   ......w.........
         4347  +|   2704: 80 80 07 03 00 3a 00 00 00 15 02 31 6e 03 08 01   .....:.....1n...
         4348  +|   2720: 01 02 05 01 00 6f 03 06 01 01 06 04 09 18 8c 80   .....o..........
         4349  +|   2736: 80 80 80 06 03 00 36 00 00 00 13 04 02 31 66 03   ......6......1f.
         4350  +|   2752: 02 02 01 01 69 03 06 01 01 03 05 06 1c 8c 80 80   ....i...........
         4351  +|   2768: 80 80 05 03 00 3e 00 00 00 17 04 30 74 68 65 03   .....>.....0the.
         4352  +|   2784: 06 01 01 04 01 05 77 68 65 72 65 03 02 04 0a 15   ......where.....
         4353  +|   2800: 8c 80 80 80 80 04 03 00 30 00 00 00 11 01 01 06   ........0.......
         4354  +|   2816: 06 30 74 61 62 6c 65 03 02 03 07 1c 8c 80 80 80   .0table.........
         4355  +|   2832: 80 03 03 00 3e 00 00 00 17 07 30 6e 75 6d 62 65   ....>.....0numbe
         4356  +|   2848: 72 03 06 01 01 05 01 02 6f 66 03 06 04 0d 13 8c   r.......of......
         4357  +|   2864: 80 80 80 80 02 03 00 2c 00 00 00 0f 01 01 03 02   .......,........
         4358  +|   2880: 30 6e 03 06 01 01 02 07 1b 8c 80 80 80 80 01 03   0n..............
         4359  +|   2896: 00 3c 00 00 00 16 08 30 66 74 73 34 61 75 78 03   .<.....0fts4aux.
         4360  +|   2912: 02 02 01 02 69 73 03 06 04 0c 00 00 00 14 2a 00   ....is........*.
         4361  +|   2928: 00 00 01 01 02 24 00 02 01 01 12 02 01 12 08 88   .....$..........
         4362  +|   2944: 80 80 80 80 12 03 00 16 00 00 00 05 02 1c 88 80   ................
         4363  +|   2960: 80 80 80 11 03 00 3e 00 00 00 17 05 34 72 6f 77   ......>.....4row
         4364  +|   2976: 73 02 06 01 01 05 01 04 74 68 65 72 02 02 04 0b   s.......ther....
         4365  +|   2992: 15 88 80 80 80 80 10 03 00 30 00 00 00 11 02 01   .........0......
         4366  +|   3008: 01 07 05 34 62 65 74 77 02 02 04 08 1b 88 80 80   ...4betw........
         4367  +|   3024: 80 80 0f 03 00 3c 00 00 00 16 04 04 33 72 6f 77   .....<......3row
         4368  +|   3040: 02 06 01 01 05 01 03 74 68 65 02 08 05 0a 1b 88   .......the......
         4369  +|   3056: 80 80 80 80 0e 03 00 3c 00 00 00 16 01 01 02 04   .......<........
         4370  +|   3072: 33 61 72 65 02 02 03 01 03 62 65 74 02 02 07 08   3are.....bet....
         4371  +|   3088: 1b 88 80 80 80 80 0d 03 00 3c 00 00 00 16 13 32   .........<.....2
         4372  +|   3104: 74 68 02 08 02 01 01 07 00 04 33 61 6e 64 02 06   th........3and..
         4373  +|   3120: 04 0a 1b 88 80 80 80 80 0c 03 00 3c 00 00 00 16   ...........<....
         4374  +|   3136: 03 32 69 6e 02 06 01 01 06 01 02 72 6f 02 06 01   .2in.......ro...
         4375  +|   3152: 01 05 04 09 18 88 80 80 80 80 0b 03 00 36 00 00   .............6..
         4376  +|   3168: 00 13 02 03 32 61 72 02 02 03 01 02 62 65 02 02   ....2ar.....be..
         4377  +|   3184: 04 05 07 1b 88 80 80 80 80 0a 03 00 3c 00 00 00   ............<...
         4378  +|   3200: 16 02 31 74 02 08 02 01 01 07 00 03 32 61 6e 02   ..1t........2an.
         4379  +|   3216: 06 01 01 04 09 19 88 80 80 80 80 09 03 00 38 00   ..............8.
         4380  +|   3232: 00 00 14 02 31 6e 02 06 01 01 03 01 01 72 02 06   ....1n.......r..
         4381  +|   3248: 01 01 05 04 08 17 88 80 80 80 80 08 03 00 34 00   ..............4.
         4382  +|   3264: 00 00 12 02 31 62 02 02 04 01 01 69 02 06 01 01   ....1b.....i....
         4383  +|   3280: 06 04 06 19 88 80 80 80 80 07 03 00 38 00 00 00   ............8...
         4384  +|   3296: 14 04 02 31 32 02 02 05 01 01 61 02 08 03 01 01   ...12.....a.....
         4385  +|   3312: 02 05 06 1b 88 80 80 80 80 06 03 00 3c 00 00 00   ............<...
         4386  +|   3328: 16 06 30 74 68 65 72 65 02 02 02 00 02 31 31 02   ..0there.....11.
         4387  +|   3344: 06 01 01 04 0a 15 88 80 80 80 80 05 03 00 30 00   ..............0.
         4388  +|   3360: 00 00 11 01 01 05 04 30 74 68 65 02 06 01 01 07   .......0the.....
         4389  +|   3376: 07 1c 88 80 80 80 80 04 03 00 3e 00 00 00 17 01   ..........>.....
         4390  +|   3392: 01 06 02 30 6e 02 06 01 01 03 01 04 72 6f 77 73   ...0n.......rows
         4391  +|   3408: 02 06 07 08 1b 88 80 80 80 80 03 03 00 3c 00 00   .............<..
         4392  +|   3424: 00 16 08 30 62 65 74 77 65 65 6e 02 02 04 01 02   ...0between.....
         4393  +|   3440: 69 6e 02 06 04 0c 1a 88 80 80 80 80 02 03 00 3a   in.............:
         4394  +|   3456: 00 00 00 15 04 30 61 6e 64 02 06 01 01 02 02 02   .....0and.......
         4395  +|   3472: 72 65 02 02 03 04 0a 17 88 80 80 80 80 01 03 00   re..............
         4396  +|   3488: 34 00 00 00 12 02 30 31 02 06 01 01 04 01 01 32   4.....01.......2
         4397  +|   3504: 02 02 05 04 08 08 84 80 80 80 80 12 03 00 16 00   ................
         4398  +|   3520: 00 00 05 04 1b 84 80 80 80 80 11 03 00 3c 00 00   .............<..
         4399  +|   3536: 00 16 05 34 74 61 62 6c 01 06 01 01 05 02 03 65   ...4tabl.......e
         4400  +|   3552: 72 6d 01 02 04 0b 1b 84 80 80 80 80 10 03 00 3c   rm.............<
         4401  +|   3568: 00 00 00 16 05 34 65 61 63 68 01 02 03 01 04 70   .....4each.....p
         4402  +|   3584: 72 65 73 01 02 05 04 09 1a 84 80 80 80 80 0f 03   res.............
         4403  +|   3600: 00 3a 00 00 00 15 04 33 74 65 72 01 02 04 02 02   .:.....3ter.....
         4404  +|   3616: 68 65 01 06 01 01 03 04 08 1b 84 80 80 80 80 0e   he..............
         4405  +|   3632: 03 00 3c 00 00 00 16 04 33 70 72 65 01 02 05 01   ..<.....3pre....
         4406  +|   3648: 03 74 61 62 01 06 01 01 05 04 08 1a 84 80 80 80   .tab............
         4407  +|   3664: 80 0d 03 00 3a 00 00 00 15 04 33 66 6f 72 01 02   ....:.....3for..
         4408  +|   3680: 02 02 02 74 73 01 06 01 01 04 04 08 1b 84 80 80   ...ts...........
         4409  +|   3696: 80 80 0c 03 00 3c 00 00 00 16 03 32 74 68 01 06   .....<.....2th..
         4410  +|   3712: 01 01 03 00 04 33 65 61 63 01 02 03 04 09 18 84   .....3eac.......
         4411  +|   3728: 80 80 80 80 0b 03 00 36 00 00 00 13 03 32 74 61   .......6.....2ta
         4412  +|   3744: 01 06 01 01 05 02 01 65 01 02 04 04 09 19 84 80   .......e........
         4413  +|   3760: 80 80 80 0a 03 00 38 00 00 00 14 03 32 69 6e 01   ......8.....2in.
         4414  +|   3776: 06 01 01 02 01 02 70 72 01 02 05 04 09 18 84 80   ......pr........
         4415  +|   3792: 80 80 80 09 03 00 36 00 00 00 13 03 32 66 6f 01   ......6.....2fo.
         4416  +|   3808: 02 02 02 01 74 01 06 01 01 04 04 07 1b 84 80 80   ....t...........
         4417  +|   3824: 80 80 08 03 00 3c 00 00 00 16 02 31 74 01 0a 04   .....<.....1t...
         4418  +|   3840: 01 01 03 04 00 03 32 65 61 01 02 03 04 0a 17 84   ......2ea.......
         4419  +|   3856: 80 80 80 80 07 03 00 34 00 00 00 12 02 31 69 01   .......4.....1i.
         4420  +|   3872: 06 01 01 02 01 01 70 01 02 05 04 08 18 84 80 80   ......p.........
         4421  +|   3888: 80 80 06 03 00 36 00 00 00 13 02 31 65 01 02 03   .....6.....1e...
         4422  +|   3904: 01 01 66 01 08 02 01 01 04 04 06 1b 84 80 80 80   ..f.............
         4423  +|   3920: 80 05 03 00 3c 00 00 00 16 05 30 74 65 72 6d 01   ....<.....0term.
         4424  +|   3936: 02 04 02 02 68 65 01 06 01 01 03 04 09 14 84 80   ....he..........
         4425  +|   3952: 80 80 80 04 03 00 2e 00 00 00 10 06 30 64 61 62   ............0dab
         4426  +|   3968: 6c 65 01 06 01 01 05 04 15 84 80 80 80 80 03 03   le..............
         4427  +|   3984: 00 30 00 00 00 11 02 08 30 70 72 65 73 65 6e 74   .0......0present
         4428  +|   4000: 01 02 05 05 1b 84 80 80 80 80 02 03 00 3c 00 00   .............<..
         4429  +|   4016: 00 16 04 30 66 74 73 01 06 01 01 04 01 02 69 6e   ...0fts.......in
         4430  +|   4032: 01 06 01 01 04 0a 1a 84 80 80 80 80 01 03 00 3a   ...............:
         4431  +|   4048: 00 00 00 15 05 30 65 61 63 68 01 02 03 01 03 66   .....0each.....f
         4432  +|   4064: 6f 72 01 02 02 04 09 06 01 03 00 12 03 0b 0f 00   or..............
         4433  +|   4080: 00 08 8c 80 80 80 80 11 03 00 16 00 00 00 05 04   ................
         4434  +| page 3 offset 8192
         4435  +|      0: 0a 00 00 00 32 0e 4f 00 0f fa 0f f1 0f e9 0f e1   ....2.O.........
         4436  +|     16: 0f d8 0f d1 0f c9 0f c1 0f b9 0f b1 0f a9 0f a0   ................
         4437  +|     32: 0f 98 0f 90 0f 87 0f 80 0f 78 0f 71 0f 68 0f 5f   .........x.q.h._
         4438  +|     48: 0f 56 0f 4d 0f 41 0f 38 0f 2f 0f 26 0f 1d 0f 13   .V.M.A.8./.&....
         4439  +|     64: 0f 0a 0f 01 0e f7 0e ee 0e e6 0e dd 0e d6 0e cd   ................
         4440  +|     80: 0e c3 0e ba 0e b0 0e a8 0e 9f 0e 96 0e 8e 0e 85   ................
         4441  +|     96: 0e 7c 0e 73 0e 6a 0e 60 0e 58 0e 4f 00 00 00 00   .|.s.j.`.X.O....
         4442  +|   3648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08   ................
         4443  +|   3664: 04 01 10 01 03 34 74 20 07 04 01 0e 01 03 34 1e   .....4t ......4.
         4444  +|   3680: 09 04 01 12 01 03 33 74 68 1c 08 04 01 10 01 03   ......3th.......
         4445  +|   3696: 33 6e 1a 08 04 01 10 01 03 32 77 18 08 04 01 10   3n.......2w.....
         4446  +|   3712: 01 03 32 74 16 08 04 01 10 01 03 32 6e 14 07 04   ..2t.......2n...
         4447  +|   3728: 01 0e 01 03 32 12 08 04 01 10 01 03 31 74 10 08   ....2.......1t..
         4448  +|   3744: 04 01 10 01 03 31 6e 0e 07 04 01 0e 01 03 31 0c   .....1n.......1.
         4449  +|   3760: 09 04 01 12 01 03 30 74 68 0a 08 04 01 10 01 03   ......0th.......
         4450  +|   3776: 30 74 08 09 04 01 12 01 03 30 6e 75 06 08 04 01   0t.......0nu....
         4451  +|   3792: 10 01 03 30 6e 04 06 04 01 0c 01 03 02 08 04 01   ...0n...........
         4452  +|   3808: 10 01 02 34 72 22 07 04 01 0e 01 02 34 20 08 04   ...4r.......4 ..
         4453  +|   3824: 01 10 01 02 33 72 1e 09 04 01 12 01 02 33 61 72   ....3r.......3ar
         4454  +|   3840: 1c 08 04 01 10 01 02 32 74 1a 08 04 01 10 01 02   .......2t.......
         4455  +|   3856: 32 69 18 09 04 01 12 01 02 32 61 72 16 08 04 01   2i.......2ar....
         4456  +|   3872: 10 01 02 31 74 14 08 04 01 10 01 02 31 6e 12 08   ...1t.......1n..
         4457  +|   3888: 04 01 10 01 02 31 62 10 08 04 01 10 01 02 31 32   .....1b.......12
         4458  +|   3904: 0e 0b 04 01 16 01 02 30 74 68 65 72 0c 08 04 01   .......0ther....
         4459  +|   3920: 10 01 02 30 74 0a 08 04 01 10 01 02 30 6e 08 08   ...0t.......0n..
         4460  +|   3936: 14 01 10 01 02 30 62 06 08 04 01 10 01 02 30 61   .....0b.......0a
         4461  +|   3952: 04 06 04 01 0c 01 02 02 07 04 09 10 01 34 74 22   .............4t.
         4462  +|   3968: 06 04 09 0e 01 34 20 08 04 09 12 01 33 74 65 1e   .....4 .....3te.
         4463  +|   3984: 07 04 09 10 01 33 70 1c 07 04 09 10 01 33 66 1a   .....3p......3f.
         4464  +|   4000: 08 04 09 12 01 32 74 68 18 07 04 09 10 01 32 74   .....2th......2t
         4465  +|   4016: 16 07 04 09 10 01 32 69 14 07 04 09 10 01 32 66   ......2i......2f
         4466  +|   4032: 12 07 04 09 10 01 31 74 10 07 04 09 10 01 31 69   ......1t......1i
         4467  +|   4048: 0e 06 04 09 0e 01 31 0c 08 04 09 12 01 30 74 65   ......1......0te
         4468  +|   4064: 0a 07 04 09 10 01 30 74 08 07 04 09 10 01 30 70   ......0t......0p
         4469  +|   4080: 06 08 04 09 12 01 30 66 74 04 05 04 09 0c 01 02   ......0ft.......
         4470  +| page 4 offset 12288
         4471  +|      0: 0d 00 00 00 03 0f eb 00 0f f9 0f f2 0f eb 00 00   ................
         4472  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10   ................
         4473  +|   4080: 03 05 05 02 03 00 10 04 06 05 01 03 00 10 04 04   ................
         4474  +| page 5 offset 16384
         4475  +|      0: 0a 00 00 00 02 0f eb 00 0f eb 0f f4 00 00 00 00   ................
         4476  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 08 03 15 01 70   ...............p
         4477  +|   4080: 67 73 7a 18 0b 03 1b 01 76 65 72 73 69 6f 6e 04   gsz.....version.
         4478  +| page 6 offset 20480
         4479  +|      0: 0d 00 00 00 03 0f f2 00 0f fc 0f f7 0f f2 00 00   ................
         4480  +|   4080: 00 00 03 03 02 01 03 03 02 02 01 02 02 01 0c e9   ................
         4481  +| end crash-a6651222df1bd1.db
         4482  +}]} {}
         4483  +
         4484  +do_catchsql_test 36.1 {
         4485  +  INSERT INTO t1(b) VALUES(
         4486  +      x'78de3fa24af3733ca8769291a0fee3669f9fddefc5cba913e4225d4b6ce2b04f26b87fad3ee6f9b7d90a1ea62a169bf41e5d32707a6ca5c3d05e4bde05c9d89eaaa8c50e74333d2e9fcd7dfe95528a3a016aac1102d825c5cd70cf99d8a88e0ea7f798d4334386518b7ad359beb168b93aba059a2a3bd93112d65b44c12b9904ea786b204d80531cdf0504bf9b203dbe927061974caf7b9f30cbc3397b61f802e732012a6663d41c3607d6f1c0dbcfd489adac05ca500c0b04439d894cd93a840159225ef73b627e178b9f84b3ffe66cf22a963a8368813ff7961fc47f573211ccec95e0220dcbb3bf429f4a50ba54d7a53784ac51bfef346e6a');
         4487  +} {1 {database disk image is malformed}}
         4488  +
         4489  +#-------------------------------------------------------------------------
         4490  +reset_db
         4491  +do_test 37.0 {
         4492  +  sqlite3 db {}
         4493  +  db deserialize [decode_hexdb {
         4494  +| size 40960 pagesize 4096 filename null-memcmp-param-1..db
         4495  +| page 1 offset 0
         4496  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         4497  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a   .....@  ........
         4498  +|     32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04   ................
         4499  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         4500  +|     96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c   ..........n....L
         4501  +|    112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50   .....$...r.....P
         4502  +|    128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00   .....n..........
         4503  +|   2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d   ..............C.
         4504  +|   2928: 06 17 11 11 08 75 74 61 62 6c 66 74 34 74 34 43   .....utablft4t4C
         4505  +|   2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
         4506  +|   2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73   BLE t4 USING fts
         4507  +|   2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f   5vocab('t2', 'ro
         4508  +|   2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65   w')C......utable
         4509  +|   3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55   t3t3CREATE VIRTU
         4510  +|   3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e   AL TABLE t3 USIN
         4511  +|   3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27   G fts5vocab('t1'
         4512  +|   3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d   , 'row')V.......
         4513  +|   3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32   tablet2_configt2
         4514  +|   3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54   _config.CREATE T
         4515  +|   3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27   ABLE 't2_config'
         4516  +|   3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   (k PRIMARY KEY, 
         4517  +|   3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   v) WITHOUT ROWID
         4518  +|   3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32   ^...!!...tablet2
         4519  +|   3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65   _contentt2_conte
         4520  +|   3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20   nt.CREATE TABLE 
         4521  +|   3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   't2_content'(id 
         4522  +|   3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         4523  +|   3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29   KEY, c0, c1, c2)
         4524  +|   3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32   i.......-tablet2
         4525  +|   3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54   _idxt2_idx.CREAT
         4526  +|   3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27   E TABLE 't2_idx'
         4527  +|   3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67   (segid, term, pg
         4528  +|   3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28   no, PRIMARY KEY(
         4529  +|   3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49   segid, term)) WI
         4530  +|   3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b   THOUT ROWIDU....
         4531  +|   3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61   ....tablet2_data
         4532  +|   3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54   t2_data.CREATE T
         4533  +|   3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69   ABLE 't2_data'(i
         4534  +|   3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52   d INTEGER PRIMAR
         4535  +|   3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f   Y KEY, block BLO
         4536  +|   3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65   B)X........table
         4537  +|   3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55   t2t2CREATE VIRTU
         4538  +|   3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e   AL TABLE t2 USIN
         4539  +|   3488: 47 20 64 44 73 35 28 27 61 27 2c 5b 62 5d 2c 22   G dDs5('a',[b],.
         4540  +|   3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63   c.,detail=none,c
         4541  +|   3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17   olumnsize=0)V...
         4542  +|   3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66   ....tablet1_conf
         4543  +|   3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41   igt1_config.CREA
         4544  +|   3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
         4545  +|   3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b   fig'(k PRIMARY K
         4546  +|   3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52   EY, v) WITHOUT R
         4547  +|   3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62   OWID[...!!...tab
         4548  +|   3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64   let1_docsizet1_d
         4549  +|   3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41   ocsize.CREATE TA
         4550  +|   3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27   BLE 't1_docsize'
         4551  +|   3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         4552  +|   3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42   ARY KEY, sz BLOB
         4553  +|   3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74   )^...!!...tablet
         4554  +|   3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74   1_contentt1_cont
         4555  +|   3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45   ent.CREATE TABLE
         4556  +|   3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64    't1_content'(id
         4557  +|   3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
         4558  +|   3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32    KEY, c0, c1, c2
         4559  +|   3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74   )i.......-tablet
         4560  +|   3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41   1_idxt1_idx.CREA
         4561  +|   3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78   TE TABLE 't1_idx
         4562  +|   3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70   '(segid, term, p
         4563  +|   3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59   gno, PRIMARY KEY
         4564  +|   3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57   (segid, term)) W
         4565  +|   3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17   ITHOUT ROWIDU...
         4566  +|   3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74   .....tablet1_dat
         4567  +|   3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20   at1_data.CREATE 
         4568  +|   3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28   TABLE 't1_data'(
         4569  +|   3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         4570  +|   3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c   RY KEY, block BL
         4571  +|   4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c   OB)[.......#tabl
         4572  +|   4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         4573  +|   4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         4574  +|   4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e   NG fts5(a,b unin
         4575  +|   4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65   dexed,c,tokenize
         4576  +|   4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29   =.porter ascii.)
         4577  +| page 2 offset 4096
         4578  +|      0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c   ..h............|
         4579  +|     16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .*..............
         4580  +|   3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00   .......0........
         4581  +|   3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80   ..........7.....
         4582  +|   3888: 01 03 00 74 00 00 00 2e 02 30 61 03 02 02 01 01   ...t.....0a.....
         4583  +|   3904: 62 03 02 03 01 01 63 03 02 04 01 01 67 03 06 01   b.....c.....g...
         4584  +|   3920: 02 02 01 01 68 03 06 01 02 03 01 01 69 03 06 01   ....h.......i...
         4585  +|   3936: 02 04 04 06 06 06 08 08 0f ef 00 14 2a 00 00 00   ............*...
         4586  +|   3952: 00 01 02 02 00 02 01 01 01 02 01 01 25 88 80 80   ............%...
         4587  +|   3968: 80 80 01 03 00 50 00 00 00 1f 01 30 67 02 08 02   .....P.....0g...
         4588  +|   3984: 01 02 02 01 01 68 02 08 03 01 02 03 01 01 69 02   .....h........i.
         4589  +|   4000: 08 04 01 02 04 04 09 09 37 84 80 80 80 80 01 03   ........7.......
         4590  +|   4016: 00 74 00 00 00 2e 02 30 61 01 5a 02 01 01 62 01   .t.....0a.Z...b.
         4591  +|   4032: 02 03 01 01 63 01 02 04 01 01 67 01 06 01 02 02   ....c.....g.....
         4592  +|   4048: 01 01 68 01 06 01 02 03 01 01 69 01 06 01 02 04   ..h.......i.....
         4593  +|   4064: 04 06 06 06 08 08 07 01 03 00 14 03 09 00 09 00   ................
         4594  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         4595  +| page 3 offset 8192
         4596  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         4597  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         4598  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         4599  +| page 4 offset 12288
         4600  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         4601  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         4602  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         4603  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         4604  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         4605  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         4606  +| page 5 offset 16384
         4607  +|      0: 0d 00 00 00 03 0f e8 00 0f f8 0f f0 0f e8 00 00   ................
         4608  +|   4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 03   ................
         4609  +|   4080: 06 02 03 00 12 03 00 03 06 01 03 00 12 03 00 03   ................
         4610  +| page 6 offset 20480
         4611  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         4612  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         4613  +| page 7 offset 24576
         4614  +|      0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00   ................
         4615  +|   3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84   ..............A.
         4616  +|   4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61   ............4.0a
         4617  +|   4016: 01 01 01 01 01 62 01 01 01 01 01 63 01 01 01 01   .....b.....c....
         4618  +|   4032: 01 64 01 01 01 65 01 01 01 66 01 01 01 67 01 01   .d...e...f...g..
         4619  +|   4048: 01 01 01 68 01 01 01 01 01 69 01 01 01 04 06 06   ...h.....i......
         4620  +|   4064: 06 04 04 04 06 06 07 01 03 00 14 03 09 09 09 0f   ................
         4621  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         4622  +| page 8 offset 28672
         4623  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         4624  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         4625  +| page 9 offset 32768
         4626  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         4627  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         4628  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         4629  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         4630  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         4631  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 30 69   .a b cd e fg h0i
         4632  +| page 10 offset 36864
         4633  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         4634  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         4635  +| end null-memcmp-param-1..db
         4636  +}]} {}
         4637  +
         4638  +do_catchsql_test 37.1 {
         4639  +  SELECT * FROM t3;
         4640  +} {1 {database disk image is malformed}}
         4641  +
         4642  +#-------------------------------------------------------------------------
         4643  +reset_db 
         4644  +do_execsql_test 37.0 {
         4645  +  CREATE VIRTUAL TABLE t1 USING fts5(b, c);
         4646  +  INSERT INTO t1 VALUES('a', 'b');
         4647  +  SELECT quote(block) FROM t1_data WHERE rowid=10;
         4648  +} {X'000000000101010001010101'}
         4649  +
         4650  +do_execsql_test 37.1 {
         4651  +  UPDATE t1_data SET block = X'FFFFFFFF0101010001010101' WHERE rowid = 10;
         4652  +  SELECT rowid FROM t1('a');
         4653  +} {1}
         4654  +
         4655  +#-------------------------------------------------------------------------
         4656  +reset_db 
         4657  +do_execsql_test 38.0 {
         4658  +  CREATE VIRTUAL TABLE t1 USING fts5(b, c);
         4659  +  INSERT INTO t1 VALUES('a', 'b');
         4660  +  INSERT INTO t1 VALUES('a', 'b');
         4661  +  SELECT quote(block) FROM t1_data WHERE rowid=1;
         4662  +} {X'020202'}
         4663  +
         4664  +do_execsql_test 38.1 {
         4665  +  SELECT * FROM t1('a b') ORDER BY rank;
         4666  +} {a b a b}
         4667  +
         4668  +do_execsql_test 38.2 {
         4669  +  UPDATE t1_data SET block = X'000202' WHERE rowid=1;
         4670  +}
         4671  +breakpoint
         4672  +do_catchsql_test 38.3 {
         4673  +  SELECT * FROM t1('a b') ORDER BY rank;
         4674  +} {1 {database disk image is malformed}}
         4675  +
         4676  +db close
         4677  +sqlite3 db test.db
         4678  +do_catchsql_test 38.4 {
         4679  +  SELECT * FROM t1('a b') ORDER BY rank;
         4680  +} {1 {database disk image is malformed}}
         4681  +
         4682  +#-------------------------------------------------------------------------
         4683  +reset_db
         4684  +do_test 38.0 {
         4685  +  sqlite3 db {}
         4686  +  db deserialize [decode_hexdb {
         4687  +| size 32768 pagesize 4096 filename crash-fd2a1313e5b5e9.db
         4688  +| page 1 offset 0
         4689  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         4690  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08   .....@  ........
         4691  +|     32: 00 00 00 02 00 00 00 01 00 00 00 09 00 00 00 04   ................
         4692  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         4693  +|     96: 00 00 00 00 0d 0f c7 00 07 0d 92 00 0f 8d 0f 36   ...............6
         4694  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d 92 0d 92 00 00 00 00   ...k............
         4695  +|   3472: 00 00 22 08 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         4696  +|   3488: 32 74 32 08 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         4697  +|   3504: 20 74 32 28 78 29 56 07 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         4698  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         4699  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         4700  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         4701  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         4702  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         4703  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         4704  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         4705  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         4706  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         4707  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         4708  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         4709  +|   3696: 21 01 81 07 74 61 62 6c 65 b8 31 5f 63 6f 6e 74   !...table.1_cont
         4710  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         4711  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         4712  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         4713  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         4714  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         4715  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         4716  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         4717  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         4718  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         4719  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         4720  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         4721  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         4722  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         4723  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         4724  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         4725  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         4726  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         4727  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         4728  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         4729  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         4730  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         4731  +| page 3 offset 8192
         4732  +|      0: 0d 00 00 00 03 0c 94 00 0f e6 0f ef 0c 94 00 00   ................
         4733  +|   3216: 00 00 00 00 86 4a 84 80 80 80 80 01 04 00 8d 18   .....J..........
         4734  +|   3232: 00 00 03 2b 02 30 30 01 02 06 01 02 06 01 02 06   ...+.00.........
         4735  +|   3248: 1f 02 03 01 02 03 01 02 03 01 08 32 30 31 36 30   ...........20160
         4736  +|   3264: 36 30 39 01 02 07 01 02 07 01 02 07 01 01 34 01   609...........4.
         4737  +|   3280: 02 05 01 02 05 01 02 05 01 01 35 01 02 04 01 02   ..........5.....
         4738  +|   3296: 04 01 02 04 02 07 30 30 30 30 30 30 30 1c 02 04   ......0000000...
         4739  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         4740  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         4741  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         4742  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         4743  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 08 63 6f 6d 70   ............comp
         4744  +|   3392: 69 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64   iler...........d
         4745  +|   3408: 62 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04   bstat...........
         4746  +|   3424: 65 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65   ebug...........e
         4747  +|   3440: 6e 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02   nable...........
         4748  +|   3456: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         4749  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         4750  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         4751  +|   3504: 02 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02   ......xtension..
         4752  +|   3520: 04 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03   .........fts4...
         4753  +|   3536: 01 02 03 01 02 03 04 01 35 0d 02 03 01 02 03 01   ........5.......
         4754  +|   3552: 02 03 01 03 67 63 63 01 02 03 01 02 03 01 02 03   ....gcc.........
         4755  +|   3568: 02 06 65 6f 70 6f 6c 79 10 02 03 01 02 03 01 02   ..eopoly........
         4756  +|   3584: 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03 01 02   ...json1........
         4757  +|   3600: 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01 02 03   ...load.........
         4758  +|   3616: 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02 02 05   ..max...........
         4759  +|   3632: 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03 04 04   emory...........
         4760  +|   3648: 73 79 73 35 16 02 03 01 02 03 01 02 03 01 06 6e   sys5...........n
         4761  +|   3664: 6f 63 61 73 65 02 06 01 02 02 03 06 01 02 02 03   ocase...........
         4762  +|   3680: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         4763  +|   3696: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         4764  +|   3712: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         4765  +|   3728: 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01 02 02   ...omit.........
         4766  +|   3744: 01 05 72 74 72 65 65 19 02 03 01 02 03 01 02 03   ..rtree.........
         4767  +|   3760: 04 02 69 6d 01 06 01 02 02 03 06 01 02 02 03 06   ..im............
         4768  +|   3776: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         4769  +|   3792: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         4770  +|   3808: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         4771  +|   3824: 01 0a 74 68 72 65 61 64 73 61 66 65 22 02 02 01   ..threadsafe....
         4772  +|   3840: 02 02 01 02 01 01 04 76 74 61 62 07 02 04 01 02   .......vtab.....
         4773  +|   3856: 04 01 02 04 01 01 78 01 06 01 01 02 01 06 01 01   ......x.........
         4774  +|   3872: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         4775  +|   3888: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         4776  +|   3904: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         4777  +|   3920: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         4778  +|   3936: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         4779  +|   3952: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         4780  +|   3968: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         4781  +|   3984: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         4782  +|   4000: 01 01 02 01 06 01 01 02 01 06 01 ec 02 01 06 01   ................
         4783  +|   4016: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         4784  +|   4032: 02 01 06 01 01 02 01 06 01 01 01 04 15 13 0c 0c   ................
         4785  +|   4048: 12 44 13 11 0f 47 13 0f 0c 0e 11 10 0f 0e 10 0f   .D...G..........
         4786  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 5a 24 24 0f   D..@.......$Z$$.
         4787  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         4788  +| page 4 offset 12288
         4789  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         4790  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         4791  +| page 5 offset 16384
         4792  +|      0: 0d 00 00 00 24 0c 0a 00 0f d8 0f af 0f 86 0f 74   ....$..........t
         4793  +|     16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5   .a.N./..........
         4794  +|     32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5   ...t.[.@.$......
         4795  +|     48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb   .......h.O.5....
         4796  +|     64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a   .......x.W.>.$..
         4797  +|   3072: 00 00 00 00 00 00 00 00 00 00 18 24 05 00 25 0f   ...........$..%.
         4798  +|   3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49   .THREADSAFE=0XBI
         4799  +|   3104: 4e 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41   NARY.#..%..THREA
         4800  +|   3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22   DSAFE=0XNOCASE..
         4801  +|   3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d   ..%..THREADSAFE=
         4802  +|   3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d   0XRTRIM.!..3..OM
         4803  +|   3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f   IT LOAD EXTENSIO
         4804  +|   3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f   NXBINARY. ..3..O
         4805  +|   3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49   MIT LOAD EXTENSI
         4806  +|   3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17   ONXNOCASE....3..
         4807  +|   3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53   OMIT LOAD EXTENS
         4808  +|   3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19   IONXRTRIM....3..
         4809  +|   3264: 4d 41 58 20 4d 45 4d 4f 52 59 60 35 30 30 30 30   MAX MEMORY`50000
         4810  +|   3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f   000XBINARY....3.
         4811  +|   3296: 19 4d 41 58 20 4d 44 4d 4f 52 59 3d 35 30 30 30   .MAX MDMORY=5000
         4812  +|   3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33   0000XNOCASE....3
         4813  +|   3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30   ..MAX MEMORY=500
         4814  +|   3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25   00000XRTRIM....%
         4815  +|   3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42   ..ENABLE RTREEXB
         4816  +|   3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         4817  +|   3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17   LE RTREEXNOCASE.
         4818  +|   3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52   ...%..ENABLE RTR
         4819  +|   3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45   EEXRTRIM....)..E
         4820  +|   3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49   NABLE MEMSYS5XBI
         4821  +|   3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         4822  +|   3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45   E MEMSYS5XNOCASE
         4823  +|   3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45   ....)..ENABLE ME
         4824  +|   3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25   MSYS5XRTRIM....%
         4825  +|   3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42   ..ENABLE JSON1XB
         4826  +|   3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         4827  +|   3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17   LE JSON1XNOCASE.
         4828  +|   3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f   ...%..ENABLE JSO
         4829  +|   3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45   N1XRTRIM....)..E
         4830  +|   3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 58 42 49   NABLE GEOPOLYXBI
         4831  +|   3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         4832  +|   3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 43 41 53 45   E GEOPOLYXNOCASE
         4833  +|   3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45   ....)..ENABLE GE
         4834  +|   3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23   OPOLYXRTRIM....#
         4835  +|   3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49   ..ENABLE FTS5XBI
         4836  +|   3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c   NARY....#..ENABL
         4837  +|   3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05   E FTS5XNOCASE...
         4838  +|   3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58   .#..ENABLE FTS5X
         4839  +|   3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42   RTRIM....#..ENAB
         4840  +|   3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b   LE FTS4XBINARY..
         4841  +|   3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34   ..#..ENABLE FTS4
         4842  +|   3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e   XNOCASE....#..EN
         4843  +|   3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e   ABLE FTS4XRTRIM.
         4844  +|   3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         4845  +|   3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e   TAT VTABXBINARY.
         4846  +|   3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         4847  +|   3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d   TAT VTABXNOCASE.
         4848  +|   3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         4849  +|   3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06   TAT VTABXRTRIM..
         4850  +|   3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52   .....DEBUGXBINAR
         4851  +|   3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f   Y.......DEBUGXNO
         4852  +|   3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47   CASE.......DEBUG
         4853  +|   3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d   XRTRIM'...C..COM
         4854  +|   3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20   PILER=gcc-5.4.0 
         4855  +|   4000: 32 30 31 36 30 36 30 39 58 42 49 4e 41 52 59 27   20160609XBINARY'
         4856  +|   4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67   ...C..COMPILER=g
         4857  +|   4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30   cc-5.4.0 2016060
         4858  +|   4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43   9XNOCASE&...C..C
         4859  +|   4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e   OMPILER=gcc-5.4.
         4860  +|   4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d   0 20160609XRTRIM
         4861  +| page 6 offset 20480
         4862  +|      0: 0d 00 00 00 24 0e e0 00 0f f8 0f f0 0f e8 0f e0   ....$...........
         4863  +|     16: 0f d8 0f d0 0f c8 0f c0 0f b8 0f b0 0f a8 0f a0   ................
         4864  +|     32: 0f 98 0f 90 0f 88 0f 80 0f 78 0f 70 0f 68 0f 60   .........x.p.h.`
         4865  +|     48: 0f 58 0f 50 0f 48 0f 40 0f 38 0f 30 0f 28 0f 20   .X.P.H.@.8.0.(. 
         4866  +|     64: 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0 0e e8 0e e0   ................
         4867  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         4868  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         4869  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         4870  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         4871  +|   3872: 06 1c 03 00 12 03 01 01 16 1b 03 00 12 02 01 01   ................
         4872  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         4873  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         4874  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         4875  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         4876  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         4877  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         4878  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         4879  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         4880  +|   4016: 06 0a 03 00 12 02 01 01 05 09 03 00 12 03 01 01   ................
         4881  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 10 12 03 01 01   ................
         4882  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         4883  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 05 f1 01   ................
         4884  +|   4080: 06 02 03 00 12 06 01 01 06 01 03 00 12 06 01 01   ................
         4885  +| page 7 offset 24576
         4886  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         4887  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         4888  +| page 8 offset 28672
         4889  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e9 0f d6 00 00   ................
         4890  +|   4048: 00 00 00 00 00 00 11 03 02 2b 69 6e 74 65 67 72   .........+integr
         4891  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
         4892  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   uild....optimize
         4893  +| end crash-fd2a1313e5b5e9.db
         4894  +}]} {}
         4895  +
         4896  +do_catchsql_test 38.1 {
         4897  +  UPDATE t1 SET b=quote(zeroblob(200)) WHERE t1 MATCH 'thread*';
         4898  +} {0 {}}
         4899  +
         4900  +#-------------------------------------------------------------------------
         4901  +reset_db
         4902  +do_test 39.0 {
         4903  +  sqlite3 db {}
         4904  +  db deserialize [decode_hexdb {
         4905  +.open --hexdb
         4906  +| size 24576 pagesize 4096 filename crash-e650fe95502908.db
         4907  +| page 1 offset 0
         4908  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         4909  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06   .....@  ........
         4910  +|     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
         4911  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         4912  +|     96: 00 00 00 00 0d 00 00 00 06 0e 0f 00 0f aa 0f 53   ...............S
         4913  +|    112: 0e e8 0e 8b 0e 33 0e 0f 00 00 00 00 00 00 00 00   .....3..........
         4914  +|   3584: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22   ................
         4915  +|   3600: 06 06 17 11 11 01 31 74 61 62 6c 65 62 62 62 62   ......1tablebbbb
         4916  +|   3616: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 62 62   .CREATE TABLE bb
         4917  +|   3632: 28 61 29 56 05 06 17 1f 1f 01 7d 74 61 62 6c 65   (a)V.......table
         4918  +|   3648: 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63 6f 6e 66   t1_configt1_conf
         4919  +|   3664: 69 67 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   ig.CREATE TABLE 
         4920  +|   3680: 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b 20 50 52   't1_config'(k PR
         4921  +|   3696: 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 57 49   IMARY KEY, v) WI
         4922  +|   3712: 54 48 4f 55 54 20 52 4f 57 49 44 5b 04 07 17 21   THOUT ROWID[...!
         4923  +|   3728: 21 01 81 01 74 61 62 6c 65 74 31 5f 64 6f 63 73   !...tablet1_docs
         4924  +|   3744: 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65 04 43 52   izet1_docsize.CR
         4925  +|   3760: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 64   EATE TABLE 't1_d
         4926  +|   3776: 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 54 45 47   ocsize'(id INTEG
         4927  +|   3792: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         4928  +|   3808: 73 7a 20 42 4c 4f 42 29 69 03 07 17 19 19 01 81   sz BLOB)i.......
         4929  +|   3824: 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 5f 69   -tablet1_idxt1_i
         4930  +|   3840: 64 78 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   dx.CREATE TABLE 
         4931  +|   3856: 27 74 31 5f 69 64 78 27 28 73 65 67 69 64 2c 20   't1_idx'(segid, 
         4932  +|   3872: 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50 52 49 4d   term, pgno, PRIM
         4933  +|   3888: 41 52 59 20 4b 45 59 28 73 65 67 69 64 2c 20 74   ARY KEY(segid, t
         4934  +|   3904: 65 72 6d 29 29 20 57 49 54 48 4f 55 54 20 52 4f   erm)) WITHOUT RO
         4935  +|   3920: 57 49 44 55 02 07 17 1b 1b 01 81 01 74 61 62 6c   WIDU........tabl
         4936  +|   3936: 65 74 31 5f 64 61 74 61 74 31 5f 64 61 74 61 02   et1_datat1_data.
         4937  +|   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31   CREATE TABLE 't1
         4938  +|   3968: 5f 64 61 74 61 27 28 69 64 20 49 4e 54 45 47 45   _data'(id INTEGE
         4939  +|   3984: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62   R PRIMARY KEY, b
         4940  +|   4000: 6c 6f 63 6b 20 42 4c 4f 42 29 54 01 07 17 11 11   lock BLOB)T.....
         4941  +|   4016: 08 81 15 74 61 62 6c 65 74 31 74 31 43 52 45 41   ...tablet1t1CREA
         4942  +|   4032: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45   TE VIRTUAL TABLE
         4943  +|   4048: 20 74 31 20 55 53 49 4e 47 20 66 74 73 35 28 61    t1 USING fts5(a
         4944  +|   4064: 2c 62 2c 70 72 65 66 69 78 3d 22 32 2c 32 2c 33   ,b,prefix=.2,2,3
         4945  +|   4080: 2c 34 22 2c 20 63 6f 6e 74 65 6e 74 3d 22 22 29   ,4., content=..)
         4946  +| page 2 offset 4096
         4947  +|      0: 0d 0b 6a 00 37 09 4c 02 0f e7 09 4c 0f c6 0f a4   ..j.7.L....L....
         4948  +|     16: 0f 88 0f 6d 0f 4b 0f 2c 0f 0e 0e ec 0e cd 0e ad   ...m.K.,........
         4949  +|     32: 0e 8e 0e 6c 0e 4b 0e 29 0e 08 0d e6 0d c4 0d b5   ...l.K.)........
         4950  +|     48: 0d 97 0d 76 0d 54 0d 31 0d 15 0c f3 0c d3 0c b5   ...v.T.1........
         4951  +|     64: 0c 95 0c 73 0c 54 0c 32 0c 10 0b ee 0b cc 0b b0   ...s.T.2........
         4952  +|     80: 0b 8d 0b 7e 0b 48 0b 2e 0b 0b 0a ef 0a cc 0a ad   ...~.H..........
         4953  +|     96: 0a 8c 0a 6d 0a 4d 0a 2b 0a 0c 09 ec 09 ca 09 a8   ...m.M.+........
         4954  +|    112: 09 86 09 63 0f f1 00 00 00 00 00 00 00 00 00 00   ...c............
         4955  +|   2368: 00 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00   ................
         4956  +|   2384: 30 00 00 00 01 01 03 35 00 03 01 01 12 02 01 12   0......5........
         4957  +|   2400: 03 01 11 1c 8c 80 80 80 80 10 03 00 3e 00 00 00   ............>...
         4958  +|   2416: 17 01 05 05 34 74 61 62 6c 03 02 03 01 04 77 68   ....4tabl.....wh
         4959  +|   2432: 65 72 03 02 06 09 1b 8c 80 80 80 80 0f 03 00 3c   er.............<
         4960  +|   2448: 00 00 00 16 05 34 66 74 73 34 03 02 02 01 04 6e   .....4fts4.....n
         4961  +|   2464: 75 6d 62 03 06 01 04 09 1b 8c 80 80 80 80 0e 03   umb.............
         4962  +|   2480: 00 3c 00 00 00 16 04 33 74 68 65 03 06 01 01 04   .<.....3the.....
         4963  +|   2496: 01 03 77 68 65 03 02 04 04 0a 1b 8c 80 80 80 80   ..whe...........
         4964  +|   2512: 0d 03 00 3c 00 00 00 16 04 33 6e 75 6d 03 06 01   ...<.....3num...
         4965  +|   2528: 01 05 01 03 74 61 62 03 02 03 04 0a 19 8c 80 80   ....tab.........
         4966  +|   2544: 80 80 0c 03 00 38 00 00 00 14 03 32 77 68 03 02   .....8.....2wh..
         4967  +|   2560: 04 00 04 33 66 74 73 03 02 02 04 07 18 8c 80 80   ...3fts.........
         4968  +|   2576: 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 03 02   .....6.....2ta..
         4969  +|   2592: 03 02 01 68 03 06 01 01 04 04 07 1b 8c 80 80 80   ...h............
         4970  +|   2608: 80 0a 03 00 3c 00 00 00 16 03 32 6e 75 03 06 01   ....<.....2nu...
         4971  +|   2624: 01 05 01 02 6f 66 03 06 01 01 06 04 09 19 8c 80   ....of..........
         4972  +|   2640: 80 80 80 09 03 00 38 00 00 00 14 03 32 66 74 03   ......8.....2ft.
         4973  +|   2656: 02 02 01 02 69 73 03 06 01 01 03 04 07 18 8c 80   ....is..........
         4974  +|   2672: 80 80 80 08 03 00 36 00 00 00 13 02 31 74 03 08   ......6.....1t..
         4975  +|   2688: 03 01 01 04 01 01 77 03 02 04 04 09 1a 8c 80 80   ......w.........
         4976  +|   2704: 80 80 07 03 00 3a ff 00 00 15 02 31 6e 03 08 01   .....:.....1n...
         4977  +|   2720: 01 02 05 01 01 6f 03 06 01 01 06 04 09 18 8c 80   .....o..........
         4978  +|   2736: 80 80 80 06 03 00 36 00 00 00 13 04 02 31 66 03   ......6......1f.
         4979  +|   2752: 02 02 01 01 69 03 06 01 01 03 05 06 1c 8c 80 80   ....i...........
         4980  +|   2768: 80 80 05 03 00 3e 00 00 00 17 04 30 74 68 65 03   .....>.....0the.
         4981  +|   2784: 06 00 f1 04 01 05 77 68 65 72 65 03 02 04 0a 15   ......where.....
         4982  +|   2800: 8c 80 80 80 80 04 03 00 30 00 00 00 11 01 01 06   ........0.......
         4983  +|   2816: 06 30 74 61 62 6c 65 03 02 03 07 1c 8c 80 80 80   .0table.........
         4984  +|   2832: 80 03 03 00 3e 00 00 00 17 07 30 6e 75 6d 62 65   ....>.....0numbe
         4985  +|   2848: 72 03 06 01 01 05 01 02 6f 66 03 06 04 0d 13 8c   r.......of......
         4986  +|   2864: 80 80 80 80 02 03 00 2c 00 00 00 0f 01 01 03 02   .......,........
         4987  +|   2880: 30 6e 03 06 01 01 02 07 1b 8c 80 80 80 80 01 03   0n..............
         4988  +|   2896: 00 3c 00 00 00 16 08 30 66 74 73 34 61 75 78 03   .<.....0fts4aux.
         4989  +|   2912: 02 02 01 02 69 73 03 06 04 0c 00 00 00 14 2a 00   ....is........*.
         4990  +|   2928: 00 00 01 01 02 24 00 02 01 01 12 02 01 12 08 88   .....$..........
         4991  +|   2944: 80 80 80 80 12 03 00 16 00 00 00 05 02 1c 88 80   ................
         4992  +|   2960: 80 80 80 11 03 00 3e 00 00 00 17 05 34 72 6f 77   ......>.....4row
         4993  +|   2976: 73 02 06 01 01 05 01 04 74 68 65 72 02 02 04 0b   s.......ther....
         4994  +|   2992: 15 88 80 80 80 80 10 03 00 30 00 00 00 11 02 01   .........0......
         4995  +|   3008: 01 07 05 34 62 65 74 77 02 02 04 08 1b 88 80 80   ...4betw........
         4996  +|   3024: 80 80 0f 03 00 3c 00 00 00 16 04 04 33 72 6f 77   .....<......3row
         4997  +|   3040: 02 06 01 01 05 01 03 74 68 65 02 08 05 0a 1b 88   .......the......
         4998  +|   3056: 80 80 80 80 0e 03 00 3c 00 00 00 16 01 01 02 04   .......<........
         4999  +|   3072: 33 61 72 65 02 02 03 01 03 62 65 74 02 02 07 08   3are.....bet....
         5000  +|   3088: 1b 88 80 80 80 80 0d 03 00 3c 00 00 00 16 03 32   .........<.....2
         5001  +|   3104: 74 68 02 08 02 01 01 07 00 04 33 61 6e 64 02 06   th........3and..
         5002  +|   3120: 04 0a 1b 88 80 80 80 80 0c 03 00 3c 00 00 00 16   ...........<....
         5003  +|   3136: 03 32 69 6e 02 06 01 01 06 01 02 72 6f 02 06 01   .2in.......ro...
         5004  +|   3152: 01 05 04 09 18 88 80 80 80 80 0b 03 00 36 00 00   .............6..
         5005  +|   3168: 00 13 02 03 32 61 72 02 02 03 01 02 62 65 02 02   ....2ar.....be..
         5006  +|   3184: 04 05 07 1b 88 80 80 80 80 0a 03 00 3c 00 00 00   ............<...
         5007  +|   3200: 16 02 31 74 02 08 02 01 01 07 00 03 32 61 6e 02   ..1t........2an.
         5008  +|   3216: 06 01 01 04 09 19 88 80 80 80 80 09 03 00 38 00   ..............8.
         5009  +|   3232: 00 00 14 02 31 6e 02 06 01 01 03 01 01 72 02 06   ....1n.......r..
         5010  +|   3248: 01 01 05 04 08 17 88 80 80 80 80 08 03 00 34 00   ..............4.
         5011  +|   3264: 00 00 12 02 31 62 02 02 04 01 01 69 02 06 01 01   ....1b.....i....
         5012  +|   3280: 06 04 06 19 88 80 80 80 80 07 03 00 38 00 00 00   ............8...
         5013  +|   3296: 14 04 02 31 32 02 02 05 01 01 61 02 08 03 01 01   ...12.....a.....
         5014  +|   3312: 02 05 06 1b 88 80 80 80 80 06 03 00 3c 00 00 00   ............<...
         5015  +|   3328: 16 06 30 74 68 65 72 65 02 02 02 00 02 31 31 02   ..0there.....11.
         5016  +|   3344: 06 01 01 04 0a 15 88 80 80 80 80 05 03 00 30 00   ..............0.
         5017  +|   3360: 00 00 11 01 01 05 04 30 74 68 65 02 06 01 01 07   .......0the.....
         5018  +|   3376: 07 1c 88 80 80 80 80 04 03 00 3e 00 00 00 17 01   ..........>.....
         5019  +|   3392: 01 06 02 30 6e 02 06 01 01 03 01 04 72 6f 77 73   ...0n.......rows
         5020  +|   3408: 02 06 07 08 1b 88 80 80 80 80 03 03 00 3c 00 00   .............<..
         5021  +|   3424: 00 16 08 30 62 65 74 77 65 65 6e 02 02 04 01 02   ...0between.....
         5022  +|   3440: 69 6e 02 06 04 0c 1a 88 80 80 80 80 02 03 00 3a   in.............:
         5023  +|   3456: 00 00 00 15 04 30 61 6e 64 02 06 01 01 02 02 02   .....0and.......
         5024  +|   3472: 72 65 02 02 03 04 0a 17 88 80 80 80 80 01 03 00   re..............
         5025  +|   3488: 34 00 00 00 12 02 30 31 02 06 01 01 04 01 01 32   4.....01.......2
         5026  +|   3504: 02 02 05 04 08 08 84 80 80 80 81 12 03 00 16 00   ................
         5027  +|   3520: 00 00 05 04 1b 84 61 80 80 80 11 03 00 3c 00 00   ......a......<..
         5028  +|   3536: 00 16 05 34 74 61 62 6c 01 06 01 01 05 02 03 65   ...4tabl.......e
         5029  +|   3552: 72 6d 01 02 04 0b 1b 84 80 80 80 80 10 03 00 3c   rm.............<
         5030  +|   3568: 00 00 00 16 05 34 65 61 63 68 01 02 03 01 04 70   .....4each.....p
         5031  +|   3584: 72 65 73 01 02 05 04 09 1a 84 80 80 80 80 0f 03   res.............
         5032  +|   3600: 00 3a 00 00 00 15 04 33 74 65 72 01 02 04 02 02   .:.....3ter.....
         5033  +|   3616: 68 65 01 06 01 01 03 04 08 1b 84 80 80 80 80 0e   he..............
         5034  +|   3632: 03 00 3c 00 00 00 16 04 33 70 72 65 01 02 05 01   ..<.....3pre....
         5035  +|   3648: 03 74 61 62 01 06 01 01 05 04 08 1a 84 80 80 80   .tab............
         5036  +|   3664: 80 0d 03 00 3a 00 00 00 15 04 33 66 6f 72 01 02   ....:.....3for..
         5037  +|   3680: 02 02 02 74 73 01 06 01 01 04 04 08 1b 84 80 80   ...ts...........
         5038  +|   3696: 80 80 0c 03 00 3c 00 00 00 16 03 32 74 68 01 06   .....<.....2th..
         5039  +|   3712: 01 01 03 00 04 33 65 61 63 01 02 03 04 09 18 84   .....3eac.......
         5040  +|   3728: 80 80 80 80 0b 03 00 36 00 00 00 13 03 32 74 71   .......6.....2tq
         5041  +|   3744: 01 06 01 01 05 02 01 65 01 02 04 04 09 19 84 80   .......e........
         5042  +|   3760: 80 80 80 0a 03 00 38 00 00 00 14 03 32 69 6e 01   ......8.....2in.
         5043  +|   3776: 06 01 01 02 01 02 70 72 01 02 05 0b 89 18 84 80   ......pr........
         5044  +|   3792: 80 80 80 09 03 00 36 00 00 00 13 03 32 66 6f 01   ......6.....2fo.
         5045  +|   3808: 02 02 02 01 74 01 06 01 01 04 04 07 1b 84 80 80   ....t...........
         5046  +|   3824: 80 80 08 03 00 3c 00 00 00 16 02 31 74 01 0a 04   .....<.....1t...
         5047  +|   3840: 01 01 03 04 00 03 32 65 61 01 02 03 04 0a 17 84   ......2ea.......
         5048  +|   3856: 80 80 80 80 07 03 00 34 00 00 00 12 02 31 69 01   .......4.....1i.
         5049  +|   3872: 06 01 01 02 01 01 70 01 02 05 04 08 18 84 80 80   ......p.........
         5050  +|   3888: 80 80 06 03 00 36 00 00 00 13 02 31 65 01 02 03   .....6.....1e...
         5051  +|   3904: 01 01 66 01 08 02 01 01 04 04 06 1b 84 80 80 80   ..f.............
         5052  +|   3920: 80 05 03 00 3c 00 00 00 16 05 30 74 65 72 6d 01   ....<.....0term.
         5053  +|   3936: 02 04 02 02 68 65 01 06 01 01 03 04 09 14 84 80   ....he..........
         5054  +|   3952: 80 80 80 04 03 00 2e 00 00 00 10 06 30 74 61 62   ............0tab
         5055  +|   3968: 6c 65 01 06 01 01 05 04 15 84 80 80 80 80 03 03   le..............
         5056  +|   3984: 00 30 00 00 00 11 02 08 30 70 72 65 73 65 6e 74   .0......0present
         5057  +|   4000: 01 02 05 05 1b 84 80 80 80 80 02 03 00 3c 00 00   .............<..
         5058  +|   4016: 00 16 04 30 66 74 73 01 06 01 01 04 01 02 69 6e   ...0fts.......in
         5059  +|   4032: 01 06 01 01 04 0a 1a 84 80 80 80 80 01 03 00 3a   ...............:
         5060  +|   4048: 00 00 00 15 05 30 65 61 63 f4 01 02 03 01 03 66   .....0eac......f
         5061  +|   4064: 6f 72 01 02 02 04 09 06 01 03 00 12 03 0b 0f 00   or..............
         5062  +|   4080: 00 08 8c 80 80 80 80 11 03 00 16 00 00 00 05 04   ................
         5063  +| page 3 offset 8192
         5064  +|      0: 0a 00 00 00 32 0e 4f 00 0f fa 0f f1 0f e9 0f e1   ....2.O.........
         5065  +|     16: 0f d8 0f d1 0f c9 0f c1 0f b9 0f b1 0f a9 0f a0   ................
         5066  +|     32: 0f 98 0f 90 0f 87 0f 80 0f 78 0f 71 0f 68 0f 5f   .........x.q.h._
         5067  +|     48: 0f 56 0f 4d 0f 41 0f 38 0f 2f 0f 26 0f 1d 0f 13   .V.M.A.8./.&....
         5068  +|     64: 0f 0a 0f 01 0e f7 0e ee 0e e6 0e dd 0e d6 0e cd   ................
         5069  +|     80: 0e c3 0e ba 0e b0 0e a8 0e 9f 0e 96 0e 8e 0e 85   ................
         5070  +|     96: 0e 7c 0e 73 0e 6a 0e 60 0e 58 0e 4f 00 00 00 00   .|.s.j.`.X.O....
         5071  +|   3648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08   ................
         5072  +|   3664: 04 01 10 01 03 34 74 20 07 04 01 0e 01 03 34 1e   .....4t ......4.
         5073  +|   3680: 09 04 01 12 01 03 33 74 68 1c 08 04 01 10 01 03   ......3th.......
         5074  +|   3696: 33 6e 1a 08 04 01 10 01 03 32 77 18 08 04 01 10   3n.......2w.....
         5075  +|   3712: 01 03 32 74 16 08 04 01 10 01 03 32 6e 14 07 04   ..2t.......2n...
         5076  +|   3728: 01 0e 01 03 32 12 08 04 01 10 01 03 31 74 10 08   ....2.......1t..
         5077  +|   3744: 04 01 10 01 03 31 6e 0e 07 04 01 0e 01 03 31 0c   .....1n.......1.
         5078  +|   3760: 09 04 01 12 01 03 30 74 68 0a 08 04 01 10 01 03   ......0th.......
         5079  +|   3776: 30 74 08 09 04 01 12 01 03 30 6e 75 06 08 04 01   0t.......0nu....
         5080  +|   3792: 10 01 03 30 6e 04 06 04 01 0c 01 03 02 08 04 01   ...0n...........
         5081  +|   3808: 10 01 02 34 72 22 07 04 01 0e 01 02 34 20 08 04   ...4r.......4 ..
         5082  +|   3824: 01 10 01 02 33 72 1e 09 04 01 12 01 02 33 61 72   ....3r.......3ar
         5083  +|   3840: 1c 08 04 01 10 01 02 32 74 1a 08 04 01 10 b3 02   .......2t.......
         5084  +|   3856: 32 69 18 09 04 01 12 01 02 32 61 72 16 08 04 01   2i.......2ar....
         5085  +|   3872: 10 01 02 31 74 14 08 04 01 10 01 02 31 6e 12 08   ...1t.......1n..
         5086  +|   3888: 04 01 10 01 02 31 62 10 08 04 01 10 01 02 31 32   .....1b.......12
         5087  +|   3904: 0e 0b 04 01 16 01 02 30 74 68 65 72 0c 08 04 01   .......0ther....
         5088  +|   3920: 10 01 02 30 74 0a 08 04 01 10 01 02 30 6e 08 08   ...0t.......0n..
         5089  +|   3936: 04 01 10 01 02 30 62 06 08 04 01 10 01 02 30 61   .....0b.......0a
         5090  +|   3952: 05 06 04 01 0c 01 02 02 07 04 09 10 01 34 74 22   .............4t.
         5091  +|   3968: 06 04 09 0e 01 34 20 08 04 09 12 01 33 74 65 1e   .....4 .....3te.
         5092  +|   3984: 07 04 09 10 01 33 70 1c 07 04 09 10 01 33 66 1a   .....3p......3f.
         5093  +|   4000: 08 04 09 12 01 32 74 68 18 07 04 09 10 01 32 2d   .....2th......2-
         5094  +|   4016: 16 07 04 09 10 01 32 69 14 07 04 09 10 01 32 66   ......2i......2f
         5095  +|   4032: 12 07 04 09 10 01 31 74 10 07 04 09 10 01 31 69   ......1t......1i
         5096  +|   4048: 0e 06 04 09 0e 01 31 0c 08 04 09 12 01 30 74 65   ......1......0te
         5097  +|   4064: 0a 07 04 09 10 01 30 74 08 07 04 09 10 01 30 70   ......0t......0p
         5098  +|   4080: 06 08 04 09 12 01 30 66 74 04 05 04 09 0c 01 02   ......0ft.......
         5099  +| page 4 offset 12288
         5100  +|      0: 0d 00 00 00 03 0f eb 00 0f f9 0f f2 0f eb 00 00   ................
         5101  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10   ................
         5102  +|   4080: 03 05 05 02 03 00 10 04 06 05 01 03 00 10 04 03   ................
         5103  +| page 5 offset 16384
         5104  +|      0: 0a 00 00 00 02 0f eb 00 0f eb 0f f4 00 00 00 00   ................
         5105  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 08 03 15 01 70   ...............p
         5106  +|   4080: 67 73 7a 18 0b 03 1b 01 76 65 72 73 69 6f 6e 04   gsz.....version.
         5107  +| page 6 offset 20480
         5108  +|      0: 0d 00 00 00 03 0f f2 00 0f fc 0f f7 0f f2 00 00   ................
         5109  +|   4080: 00 00 03 03 02 01 03 03 02 02 01 02 02 01 02 09   ................
         5110  +| end crash-e650fe95502908.db
         5111  +}]} {}
         5112  +
         5113  +do_execsql_test 39.1 {
         5114  +  SELECT rowid FROM t1('t*');
         5115  +} {1 2 3}
         5116  +
         5117  +#-------------------------------------------------------------------------
         5118  +reset_db
         5119  +do_test 40.0 {
         5120  +  sqlite3 db {}
         5121  +  db deserialize [decode_hexdb {
         5122  +.open --hexdb
         5123  +| size 24576 pagesize 4096 filename crash2.txt.db
         5124  +| page 1 offset 0
         5125  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         5126  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06   .....@  ........
         5127  +|     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
         5128  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         5129  +|     96: 00 00 00 00 0d 00 00 00 06 0e 0f 00 0f aa 0f 53   ...............S
         5130  +|    112: 0e e8 0e 8b 0e 33 0e 0f 00 00 00 00 00 00 00 00   .....3..........
         5131  +|   3584: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22   ................
         5132  +|   3600: 06 06 17 11 11 01 31 74 61 62 6c 65 62 62 62 62   ......1tablebbbb
         5133  +|   3616: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 62 62   .CREATE TABLE bb
         5134  +|   3632: 28 61 29 56 05 06 17 1f 1f 01 7d 74 61 52 6c 65   (a)V.......taRle
         5135  +|   3648: 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63 6f 6e 66   t1_configt1_conf
         5136  +|   3664: 69 67 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   ig.CREATE TABLE 
         5137  +|   3680: 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b 20 50 52   't1_config'(k PR
         5138  +|   3696: 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 57 49   IMARY KEY, v) WI
         5139  +|   3712: 54 48 4f 55 54 20 52 4f 57 49 44 5b 04 07 17 21   THOUT ROWID[...!
         5140  +|   3728: 21 01 81 01 74 61 62 6c 65 74 31 5f 64 6f 73 73   !...tablet1_doss
         5141  +|   3744: 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65 04 43 52   izet1_docsize.CR
         5142  +|   3760: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 64   EATE TABLE 't1_d
         5143  +|   3776: 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 54 45 47   ocsize'(id INTEG
         5144  +|   3792: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         5145  +|   3808: 73 7a 20 42 4c 4f 42 29 69 03 07 17 19 19 01 81   sz BLOB)i.......
         5146  +|   3824: 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 5f 69   -tablet1_idxt1_i
         5147  +|   3840: 64 78 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   dx.CREATE TABLE 
         5148  +|   3856: 27 74 31 5f 69 64 78 27 28 73 65 67 69 64 2c 20   't1_idx'(segid, 
         5149  +|   3872: 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50 52 49 4d   term, pgno, PRIM
         5150  +|   3888: 41 52 59 20 4b 45 59 28 73 65 67 69 64 2c 20 74   ARY KEY(segid, t
         5151  +|   3904: 65 72 6d 29 29 20 57 49 54 48 4f 55 54 20 52 4f   erm)) WITHOUT RO
         5152  +|   3920: 57 49 44 55 02 07 17 1b 1b 01 81 01 74 61 62 6c   WIDU........tabl
         5153  +|   3936: 65 74 31 5f 64 61 74 61 74 31 5f 64 61 74 61 02   et1_datat1_data.
         5154  +|   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31   CREATE TABLE 't1
         5155  +|   3968: 5f 64 61 74 61 27 28 69 64 20 49 4e 54 45 47 45   _data'(id INTEGE
         5156  +|   3984: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62   R PRIMARY KEY, b
         5157  +|   4000: 6c 6f 63 6b 20 42 4c 4f 42 29 54 01 07 17 11 11   lock BLOB)T.....
         5158  +|   4016: 08 81 15 74 61 62 6c 65 74 31 74 31 43 52 45 41   ...tablet1t1CREA
         5159  +|   4032: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45   TE VIRTUAL TABLE
         5160  +|   4048: 20 74 31 20 55 53 49 4e 47 20 66 74 73 35 28 61    t1 USING fts5(a
         5161  +|   4064: 2c 62 2c 70 72 65 66 69 78 3d 22 31 2c 32 2c 33   ,b,prefix=.1,2,3
         5162  +|   4080: 2c 34 22 2c 20 63 6f 6e 74 65 6e 74 3d 22 22 29   ,4., content=..)
         5163  +| page 2 offset 4096
         5164  +|      0: 0d 0b 6a 00 37 09 4c 02 0f e7 09 4c 0f c6 0f a4   ..j.7.L....L....
         5165  +|     16: 0f 88 0f 6d 0f 4b 0f 2c 0f 0e 0e ec 0e cd 0e ad   ...m.K.,........
         5166  +|     32: 0e 8e 0e 6c 0e 4b 0e 29 0e 08 0d e6 0d c4 0d b5   ...l.K.)........
         5167  +|     48: 0d 97 0d 76 0d 54 0d 31 0d 15 0c f3 0c d3 0c b5   ...v.T.1........
         5168  +|     64: 0c 95 0c 73 0c 54 0c 32 0c 10 0b ee 0b cc 0b b0   ...s.T.2........
         5169  +|     80: 0b 8d 0b 7e 0b 48 0b 2e 0b 0b 0a ef 0a cc 0a ad   ...~.H..........
         5170  +|     96: 0a 8c 0a 6d 0a 4d 0a 2b 0a 0c 09 ec 09 ca 09 a8   ...m.M.+........
         5171  +|    112: 09 86 09 63 0f f1 00 00 00 00 00 00 00 00 00 00   ...c............
         5172  +|   2368: 00 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00   ................
         5173  +|   2384: 30 00 00 00 01 01 03 35 00 03 01 01 12 02 01 12   0......5........
         5174  +|   2400: 03 01 11 1c 8c 80 80 80 80 10 03 00 3e 00 00 00   ............>...
         5175  +|   2416: 17 01 05 05 34 74 61 62 6c 03 02 03 01 04 77 68   ....4tabl.....wh
         5176  +|   2432: 65 72 03 02 06 09 1b 8c 80 80 80 80 0f 03 00 3c   er.............<
         5177  +|   2448: 00 00 00 16 05 34 66 75 73 34 03 02 02 01 04 6e   .....4fus4.....n
         5178  +|   2464: 75 6d 62 03 06 01 04 09 1b 8c 80 80 80 80 0e 03   umb.............
         5179  +|   2480: 00 3c 00 00 00 16 04 33 74 68 65 03 06 01 01 04   .<.....3the.....
         5180  +|   2496: 01 03 77 68 65 03 02 04 04 0a 1b 8c 80 80 80 80   ..whe...........
         5181  +|   2512: 0d 03 00 3c 00 00 00 16 04 33 6e 75 6d 03 06 01   ...<.....3num...
         5182  +|   2528: 01 05 01 03 74 61 62 05 62 03 04 0a 19 8c 80 80   ....tab.b.......
         5183  +|   2544: 80 80 0c 03 00 38 00 00 00 14 03 32 77 68 03 02   .....8.....2wh..
         5184  +|   2560: 04 00 04 33 66 74 73 03 02 02 04 07 18 8c 80 80   ...3fts.........
         5185  +|   2576: 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 03 02   .....6.....2ta..
         5186  +|   2592: 03 02 01 68 03 06 01 01 04 04 07 1b 8c 80 80 80   ...h............
         5187  +|   2608: 80 0a 03 00 3c 00 00 00 16 03 32 6e 75 03 06 01   ....<.....2nu...
         5188  +|   2624: 01 05 01 02 6f 66 03 06 01 01 06 04 09 19 8c 80   ....of..........
         5189  +|   2640: 80 80 80 09 03 00 38 00 00 00 14 03 32 66 74 03   ......8.....2ft.
         5190  +|   2656: 02 02 01 02 69 73 03 06 01 01 03 04 07 18 8c 80   ....is..........
         5191  +|   2672: 80 80 80 08 03 00 36 00 00 00 13 02 31 74 03 08   ......6.....1t..
         5192  +|   2688: 03 01 01 04 01 01 77 03 02 04 04 09 1a 8c 80 80   ......w.........
         5193  +|   2704: 80 80 07 03 00 3a ff 00 00 15 02 31 6e 03 08 01   .....:.....1n...
         5194  +|   2720: 01 02 05 01 01 6f 03 06 01 01 06 04 09 18 8c 80   .....o..........
         5195  +|   2736: 80 80 80 06 03 00 36 00 00 00 13 04 02 31 66 03   ......6......1f.
         5196  +|   2752: 02 02 01 01 69 03 06 01 01 03 05 06 1c 8c 80 80   ....i...........
         5197  +|   2768: 80 80 05 03 00 3e 00 00 00 17 04 30 74 68 65 03   .....>.....0the.
         5198  +|   2784: 06 01 01 04 01 05 77 68 65 72 65 03 02 04 0a 15   ......where.....
         5199  +|   2800: 8c 80 80 80 80 04 03 00 30 00 00 00 11 01 01 06   ........0.......
         5200  +|   2816: 06 30 74 61 62 6c 65 03 02 03 07 1c 8c 80 80 80   .0table.........
         5201  +|   2832: 80 03 03 00 3e 00 00 00 17 07 30 6e 75 6d 62 65   ....>.....0numbe
         5202  +|   2848: 72 03 06 01 01 05 01 02 6f 66 03 06 04 0d 13 8c   r.......of......
         5203  +|   2864: 80 80 80 80 02 03 00 2c 00 00 00 0f 01 01 03 02   .......,........
         5204  +|   2880: 30 6e 03 06 01 01 02 07 1b 8c 80 80 80 80 01 03   0n..............
         5205  +|   2896: 00 3c 00 00 00 16 08 30 66 74 73 34 61 75 78 03   .<.....0fts4aux.
         5206  +|   2912: 02 02 01 02 69 73 03 06 04 0c 00 00 00 14 2a 00   ....is........*.
         5207  +|   2928: 00 00 01 01 02 24 00 02 01 01 12 02 01 12 08 88   .....$..........
         5208  +|   2944: 80 80 80 80 11 03 00 16 00 00 00 05 02 1c 88 80   ................
         5209  +|   2960: 80 80 80 11 03 00 3e 00 00 00 17 05 34 72 6f 77   ......>.....4row
         5210  +|   2976: 73 02 06 01 01 05 01 04 74 68 65 72 02 02 04 0b   s.......ther....
         5211  +|   2992: 15 88 80 80 80 80 10 03 00 30 00 00 00 11 02 01   .........0......
         5212  +|   3008: 01 07 05 34 62 65 74 77 02 02 04 08 1b 88 80 80   ...4betw........
         5213  +|   3024: 80 80 0f 03 00 3c 00 00 00 16 04 04 33 72 6f 77   .....<......3row
         5214  +|   3040: 02 06 01 01 05 01 03 74 68 65 02 08 05 0a 1b 88   .......the......
         5215  +|   3056: 80 80 80 80 0e 03 00 3c 00 00 00 16 02 01 02 04   .......<........
         5216  +|   3072: 33 61 72 65 02 02 03 01 03 62 65 74 02 02 07 08   3are.....bet....
         5217  +|   3088: 1b 88 80 80 80 80 0d 03 00 3c 00 00 00 16 03 32   .........<.....2
         5218  +|   3104: 74 68 02 08 02 01 01 07 00 04 33 61 6e 64 02 06   th........3and..
         5219  +|   3120: 04 0a 1b 88 80 80 80 80 0c 03 00 3c 00 00 00 16   ...........<....
         5220  +|   3136: 03 32 69 6e 02 06 01 01 06 01 02 72 6f 02 06 01   .2in.......ro...
         5221  +|   3152: 01 05 04 09 18 88 80 80 80 80 0b 03 00 36 00 00   .............6..
         5222  +|   3168: 00 13 02 03 32 61 72 02 02 03 01 02 62 65 02 02   ....2ar.....be..
         5223  +|   3184: 04 05 07 1b 88 80 80 80 80 0a 03 00 3c 00 00 00   ............<...
         5224  +|   3200: 16 02 31 74 02 08 02 01 01 07 00 03 32 61 6e 02   ..1t........2an.
         5225  +|   3216: 06 01 01 04 09 19 88 80 80 80 80 09 03 00 38 00   ..............8.
         5226  +|   3232: 00 00 14 02 31 6e 02 06 01 01 03 01 01 72 02 06   ....1n.......r..
         5227  +|   3248: 01 01 05 04 08 17 88 80 80 80 80 08 03 00 34 00   ..............4.
         5228  +|   3264: 00 00 12 02 31 62 02 02 04 01 01 69 02 06 01 01   ....1b.....i....
         5229  +|   3280: 06 04 06 19 88 80 80 80 80 07 03 00 38 00 00 00   ............8...
         5230  +|   3296: 14 04 02 31 32 02 02 05 01 01 61 02 08 03 01 01   ...12.....a.....
         5231  +|   3312: 02 05 06 1b 88 80 80 80 80 06 03 00 3c 00 00 00   ............<...
         5232  +|   3328: 16 06 30 74 68 65 72 65 02 02 02 00 02 31 31 02   ..0there.....11.
         5233  +|   3344: 06 01 01 04 0a 15 88 80 80 80 80 05 03 00 30 00   ..............0.
         5234  +|   3360: 00 00 11 01 01 05 04 30 74 68 65 02 06 01 01 07   .......0the.....
         5235  +|   3376: 07 1c 88 80 80 80 80 04 03 00 3e 00 00 00 17 01   ..........>.....
         5236  +|   3392: 01 06 02 30 6e 02 06 01 01 03 01 04 72 6f 77 73   ...0n.......rows
         5237  +|   3408: 02 06 07 08 1b 88 80 80 80 80 03 03 00 3c 00 00   .............<..
         5238  +|   3424: 00 16 08 30 62 65 74 77 65 65 6e 02 02 04 01 02   ...0between.....
         5239  +|   3440: 69 6e 02 06 04 0c 1a 88 80 80 80 80 02 03 00 3a   in.............:
         5240  +|   3456: 00 00 00 15 04 30 61 6e 64 02 06 01 01 02 02 02   .....0and.......
         5241  +|   3472: 72 65 02 02 03 04 0a 17 88 80 80 80 80 01 03 00   re..............
         5242  +|   3488: 34 00 00 00 12 02 30 31 02 06 01 01 04 01 01 32   4.....01.......2
         5243  +|   3504: 02 02 06 04 08 08 84 80 80 80 80 12 03 00 16 00   ................
         5244  +|   3520: 00 00 05 04 1b 84 80 80 80 80 11 03 00 3c 00 00   .............<..
         5245  +|   3536: 00 16 05 34 74 61 62 6c 01 06 01 01 05 02 03 65   ...4tabl.......e
         5246  +|   3552: 72 6d 01 02 04 0b 1b 84 80 80 80 80 10 03 00 3c   rm.............<
         5247  +|   3568: 00 00 00 16 05 34 65 61 63 68 01 02 03 01 04 70   .....4each.....p
         5248  +|   3584: 72 65 73 01 02 05 04 09 1a 84 80 80 80 80 0f 03   res.............
         5249  +|   3600: 00 3a 00 00 00 15 04 33 74 65 72 01 02 04 02 02   .:.....3ter.....
         5250  +|   3616: 68 65 01 06 01 01 03 04 08 1b 84 80 80 80 80 0e   he..............
         5251  +|   3632: 03 00 3c 00 00 00 16 04 33 70 72 65 01 02 05 01   ..<.....3pre....
         5252  +|   3648: 03 74 61 62 01 06 01 01 05 04 08 1a 84 80 80 80   .tab............
         5253  +|   3664: 80 0d 03 00 3a 00 00 00 15 04 33 66 6f 72 01 02   ....:.....3for..
         5254  +|   3680: 02 02 02 74 73 01 06 01 01 04 04 08 1b 84 80 80   ...ts...........
         5255  +|   3696: 80 80 0c 03 00 3c 00 00 00 16 03 32 74 68 01 06   .....<.....2th..
         5256  +|   3712: 01 01 03 00 04 33 65 61 63 01 02 03 04 09 18 84   .....3eac.......
         5257  +|   3728: 80 80 80 80 0b 03 00 36 00 00 00 13 03 32 74 61   .......6.....2ta
         5258  +|   3744: 01 06 01 01 05 02 01 65 01 02 04 04 09 19 84 80   .......e........
         5259  +|   3760: 80 80 80 0a 03 00 38 00 00 00 14 03 32 69 6e 01   ......8.....2in.
         5260  +|   3776: 06 01 01 02 01 02 70 72 01 02 05 04 09 18 84 80   ......pr........
         5261  +|   3792: 80 80 80 09 03 00 36 00 00 00 13 03 32 66 6f 01   ......6.....2fo.
         5262  +|   3808: 02 02 02 01 74 01 06 01 01 04 04 07 1b 84 80 80   ....t...........
         5263  +|   3824: 80 80 08 03 00 3c 00 00 00 16 02 31 74 01 0a 04   .....<.....1t...
         5264  +|   3840: 01 01 03 04 00 03 32 65 61 01 02 03 04 0a 17 84   ......2ea.......
         5265  +|   3856: 80 80 80 80 07 03 00 34 00 00 00 12 02 31 69 01   .......4.....1i.
         5266  +|   3872: 06 01 01 02 01 01 70 01 02 05 04 08 18 84 80 80   ......p.........
         5267  +|   3888: 80 80 06 03 00 36 00 00 00 13 02 31 65 01 02 03   .....6.....1e...
         5268  +|   3904: 01 01 66 01 08 02 01 01 04 04 06 1b 84 80 80 80   ..f.............
         5269  +|   3920: 80 05 03 00 3c 00 00 00 16 05 30 74 65 72 6d 01   ....<.....0term.
         5270  +|   3936: 02 04 02 02 68 65 01 06 01 01 03 04 09 14 84 80   ....he..........
         5271  +|   3952: 80 80 80 04 03 00 2e 00 00 00 10 06 30 74 61 62   ............0tab
         5272  +|   3968: 6c 65 01 06 00 01 05 04 15 84 80 80 80 80 03 03   le..............
         5273  +|   3984: 00 30 00 00 00 11 02 08 30 70 72 65 73 65 6e 74   .0......0present
         5274  +|   4000: 01 02 05 05 1b 84 80 80 80 80 02 03 00 3c 00 00   .............<..
         5275  +|   4016: 00 16 04 30 66 74 73 01 06 01 01 04 01 02 69 6e   ...0fts.......in
         5276  +|   4032: 01 06 01 01 04 0a 1a 84 80 80 80 80 01 03 00 3a   ...............:
         5277  +|   4048: 00 00 00 15 05 30 65 61 63 68 01 02 03 01 03 66   .....0each.....f
         5278  +|   4064: 6f 72 01 02 02 04 09 06 01 03 00 12 03 0b 0f 00   or..............
         5279  +|   4080: 00 08 8c 80 80 80 80 11 03 00 16 00 00 00 05 04   ................
         5280  +| page 3 offset 8192
         5281  +|      0: 0a 00 00 00 32 0e 4f 00 0f fa 10 f1 0f e9 0f e1   ....2.O.........
         5282  +|     16: 0f d8 0f d1 0f c9 0f c1 0f b9 0f b1 0f a9 0f a0   ................
         5283  +|     32: 0f 98 0f 90 0f 87 0f 80 0f 78 0f 71 0f 68 0f 5f   .........x.q.h._
         5284  +|     48: bd 56 0f 4d 0f 41 0f 38 0f 2f 0f 26 0f 1d 0f 13   .V.M.A.8./.&....
         5285  +|     64: 0f 0a 0f 01 0e f7 0e ee 0e e6 0e dd 0e d6 0e cd   ................
         5286  +|     80: 0e c3 0e ba 0e b0 0e a8 0e 9f 0e 96 0e 8e 0e 85   ................
         5287  +|     96: 0e 7c 0e 73 0e 6a 0e 60 0e 58 0e 4f 00 00 00 00   .|.s.j.`.X.O....
         5288  +|   3648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08   ................
         5289  +|   3664: 04 01 10 01 03 34 74 20 07 04 01 0e 01 03 34 1e   .....4t ......4.
         5290  +|   3680: 09 04 01 12 01 03 33 74 68 1c 08 04 01 10 01 03   ......3th.......
         5291  +|   3696: 33 6e 1a 08 04 01 10 01 03 32 77 18 08 04 01 10   3n.......2w.....
         5292  +|   3712: 01 03 32 74 16 08 04 01 10 01 03 32 6e 14 07 04   ..2t.......2n...
         5293  +|   3728: 01 0e 01 03 32 12 08 04 01 10 01 03 31 74 10 08   ....2.......1t..
         5294  +|   3744: 04 01 10 01 03 31 6e 0e 07 04 01 0e 01 03 31 0c   .....1n.......1.
         5295  +|   3760: 09 04 01 12 01 03 30 74 68 0a 08 04 01 10 01 03   ......0th.......
         5296  +|   3776: 30 74 08 09 04 01 12 01 03 30 6e 75 06 08 04 01   0t.......0nu....
         5297  +|   3792: 10 01 03 30 6e 04 06 04 01 0c 01 05 52 08 04 01   ...0n.......R...
         5298  +|   3808: 10 01 02 34 72 22 07 04 01 0e 01 02 34 20 08 04   ...4r.......4 ..
         5299  +|   3824: 01 10 01 02 33 72 1e 09 04 01 12 01 02 33 61 72   ....3r.......3ar
         5300  +|   3840: 1c 08 04 01 10 01 02 32 74 1a 08 04 01 10 b3 02   .......2t.......
         5301  +|   3856: 32 69 18 09 04 01 12 01 02 32 61 72 16 08 04 01   2i.......2ar....
         5302  +|   3872: 10 01 02 31 74 14 08 04 01 10 01 02 31 6e 12 08   ...1t.......1n..
         5303  +|   3888: 04 01 10 01 02 31 62 10 08 04 01 10 01 02 31 32   .....1b.......12
         5304  +|   3904: 0e 0b 04 01 16 01 02 30 74 68 65 72 0c 08 04 01   .......0ther....
         5305  +|   3920: 10 01 02 30 74 0a 08 04 01 10 01 02 30 6e 08 08   ...0t.......0n..
         5306  +|   3936: 04 01 10 01 02 30 62 06 08 04 01 10 01 02 30 61   .....0b.......0a
         5307  +|   3952: 04 06 04 01 0c 01 02 02 07 04 09 10 01 34 74 22   .............4t.
         5308  +|   3968: 06 04 09 0e 01 34 20 08 04 09 12 01 33 74 65 1e   .....4 .....3te.
         5309  +|   3984: 07 04 09 10 01 33 70 1c 07 04 09 10 01 33 66 1a   .....3p......3f.
         5310  +|   4000: 08 04 09 12 01 32 74 68 18 07 04 09 10 01 32 74   .....2th......2t
         5311  +|   4016: 16 07 04 09 10 01 32 69 14 07 04 09 10 01 32 66   ......2i......2f
         5312  +|   4032: 12 07 04 09 10 01 31 74 10 07 04 09 10 01 31 69   ......1t......1i
         5313  +|   4048: 0e 06 04 09 0e 01 31 0c 08 04 09 12 01 30 74 65   ......1......0te
         5314  +|   4064: 0a 07 04 09 10 01 30 74 08 07 04 09 10 01 30 70   ......0t......0p
         5315  +|   4080: 06 08 04 09 12 01 30 66 74 04 05 04 09 0c 01 02   ......0ft.......
         5316  +| page 4 offset 12288
         5317  +|      0: 0d 00 00 00 03 0f eb 00 0f f9 0f f2 0f eb 00 00   ................
         5318  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10   ................
         5319  +|   4080: 03 05 05 02 03 00 10 04 06 05 01 03 00 10 04 04   ................
         5320  +| page 5 offset 16384
         5321  +|      0: 0a 00 00 00 02 0f eb 00 0f eb 0f f4 00 00 00 00   ................
         5322  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 08 03 15 01 70   ...............p
         5323  +|   4080: 67 73 7a 18 0b 03 1b 01 76 65 72 73 69 6f 6e 04   gsz.....version.
         5324  +| page 6 offset 20480
         5325  +|      0: 0d 00 00 00 03 0f f2 00 0f fc 0f f7 0f f2 00 00   ................
         5326  +|   4080: 00 00 03 03 02 01 03 03 02 02 01 02 02 01 02 09   ................
         5327  +| end crash2.txt.db
         5328  +}]} {}
         5329  +
         5330  +do_execsql_test 40.1 {
         5331  +  BEGIN;
         5332  +  INSERT INTO t1(b) VALUES(X'819192e578de3fa24af3733ca8769291a0fee3669f9fddefc5cba913e4225d4b6ce2b04f26b87fad3ee6f9b7d90a1ea62a169bf41e5d32707a6ca5c3d05e4bde05c9d89eaaa8c50e74333d2e9fcd7dfe95528a3a016aac1102d825c5cd70cf99d8a88e0ea7f798d4334386518b7ad359beb168b93aba059a2a3bd93112d65b44c12b9904ea786b204d80531cdf0504bf9b203dbe927061974caf7b9f30cbc3397b61f802e732012a6663d41c3607d6f1c0dbcfd489adac05ca500c0b04439d894cd93a840159225ef73b627e178b9f84b3ffe66cf22a963a8368813ff7961fc47f573211ccec95e0220dcbb3bf429f4a50ba54d7a53784ac51bf');
         5333  +  INSERT INTO t1(b) VALUES(X'c8ae0d0e7c3175946e62ba2b449511d4eb504079984a20f77969f62206c9f3d7ea25358ab705e6978627290b6d48db9032f815a06a79a4f4b809841a0942eed12954ed166f666111812a508abc3bec87958846edaec0a6fe14564bc0a4b78f1c35ebcacca6bae29cc37ae9b59d8a2d7593af1e47dda0ece2268a98d20febafad037964f139851f9a57f48b3706b01721769071991412044cd6006f1d72eb6eb4aa5ad77e378176db8c15575fbeee47165e38a7c6c5a557ac2dfe11813976eaf6741cf593a9e457053a3c34cddfbe605a6e25419f993de8374fafcd3636509d8416a51dc7bcc14cfca322ae343078f47e23522431c17d0da0c033');
         5334  +  INSERT INTO t1(b) VALUES(X'dc29a94e873a45a4243fce9b912aaefbadf1d0423e0345793874b356eeb500b92fb05284c1601fe9bad3143f72162f10242cec27c44ebf764c8fc9fb0824e32c4161472a4f914f579e0e8274f08ca1a02e59b9d8eec1f31061f9ccb9ed97a6f06534e991f7992c761489e6a7724f6e9c2b581e77487ded3a986d53c4419bbd3e9747cee300e670dd7294874c77e2ed48da68eaa6c3ec954a09ac410493d98e34d6686e54fbbe80696705f10e040c66093efb40746b33600685c94c664c7942835a9e954866121d5dcfb2cb12e92521ea3df175ee17072502dad9b9c1565f801b2179799011eb7418bfa00323e3157589e648ff7378be233c79b7');
         5335  +}
         5336  +
         5337  +do_catchsql_test 40.2 {
         5338  +  INSERT INTO t1(a,b) VALUES(1,11),(2,22),(3, true ),(4,44);
         5339  +} {1 {database disk image is malformed}}
         5340  +
         5341  +#-------------------------------------------------------------------------
         5342  +reset_db
         5343  +do_execsql_test 41.0 {
         5344  +  CREATE VIRTUAL TABLE t1 USING fts5(a,b,c);
         5345  +  REPLACE INTO t1_data VALUES(1,X'255a5824');
         5346  +  REPLACE INTO t1_data VALUES(10,X'0a1000000102020002010101020101');
         5347  +  INSERT INTO t1_data VALUES(137438953473,X'0000032b0030300102060102060102061f0203010203010203010832303136303630390102070102070102070101340102050102050102050101350102040102040102040207303030303030301c0204010204010204010662696e6272790306010202030601020203060102020306010202030601020203060102020306010202030601020203060102020306010202030601020203060102020108636f6d70696c657201020201020201020201066462737461740702030102030102030424656275670402020102020102020106656e61626c6507020201020201020201020201020201020201020201020201020201020201020201020201020201020201020201020201020201020201020201020201020202087874656e73696f6e1f02040102040102040104667473340a02030102030102030401350d020301020301020301036763630102030102030102030206656f706f6c7910020301020301020301056a736f6e3113020301020301020301046c6f61641f020301020301020301036d61781c02020102020102020205656d6f72791c020301020301020304047379733516020301020301020301066e6f6361736502060102020306010202030601020203060102020306010202030601020203060102020306010202030601020203060102020301b10202030601020201046f6d69741f0202010202010202010572747265651902030102030102030402696d010601020203060102020306010202030601020203060102020306010202030601020203060102020306010202030601020203060102020306010202010a746872656164736166652202020102020102020104767461620702040102040102040101780106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020106010102010601010201060101020415130c0c124413110f47130f0c0e11100f0e100f440f1040150f');
         5348  +  INSERT INTO t1_data VALUES(274877906945,X'00000183023030250601011d010331c2ba250601010d0101342506010121010135250601011e02036ec2ba250601012b0101382506010112010161250a0101021a1d02016f2506010111010162250601013201026377250601012f010166250801011f0c010167250601012701026863250601010f02026473250601013002016b2506010133020175250601010e010169250601012c0204386ec2be250601012001016a250601010401056bc2b2cebc250601010901016c25060101150203cebc71250601011301036dd18a250601010c01016f25060101260102706425060101240101712506010122010173250a010116040d02016f2506010134010175250801011b14020161250601010b010376c2aa25060101100202d7ac250601010601017725060101030201752506010114010179250a0101190e050202357a250601010701017a250601012e0102c2aa250801011c100201b3250601010a0202ba6225060101310203be656625060101080103c5a77425060101050102de8e250601011704080a08080a080a080809090809090808080b080c080a0a0809080a0809080a0908080a09080a08090a0a');
         5349  +  INSERT INTO t1_idx VALUES(1,X'',2);
         5350  +  INSERT INTO t1_idx VALUES(2,X'',2);
         5351  +}
         5352  +
         5353  +do_catchsql_test 41.1 {
         5354  +  INSERT INTO t1(t1) VALUES('optimize');
         5355  +} {1 {database disk image is malformed}}
         5356  +
         5357  +do_catchsql_test 41.2 {
         5358  +  INSERT INTO t1(t1) VALUES('integrity-check');
         5359  +} {1 {database disk image is malformed}}
         5360  +
         5361  +#-------------------------------------------------------------------------
         5362  +reset_db
         5363  +do_test 42.0 {
         5364  +  sqlite3 db {}
         5365  +  db deserialize [decode_hexdb {
         5366  +| size 32768 pagesize 4096 filename 8cfba7fbb67e48de92c6.db
         5367  +| page 1 offset 0
         5368  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         5369  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08   .....@  ........
         5370  +|     32: 00 00 00 02 00 00 00 01 00 00 00 09 00 00 00 04   ................
         5371  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         5372  +|     96: 00 00 00 00 0d 0f c7 00 07 0d 92 00 0f 8d 0f 36   ...............6
         5373  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d 92 0d 92 00 00 00 00   ...k............
         5374  +|   3472: 00 00 22 08 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         5375  +|   3488: 32 74 32 08 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         5376  +|   3504: 20 74 32 28 78 29 56 07 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         5377  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         5378  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         5379  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         5380  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         5381  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         5382  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         5383  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         5384  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         5385  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         5386  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         5387  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         5388  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         5389  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         5390  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         5391  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         5392  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         5393  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         5394  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         5395  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         5396  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         5397  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         5398  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         5399  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         5400  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         5401  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         5402  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         5403  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         5404  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         5405  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         5406  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         5407  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         5408  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         5409  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         5410  +| page 3 offset 8192
         5411  +|      0: 0d 00 00 00 03 0c 94 00 0f e6 0f ef 0c 94 00 00   ................
         5412  +|   3216: 00 00 00 00 86 4a 84 80 80 80 80 01 04 00 8d 18   .....J..........
         5413  +|   3232: 00 00 03 2b 02 30 30 01 02 06 01 02 06 01 02 06   ...+.00.........
         5414  +|   3248: 1f 02 03 01 02 03 01 02 03 01 08 32 30 31 36 30   ...........20160
         5415  +|   3264: 36 30 39 01 02 07 01 02 07 01 02 07 01 01 34 01   609...........4.
         5416  +|   3280: 02 05 01 02 05 01 02 05 01 01 35 01 02 04 01 02   ..........5.....
         5417  +|   3296: 04 01 02 04 02 07 30 30 30 30 30 30 30 1c 02 04   ......0000000...
         5418  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 62 72 79 03 06   ........binbry..
         5419  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 01 03 06 01   ................
         5420  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         5421  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         5422  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 08 63 6f 6d 70   ............comp
         5423  +|   3392: 69 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64   iler...........d
         5424  +|   3408: 62 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04   bstat...........
         5425  +|   3424: 65 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65   ebug...........e
         5426  +|   3440: 6e 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02   nable...........
         5427  +|   3456: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         5428  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         5429  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         5430  +|   3504: 02 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02   ......xtension..
         5431  +|   3520: 04 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03   .........fts4...
         5432  +|   3536: 01 02 03 01 02 03 04 01 35 0d 02 03 01 02 03 01   ........5.......
         5433  +|   3552: 02 03 01 03 67 63 63 01 02 03 01 02 03 01 02 03   ....gcc.........
         5434  +|   3568: 02 06 65 6f 70 6f 6c 79 10 02 03 01 02 03 01 02   ..eopoly........
         5435  +|   3584: 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03 01 02   ...json1........
         5436  +|   3600: 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01 02 03   ...load.........
         5437  +|   3616: 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02 02 05   ..max...........
         5438  +|   3632: 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03 04 04   emory...........
         5439  +|   3648: 73 79 73 35 16 02 03 01 02 03 01 02 03 01 06 6e   sys5...........n
         5440  +|   3664: 6f 63 61 73 65 02 06 01 02 02 03 06 01 02 02 03   ocase...........
         5441  +|   3680: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         5442  +|   3696: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         5443  +|   3712: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         5444  +|   3728: 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01 02 02   ...omit.........
         5445  +|   3744: 01 05 72 74 72 65 65 19 02 03 01 02 03 01 02 03   ..rtree.........
         5446  +|   3760: 04 02 69 6d 01 06 01 02 02 03 06 01 02 02 03 06   ..im............
         5447  +|   3776: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         5448  +|   3792: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         5449  +|   3808: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         5450  +|   3824: 01 0a 74 68 72 65 61 64 73 61 66 65 22 02 02 01   ..threadsafe....
         5451  +|   3840: 02 02 01 02 02 01 04 76 74 61 62 07 02 04 01 02   .......vtab.....
         5452  +|   3856: 04 01 02 04 01 01 78 01 06 01 01 02 01 06 01 01   ......x.........
         5453  +|   3872: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         5454  +|   3888: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         5455  +|   3904: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         5456  +|   3920: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         5457  +|   3936: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         5458  +|   3952: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         5459  +|   3968: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         5460  +|   3984: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         5461  +|   4000: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         5462  +|   4016: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         5463  +|   4032: 02 01 06 01 01 02 01 06 01 01 02 04 15 13 0c 0c   ................
         5464  +|   4048: 12 44 13 11 0f 47 13 0f 0c 0e 11 10 0f 0e 10 0f   .D...G..........
         5465  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 5a 24 24 0f   D..@.......$Z$$.
         5466  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         5467  +| page 4 offset 12288
         5468  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         5469  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0b 01 02   ................
         5470  +| page 5 offset 16384
         5471  +|      0: 0d 00 00 00 24 0c 0a 00 0f d8 0f af 0f 86 0f 74   ....$..........t
         5472  +|     16: 0f 61 0f 4e 0f 2f 0f 0f 0e ef 0e d7 0e be 0e a5   .a.N./..........
         5473  +|     32: 0e 8d 0e 74 0e 5b 0e 40 0e 24 0e 08 0d ef 0d d5   ...t.[.@.$......
         5474  +|     48: 0d bb 0d a0 0d 84 0d 68 0d 4f 0d 35 0d 1b 0c fb   .......h.O.5....
         5475  +|     64: 0c da 0c b9 0c 99 0c 78 0c 57 0c 3e 0c 24 0c 0a   .......x.W.>.$..
         5476  +|   3072: 00 00 00 00 00 00 00 00 00 00 18 24 05 00 25 0f   ...........$..%.
         5477  +|   3088: 19 54 48 52 45 41 44 53 41 46 45 3d 30 58 42 49   .THREADSAFE=0XBI
         5478  +|   3104: 4f 41 52 59 18 23 05 00 25 0f 19 54 48 52 45 41   OARY.#..%..THREA
         5479  +|   3120: 44 53 41 46 45 3d 30 58 4e 4f 43 41 53 45 17 22   DSAFE=0XNOCASE..
         5480  +|   3136: 05 00 25 0f 17 54 48 52 45 41 44 53 41 46 45 3d   ..%..THREADSAFE=
         5481  +|   3152: 30 58 52 54 52 49 4d 1f 21 05 00 33 0f 19 4f 4d   0XRTRIM.!..3..OM
         5482  +|   3168: 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f   IT LOAD EXTENSIO
         5483  +|   3184: 4e 58 42 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f   NXBINARY. ..3..O
         5484  +|   3200: 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53 49   MIT LOAD EXTENSI
         5485  +|   3216: 4f 4e 58 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17   ONXNOCASE....3..
         5486  +|   3232: 4f 4d 49 54 20 4c 4f 41 44 20 45 58 54 45 4e 53   OMIT LOAD EXTENS
         5487  +|   3248: 49 4f 4e 58 52 54 52 49 4d 1f 1e 05 00 33 0f 19   IONXRTRIM....3..
         5488  +|   3264: 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30 30   MAX MEMORY=50000
         5489  +|   3280: 30 30 30 58 42 49 4e 41 52 59 1f 1d 05 00 33 0f   000XBINARY....3.
         5490  +|   3296: 19 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30 30   .MAX MEMORY=5000
         5491  +|   3312: 30 30 30 30 58 4e 4f 43 41 53 45 1e 1c 05 00 33   0000XNOCASE....3
         5492  +|   3328: 0f 17 4d 41 58 20 4d 45 4d 4f 52 59 3d 35 30 30   ..MAX MEMORY=500
         5493  +|   3344: 30 30 30 30 30 58 52 54 52 49 4d 18 1b 05 00 25   00000XRTRIM....%
         5494  +|   3360: 0f 19 45 4e 41 42 4c 45 20 52 54 52 45 45 58 42   ..ENABLE RTREEXB
         5495  +|   3376: 49 4e 41 52 59 18 1a 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         5496  +|   3392: 4c 45 20 52 54 52 45 45 58 4e 4f 43 41 53 45 17   LE RTREEXNOCASE.
         5497  +|   3408: 19 05 00 25 0f 17 45 4e 41 42 4c 45 20 52 54 52   ...%..ENABLE RTR
         5498  +|   3424: 45 45 58 52 54 52 49 4d 1a 18 05 00 29 0f 19 45   EEXRTRIM....)..E
         5499  +|   3440: 4e 41 42 4c 45 20 4d 45 4d 53 59 53 35 58 42 49   NABLE MEMSYS5XBI
         5500  +|   3456: 4e 41 52 59 1a 17 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         5501  +|   3472: 45 20 4d 45 4d 53 59 53 35 58 4e 4f 43 41 53 45   E MEMSYS5XNOCASE
         5502  +|   3488: 19 16 05 00 29 0f 17 45 4e 41 42 4c 45 20 4d 45   ....)..ENABLE ME
         5503  +|   3504: 4d 53 59 53 35 58 52 54 52 49 4d 18 15 05 00 25   MSYS5XRTRIM....%
         5504  +|   3520: 0f 19 45 4e 41 42 4c 45 20 4a 53 4f 4e 31 58 42   ..ENABLE JSON1XB
         5505  +|   3536: 49 4e 41 52 59 18 14 05 00 25 0f 19 45 4e 41 42   INARY....%..ENAB
         5506  +|   3552: 4c 45 20 4a 53 4f 4e 31 58 4e 4f 43 41 53 45 17   LE JSON1XNOCASE.
         5507  +|   3568: 13 05 00 25 0f 17 45 4e 41 42 4c 45 20 4a 53 4f   ...%..ENABLE JSO
         5508  +|   3584: 4e 31 58 52 54 52 49 4d 1a 12 05 00 29 0f 19 45   N1XRTRIM....)..E
         5509  +|   3600: 4e 41 42 4c 45 20 47 45 4f 50 4f 4c 59 57 42 49   NABLE GEOPOLYWBI
         5510  +|   3616: 4e 41 52 59 1a 11 05 00 29 0f 19 45 4e 41 42 4c   NARY....)..ENABL
         5511  +|   3632: 45 20 47 45 4f 50 4f 4c 59 58 4e 4f 42 41 53 45   E GEOPOLYXNOBASE
         5512  +|   3648: 19 10 05 00 29 0f 17 45 4e 41 42 4c 45 20 47 45   ....)..ENABLE GE
         5513  +|   3664: 4f 50 4f 4c 59 58 52 54 52 49 4d 17 0f 05 00 23   OPOLYXRTRIM....#
         5514  +|   3680: 0f 19 45 4e 41 42 4c 45 20 46 54 53 35 58 42 49   ..ENABLE FTS5XBI
         5515  +|   3696: 4e 41 52 59 17 0e 05 00 23 0f 19 45 4e 41 42 4c   NARY....#..ENABL
         5516  +|   3712: 45 20 46 54 53 35 58 4e 4f 43 41 53 45 16 0d 05   E FTS5XNOCASE...
         5517  +|   3728: 00 23 0f 17 45 4e 41 42 4c 45 20 46 54 53 35 58   .#..ENABLE FTS5X
         5518  +|   3744: 52 54 52 49 4d 17 0c 05 00 23 0f 19 45 4e 41 42   RTRIM....#..ENAB
         5519  +|   3760: 4c 45 20 46 54 53 34 58 42 49 4e 41 52 59 17 0b   LE FTS4XBINARY..
         5520  +|   3776: 05 00 23 0f 19 45 4e 41 42 4c 45 20 46 54 53 34   ..#..ENABLE FTS4
         5521  +|   3792: 58 4e 4f 43 41 53 45 16 0a 05 00 23 0f 17 45 4e   XNOCASE....#..EN
         5522  +|   3808: 41 42 4c 45 20 46 54 53 34 58 52 54 52 49 4d 1e   ABLE FTS4XRTRIM.
         5523  +|   3824: 09 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         5524  +|   3840: 54 41 54 20 56 54 41 42 58 42 49 4e 41 52 59 1e   TAT VTABXBINARY.
         5525  +|   3856: 08 05 00 31 0f 19 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         5526  +|   3872: 54 41 54 20 56 54 41 42 58 4e 4f 43 41 53 45 1d   TAT VTABXNOCASE.
         5527  +|   3888: 07 05 00 31 0f 17 45 4e 41 42 4c 45 20 44 42 53   ...1..ENABLE DBS
         5528  +|   3904: 54 41 54 20 56 54 41 42 58 52 54 52 49 4d 11 06   TAT VTABXRTRIM..
         5529  +|   3920: 05 00 17 0f 19 44 45 42 55 47 58 42 49 4e 41 52   .....DEBUGXBINAR
         5530  +|   3936: 59 11 05 05 00 17 0f 19 44 45 42 55 47 58 4e 4f   Y.......DEBUGXNO
         5531  +|   3952: 43 41 53 45 10 04 05 00 17 0f 17 44 45 42 55 47   CASE.......DEBUG
         5532  +|   3968: 58 52 54 52 49 4d 27 03 05 00 43 0f 19 43 4f 4d   XRTRIM'...C..COM
         5533  +|   3984: 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e 30 20   PILER=gcc-5.4.0 
         5534  +|   4000: 32 30 31 36 30 36 30 39 52 02 49 4e 41 52 59 27   20160609R.INARY'
         5535  +|   4016: 02 05 00 43 0f 19 43 4f 4d 50 49 4c 45 52 3d 67   ...C..COMPILER=g
         5536  +|   4032: 63 63 2d 35 2e 34 2e 30 20 32 30 31 36 30 36 30   cc-5.4.0 2016060
         5537  +|   4048: 39 58 4e 4f 43 41 53 45 26 01 05 00 43 0f 17 43   9XNOCASE&...C..C
         5538  +|   4064: 4f 4d 50 49 4c 45 52 3d 67 63 63 2d 35 2e 34 2e   OMPILER=gcc-5.4.
         5539  +|   4080: 30 20 32 30 31 36 30 36 30 39 58 52 54 52 49 4d   0 20160609XRTRIM
         5540  +| page 6 offset 20480
         5541  +|      0: 0d 00 00 00 24 0e e0 00 0f f8 0f f0 0f e8 0f e0   ....$...........
         5542  +|     16: 0f d8 0f d0 0f c8 0f c0 0f b8 0f b0 0f a8 0f a0   ................
         5543  +|     32: 0f 98 0f 90 0f 88 0f 80 0f 78 0f 70 0f 68 0f 60   .........x.p.h.`
         5544  +|     48: 0f 58 0f 50 0f 48 0f 40 0f 38 0f 30 0f 28 0f 20   .X.P.H.@.8.0.(. 
         5545  +|     64: 0f 18 0f 10 0f 08 0f 00 0e f8 0e f0 0e e8 0e e0   ................
         5546  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         5547  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         5548  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         5549  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         5550  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         5551  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         5552  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         5553  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         5554  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         5555  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         5556  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         5557  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         5558  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         5559  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         5560  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         5561  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         5562  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 06 01 01   ................
         5563  +|   4080: 06 02 03 00 12 06 01 01 06 01 03 00 12 06 01 01   ................
         5564  +| page 7 offset 24576
         5565  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         5566  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         5567  +| page 8 offset 28672
         5568  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e9 0f d6 00 00   ................
         5569  +|   4048: 00 00 00 00 00 00 11 03 02 2b 69 6e 74 65 67 72   .........+integr
         5570  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
         5571  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 5d 69 7a 65   uild....opti]ize
         5572  +| end 8cfba7fbb67e48de92c6.db
         5573  +}]} {}
         5574  +
         5575  +do_catchsql_test 42.1 {
         5576  +  INSERT INTO t1(t1) VALUES('integrity-check');
         5577  +} {1 {database disk image is malformed}}
         5578  +
         5579  +#-------------------------------------------------------------------------
         5580  +reset_db
         5581  +do_test 43.0 {
         5582  +  sqlite3 db {}
         5583  +  db deserialize [decode_hexdb {
         5584  +| size 24576 pagesize 4096 filename 89028ffd2c29b679e250.db
         5585  +| page 1 offset 0
         5586  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         5587  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06   .....@  ........
         5588  +|     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
         5589  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         5590  +|     96: 00 00 00 00 0d 00 00 00 06 0e 0f 00 0f aa 0f 53   ...............S
         5591  +|    112: 0e e8 0e 8b 0e 33 0e 0f 00 00 00 00 00 00 00 00   .....3..........
         5592  +|   3584: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22   ................
         5593  +|   3600: 06 06 17 11 11 01 31 74 61 62 6c 65 62 62 62 62   ......1tablebbbb
         5594  +|   3616: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 62 62   .CREATE TABLE bb
         5595  +|   3632: 28 61 29 56 05 06 17 1f 1f 01 7d 74 61 62 6c 65   (a)V.......table
         5596  +|   3648: 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63 6f 6e 66   t1_configt1_conf
         5597  +|   3664: 69 67 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   ig.CREATE TABLE 
         5598  +|   3680: 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b 20 50 52   't1_config'(k PR
         5599  +|   3696: 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 57 49   IMARY KEY, v) WI
         5600  +|   3712: 54 48 4f 55 54 20 52 4f 57 49 44 5b 04 07 17 21   THOUT ROWID[...!
         5601  +|   3728: 21 01 81 01 74 61 62 6c 65 74 31 5f 64 6f 63 73   !...tablet1_docs
         5602  +|   3744: 69 7a 65 74 31 5f 12 6f 63 73 69 7a 65 04 43 52   izet1_.ocsize.CR
         5603  +|   3760: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 64   EATE TABLE 't1_d
         5604  +|   3776: 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 54 45 47   ocsize'(id INTEG
         5605  +|   3792: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         5606  +|   3808: 73 7a 20 42 4c 4f 42 29 69 03 07 17 19 19 01 81   sz BLOB)i.......
         5607  +|   3824: 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 5f 69   -tablet1_idxt1_i
         5608  +|   3840: 64 78 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   dx.CREATE TABLE 
         5609  +|   3856: 27 74 31 5f 69 64 78 27 28 73 65 67 69 64 2c 20   't1_idx'(segid, 
         5610  +|   3872: 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50 52 49 4d   term, pgno, PRIM
         5611  +|   3888: 41 52 59 20 4b 45 59 28 73 65 67 69 64 2c 20 74   ARY KEY(segid, t
         5612  +|   3904: 65 72 6d 29 29 20 57 49 54 48 4f 55 54 20 52 4f   erm)) WITHOUT RO
         5613  +|   3920: 57 49 44 55 02 07 17 1b 1b 01 81 01 74 61 62 6c   WIDU........tabl
         5614  +|   3936: 65 74 31 5f 64 61 74 61 74 31 5e 64 61 74 61 02   et1_datat1^data.
         5615  +|   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31   CREATE TABLE 't1
         5616  +|   3968: 5f 64 61 74 61 27 28 69 64 20 49 4e 54 45 47 45   _data'(id INTEGE
         5617  +|   3984: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62   R PRIMARY KEY, b
         5618  +|   4000: 6c 6f 63 6b 20 42 4c 4f 42 29 54 01 07 17 11 11   lock BLOB)T.....
         5619  +|   4016: 08 81 15 74 61 62 6c 65 74 31 74 31 43 52 45 41   ...tablet1t1CREA
         5620  +|   4032: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45   TE VIRTUAL TABLE
         5621  +|   4048: 20 74 31 20 55 53 49 4e 47 20 66 74 73 35 28 61    t1 USING fts5(a
         5622  +|   4064: 2c 62 2c 70 72 65 66 69 78 3d 22 31 2c 32 2c 33   ,b,prefix=.1,2,3
         5623  +|   4080: 2c 34 22 2c 20 63 6f 6e 74 65 6e 74 3d 22 22 29   ,4., content=..)
         5624  +| page 2 offset 4096
         5625  +|      0: 0d 0b 6a 00 37 09 4c 02 0f e8 09 4c 0f c6 0f a4   ..j.7.L....L....
         5626  +|     16: 0f 88 0f 6d 0f 4b 0f 2c 0f 0e 0e ec 0e cd 0e ad   ...m.K.,........
         5627  +|     32: 0e 8e 0e 6c 0e 4b 0e 29 0e 08 0d e6 0d c4 0d b5   ...l.K.)........
         5628  +|     48: 0d 97 0d 76 0d 54 0d 31 0d 15 0c f3 0c d3 0c b5   ...v.T.1........
         5629  +|     64: 0c 95 0c 73 0c 54 0c 32 0c 10 0b ee 0b cc 0b b0   ...s.T.2........
         5630  +|     80: 0b 8d 0b 7e 0b 48 0b 2e 0b 0b 0a ef 0a cc 0a ad   ...~.H..........
         5631  +|     96: 0a 8c 0a 6d 0a 4d 0a 2b 0a 0c 09 ec 09 ca 09 a8   ...m.M.+........
         5632  +|    112: 09 86 09 63 0f f1 00 00 00 00 00 00 00 00 00 00   ...c............
         5633  +|   2368: 00 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00   ................
         5634  +|   2384: 30 00 00 00 01 01 03 35 00 03 00 01 12 02 01 12   0......5........
         5635  +|   2400: 03 01 11 1c 8c 80 80 80 80 10 03 00 3e 00 00 00   ............>...
         5636  +|   2416: 17 01 05 05 34 74 61 62 6c 03 02 03 01 04 77 68   ....4tabl.....wh
         5637  +|   2432: 65 72 03 02 06 09 1b 8c 80 80 80 80 0f 03 00 3c   er.............<
         5638  +|   2448: 00 00 00 16 05 34 66 74 73 34 03 02 02 01 04 6e   .....4fts4.....n
         5639  +|   2464: 75 6d 62 03 06 01 04 09 1b 8c 80 80 80 80 0e 03   umb.............
         5640  +|   2480: 00 3c 00 00 00 16 04 33 74 68 65 03 06 01 01 04   .<.....3the.....
         5641  +|   2496: 01 03 77 68 65 03 02 04 04 0a 1b 8c 80 80 80 80   ..whe...........
         5642  +|   2512: 0d 03 00 3c 00 00 00 16 04 33 6e 75 6d 03 06 01   ...<.....3num...
         5643  +|   2528: 01 05 01 03 74 61 62 03 02 03 04 0a 19 8c 80 80   ....tab.........
         5644  +|   2544: 80 80 0c 03 00 38 00 00 00 14 03 32 77 68 03 02   .....8.....2wh..
         5645  +|   2560: 04 00 04 33 66 74 73 03 02 02 04 07 18 8c 80 80   ...3fts.........
         5646  +|   2576: 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 03 02   .....6.....2ta..
         5647  +|   2592: 03 02 01 68 03 06 01 01 04 04 07 1b 8c 80 80 80   ...h............
         5648  +|   2608: 80 0a 03 00 3c 00 00 00 16 03 32 6e 75 03 06 01   ....<.....2nu...
         5649  +|   2624: 01 05 01 02 6f 66 03 06 01 01 06 04 09 19 8c 80   ....of..........
         5650  +|   2640: 80 80 80 09 03 00 38 00 00 00 14 03 32 66 74 03   ......8.....2ft.
         5651  +|   2656: 02 02 01 02 69 73 03 06 01 01 03 04 07 18 8c 80   ....is..........
         5652  +|   2672: 80 80 80 08 03 00 36 94 00 00 13 02 31 74 03 08   ......6.....1t..
         5653  +|   2688: 03 01 01 04 01 01 77 03 02 04 04 09 1a 8c 80 80   ......w.........
         5654  +|   2704: 80 80 07 03 00 3a 00 00 00 15 02 31 6e 03 08 01   .....:.....1n...
         5655  +|   2720: 01 02 05 01 01 6f 03 06 01 01 06 04 09 18 8c 80   .....o..........
         5656  +|   2736: 80 80 80 06 03 00 36 00 00 00 13 04 02 31 66 03   ......6......1f.
         5657  +|   2752: 02 02 01 01 69 03 06 01 01 03 05 06 1c 8c 80 80   ....i...........
         5658  +|   2768: 80 80 05 03 00 3e 00 00 00 17 04 30 74 68 65 03   .....>.....0the.
         5659  +|   2784: 06 01 01 04 01 05 77 68 65 72 65 03 02 04 0a 15   ......where.....
         5660  +|   2800: 8c 80 80 80 80 04 03 00 30 00 00 00 11 01 01 06   ........0.......
         5661  +|   2816: 06 30 74 61 62 6c 65 03 02 03 07 1c 8c 80 80 80   .0table.........
         5662  +|   2832: 80 03 03 00 3e 00 00 00 17 07 30 6e 75 6d 62 65   ....>.....0numbe
         5663  +|   2848: 72 03 06 01 01 05 01 02 6f 66 03 06 04 0d 13 8c   r.......of......
         5664  +|   2864: 80 80 80 80 02 03 00 2c 00 00 00 0f 01 01 03 02   .......,........
         5665  +|   2880: 30 6e 03 06 01 01 02 07 1b 8c 80 80 80 80 01 03   0n..............
         5666  +|   2896: 00 3c 00 00 00 16 08 30 66 74 73 34 61 75 78 03   .<.....0fts4aux.
         5667  +|   2912: 02 02 01 02 69 73 04 06 04 0c 00 00 00 14 2a 00   ....is........*.
         5668  +|   2928: 00 00 01 01 02 24 00 02 01 01 12 02 01 12 08 88   .....$..........
         5669  +|   2944: 80 80 80 80 12 03 00 16 00 00 00 05 02 1c 88 80   ................
         5670  +|   2960: 80 80 80 11 03 00 3e 00 00 00 17 05 34 72 6f 77   ......>.....4row
         5671  +|   2976: 73 02 06 01 01 05 01 04 74 68 65 72 02 02 04 0b   s.......ther....
         5672  +|   2992: 15 88 80 80 80 80 10 03 00 30 00 00 00 11 02 01   .........0......
         5673  +|   3008: 01 07 05 34 62 65 74 77 02 02 04 08 1b 88 80 80   ...4betw........
         5674  +|   3024: 80 80 0f 03 00 3c 00 00 00 16 04 04 33 72 6f 77   .....<......3row
         5675  +|   3040: 02 06 01 01 05 01 03 74 68 65 02 08 05 0a 1b 88   .......the......
         5676  +|   3056: 80 80 80 80 0e 03 00 3c 00 00 00 16 01 01 02 04   .......<........
         5677  +|   3072: 33 61 72 65 02 02 03 01 03 62 65 74 02 02 07 08   3are.....bet....
         5678  +|   3088: 1b 88 80 80 80 80 0d 03 00 3c 00 00 00 16 03 32   .........<.....2
         5679  +|   3104: 74 68 02 08 02 01 01 07 00 04 33 61 6e 64 02 06   th........3and..
         5680  +|   3120: 04 0a 1b 88 80 80 80 80 0c 03 00 3c 00 00 00 16   ...........<....
         5681  +|   3136: 03 32 69 6e 02 06 01 01 06 01 02 72 6f 02 06 01   .2in.......ro...
         5682  +|   3152: 01 05 04 09 18 88 80 80 80 80 0b 03 00 36 00 00   .............6..
         5683  +|   3168: 00 13 02 03 32 61 72 02 02 03 01 02 62 65 02 02   ....2ar.....be..
         5684  +|   3184: 04 05 07 1b 88 80 80 80 80 0a 03 00 3c 00 00 00   ............<...
         5685  +|   3200: 16 02 31 74 02 08 02 01 01 07 00 03 32 61 6e 02   ..1t........2an.
         5686  +|   3216: 06 01 01 04 09 19 88 80 80 80 80 09 03 00 38 00   ..............8.
         5687  +|   3232: 00 00 14 02 31 6e 02 06 01 01 03 01 01 72 02 06   ....1n.......r..
         5688  +|   3248: 01 01 05 04 08 17 88 80 80 80 80 08 03 00 34 00   ..............4.
         5689  +|   3264: 00 00 12 02 31 62 02 02 04 01 01 69 02 06 01 01   ....1b.....i....
         5690  +|   3280: 06 04 06 19 88 80 80 80 80 07 03 00 38 00 00 00   ............8...
         5691  +|   3296: 14 04 02 31 32 02 02 05 01 01 61 02 08 03 01 01   ...12.....a.....
         5692  +|   3312: 02 05 06 1b 88 80 80 80 80 06 03 00 3c 00 00 00   ............<...
         5693  +|   3328: 16 06 30 74 68 65 72 65 02 02 02 00 02 31 31 02   ..0there.....11.
         5694  +|   3344: 06 01 01 04 0a 15 88 80 80 80 80 05 00 90 30 00   ..............0.
         5695  +|   3360: 00 00 11 01 01 05 04 30 74 68 65 02 06 01 01 07   .......0the.....
         5696  +|   3376: 07 1c 88 80 80 80 80 04 03 00 3e 00 00 00 17 01   ..........>.....
         5697  +|   3392: 01 06 02 30 6e 02 06 01 01 03 01 04 72 6f 77 73   ...0n.......rows
         5698  +|   3408: 02 06 07 08 1b 88 80 80 80 80 03 03 00 3c 00 00   .............<..
         5699  +|   3424: 00 16 07 30 62 65 74 77 65 65 6e 02 02 04 01 02   ...0between.....
         5700  +|   3440: 69 6e 02 06 04 0c 1a 88 80 80 80 80 02 03 00 3a   in.............:
         5701  +|   3456: 00 00 00 15 04 30 61 6e 64 02 06 01 01 02 02 02   .....0and.......
         5702  +|   3472: 72 65 02 02 03 04 0a 17 88 80 80 80 80 01 03 00   re..............
         5703  +|   3488: 34 00 00 00 12 02 30 31 02 06 01 01 04 01 01 32   4.....01.......2
         5704  +|   3504: 02 02 05 04 08 08 84 80 80 80 80 12 03 00 16 00   ................
         5705  +|   3520: 00 00 05 04 1b 84 80 80 80 80 11 03 00 3c 00 00   .............<..
         5706  +|   3536: 00 16 05 34 74 61 62 6c 01 06 01 01 05 02 03 65   ...4tabl.......e
         5707  +|   3552: 72 6d 01 02 04 0b 1b 84 80 80 80 80 10 03 00 3c   rm.............<
         5708  +|   3568: 00 00 00 16 05 34 65 61 63 68 01 02 03 01 04 70   .....4each.....p
         5709  +|   3584: 72 65 73 01 02 05 04 09 1a 84 80 80 80 80 0f 03   res.............
         5710  +|   3600: 00 3a 00 00 00 15 04 33 74 65 72 01 02 04 02 02   .:.....3ter.....
         5711  +|   3616: 68 65 01 06 01 01 03 04 08 1b 84 80 80 80 80 0e   he..............
         5712  +|   3632: 03 00 3c 00 00 00 16 04 33 70 72 65 01 02 05 01   ..<.....3pre....
         5713  +|   3648: 03 74 61 62 01 06 01 01 05 04 08 1a 84 80 80 80   .tab............
         5714  +|   3664: 80 0d 03 00 3a 00 00 00 15 04 33 66 6f 72 01 02   ....:.....3for..
         5715  +|   3680: 02 02 02 74 73 01 06 01 01 04 04 08 1b 84 80 80   ...ts...........
         5716  +|   3696: 80 80 0c 03 00 3c 00 00 00 16 03 32 74 68 01 06   .....<.....2th..
         5717  +|   3712: 01 01 03 00 04 33 65 61 63 01 02 03 04 09 18 84   .....3eac.......
         5718  +|   3728: 80 80 80 80 0b 03 00 36 00 00 00 13 03 32 74 61   .......6.....2ta
         5719  +|   3744: 01 06 01 01 05 02 01 65 01 02 04 04 09 19 84 80   .......e........
         5720  +|   3760: 80 80 80 0a 03 00 38 00 00 00 14 03 32 69 6e 01   ......8.....2in.
         5721  +|   3776: 06 01 01 02 01 02 70 72 01 02 05 04 09 18 84 80   ......pr........
         5722  +|   3792: 80 80 80 09 03 00 36 00 00 00 13 03 32 66 6f 01   ......6.....2fo.
         5723  +|   3808: 02 02 02 01 74 01 06 01 01 04 04 07 1b 84 80 80   ....t...........
         5724  +|   3824: 80 80 08 03 00 3c 00 00 00 16 02 31 74 01 0a 04   .....<.....1t...
         5725  +|   3840: 01 01 03 04 00 03 32 65 61 01 02 03 04 0a 17 84   ......2ea.......
         5726  +|   3856: 80 80 80 80 07 03 00 34 00 00 00 12 02 31 69 01   .......4.....1i.
         5727  +|   3872: 06 01 01 02 01 01 71 01 02 05 04 08 18 84 80 80   ......q.........
         5728  +|   3888: 80 80 06 03 00 36 00 00 00 13 02 31 65 01 02 03   .....6.....1e...
         5729  +|   3904: 01 01 66 01 08 02 01 01 04 04 06 1b 84 80 80 80   ..f.............
         5730  +|   3920: 80 05 03 00 3c 00 00 00 16 05 30 74 65 72 6d 01   ....<.....0term.
         5731  +|   3936: 02 04 02 02 68 65 01 06 01 01 03 04 09 14 84 80   ....he..........
         5732  +|   3952: 80 80 80 04 03 00 2e 00 00 00 10 06 30 74 61 62   ............0tab
         5733  +|   3968: 6c 65 01 06 01 01 05 04 15 84 80 80 80 80 03 03   le..............
         5734  +|   3984: 00 30 00 00 00 11 02 08 30 70 72 65 73 65 6e 74   .0......0present
         5735  +|   4000: 01 02 05 05 1b 84 80 80 80 80 02 03 00 3c 00 00   .............<..
         5736  +|   4016: 00 16 04 30 66 74 73 01 06 01 01 04 01 02 69 6e   ...0fts.......in
         5737  +|   4032: 01 06 01 01 04 0a 1a 84 80 80 80 80 01 03 00 3a   ...............:
         5738  +|   4048: 00 00 00 15 05 30 65 61 63 68 01 02 03 01 03 66   .....0each.....f
         5739  +|   4064: 6f 72 01 02 02 04 09 06 01 03 00 12 03 0b 0f 00   or..............
         5740  +|   4080: 00 08 8c 80 80 80 80 11 03 00 16 00 00 00 05 04   ................
         5741  +| page 3 offset 8192
         5742  +|      0: 0a 00 00 00 32 0e 4f 00 0f fa 0f f1 0f e9 0f e1   ....2.O.........
         5743  +|     16: 0f d8 0f d1 0f c9 0f c1 0f b9 0f b1 0f a9 0f a0   ................
         5744  +|     32: 0f 98 0f 91 0f 87 0f 80 0f 78 0f 71 0f 68 0f 5f   .........x.q.h._
         5745  +|     48: 0f 56 0f 4d 0f 41 0f 38 0f 2f 0f 26 0f 1d 0f 13   .V.M.A.8./.&....
         5746  +|     64: 0f 0a 0f 01 0e f7 0e ee 0e e6 0e dd 0e d6 0e cd   ................
         5747  +|     80: 0e c3 0e ba 0e b0 0e a8 0e 9f 0e 96 0e 8e 0e 85   ................
         5748  +|     96: 0e 7c 0e 73 0e 6a 0e 60 0e 58 0e 4f 00 00 00 00   .|.s.j.`.X.O....
         5749  +|   3648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08   ................
         5750  +|   3664: 04 01 10 01 03 34 74 20 07 04 01 0e 01 03 34 1e   .....4t ......4.
         5751  +|   3680: 09 05 01 12 01 03 33 74 68 1c 08 04 01 10 01 03   ......3th.......
         5752  +|   3696: 33 6e 1a 08 04 01 10 01 03 32 77 18 08 04 01 10   3n.......2w.....
         5753  +|   3712: 01 03 32 74 16 08 04 01 10 01 03 32 6e 14 07 04   ..2t.......2n...
         5754  +|   3728: 01 0e 01 03 32 12 08 04 01 10 01 03 31 74 10 08   ....2.......1t..
         5755  +|   3744: 04 01 10 01 03 31 6e 0e 07 04 01 0e 01 03 31 0c   .....1n.......1.
         5756  +|   3760: 09 04 01 12 01 03 30 74 68 0a 08 04 01 10 01 03   ......0th.......
         5757  +|   3776: 30 74 08 09 04 01 12 01 03 30 6e 75 06 08 04 01   0t.......0nu....
         5758  +|   3792: 10 01 03 30 6e 04 06 04 01 0c 01 03 02 08 04 01   ...0n...........
         5759  +|   3808: 10 01 02 34 72 22 07 04 01 0e 01 02 34 20 08 04   ...4r.......4 ..
         5760  +|   3824: 01 10 01 02 33 72 1e 09 04 01 12 01 02 33 61 72   ....3r.......3ar
         5761  +|   3840: 1c 08 04 01 10 01 02 32 74 1a 08 04 01 10 02 02   .......2t.......
         5762  +|   3856: 32 69 18 09 04 01 12 01 02 32 61 72 16 08 04 01   2i.......2ar....
         5763  +|   3872: 10 01 02 31 74 14 08 04 01 10 01 02 31 6e 12 08   ...1t.......1n..
         5764  +|   3888: 04 01 10 01 02 31 62 10 08 04 01 10 01 02 31 32   .....1b.......12
         5765  +|   3904: 0e 0b 04 01 16 01 02 30 74 68 65 72 0c 08 04 01   .......0ther....
         5766  +|   3920: 10 01 02 30 74 0a 08 04 01 10 01 02 30 6e 08 08   ...0t.......0n..
         5767  +|   3936: 04 01 10 01 02 30 62 06 08 04 01 10 01 02 30 61   .....0b.......0a
         5768  +|   3952: 04 06 04 01 0c 01 02 02 07 04 09 10 01 34 74 22   .............4t.
         5769  +|   3968: 06 04 09 0e 01 34 20 08 04 09 12 01 33 74 65 1e   .....4 .....3te.
         5770  +|   3984: 07 04 09 10 01 33 70 1c 07 04 09 10 01 33 66 1a   .....3p......3f.
         5771  +|   4000: 08 04 09 12 01 32 74 68 18 07 04 09 10 01 32 74   .....2th......2t
         5772  +|   4016: 16 07 04 09 10 01 32 69 14 07 04 09 10 01 32 66   ......2i......2f
         5773  +|   4032: 12 07 04 09 10 01 31 74 10 07 04 09 10 01 31 69   ......1t......1i
         5774  +|   4048: 0e 06 04 09 0e 01 31 0c 08 04 09 12 01 30 74 65   ......1......0te
         5775  +|   4064: 0a 07 04 09 10 01 30 74 08 07 04 09 10 01 30 70   ......0t......0p
         5776  +|   4080: 06 08 04 09 12 01 30 66 74 04 05 04 09 0c 01 02   ......0ft.......
         5777  +| page 4 offset 12288
         5778  +|      0: 0d 00 00 00 03 0f eb 00 0f f9 0f f2 0f eb 00 00   ................
         5779  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10   ................
         5780  +|   4080: 03 05 05 02 03 00 10 04 06 05 01 03 00 10 04 04   ................
         5781  +| page 5 offset 16384
         5782  +|      0: 0a 00 00 00 02 0f eb 00 0f eb 0f f4 00 00 00 00   ................
         5783  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 08 03 15 01 70   ...............p
         5784  +|   4080: 67 73 7a 18 0b 03 1b 01 76 65 72 73 69 6f 6e 04   gsz.....version.
         5785  +| page 6 offset 20480
         5786  +|      0: 0d 00 00 00 03 0f f2 00 0f fc 0f f7 0f f2 00 00   ................
         5787  +|   4080: 00 00 03 03 02 01 03 03 02 02 01 02 02 01 02 09   ................
         5788  +| end 89028ffd2c29b679e250.db
         5789  +}]} {}
         5790  +
         5791  +do_catchsql_test 43.1 {
         5792  +  INSERT INTO t1(t1) VALUES('optimize');
         5793  +} {1 {database disk image is malformed}}
         5794  +
         5795  +#-------------------------------------------------------------------------
         5796  +reset_db
         5797  +do_execsql_test 44.1 {
         5798  +  CREATE VIRTUAL TABLE t1 USING fts5(a,b unindexed,c,tokenize="porter ascii");
         5799  +  REPLACE INTO t1_data VALUES(1,X'03090009');
         5800  +  REPLACE INTO t1_data VALUES(10,X'000000000103030003010101020101030101');
         5801  +  INSERT INTO t1_data VALUES(137438953473,X'0000002e023061011202010162010203010163010204010167010601020201016801050102030101690106010204040606060808');
         5802  +  INSERT INTO t1_data VALUES(274877906945,X'0000001f02306702080201020201016802080301020301016a420804010204040909');
         5803  +  INSERT INTO t1_data VALUES(412316860417,X'0000002e023061030202010162030203010163030204010167030601020201016803060102030101690306010204040606060808');
         5804  +  INSERT INTO t1_idx VALUES(1,X'',2);
         5805  +  INSERT INTO t1_idx VALUES(2,X'',2);
         5806  +  INSERT INTO t1_idx VALUES(3,X'',2);
         5807  +  INSERT INTO t1_content VALUES(1,'a b c','d e f','g h i');
         5808  +  INSERT INTO t1_content VALUES(2,'g h i','a b c','g h i');
         5809  +  INSERT INTO t1_content VALUES(3,'a b c','g h i','g h i');
         5810  +  INSERT INTO t1_docsize VALUES(1,X'030003');
         5811  +  INSERT INTO t1_docsize VALUES(2,X'030003');
         5812  +  INSERT INTO t1_docsize VALUES(3,X'030003');
         5813  +} {}
         5814  +
         5815  +do_catchsql_test 44.2 {
         5816  +INSERT INTO t1(t1) VALUES('integrity-check');
         5817  +} {1 {database disk image is malformed}}
         5818  +
         5819  +do_catchsql_test 44.2 {
         5820  +  SELECT snippet(t1, -1, '.', '..', '', 2 ) FROM t1('g h') ORDER BY rank; 
         5821  +} {1 {database disk image is malformed}}
         5822  +
         5823  +#--------------------------------------------------------------------------
         5824  +reset_db
         5825  +do_test 45.0 {
         5826  +  sqlite3 db {}
         5827  +  db deserialize [decode_hexdb {
         5828  +| size 24576 pagesize 4096 filename crash-0b162c9e69b999.db
         5829  +| page 1 offset 0
         5830  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         5831  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06   .....@  ........
         5832  +|     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
         5833  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         5834  +|     96: 00 00 00 00 0d 00 00 00 06 0e 0f 00 0f aa 0f 53   ...............S
         5835  +|    112: 0e e8 0e 8b 0e 33 0e 0f 00 00 00 00 00 00 00 00   .....3..........
         5836  +|   3584: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22   ................
         5837  +|   3600: 06 06 17 11 11 01 31 74 61 62 6c 65 62 62 62 62   ......1tablebbbb
         5838  +|   3616: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 62 62   .CREATE TABLE bb
         5839  +|   3632: 28 61 29 56 05 06 17 1f 1f 01 7d 74 61 52 6c 65   (a)V.......taRle
         5840  +|   3648: 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63 6f 6e 66   t1_configt1_conf
         5841  +|   3664: 69 67 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   ig.CREATE TABLE 
         5842  +|   3680: 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b 20 50 52   't1_config'(k PR
         5843  +|   3696: 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 57 49   IMARY KEY, v) WI
         5844  +|   3712: 54 48 4f 55 54 20 52 4f 57 49 44 5b 04 07 17 21   THOUT ROWID[...!
         5845  +|   3728: 21 01 81 01 74 61 62 6c 65 74 31 5f 64 6f 73 73   !...tablet1_doss
         5846  +|   3744: 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65 04 43 52   izet1_docsize.CR
         5847  +|   3760: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 64   EATE TABLE 't1_d
         5848  +|   3776: 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 54 45 47   ocsize'(id INTEG
         5849  +|   3792: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         5850  +|   3808: 73 7a 20 42 4c 4f 42 29 69 03 07 17 19 19 01 81   sz BLOB)i.......
         5851  +|   3824: 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 5f 69   -tablet1_idxt1_i
         5852  +|   3840: 64 78 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   dx.CREATE TABLE 
         5853  +|   3856: 27 74 31 5f 69 64 78 27 28 73 65 67 69 64 2c 20   't1_idx'(segid, 
         5854  +|   3872: 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50 52 49 4d   term, pgno, PRIM
         5855  +|   3888: 41 52 59 20 4b 45 59 28 73 65 67 69 64 2c 20 74   ARY KEY(segid, t
         5856  +|   3904: 65 72 6d 29 29 20 57 49 54 48 4f 55 54 20 52 4f   erm)) WITHOUT RO
         5857  +|   3920: 57 49 44 55 02 07 17 1b 1b 01 81 01 74 61 62 6c   WIDU........tabl
         5858  +|   3936: 65 74 31 5f 64 61 74 61 74 31 5f 64 61 74 61 02   et1_datat1_data.
         5859  +|   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31   CREATE TABLE 't1
         5860  +|   3968: 5f 64 61 74 61 27 28 69 64 20 49 4e 54 45 47 45   _data'(id INTEGE
         5861  +|   3984: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62   R PRIMARY KEY, b
         5862  +|   4000: 6c 6f 63 6b 20 42 4c 4f 42 29 54 01 07 17 11 11   lock BLOB)T.....
         5863  +|   4016: 08 81 15 74 61 62 6c 65 74 31 74 31 43 52 45 41   ...tablet1t1CREA
         5864  +|   4032: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45   TE VIRTUAL TABLE
         5865  +|   4048: 20 74 31 20 55 53 49 4e 47 20 66 74 73 35 28 61    t1 USING fts5(a
         5866  +|   4064: 2c 62 2c 70 72 65 66 69 78 3d 22 31 2c 32 2c 33   ,b,prefix=.1,2,3
         5867  +|   4080: 2c 34 22 2c 20 63 6f 6e 74 65 6e 74 3d 22 22 29   ,4., content=..)
         5868  +| page 2 offset 4096
         5869  +|      0: 0d 0b 6a 00 37 09 4c 02 0f e7 09 4c 0f c6 0f a4   ..j.7.L....L....
         5870  +|     16: 0f 88 0f 6d 0f 4b 0f 2c 0f 0e 0e ec 0e cd 0e ad   ...m.K.,........
         5871  +|     32: 0e 8e 0e 6c 0e 4b 0e 29 0e 08 0d e6 0d c4 0d b5   ...l.K.)........
         5872  +|     48: 0d 97 0d 76 0d 54 0d 31 0d 15 0c f3 0c d3 0c b5   ...v.T.1........
         5873  +|     64: 0c 95 0c 73 0c 54 0c 32 0c 10 0b ee 0b cc 0b b0   ...s.T.2........
         5874  +|     80: 0b 8d 0b 7e 0b 48 0b 2e 0b 0b 0a ef 0a cc 0a ad   ...~.H..........
         5875  +|     96: 0a 8c 0a 6d 0a 4d 0a 2b 0a 0c 09 ec 09 ca 09 a8   ...m.M.+........
         5876  +|    112: 09 86 09 63 0f f1 00 00 00 00 00 00 00 00 00 00   ...c............
         5877  +|   2368: 00 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00   ................
         5878  +|   2384: 30 00 00 00 01 01 03 35 00 03 01 01 12 02 01 12   0......5........
         5879  +|   2400: 03 01 11 1c 8c 80 80 80 80 10 03 00 3e 00 00 00   ............>...
         5880  +|   2416: 17 01 05 05 34 74 61 62 6c 03 02 03 01 04 77 68   ....4tabl.....wh
         5881  +|   2432: 65 72 03 02 06 09 1b 8c 80 80 80 80 0f 03 00 3c   er.............<
         5882  +|   2448: 00 00 00 16 05 34 66 75 73 34 03 02 02 01 04 6e   .....4fus4.....n
         5883  +|   2464: 75 6d 62 03 06 01 04 09 1b 8c 80 80 80 80 0e 03   umb.............
         5884  +|   2480: 00 3c 00 00 00 16 04 33 74 68 65 03 06 01 01 04   .<.....3the.....
         5885  +|   2496: 01 03 77 68 65 03 02 04 04 0a 1b 8c 80 80 80 80   ..whe...........
         5886  +|   2512: 0d 03 00 3c 00 00 00 16 04 33 6e 74 6d 03 06 01   ...<.....3ntm...
         5887  +|   2528: 01 05 01 03 74 61 62 05 62 03 04 0a 19 8c 80 80   ....tab.b.......
         5888  +|   2544: 80 80 0c 03 00 38 00 00 00 14 03 32 77 68 03 02   .....8.....2wh..
         5889  +|   2560: 04 00 04 33 66 74 73 03 02 02 04 07 18 8c 80 80   ...3fts.........
         5890  +|   2576: 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 03 02   .....6.....2ta..
         5891  +|   2592: 03 02 01 68 03 06 01 01 04 04 07 1b 8c 80 80 80   ...h............
         5892  +|   2608: 80 0a 03 00 3c 00 00 00 16 03 32 6e 75 03 06 01   ....<.....2nu...
         5893  +|   2624: 01 05 01 02 6f 66 03 06 01 01 06 04 09 19 8c 80   ....of..........
         5894  +|   2640: 80 80 80 09 03 00 38 00 00 00 14 03 32 66 74 03   ......8.....2ft.
         5895  +|   2656: 02 02 01 02 69 73 03 06 01 01 03 04 07 18 8c 80   ....is..........
         5896  +|   2672: 80 80 80 08 03 00 36 00 00 00 13 02 31 74 03 08   ......6.....1t..
         5897  +|   2688: 03 01 01 04 01 01 77 03 02 04 04 09 1a 8c 80 80   ......w.........
         5898  +|   2704: 80 80 07 03 00 3a ff 00 00 15 02 31 6e 03 08 01   .....:.....1n...
         5899  +|   2720: 01 02 05 01 01 6f 03 06 01 01 06 04 09 18 8c 80   .....o..........
         5900  +|   2736: 80 80 80 06 03 00 36 00 00 00 13 04 02 31 66 03   ......6......1f.
         5901  +|   2752: 02 02 01 01 69 03 06 01 01 03 05 06 1c 8c 80 80   ....i...........
         5902  +|   2768: 80 80 05 03 00 3e 00 00 00 17 04 30 74 68 65 03   .....>.....0the.
         5903  +|   2784: 06 01 01 04 01 05 77 68 65 72 65 03 02 04 0a 15   ......where.....
         5904  +|   2800: 8c 80 80 80 80 04 03 00 30 00 00 00 11 01 01 06   ........0.......
         5905  +|   2816: 06 30 74 61 62 6c 65 03 02 03 07 1c 8c 80 80 80   .0table.........
         5906  +|   2832: 80 03 03 00 3e 00 00 00 17 07 30 6e 75 6d 62 65   ....>.....0numbe
         5907  +|   2848: 72 03 06 01 01 05 01 02 6f 66 03 06 04 0d 13 8c   r.......of......
         5908  +|   2864: 80 80 80 80 02 03 00 2c 00 00 00 0f 01 01 03 02   .......,........
         5909  +|   2880: 30 6e 03 06 01 01 02 07 1b 8c 80 80 80 80 01 03   0n..............
         5910  +|   2896: 00 3c 00 00 00 16 08 30 66 74 73 34 61 75 78 03   .<.....0fts4aux.
         5911  +|   2912: 02 02 01 02 69 73 03 06 04 0c 00 00 00 14 2a 00   ....is........*.
         5912  +|   2928: 00 00 01 01 02 24 00 02 01 01 12 02 01 12 08 88   .....$..........
         5913  +|   2944: 80 80 80 80 11 03 00 16 00 00 01 05 02 1c 88 80   ................
         5914  +|   2960: 80 80 80 11 03 00 3e 00 00 00 17 05 34 72 6f 77   ......>.....4row
         5915  +|   2976: 73 02 06 01 01 05 01 04 74 68 65 72 02 02 04 0b   s.......ther....
         5916  +|   2992: 15 88 80 80 80 80 10 03 00 30 00 00 00 11 02 01   .........0......
         5917  +|   3008: 01 07 05 34 62 65 74 77 02 02 04 08 1b 88 80 80   ...4betw........
         5918  +|   3024: 80 80 0f 03 00 3c 00 00 00 16 04 04 33 72 6f 77   .....<......3row
         5919  +|   3040: 02 06 01 01 05 01 03 74 68 65 02 08 05 0a 1b 88   .......the......
         5920  +|   3056: 80 80 80 80 0e 03 00 3c 00 00 00 16 02 01 02 04   .......<........
         5921  +|   3072: 33 61 72 65 02 02 03 01 03 62 65 74 02 02 07 08   3are.....bet....
         5922  +|   3088: 1b 88 80 80 80 80 0d 03 00 3c 00 00 00 16 03 32   .........<.....2
         5923  +|   3104: 74 68 02 08 02 01 01 07 00 04 33 61 6e 64 02 06   th........3and..
         5924  +|   3120: 04 0a 1b 88 80 80 80 80 0c 03 00 3c 00 00 00 16   ...........<....
         5925  +|   3136: 03 32 69 6e 02 06 01 01 06 01 02 72 6f 02 06 01   .2in.......ro...
         5926  +|   3152: 01 05 04 09 18 88 80 80 80 80 0b 03 00 36 00 00   .............6..
         5927  +|   3168: 00 13 02 03 32 61 72 02 02 03 01 02 62 65 02 02   ....2ar.....be..
         5928  +|   3184: 04 05 07 1b 88 80 80 80 80 0a 03 00 3c 00 00 00   ............<...
         5929  +|   3200: 16 02 31 74 02 08 02 01 01 07 00 03 32 61 6e 02   ..1t........2an.
         5930  +|   3216: 06 01 01 04 09 19 88 80 80 80 80 09 03 00 38 00   ..............8.
         5931  +|   3232: 00 00 14 02 31 6e 02 06 01 01 03 01 01 72 02 06   ....1n.......r..
         5932  +|   3248: 01 01 05 04 08 17 88 80 80 80 80 08 03 00 34 00   ..............4.
         5933  +|   3264: 00 00 12 02 31 62 02 02 04 01 01 69 02 06 01 01   ....1b.....i....
         5934  +|   3280: 06 04 06 19 88 80 80 80 80 07 03 00 38 00 00 00   ............8...
         5935  +|   3296: 14 04 02 31 32 02 02 05 01 01 61 02 08 03 01 01   ...12.....a.....
         5936  +|   3312: 02 05 06 1b 88 80 80 80 80 06 03 00 3c 00 00 00   ............<...
         5937  +|   3328: 16 06 30 74 68 65 72 65 02 02 02 00 02 31 31 02   ..0there.....11.