/ Check-in [475a179a]
Login

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

Overview
Comment:Sync up with the latest enhancements on trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA3-256:475a179a276df37262435b5c5dcb6ab890ef086e218ebc2dd9157e5a4550f2f0
User & Date: drh 2019-01-17 15:47:01
Context
2019-01-29
19:17
Merge enhancements from trunk. check-in: 31efcc37 user: drh tags: apple-osx
2019-01-17
15:47
Sync up with the latest enhancements on trunk. check-in: 475a179a user: drh tags: apple-osx
15:40
Revamp the SrcList allocator routines to be methods of Parse instead of being methods of the "sqlite3" object, so that they can leave better error messages when the SrcList object grows too large. check-in: df08d472 user: drh tags: trunk
2018-12-10
02:00
Merge enhancements from trunk. check-in: b1bbc718 user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   451    451     $(TOP)/ext/fts5/fts5_test_mi.c \
   452    452     $(TOP)/ext/fts5/fts5_test_tok.c \
   453    453     $(TOP)/ext/misc/ieee754.c \
   454    454     $(TOP)/ext/misc/mmapwarm.c \
   455    455     $(TOP)/ext/misc/nextchar.c \
   456    456     $(TOP)/ext/misc/normalize.c \
   457    457     $(TOP)/ext/misc/percentile.c \
          458  +  $(TOP)/ext/misc/prefixes.c \
   458    459     $(TOP)/ext/misc/regexp.c \
   459    460     $(TOP)/ext/misc/remember.c \
   460    461     $(TOP)/ext/misc/series.c \
   461    462     $(TOP)/ext/misc/spellfix.c \
   462    463     $(TOP)/ext/misc/totype.c \
   463    464     $(TOP)/ext/misc/unionvtab.c \
   464    465     $(TOP)/ext/misc/wholenumber.c \
................................................................................
   678    679   	$(LTLINK) -o $@ $(FUZZCHECK_OPT) $(FUZZCHECK_SRC) sqlite3.c $(TLIBS)
   679    680   
   680    681   ossshell$(TEXE):	$(TOP)/test/ossfuzz.c $(TOP)/test/ossshell.c sqlite3.c sqlite3.h
   681    682   	$(LTLINK) -o $@ $(FUZZCHECK_OPT) $(TOP)/test/ossshell.c \
   682    683                $(TOP)/test/ossfuzz.c sqlite3.c $(TLIBS)
   683    684   
   684    685   sessionfuzz$(TEXE):	$(TOP)/test/sessionfuzz.c sqlite3.c sqlite3.h
   685         -	$(CC) $(CFLAGS) -I. -o $@ $(TOP)/test/sessionfuzz.c $(TLIBS)
          686  +	$(LTLINK) -o $@ $(TOP)/test/sessionfuzz.c $(TLIBS)
   686    687   
   687    688   dbfuzz$(TEXE):	$(TOP)/test/dbfuzz.c sqlite3.c sqlite3.h
   688    689   	$(LTLINK) -o $@ $(DBFUZZ_OPT) $(TOP)/test/dbfuzz.c sqlite3.c $(TLIBS)
   689    690   
   690    691   DBFUZZ2_OPTS = \
   691    692     -DSQLITE_THREADSAFE=0 \
   692    693     -DSQLITE_OMIT_LOAD_EXTENSION \
   693    694     -DSQLITE_ENABLE_DESERIALIZE \
   694    695     -DSQLITE_DEBUG \
   695    696     -DSQLITE_ENABLE_DBSTAT_VTAB \
   696    697     -DSQLITE_ENABLE_RTREE \
   697    698     -DSQLITE_ENABLE_FTS4 \
   698         -  -DSQLITE_EANBLE_FTS5
          699  +  -DSQLITE_ENABLE_FTS5
   699    700   
   700         -dbfuzz2:	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
   701         -	clang-6.0 -I. -g -O0 -fsanitize=fuzzer,undefined,address -o dbfuzz2 \
   702         -		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c
          701  +dbfuzz2$(TEXE):	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
          702  +	$(CC) $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
          703  +		-DSTANDALONE -o dbfuzz2 \
          704  +		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
          705  +	mkdir -p dbfuzz2-dir
          706  +	cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
          707  +
          708  +dbfuzz2-asan:	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
          709  +	clang-6.0 $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
          710  +		-fsanitize=fuzzer,undefined,address -o dbfuzz2-asan \
          711  +		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
          712  +	mkdir -p dbfuzz2-dir
          713  +	cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
          714  +
          715  +dbfuzz2-msan:	$(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
          716  +	clang-6.0 $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
          717  +		-fsanitize=fuzzer,undefined,memory -o dbfuzz2-msan \
          718  +		$(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
   703    719   	mkdir -p dbfuzz2-dir
   704    720   	cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
   705    721   
   706    722   mptester$(TEXE):	sqlite3.lo $(TOP)/mptest/mptest.c
   707    723   	$(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.lo \
   708    724   		$(TLIBS) -rpath "$(libdir)"
   709    725   
................................................................................
  1198   1214   TESTFIXTURE_FLAGS += -DTCLSH_INIT_PROC=sqlite3TestInit
  1199   1215   TESTFIXTURE_FLAGS += -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE
  1200   1216   TESTFIXTURE_FLAGS += -DBUILD_sqlite
  1201   1217   TESTFIXTURE_FLAGS += -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
  1202   1218   TESTFIXTURE_FLAGS += -DSQLITE_DEFAULT_PAGE_SIZE=1024
  1203   1219   TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_STMTVTAB
  1204   1220   TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DBPAGE_VTAB
         1221  +TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DESERIALIZE
  1205   1222   
  1206   1223   TESTFIXTURE_SRC0 = $(TESTSRC2) libsqlite3.la
  1207   1224   TESTFIXTURE_SRC1 = sqlite3.c
  1208   1225   TESTFIXTURE_SRC = $(TESTSRC) $(TOP)/src/tclsqlite.c
  1209   1226   TESTFIXTURE_SRC += $(TESTFIXTURE_SRC$(USE_AMALGAMATION))
  1210   1227   
  1211   1228   testfixture$(TEXE):	$(TESTFIXTURE_SRC)
................................................................................
  1299   1316   
  1300   1317   sqlite3_checker$(TEXE):	sqlite3_checker.c
  1301   1318   	$(LTLINK) sqlite3_checker.c -o $@ $(LIBTCL) $(TLIBS)
  1302   1319   
  1303   1320   dbdump$(TEXE): $(TOP)/ext/misc/dbdump.c sqlite3.lo
  1304   1321   	$(LTLINK) -DDBDUMP_STANDALONE -o $@ \
  1305   1322              $(TOP)/ext/misc/dbdump.c sqlite3.lo $(TLIBS)
         1323  +
         1324  +dbtotxt$(TEXE): $(TOP)/tool/dbtotxt.c
         1325  +	$(LTLINK)-o $@ $(TOP)/tool/dbtotxt.c
  1306   1326   
  1307   1327   showdb$(TEXE):	$(TOP)/tool/showdb.c sqlite3.lo
  1308   1328   	$(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.lo $(TLIBS)
  1309   1329   
  1310   1330   showstat4$(TEXE):	$(TOP)/tool/showstat4.c sqlite3.lo
  1311   1331   	$(LTLINK) -o $@ $(TOP)/tool/showstat4.c sqlite3.lo $(TLIBS)
  1312   1332   

Changes to Makefile.msc.

  1523   1523     $(TOP)\ext\fts5\fts5_test_mi.c \
  1524   1524     $(TOP)\ext\fts5\fts5_test_tok.c \
  1525   1525     $(TOP)\ext\misc\ieee754.c \
  1526   1526     $(TOP)\ext\misc\mmapwarm.c \
  1527   1527     $(TOP)\ext\misc\nextchar.c \
  1528   1528     $(TOP)\ext\misc\normalize.c \
  1529   1529     $(TOP)\ext\misc\percentile.c \
         1530  +  $(TOP)\ext\misc\prefixes.c \
  1530   1531     $(TOP)\ext\misc\regexp.c \
  1531   1532     $(TOP)\ext\misc\remember.c \
  1532   1533     $(TOP)\ext\misc\series.c \
  1533   1534     $(TOP)\ext\misc\spellfix.c \
  1534   1535     $(TOP)\ext\misc\totype.c \
  1535   1536     $(TOP)\ext\misc\unionvtab.c \
  1536   1537     $(TOP)\ext\misc\wholenumber.c
................................................................................
  2294   2295   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE=""
  2295   2296   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_CORE $(NO_WARN)
  2296   2297   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
  2297   2298   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_DEFAULT_PAGE_SIZE=1024
  2298   2299   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
  2299   2300   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
  2300   2301   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
         2302  +TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1
  2301   2303   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS)
  2302   2304   
  2303   2305   TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2)
  2304   2306   TESTFIXTURE_SRC1 = $(TESTEXT) $(SQLITE3C)
  2305   2307   !IF $(USE_AMALGAMATION)==0
  2306   2308   TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0)
  2307   2309   !ELSE
................................................................................
  2421   2423   
  2422   2424   testloadext.lo:	$(TOP)\src\test_loadext.c $(SQLITE3H)
  2423   2425   	$(LTCOMPILE) $(NO_WARN) -c $(TOP)\src\test_loadext.c
  2424   2426   
  2425   2427   testloadext.dll:	testloadext.lo
  2426   2428   	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ testloadext.lo
  2427   2429   
         2430  +dbtotxt.exe:	$(TOP)\tool\dbtotxt.c
         2431  +	$(LTLINK) $(NO_WARN)	$(TOP)\tool\dbtotxt.c /link $(LDFLAGS) $(LTLINKOPTS)
         2432  +
  2428   2433   showdb.exe:	$(TOP)\tool\showdb.c $(SQLITE3C) $(SQLITE3H)
  2429   2434   	$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
  2430   2435   		$(TOP)\tool\showdb.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  2431   2436   
  2432   2437   showstat4.exe:	$(TOP)\tool\showstat4.c $(SQLITE3C) $(SQLITE3H)
  2433   2438   	$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
  2434   2439   		$(TOP)\tool\showstat4.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)

Changes to ext/expert/expert1.test.

   239    239     CREATE TABLE t7(a, b);
   240    240   } {
   241    241     SELECT * FROM t7 WHERE a=? OR b=?
   242    242   } {
   243    243     CREATE INDEX t7_idx_00000062 ON t7(b);
   244    244     CREATE INDEX t7_idx_00000061 ON t7(a);
   245    245     MULTI-INDEX OR
   246         -    SEARCH TABLE t7 USING INDEX t7_idx_00000061 (a=?) 
   247         -    SEARCH TABLE t7 USING INDEX t7_idx_00000062 (b=?)
          246  +    INDEX 1
          247  +      SEARCH TABLE t7 USING INDEX t7_idx_00000061 (a=?) 
          248  +    INDEX 2
          249  +      SEARCH TABLE t7 USING INDEX t7_idx_00000062 (b=?)
   248    250   }
   249    251   
   250    252   # rowid terms.
   251    253   #
   252    254   do_setup_rec_test $tn.13.1 {
   253    255     CREATE TABLE t8(a, b);
   254    256   } {

Changes to ext/fts3/fts3.c.

   334    334     }while( vu!=0 );
   335    335     q[-1] &= 0x7f;  /* turn off high bit in final byte */
   336    336     assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );
   337    337     return (int) (q - (unsigned char *)p);
   338    338   }
   339    339   
   340    340   #define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \
   341         -  v = (v & mask1) | ( (*ptr++) << shift );                    \
          341  +  v = (v & mask1) | ( (*(const unsigned char*)(ptr++)) << shift );  \
   342    342     if( (v & mask2)==0 ){ var = v; return ret; }
   343    343   #define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
   344    344     v = (*ptr++);                                               \
   345    345     if( (v & mask2)==0 ){ var = v; return ret; }
   346    346   
   347    347   /* 
   348    348   ** Read a 64-bit variable-length integer from memory starting at p[0].
................................................................................
   372    372   }
   373    373   
   374    374   /*
   375    375   ** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to 
   376    376   ** a non-negative 32-bit integer before it is returned.
   377    377   */
   378    378   int sqlite3Fts3GetVarint32(const char *p, int *pi){
          379  +  const unsigned char *ptr = (const unsigned char*)p;
   379    380     u32 a;
   380    381   
   381    382   #ifndef fts3GetVarint32
   382         -  GETVARINT_INIT(a, p, 0,  0x00,     0x80, *pi, 1);
          383  +  GETVARINT_INIT(a, ptr, 0,  0x00,     0x80, *pi, 1);
   383    384   #else
   384         -  a = (*p++);
          385  +  a = (*ptr++);
   385    386     assert( a & 0x80 );
   386    387   #endif
   387    388   
   388         -  GETVARINT_STEP(a, p, 7,  0x7F,     0x4000, *pi, 2);
   389         -  GETVARINT_STEP(a, p, 14, 0x3FFF,   0x200000, *pi, 3);
   390         -  GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);
          389  +  GETVARINT_STEP(a, ptr, 7,  0x7F,     0x4000, *pi, 2);
          390  +  GETVARINT_STEP(a, ptr, 14, 0x3FFF,   0x200000, *pi, 3);
          391  +  GETVARINT_STEP(a, ptr, 21, 0x1FFFFF, 0x10000000, *pi, 4);
   391    392     a = (a & 0x0FFFFFFF );
   392         -  *pi = (int)(a | ((u32)(*p & 0x07) << 28));
          393  +  *pi = (int)(a | ((u32)(*ptr & 0x07) << 28));
   393    394     assert( 0==(a & 0x80000000) );
   394    395     assert( *pi>=0 );
   395    396     return 5;
   396    397   }
   397    398   
   398    399   /*
   399    400   ** Return the number of bytes required to encode v as a varint
................................................................................
   794    795   **     fts3QuoteId("un \"zip\"")   ->    "un \"\"zip\"\""
   795    796   **
   796    797   ** The pointer returned points to memory obtained from sqlite3_malloc(). It
   797    798   ** is the callers responsibility to call sqlite3_free() to release this
   798    799   ** memory.
   799    800   */
   800    801   static char *fts3QuoteId(char const *zInput){
   801         -  int nRet;
          802  +  sqlite3_int64 nRet;
   802    803     char *zRet;
   803    804     nRet = 2 + (int)strlen(zInput)*2 + 1;
   804         -  zRet = sqlite3_malloc(nRet);
          805  +  zRet = sqlite3_malloc64(nRet);
   805    806     if( zRet ){
   806    807       int i;
   807    808       char *z = zRet;
   808    809       *(z++) = '"';
   809    810       for(i=0; zInput[i]; i++){
   810    811         if( zInput[i]=='"' ) *(z++) = '"';
   811    812         *(z++) = zInput[i];
................................................................................
   978    979       const char *p;
   979    980       nIndex++;
   980    981       for(p=zParam; *p; p++){
   981    982         if( *p==',' ) nIndex++;
   982    983       }
   983    984     }
   984    985   
   985         -  aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
          986  +  aIndex = sqlite3_malloc64(sizeof(struct Fts3Index) * nIndex);
   986    987     *apIndex = aIndex;
   987    988     if( !aIndex ){
   988    989       return SQLITE_NOMEM;
   989    990     }
   990    991   
   991    992     memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);
   992    993     if( zParam ){
................................................................................
  1057   1058         sqlite3Fts3ErrMsg(pzErr, "%s", sqlite3_errmsg(db));
  1058   1059       }
  1059   1060     }
  1060   1061     sqlite3_free(zSql);
  1061   1062   
  1062   1063     if( rc==SQLITE_OK ){
  1063   1064       const char **azCol;           /* Output array */
  1064         -    int nStr = 0;                 /* Size of all column names (incl. 0x00) */
         1065  +    sqlite3_int64 nStr = 0;       /* Size of all column names (incl. 0x00) */
  1065   1066       int nCol;                     /* Number of table columns */
  1066   1067       int i;                        /* Used to iterate through columns */
  1067   1068   
  1068   1069       /* Loop through the returned columns. Set nStr to the number of bytes of
  1069   1070       ** space required to store a copy of each column name, including the
  1070   1071       ** nul-terminator byte.  */
  1071   1072       nCol = sqlite3_column_count(pStmt);
  1072   1073       for(i=0; i<nCol; i++){
  1073   1074         const char *zCol = sqlite3_column_name(pStmt, i);
  1074         -      nStr += (int)strlen(zCol) + 1;
         1075  +      nStr += strlen(zCol) + 1;
  1075   1076       }
  1076   1077   
  1077   1078       /* Allocate and populate the array to return. */
  1078         -    azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
         1079  +    azCol = (const char **)sqlite3_malloc64(sizeof(char *) * nCol + nStr);
  1079   1080       if( azCol==0 ){
  1080   1081         rc = SQLITE_NOMEM;
  1081   1082       }else{
  1082   1083         char *p = (char *)&azCol[nCol];
  1083   1084         for(i=0; i<nCol; i++){
  1084   1085           const char *zCol = sqlite3_column_name(pStmt, i);
  1085   1086           int n = (int)strlen(zCol)+1;
................................................................................
  1119   1120     sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */
  1120   1121     char **pzErr                    /* Write any error message here */
  1121   1122   ){
  1122   1123     Fts3Hash *pHash = (Fts3Hash *)pAux;
  1123   1124     Fts3Table *p = 0;               /* Pointer to allocated vtab */
  1124   1125     int rc = SQLITE_OK;             /* Return code */
  1125   1126     int i;                          /* Iterator variable */
  1126         -  int nByte;                      /* Size of allocation used for *p */
         1127  +  sqlite3_int64 nByte;            /* Size of allocation used for *p */
  1127   1128     int iCol;                       /* Column index */
  1128   1129     int nString = 0;                /* Bytes required to hold all column names */
  1129   1130     int nCol = 0;                   /* Number of columns in the FTS table */
  1130   1131     char *zCsr;                     /* Space for holding column names */
  1131   1132     int nDb;                        /* Bytes required to hold database name */
  1132   1133     int nName;                      /* Bytes required to hold table name */
  1133   1134     int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
................................................................................
  1153   1154          || (sqlite3_strnicmp(argv[0], "fts3", 4)==0 && !isFts4)
  1154   1155     );
  1155   1156   
  1156   1157     nDb = (int)strlen(argv[1]) + 1;
  1157   1158     nName = (int)strlen(argv[2]) + 1;
  1158   1159   
  1159   1160     nByte = sizeof(const char *) * (argc-2);
  1160         -  aCol = (const char **)sqlite3_malloc(nByte);
         1161  +  aCol = (const char **)sqlite3_malloc64(nByte);
  1161   1162     if( aCol ){
  1162   1163       memset((void*)aCol, 0, nByte);
  1163         -    azNotindexed = (char **)sqlite3_malloc(nByte);
         1164  +    azNotindexed = (char **)sqlite3_malloc64(nByte);
  1164   1165     }
  1165   1166     if( azNotindexed ){
  1166   1167       memset(azNotindexed, 0, nByte);
  1167   1168     }
  1168   1169     if( !aCol || !azNotindexed ){
  1169   1170       rc = SQLITE_NOMEM;
  1170   1171       goto fts3_init_out;
................................................................................
  1351   1352     nByte = sizeof(Fts3Table) +                  /* Fts3Table */
  1352   1353             nCol * sizeof(char *) +              /* azColumn */
  1353   1354             nIndex * sizeof(struct Fts3Index) +  /* aIndex */
  1354   1355             nCol * sizeof(u8) +                  /* abNotindexed */
  1355   1356             nName +                              /* zName */
  1356   1357             nDb +                                /* zDb */
  1357   1358             nString;                             /* Space for azColumn strings */
  1358         -  p = (Fts3Table*)sqlite3_malloc(nByte);
         1359  +  p = (Fts3Table*)sqlite3_malloc64(nByte);
  1359   1360     if( p==0 ){
  1360   1361       rc = SQLITE_NOMEM;
  1361   1362       goto fts3_init_out;
  1362   1363     }
  1363   1364     memset(p, 0, nByte);
  1364   1365     p->db = db;
  1365   1366     p->nColumn = nCol;
................................................................................
  2259   2260         sqlite3_int64 iPos2 = 0;
  2260   2261   
  2261   2262         if( iCol1 ){
  2262   2263           *p++ = POS_COLUMN;
  2263   2264           p += sqlite3Fts3PutVarint(p, iCol1);
  2264   2265         }
  2265   2266   
  2266         -      assert( *p1!=POS_END && *p1!=POS_COLUMN );
  2267         -      assert( *p2!=POS_END && *p2!=POS_COLUMN );
  2268   2267         fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
  2269   2268         fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
         2269  +      if( iPos1<0 || iPos2<0 ) break;
  2270   2270   
  2271   2271         while( 1 ){
  2272   2272           if( iPos2==iPos1+nToken 
  2273   2273            || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) 
  2274   2274           ){
  2275   2275             sqlite3_int64 iSave;
  2276   2276             iSave = isSaveLeft ? iPos1 : iPos2;
................................................................................
  2531   2531     ** The space required to store the output is therefore the sum of the
  2532   2532     ** sizes of the two inputs, plus enough space for exactly one of the input
  2533   2533     ** docids to grow. 
  2534   2534     **
  2535   2535     ** A symetric argument may be made if the doclists are in descending 
  2536   2536     ** order.
  2537   2537     */
  2538         -  aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);
         2538  +  aOut = sqlite3_malloc64((sqlite3_int64)n1+n2+FTS3_VARINT_MAX-1);
  2539   2539     if( !aOut ) return SQLITE_NOMEM;
  2540   2540   
  2541   2541     p = aOut;
  2542   2542     fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
  2543   2543     fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
  2544   2544     while( p1 || p2 ){
  2545   2545       sqlite3_int64 iDiff = DOCID_CMP(i1, i2);
................................................................................
  2594   2594     char *p2 = aRight;
  2595   2595     char *p;
  2596   2596     int bFirstOut = 0;
  2597   2597     char *aOut;
  2598   2598   
  2599   2599     assert( nDist>0 );
  2600   2600     if( bDescDoclist ){
  2601         -    aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
         2601  +    aOut = sqlite3_malloc64((sqlite3_int64)*pnRight + FTS3_VARINT_MAX);
  2602   2602       if( aOut==0 ) return SQLITE_NOMEM;
  2603   2603     }else{
  2604   2604       aOut = aRight;
  2605   2605     }
  2606   2606     p = aOut;
  2607   2607   
  2608   2608     fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
................................................................................
  2829   2829   */
  2830   2830   static int fts3SegReaderCursorAppend(
  2831   2831     Fts3MultiSegReader *pCsr, 
  2832   2832     Fts3SegReader *pNew
  2833   2833   ){
  2834   2834     if( (pCsr->nSegment%16)==0 ){
  2835   2835       Fts3SegReader **apNew;
  2836         -    int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
  2837         -    apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);
         2836  +    sqlite3_int64 nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
         2837  +    apNew = (Fts3SegReader **)sqlite3_realloc64(pCsr->apSegment, nByte);
  2838   2838       if( !apNew ){
  2839   2839         sqlite3Fts3SegReaderFree(pNew);
  2840   2840         return SQLITE_NOMEM;
  2841   2841       }
  2842   2842       pCsr->apSegment = apNew;
  2843   2843     }
  2844   2844     pCsr->apSegment[pCsr->nSegment++] = pNew;
................................................................................
  2894   2894         sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);
  2895   2895         sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);
  2896   2896         int nRoot = sqlite3_column_bytes(pStmt, 4);
  2897   2897         char const *zRoot = sqlite3_column_blob(pStmt, 4);
  2898   2898   
  2899   2899         /* If zTerm is not NULL, and this segment is not stored entirely on its
  2900   2900         ** root node, the range of leaves scanned can be reduced. Do this. */
  2901         -      if( iStartBlock && zTerm ){
         2901  +      if( iStartBlock && zTerm && zRoot ){
  2902   2902           sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
  2903   2903           rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
  2904   2904           if( rc!=SQLITE_OK ) goto finished;
  2905   2905           if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;
  2906   2906         }
  2907   2907    
  2908   2908         rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, 
................................................................................
  4611   4611           }
  4612   4612         }
  4613   4613   
  4614   4614         /* Check if the current entries really are a phrase match */
  4615   4615         if( bEof==0 ){
  4616   4616           int nList = 0;
  4617   4617           int nByte = a[p->nToken-1].nList;
  4618         -        char *aDoclist = sqlite3_malloc(nByte+1);
         4618  +        char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING);
  4619   4619           if( !aDoclist ) return SQLITE_NOMEM;
  4620   4620           memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);
         4621  +        memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING);
  4621   4622   
  4622   4623           for(i=0; i<(p->nToken-1); i++){
  4623   4624             if( a[i].bIgnore==0 ){
  4624   4625               char *pL = a[i].pList;
  4625   4626               char *pR = aDoclist;
  4626   4627               char *pOut = aDoclist;
  4627   4628               int nDist = p->nToken-1-i;
................................................................................
  5004   5005     fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
  5005   5006   
  5006   5007     /* Determine which, if any, tokens in the expression should be deferred. */
  5007   5008   #ifndef SQLITE_DISABLE_FTS4_DEFERRED
  5008   5009     if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
  5009   5010       Fts3TokenAndCost *aTC;
  5010   5011       Fts3Expr **apOr;
  5011         -    aTC = (Fts3TokenAndCost *)sqlite3_malloc(
         5012  +    aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
  5012   5013           sizeof(Fts3TokenAndCost) * nToken
  5013   5014         + sizeof(Fts3Expr *) * nOr * 2
  5014   5015       );
  5015   5016       apOr = (Fts3Expr **)&aTC[nToken];
  5016   5017   
  5017   5018       if( !aTC ){
  5018   5019         rc = SQLITE_NOMEM;
................................................................................
  5315   5316     ** no exceptions to this - it's the way the parser in fts3_expr.c works.
  5316   5317     */
  5317   5318     if( *pRc==SQLITE_OK 
  5318   5319      && pExpr->eType==FTSQUERY_NEAR 
  5319   5320      && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
  5320   5321     ){
  5321   5322       Fts3Expr *p; 
  5322         -    int nTmp = 0;                 /* Bytes of temp space */
         5323  +    sqlite3_int64 nTmp = 0;       /* Bytes of temp space */
  5323   5324       char *aTmp;                   /* Temp space for PoslistNearMerge() */
  5324   5325   
  5325   5326       /* Allocate temporary working space. */
  5326   5327       for(p=pExpr; p->pLeft; p=p->pLeft){
  5327   5328         assert( p->pRight->pPhrase->doclist.nList>0 );
  5328   5329         nTmp += p->pRight->pPhrase->doclist.nList;
  5329   5330       }
  5330   5331       nTmp += p->pPhrase->doclist.nList;
  5331         -    aTmp = sqlite3_malloc(nTmp*2);
         5332  +    aTmp = sqlite3_malloc64(nTmp*2);
  5332   5333       if( !aTmp ){
  5333   5334         *pRc = SQLITE_NOMEM;
  5334   5335         res = 0;
  5335   5336       }else{
  5336   5337         char *aPoslist = p->pPhrase->doclist.pList;
  5337   5338         int nToken = p->pPhrase->nToken;
  5338   5339   
................................................................................
  5594   5595   ** After allocating the Fts3Expr.aMI[] array for each phrase in the 
  5595   5596   ** expression rooted at pExpr, the cursor iterates through all rows matched
  5596   5597   ** by pExpr, calling this function for each row. This function increments
  5597   5598   ** the values in Fts3Expr.aMI[] according to the position-list currently
  5598   5599   ** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase 
  5599   5600   ** expression nodes.
  5600   5601   */
  5601         -static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
         5602  +static void fts3EvalUpdateCounts(Fts3Expr *pExpr, int nCol){
  5602   5603     if( pExpr ){
  5603   5604       Fts3Phrase *pPhrase = pExpr->pPhrase;
  5604   5605       if( pPhrase && pPhrase->doclist.pList ){
  5605   5606         int iCol = 0;
  5606   5607         char *p = pPhrase->doclist.pList;
  5607   5608   
  5608   5609         assert( *p );
  5609         -      while( 1 ){
         5610  +      do{
  5610   5611           u8 c = 0;
  5611   5612           int iCnt = 0;
  5612   5613           while( 0xFE & (*p | c) ){
  5613   5614             if( (c&0x80)==0 ) iCnt++;
  5614   5615             c = *p++ & 0x80;
  5615   5616           }
  5616   5617   
................................................................................
  5618   5619           ** aMI[iCol*3 + 2] = Number of rows containing at least one instance
  5619   5620           */
  5620   5621           pExpr->aMI[iCol*3 + 1] += iCnt;
  5621   5622           pExpr->aMI[iCol*3 + 2] += (iCnt>0);
  5622   5623           if( *p==0x00 ) break;
  5623   5624           p++;
  5624   5625           p += fts3GetVarint32(p, &iCol);
  5625         -      }
         5626  +      }while( iCol<nCol );
  5626   5627       }
  5627   5628   
  5628         -    fts3EvalUpdateCounts(pExpr->pLeft);
  5629         -    fts3EvalUpdateCounts(pExpr->pRight);
         5629  +    fts3EvalUpdateCounts(pExpr->pLeft, nCol);
         5630  +    fts3EvalUpdateCounts(pExpr->pRight, nCol);
  5630   5631     }
  5631   5632   }
  5632   5633   
  5633   5634   /*
  5634   5635   ** Expression pExpr must be of type FTSQUERY_PHRASE.
  5635   5636   **
  5636   5637   ** If it is not already allocated and populated, this function allocates and
................................................................................
  5666   5667       bEof = pRoot->bEof;
  5667   5668       assert( pRoot->bStart );
  5668   5669   
  5669   5670       /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */
  5670   5671       for(p=pRoot; p; p=p->pLeft){
  5671   5672         Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);
  5672   5673         assert( pE->aMI==0 );
  5673         -      pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));
         5674  +      pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
  5674   5675         if( !pE->aMI ) return SQLITE_NOMEM;
  5675   5676         memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
  5676   5677       }
  5677   5678   
  5678   5679       fts3EvalRestart(pCsr, pRoot, &rc);
  5679   5680   
  5680   5681       while( pCsr->isEof==0 && rc==SQLITE_OK ){
................................................................................
  5692   5693           pCsr->iPrevId = pRoot->iDocid;
  5693   5694         }while( pCsr->isEof==0 
  5694   5695              && pRoot->eType==FTSQUERY_NEAR 
  5695   5696              && sqlite3Fts3EvalTestDeferred(pCsr, &rc) 
  5696   5697         );
  5697   5698   
  5698   5699         if( rc==SQLITE_OK && pCsr->isEof==0 ){
  5699         -        fts3EvalUpdateCounts(pRoot);
         5700  +        fts3EvalUpdateCounts(pRoot, pTab->nColumn);
  5700   5701         }
  5701   5702       }
  5702   5703   
  5703   5704       pCsr->isEof = 0;
  5704   5705       pCsr->iPrevId = iPrevId;
  5705   5706   
  5706   5707       if( bEof ){

Changes to ext/fts3/fts3Int.h.

    90     90   #endif
    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  +
           98  +#define FTS3_BUFFER_PADDING 8
    97     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

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;

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;
................................................................................
   512    512     u64 *pmSeen,                    /* IN/OUT: Mask of phrases seen */
   513    513     SnippetFragment *pFragment,     /* OUT: Best snippet found */
   514    514     int *piScore                    /* OUT: Score of snippet pFragment */
   515    515   ){
   516    516     int rc;                         /* Return Code */
   517    517     int nList;                      /* Number of phrases in expression */
   518    518     SnippetIter sIter;              /* Iterates through snippet candidates */
   519         -  int nByte;                      /* Number of bytes of space to allocate */
          519  +  sqlite3_int64 nByte;            /* Number of bytes of space to allocate */
   520    520     int iBestScore = -1;            /* Best snippet score found so far */
   521    521     int i;                          /* Loop counter */
   522    522   
   523    523     memset(&sIter, 0, sizeof(sIter));
   524    524   
   525    525     /* Iterate through the phrases in the expression to count them. The same
   526    526     ** callback makes sure the doclists are loaded for each phrase.
................................................................................
   530    530       return rc;
   531    531     }
   532    532   
   533    533     /* Now that it is known how many phrases there are, allocate and zero
   534    534     ** the required space using malloc().
   535    535     */
   536    536     nByte = sizeof(SnippetPhrase) * nList;
   537         -  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);
          537  +  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc64(nByte);
   538    538     if( !sIter.aPhrase ){
   539    539       return SQLITE_NOMEM;
   540    540     }
   541    541     memset(sIter.aPhrase, 0, nByte);
   542    542   
   543    543     /* Initialize the contents of the SnippetIter object. Then iterate through
   544    544     ** the set of phrases in the expression to populate the aPhrase[] array.
................................................................................
   600    600     }
   601    601   
   602    602     /* If there is insufficient space allocated at StrBuffer.z, use realloc()
   603    603     ** to grow the buffer until so that it is big enough to accomadate the
   604    604     ** appended data.
   605    605     */
   606    606     if( pStr->n+nAppend+1>=pStr->nAlloc ){
   607         -    int nAlloc = pStr->nAlloc+nAppend+100;
   608         -    char *zNew = sqlite3_realloc(pStr->z, nAlloc);
          607  +    sqlite3_int64 nAlloc = pStr->nAlloc+(sqlite3_int64)nAppend+100;
          608  +    char *zNew = sqlite3_realloc64(pStr->z, nAlloc);
   609    609       if( !zNew ){
   610    610         return SQLITE_NOMEM;
   611    611       }
   612    612       pStr->z = zNew;
   613    613       pStr->nAlloc = nAlloc;
   614    614     }
   615    615     assert( pStr->z!=0 && (pStr->nAlloc >= pStr->n+nAppend+1) );
................................................................................
   848    848     *ppCollist = pEnd;
   849    849     return nEntry;
   850    850   }
   851    851   
   852    852   /*
   853    853   ** This function gathers 'y' or 'b' data for a single phrase.
   854    854   */
   855         -static void fts3ExprLHits(
          855  +static int fts3ExprLHits(
   856    856     Fts3Expr *pExpr,                /* Phrase expression node */
   857    857     MatchInfo *p                    /* Matchinfo context */
   858    858   ){
   859    859     Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;
   860    860     int iStart;
   861    861     Fts3Phrase *pPhrase = pExpr->pPhrase;
   862    862     char *pIter = pPhrase->doclist.pList;
................................................................................
   878    878           p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));
   879    879         }
   880    880       }
   881    881       assert( *pIter==0x00 || *pIter==0x01 );
   882    882       if( *pIter!=0x01 ) break;
   883    883       pIter++;
   884    884       pIter += fts3GetVarint32(pIter, &iCol);
          885  +    if( iCol>=p->nCol ) return FTS_CORRUPT_VTAB;
   885    886     }
          887  +  return SQLITE_OK;
   886    888   }
   887    889   
   888    890   /*
   889    891   ** Gather the results for matchinfo directives 'y' and 'b'.
   890    892   */
   891         -static void fts3ExprLHitGather(
          893  +static int fts3ExprLHitGather(
   892    894     Fts3Expr *pExpr,
   893    895     MatchInfo *p
   894    896   ){
          897  +  int rc = SQLITE_OK;
   895    898     assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );
   896    899     if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
   897    900       if( pExpr->pLeft ){
   898         -      fts3ExprLHitGather(pExpr->pLeft, p);
   899         -      fts3ExprLHitGather(pExpr->pRight, p);
          901  +      rc = fts3ExprLHitGather(pExpr->pLeft, p);
          902  +      if( rc==SQLITE_OK ) rc = fts3ExprLHitGather(pExpr->pRight, p);
   900    903       }else{
   901         -      fts3ExprLHits(pExpr, p);
          904  +      rc = fts3ExprLHits(pExpr, p);
   902    905       }
   903    906     }
          907  +  return rc;
   904    908   }
   905    909   
   906    910   /*
   907    911   ** fts3ExprIterate() callback used to collect the "global" matchinfo stats
   908    912   ** for a single query. 
   909    913   **
   910    914   ** fts3ExprIterate() callback to load the 'global' elements of a
................................................................................
  1113   1117   ** undefined.
  1114   1118   */
  1115   1119   static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
  1116   1120     LcsIterator *aIter;
  1117   1121     int i;
  1118   1122     int iCol;
  1119   1123     int nToken = 0;
         1124  +  int rc = SQLITE_OK;
  1120   1125   
  1121   1126     /* Allocate and populate the array of LcsIterator objects. The array
  1122   1127     ** contains one element for each matchable phrase in the query.
  1123   1128     **/
  1124         -  aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);
         1129  +  aIter = sqlite3_malloc64(sizeof(LcsIterator) * pCsr->nPhrase);
  1125   1130     if( !aIter ) return SQLITE_NOMEM;
  1126   1131     memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);
  1127   1132     (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
  1128   1133   
  1129   1134     for(i=0; i<pInfo->nPhrase; i++){
  1130   1135       LcsIterator *pIter = &aIter[i];
  1131   1136       nToken -= pIter->pExpr->pPhrase->nToken;
................................................................................
  1133   1138     }
  1134   1139   
  1135   1140     for(iCol=0; iCol<pInfo->nCol; iCol++){
  1136   1141       int nLcs = 0;                 /* LCS value for this column */
  1137   1142       int nLive = 0;                /* Number of iterators in aIter not at EOF */
  1138   1143   
  1139   1144       for(i=0; i<pInfo->nPhrase; i++){
  1140         -      int rc;
  1141   1145         LcsIterator *pIt = &aIter[i];
  1142   1146         rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
  1143         -      if( rc!=SQLITE_OK ) return rc;
         1147  +      if( rc!=SQLITE_OK ) goto matchinfo_lcs_out;
  1144   1148         if( pIt->pRead ){
  1145   1149           pIt->iPos = pIt->iPosOffset;
  1146         -        fts3LcsIteratorAdvance(&aIter[i]);
         1150  +        fts3LcsIteratorAdvance(pIt);
         1151  +        if( pIt->pRead==0 ){
         1152  +          rc = FTS_CORRUPT_VTAB;
         1153  +          goto matchinfo_lcs_out;
         1154  +        }
  1147   1155           nLive++;
  1148   1156         }
  1149   1157       }
  1150   1158   
  1151   1159       while( nLive>0 ){
  1152   1160         LcsIterator *pAdv = 0;      /* The iterator to advance by one position */
  1153   1161         int nThisLcs = 0;           /* LCS for the current iterator positions */
................................................................................
  1171   1179         }
  1172   1180         if( fts3LcsIteratorAdvance(pAdv) ) nLive--;
  1173   1181       }
  1174   1182   
  1175   1183       pInfo->aMatchinfo[iCol] = nLcs;
  1176   1184     }
  1177   1185   
         1186  + matchinfo_lcs_out:
  1178   1187     sqlite3_free(aIter);
  1179         -  return SQLITE_OK;
         1188  +  return rc;
  1180   1189   }
  1181   1190   
  1182   1191   /*
  1183   1192   ** Populate the buffer pInfo->aMatchinfo[] with an array of integers to
  1184   1193   ** be returned by the matchinfo() function. Argument zArg contains the 
  1185   1194   ** format string passed as the second argument to matchinfo (or the
  1186   1195   ** default value "pcx" if no second argument was specified). The format
................................................................................
  1268   1277           }
  1269   1278           break;
  1270   1279   
  1271   1280         case FTS3_MATCHINFO_LHITS_BM:
  1272   1281         case FTS3_MATCHINFO_LHITS: {
  1273   1282           int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);
  1274   1283           memset(pInfo->aMatchinfo, 0, nZero);
  1275         -        fts3ExprLHitGather(pCsr->pExpr, pInfo);
         1284  +        rc = fts3ExprLHitGather(pCsr->pExpr, pInfo);
  1276   1285           break;
  1277   1286         }
  1278   1287   
  1279   1288         default: {
  1280   1289           Fts3Expr *pExpr;
  1281   1290           assert( zArg[i]==FTS3_MATCHINFO_HITS );
  1282   1291           pExpr = pCsr->pExpr;
................................................................................
  1562   1571     assert( pCsr->isRequireSeek==0 );
  1563   1572   
  1564   1573     /* Count the number of terms in the query */
  1565   1574     rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);
  1566   1575     if( rc!=SQLITE_OK ) goto offsets_out;
  1567   1576   
  1568   1577     /* Allocate the array of TermOffset iterators. */
  1569         -  sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);
         1578  +  sCtx.aTerm = (TermOffset *)sqlite3_malloc64(sizeof(TermOffset)*nToken);
  1570   1579     if( 0==sCtx.aTerm ){
  1571   1580       rc = SQLITE_NOMEM;
  1572   1581       goto offsets_out;
  1573   1582     }
  1574   1583     sCtx.iDocid = pCsr->iPrevId;
  1575   1584     sCtx.pCsr = pCsr;
  1576   1585   

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_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_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         -  char aChar[] = {
   182         -    '\0',      'a'|0x00,  'c'|0x00,  'e'|0x00,  'i'|0x00,  'n'|0x00,  
   183         -    'o'|0x00,  'u'|0x00,  'y'|0x00,  'y'|0x00,  'a'|0x00,  'c'|0x00,  
   184         -    'd'|0x00,  'e'|0x00,  'e'|0x00,  'g'|0x00,  'h'|0x00,  'i'|0x00,  
   185         -    'j'|0x00,  'k'|0x00,  'l'|0x00,  'n'|0x00,  'o'|0x00,  'r'|0x00,  
   186         -    's'|0x00,  't'|0x00,  'u'|0x00,  'u'|0x00,  'w'|0x00,  'y'|0x00,  
   187         -    'z'|0x00,  'o'|0x00,  'u'|0x00,  'a'|0x00,  'i'|0x00,  'o'|0x00,  
   188         -    'u'|0x00,  'u'|0x80,  'a'|0x80,  'g'|0x00,  'k'|0x00,  'o'|0x00,  
   189         -    'o'|0x80,  'j'|0x00,  'g'|0x00,  'n'|0x00,  'a'|0x80,  'a'|0x00,  
   190         -    'e'|0x00,  'i'|0x00,  'o'|0x00,  'r'|0x00,  'u'|0x00,  's'|0x00,  
   191         -    't'|0x00,  'h'|0x00,  'a'|0x00,  'e'|0x00,  'o'|0x80,  'o'|0x00,  
   192         -    'o'|0x80,  'y'|0x00,  '\0',      '\0',      '\0',      '\0',      
   193         -    '\0',      '\0',      '\0',      '\0',      'a'|0x00,  'b'|0x00,  
   194         -    'c'|0x80,  'd'|0x00,  'd'|0x00,  'e'|0x80,  'e'|0x00,  'e'|0x80,  
   195         -    'f'|0x00,  'g'|0x00,  'h'|0x00,  'h'|0x00,  'i'|0x00,  'i'|0x80,  
   196         -    'k'|0x00,  'l'|0x00,  'l'|0x80,  'l'|0x00,  'm'|0x00,  'n'|0x00,  
   197         -    'o'|0x80,  'p'|0x00,  'r'|0x00,  'r'|0x80,  'r'|0x00,  's'|0x00,  
   198         -    's'|0x80,  't'|0x00,  'u'|0x00,  'u'|0x80,  'v'|0x00,  'w'|0x00,  
   199         -    'w'|0x00,  'x'|0x00,  'y'|0x00,  'z'|0x00,  'h'|0x00,  't'|0x00,  
   200         -    'w'|0x00,  'y'|0x00,  'a'|0x00,  'a'|0x80,  'a'|0x80,  'a'|0x80,  
   201         -    'e'|0x00,  'e'|0x80,  'e'|0x80,  'i'|0x00,  'o'|0x00,  'o'|0x80,  
   202         -    'o'|0x80,  'o'|0x80,  'u'|0x00,  'u'|0x80,  'u'|0x80,  'y'|0x00,  
          181  +#define HIBIT ((unsigned char)0x80)
          182  +  unsigned char aChar[] = {
          183  +    '\0',      'a',       'c',       'e',       'i',       'n',       
          184  +    'o',       'u',       'y',       'y',       'a',       'c',       
          185  +    'd',       'e',       'e',       'g',       'h',       'i',       
          186  +    'j',       'k',       'l',       'n',       'o',       'r',       
          187  +    's',       't',       'u',       'u',       'w',       'y',       
          188  +    'z',       'o',       'u',       'a',       'i',       'o',       
          189  +    'u',       'u'|HIBIT, 'a'|HIBIT, 'g',       'k',       'o',       
          190  +    'o'|HIBIT, 'j',       'g',       'n',       'a'|HIBIT, 'a',       
          191  +    'e',       'i',       'o',       'r',       'u',       's',       
          192  +    't',       'h',       'a',       'e',       'o'|HIBIT, 'o',       
          193  +    'o'|HIBIT, 'y',       '\0',      '\0',      '\0',      '\0',      
          194  +    '\0',      '\0',      '\0',      '\0',      'a',       'b',       
          195  +    'c'|HIBIT, 'd',       'd',       'e'|HIBIT, 'e',       'e'|HIBIT, 
          196  +    'f',       'g',       'h',       'h',       'i',       'i'|HIBIT, 
          197  +    'k',       'l',       'l'|HIBIT, 'l',       'm',       'n',       
          198  +    'o'|HIBIT, 'p',       'r',       'r'|HIBIT, 'r',       's',       
          199  +    's'|HIBIT, 't',       'u',       'u'|HIBIT, 'v',       'w',       
          200  +    'w',       'x',       'y',       'z',       'h',       't',       
          201  +    'w',       'y',       'a',       'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT, 
          202  +    'e',       'e'|HIBIT, 'e'|HIBIT, 'i',       'o',       'o'|HIBIT, 
          203  +    'o'|HIBIT, 'o'|HIBIT, 'u',       'u'|HIBIT, 'u'|HIBIT, 'y',       
   203    204     };
   204    205   
   205    206     unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
   206    207     int iRes = 0;
   207    208     int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;
   208    209     int iLo = 0;
   209    210     while( iHi>=iLo ){
................................................................................
   226    227   ** is a diacritical modifier character.
   227    228   */
   228    229   int sqlite3FtsUnicodeIsdiacritic(int c){
   229    230     unsigned int mask0 = 0x08029FDF;
   230    231     unsigned int mask1 = 0x000361F8;
   231    232     if( c<768 || c>817 ) return 0;
   232    233     return (c < 768+32) ?
   233         -      (mask0 & (1 << (c-768))) :
   234         -      (mask1 & (1 << (c-768-32)));
          234  +      (mask0 & ((unsigned int)1 << (c-768))) :
          235  +      (mask1 & ((unsigned int)1 << (c-768-32)));
   235    236   }
   236    237   
   237    238   
   238    239   /*
   239    240   ** Interpret the argument as a unicode codepoint. If the codepoint
   240    241   ** is an upper case character that has a lower case equivalent,
   241    242   ** return the codepoint corresponding to the lower case version.

Changes to ext/fts3/fts3_write.c.

   392    392     sqlite3_stmt *pStmt;
   393    393   
   394    394     assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
   395    395     assert( eStmt<SizeofArray(azSql) && eStmt>=0 );
   396    396     
   397    397     pStmt = p->aStmt[eStmt];
   398    398     if( !pStmt ){
          399  +    int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
   399    400       char *zSql;
   400    401       if( eStmt==SQL_CONTENT_INSERT ){
   401    402         zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);
   402    403       }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){
          404  +      f &= ~SQLITE_PREPARE_NO_VTAB;
   403    405         zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);
   404    406       }else{
   405    407         zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
   406    408       }
   407    409       if( !zSql ){
   408    410         rc = SQLITE_NOMEM;
   409    411       }else{
   410         -      rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
   411         -                              &pStmt, NULL);
          412  +      rc = sqlite3_prepare_v3(p->db, zSql, -1, f, &pStmt, NULL);
   412    413         sqlite3_free(zSql);
   413    414         assert( rc==SQLITE_OK || pStmt==0 );
   414    415         p->aStmt[eStmt] = pStmt;
   415    416       }
   416    417     }
   417    418     if( apVal ){
   418    419       int i;
................................................................................
  1404   1405     pReader->aDoclist = pNext;
  1405   1406     pReader->pOffsetList = 0;
  1406   1407   
  1407   1408     /* Check that the doclist does not appear to extend past the end of the
  1408   1409     ** b-tree node. And that the final byte of the doclist is 0x00. If either 
  1409   1410     ** of these statements is untrue, then the data structure is corrupt.
  1410   1411     */
  1411         -  if( (&pReader->aNode[pReader->nNode] - pReader->aDoclist)<pReader->nDoclist
         1412  +  if( pReader->nDoclist > pReader->nNode-(pReader->aDoclist-pReader->aNode)
  1412   1413      || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
  1413   1414     ){
  1414   1415       return FTS_CORRUPT_VTAB;
  1415   1416     }
  1416   1417     return SQLITE_OK;
  1417   1418   }
  1418   1419   
................................................................................
  1604   1605     const char *zRoot,              /* Buffer containing root node */
  1605   1606     int nRoot,                      /* Size of buffer containing root node */
  1606   1607     Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */
  1607   1608   ){
  1608   1609     Fts3SegReader *pReader;         /* Newly allocated SegReader object */
  1609   1610     int nExtra = 0;                 /* Bytes to allocate segment root node */
  1610   1611   
  1611         -  assert( iStartLeaf<=iEndLeaf );
         1612  +  assert( zRoot!=0 || nRoot==0 );
         1613  +#ifdef CORRUPT_DB
         1614  +  assert( zRoot!=0 || CORRUPT_DB );
         1615  +#endif
         1616  +
  1612   1617     if( iStartLeaf==0 ){
         1618  +    if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB;
  1613   1619       nExtra = nRoot + FTS3_NODE_PADDING;
  1614   1620     }
  1615   1621   
  1616   1622     pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);
  1617   1623     if( !pReader ){
  1618   1624       return SQLITE_NOMEM;
  1619   1625     }
................................................................................
  1625   1631     pReader->iEndBlock = iEndBlock;
  1626   1632   
  1627   1633     if( nExtra ){
  1628   1634       /* The entire segment is stored in the root node. */
  1629   1635       pReader->aNode = (char *)&pReader[1];
  1630   1636       pReader->rootOnly = 1;
  1631   1637       pReader->nNode = nRoot;
  1632         -    memcpy(pReader->aNode, zRoot, nRoot);
         1638  +    if( nRoot ) memcpy(pReader->aNode, zRoot, nRoot);
  1633   1639       memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);
  1634   1640     }else{
  1635   1641       pReader->iCurrentBlock = iStartLeaf-1;
  1636   1642     }
  1637   1643     *ppReader = pReader;
  1638   1644     return SQLITE_OK;
  1639   1645   }
................................................................................
  2952   2958             ** doclist. */
  2953   2959             sqlite3_int64 iDelta;
  2954   2960             if( p->bDescIdx && nDoclist>0 ){
  2955   2961               iDelta = iPrev - iDocid;
  2956   2962             }else{
  2957   2963               iDelta = iDocid - iPrev;
  2958   2964             }
  2959         -          assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );
         2965  +          if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){
         2966  +            return FTS_CORRUPT_VTAB;
         2967  +          }
  2960   2968             assert( nDoclist>0 || iDelta==iDocid );
  2961   2969   
  2962   2970             nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
  2963   2971             if( nDoclist+nByte>pCsr->nBuffer ){
  2964   2972               char *aNew;
  2965   2973               pCsr->nBuffer = (nDoclist+nByte)*2;
  2966   2974               aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer);
................................................................................
  3318   3326   */
  3319   3327   static void fts3DecodeIntArray(
  3320   3328     int N,             /* The number of integers to decode */
  3321   3329     u32 *a,            /* Write the integer values */
  3322   3330     const char *zBuf,  /* The BLOB containing the varints */
  3323   3331     int nBuf           /* size of the BLOB */
  3324   3332   ){
  3325         -  int i, j;
  3326         -  UNUSED_PARAMETER(nBuf);
  3327         -  for(i=j=0; i<N; i++){
  3328         -    sqlite3_int64 x;
  3329         -    j += sqlite3Fts3GetVarint(&zBuf[j], &x);
  3330         -    assert(j<=nBuf);
  3331         -    a[i] = (u32)(x & 0xffffffff);
         3333  +  int i = 0;
         3334  +  if( nBuf && (zBuf[nBuf-1]&0x80)==0 ){
         3335  +    int j;
         3336  +    for(i=j=0; i<N && j<nBuf; i++){
         3337  +      sqlite3_int64 x;
         3338  +      j += sqlite3Fts3GetVarint(&zBuf[j], &x);
         3339  +      a[i] = (u32)(x & 0xffffffff);
         3340  +    }
  3332   3341     }
         3342  +  while( i<N ) a[i++] = 0;
  3333   3343   }
  3334   3344   
  3335   3345   /*
  3336   3346   ** Insert the sizes (in tokens) for each column of the document
  3337   3347   ** with docid equal to p->iPrevDocid.  The sizes are encoded as
  3338   3348   ** a blob of varints.
  3339   3349   */
................................................................................
  3731   3741     }else{
  3732   3742       if( bFirst==0 ){
  3733   3743         p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
  3734   3744       }
  3735   3745       p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
  3736   3746   
  3737   3747       if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){
  3738         -      return SQLITE_CORRUPT_VTAB;
         3748  +      return FTS_CORRUPT_VTAB;
  3739   3749       }
  3740   3750       blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
  3741   3751       if( rc==SQLITE_OK ){
  3742   3752         memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
  3743   3753         p->term.n = nPrefix+nSuffix;
  3744   3754         p->iOff += nSuffix;
  3745   3755         if( p->iChild==0 ){
  3746   3756           p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
  3747   3757           if( (p->nNode-p->iOff)<p->nDoclist ){
  3748         -          return SQLITE_CORRUPT_VTAB;
         3758  +          return FTS_CORRUPT_VTAB;
  3749   3759           }
  3750   3760           p->aDoclist = &p->aNode[p->iOff];
  3751   3761           p->iOff += p->nDoclist;
  3752   3762         }
  3753   3763       }
  3754   3764     }
  3755   3765   

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 "  char aChar\[\] = \{"
           66  +  puts "#define HIBIT ((unsigned char)0x80)"
           67  +  puts "  unsigned char aChar\[\] = \{"
    67     68     puts -nonewline "    '\\0',      "
    68     69     set i 1
    69     70     foreach c $aChar f $aFlag {
    70     71       if { $f } {
    71         -      set str "'$c'|0x80,  "
           72  +      set str "'$c'|HIBIT, "
    72     73       } else {
    73         -      set str "'$c'|0x00,  "
           74  +      set str "'$c',       "
    74     75       }
    75     76       if {$c == ""} { set str "'\\0',      " }
    76     77   
    77     78       if {($i % 6)==0} {puts "" ; puts -nonewline "    " }
    78     79       incr i
    79     80       puts -nonewline "$str"
    80     81     }
................................................................................
   130    131     puts "*/"
   131    132     puts "int ${zFunc}\(int c)\{"
   132    133     puts "  unsigned int mask0 = [format "0x%08X" $i1];"
   133    134     puts "  unsigned int mask1 = [format "0x%08X" $i2];"
   134    135   
   135    136     puts "  if( c<$iFirst || c>$iLast ) return 0;"
   136    137     puts "  return (c < $iFirst+32) ?"
   137         -  puts "      (mask0 & (1 << (c-$iFirst))) :"
   138         -  puts "      (mask1 & (1 << (c-$iFirst-32)));"
          138  +  puts "      (mask0 & ((unsigned int)1 << (c-$iFirst))) :"
          139  +  puts "      (mask1 & ((unsigned int)1 << (c-$iFirst-32)));"
   139    140     puts "\}"
   140    141   }
   141    142   
   142    143   
   143    144   #-------------------------------------------------------------------------
   144    145   
   145    146   proc an_load_separator_ranges {} {
................................................................................
   695    696     set aMapArray [intarray $aMap]
   696    697     set aDataArray [intarray $aData]
   697    698     puts [code {
   698    699       static u16 aFts5UnicodeBlock[] = {$aBlockArray};
   699    700       static u16 aFts5UnicodeMap[] = {$aMapArray};
   700    701       static u16 aFts5UnicodeData[] = {$aDataArray};
   701    702   
   702         -    int sqlite3Fts5UnicodeCategory(int iCode) { 
          703  +    int sqlite3Fts5UnicodeCategory(u32 iCode) { 
   703    704         int iRes = -1;
   704    705         int iHi;
   705    706         int iLo;
   706    707         int ret;
   707    708         u16 iKey;
   708    709   
   709    710         if( iCode>=(1<<20) ){
................................................................................
   778    779           if( aCP[iCP].iCode==i ){
   779    780             sqlite3Fts5UnicodeCatParse(aCP[iCP].zCat, aArray);
   780    781             iCP++;
   781    782           }else{
   782    783             aArray[0] = 1;
   783    784           }
   784    785   
   785         -        c = sqlite3Fts5UnicodeCategory(i);
          786  +        c = sqlite3Fts5UnicodeCategory((u32)i);
   786    787           if( aArray[c]==0 ){
   787    788             *piCode = i;
   788    789             return 1;
   789    790           }
   790    791         }
   791    792   
   792    793         return 0;
................................................................................
   833    834     puts "\}"
   834    835   }
   835    836   
   836    837   
   837    838   proc print_fileheader {} {
   838    839     puts [string trim {
   839    840   /*
   840         -** 2012 May 25
          841  +** 2012-05-25
   841    842   **
   842    843   ** The author disclaims copyright to this source code.  In place of
   843    844   ** a legal notice, here is a blessing:
   844    845   **
   845    846   **    May you do good and not evil.
   846    847   **    May you find forgiveness for yourself and forgive others.
   847    848   **    May you share freely, never taking more than you give.

Changes to ext/fts5/fts5.h.

   410    410   **            same token for inputs "first" and "1st". Say that token is in
   411    411   **            fact "first", so that when the user inserts the document "I won
   412    412   **            1st place" entries are added to the index for tokens "i", "won",
   413    413   **            "first" and "place". If the user then queries for '1st + place',
   414    414   **            the tokenizer substitutes "first" for "1st" and the query works
   415    415   **            as expected.
   416    416   **
   417         -**       <li> By adding multiple synonyms for a single term to the FTS index.
   418         -**            In this case, when tokenizing query text, the tokenizer may 
   419         -**            provide multiple synonyms for a single term within the document.
   420         -**            FTS5 then queries the index for each synonym individually. For
   421         -**            example, faced with the query:
          417  +**       <li> By querying the index for all synonyms of each query term
          418  +**            separately. In this case, when tokenizing query text, the
          419  +**            tokenizer may provide multiple synonyms for a single term 
          420  +**            within the document. FTS5 then queries the index for each 
          421  +**            synonym individually. For example, faced with the query:
   422    422   **
   423    423   **   <codeblock>
   424    424   **     ... MATCH 'first place'</codeblock>
   425    425   **
   426    426   **            the tokenizer offers both "1st" and "first" as synonyms for the
   427    427   **            first token in the MATCH query and FTS5 effectively runs a query 
   428    428   **            similar to:
................................................................................
   438    438   **            Using this method, when tokenizing document text, the tokenizer
   439    439   **            provides multiple synonyms for each token. So that when a 
   440    440   **            document such as "I won first place" is tokenized, entries are
   441    441   **            added to the FTS index for "i", "won", "first", "1st" and
   442    442   **            "place".
   443    443   **
   444    444   **            This way, even if the tokenizer does not provide synonyms
   445         -**            when tokenizing query text (it should not - to do would be
          445  +**            when tokenizing query text (it should not - to do so would be
   446    446   **            inefficient), it doesn't matter if the user queries for 
   447    447   **            'first + place' or '1st + place', as there are entries in the
   448    448   **            FTS index corresponding to both forms of the first token.
   449    449   **   </ol>
   450    450   **
   451    451   **   Whether it is parsing document or query text, any call to xToken that
   452    452   **   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit

Changes to ext/fts5/fts5Int.h.

   305    305   int sqlite3Fts5PoslistNext64(
   306    306     const u8 *a, int n,             /* Buffer containing poslist */
   307    307     int *pi,                        /* IN/OUT: Offset within a[] */
   308    308     i64 *piOff                      /* IN/OUT: Current offset */
   309    309   );
   310    310   
   311    311   /* Malloc utility */
   312         -void *sqlite3Fts5MallocZero(int *pRc, int nByte);
          312  +void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte);
   313    313   char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);
   314    314   
   315    315   /* Character set tests (like isspace(), isalpha() etc.) */
   316    316   int sqlite3Fts5IsBareword(char t);
   317    317   
   318    318   
   319    319   /* Bucket of terms object used by the integrity-check in offsets=0 mode. */
................................................................................
   784    784   /**************************************************************************
   785    785   ** Interface to automatically generated code in fts5_unicode2.c. 
   786    786   */
   787    787   int sqlite3Fts5UnicodeIsdiacritic(int c);
   788    788   int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
   789    789   
   790    790   int sqlite3Fts5UnicodeCatParse(const char*, u8*);
   791         -int sqlite3Fts5UnicodeCategory(int iCode);
          791  +int sqlite3Fts5UnicodeCategory(u32 iCode);
   792    792   void sqlite3Fts5UnicodeAscii(u8*, u8*);
   793    793   /*
   794    794   ** End of interface to code in fts5_unicode2.c.
   795    795   **************************************************************************/
   796    796   
   797    797   #endif

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   }
................................................................................
   564    564     Fts5Bm25Data *p;                /* Object to return */
   565    565   
   566    566     p = pApi->xGetAuxdata(pFts, 0);
   567    567     if( p==0 ){
   568    568       int nPhrase;                  /* Number of phrases in query */
   569    569       sqlite3_int64 nRow = 0;       /* Number of rows in table */
   570    570       sqlite3_int64 nToken = 0;     /* Number of tokens in table */
   571         -    int nByte;                    /* Bytes of space to allocate */
          571  +    sqlite3_int64 nByte;          /* Bytes of space to allocate */
   572    572       int i;
   573    573   
   574    574       /* Allocate the Fts5Bm25Data object */
   575    575       nPhrase = pApi->xPhraseCount(pFts);
   576    576       nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
   577         -    p = (Fts5Bm25Data*)sqlite3_malloc(nByte);
          577  +    p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
   578    578       if( p==0 ){
   579    579         rc = SQLITE_NOMEM;
   580    580       }else{
   581    581         memset(p, 0, nByte);
   582    582         p->nPhrase = nPhrase;
   583    583         p->aIDF = (double*)&p[1];
   584    584         p->aFreq = &p->aIDF[nPhrase];
................................................................................
   706    706           aBuiltin[i].xFunc,
   707    707           aBuiltin[i].xDestroy
   708    708       );
   709    709     }
   710    710   
   711    711     return rc;
   712    712   }
   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       }
................................................................................
   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";
................................................................................
  2549   2553       return;
  2550   2554     }
  2551   2555     memset(aArr, 0, sizeof(aArr));
  2552   2556     sqlite3Fts5UnicodeCatParse("L*", aArr);
  2553   2557     sqlite3Fts5UnicodeCatParse("N*", aArr);
  2554   2558     sqlite3Fts5UnicodeCatParse("Co", aArr);
  2555   2559     iCode = sqlite3_value_int(apVal[0]);
  2556         -  sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory(iCode)]);
         2560  +  sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory((u32)iCode)]);
  2557   2561   }
  2558   2562   
  2559   2563   static void fts5ExprFold(
  2560   2564     sqlite3_context *pCtx,          /* Function call context */
  2561   2565     int nArg,                       /* Number of args */
  2562   2566     sqlite3_value **apVal           /* Function arguments */
  2563   2567   ){
................................................................................
  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
................................................................................
   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   
................................................................................
   686    685           rc = sqlite3_blob_read(p->pReader, aOut, nByte, 0);
   687    686         }
   688    687         if( rc!=SQLITE_OK ){
   689    688           sqlite3_free(pRet);
   690    689           pRet = 0;
   691    690         }else{
   692    691           /* TODO1: Fix this */
          692  +        pRet->p[nByte] = 0x00;
   693    693           pRet->szLeaf = fts5GetU16(&pRet->p[2]);
   694    694         }
   695    695       }
   696    696       p->rc = rc;
   697    697       p->nRead++;
   698    698     }
   699    699   
................................................................................
   725    725     Fts5Index *p,
   726    726     sqlite3_stmt **ppStmt,
   727    727     char *zSql
   728    728   ){
   729    729     if( p->rc==SQLITE_OK ){
   730    730       if( zSql ){
   731    731         p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
   732         -                                 SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
          732  +          SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
          733  +          ppStmt, 0);
   733    734       }else{
   734    735         p->rc = SQLITE_NOMEM;
   735    736       }
   736    737     }
   737    738     sqlite3_free(zSql);
   738    739     return p->rc;
   739    740   }
................................................................................
   766    767   **
   767    768   **     DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast
   768    769   */
   769    770   static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){
   770    771     if( p->rc!=SQLITE_OK ) return;
   771    772   
   772    773     if( p->pDeleter==0 ){
   773         -    int rc;
   774    774       Fts5Config *pConfig = p->pConfig;
   775    775       char *zSql = sqlite3_mprintf(
   776    776           "DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?", 
   777    777             pConfig->zDb, pConfig->zName
   778    778       );
   779         -    if( zSql==0 ){
   780         -      rc = SQLITE_NOMEM;
   781         -    }else{
   782         -      rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
   783         -                              SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
   784         -      sqlite3_free(zSql);
   785         -    }
   786         -    if( rc!=SQLITE_OK ){
   787         -      p->rc = rc;
   788         -      return;
   789         -    }
          779  +    if( fts5IndexPrepareStmt(p, &p->pDeleter, zSql) ) return;
   790    780     }
   791    781   
   792    782     sqlite3_bind_int64(p->pDeleter, 1, iFirst);
   793    783     sqlite3_bind_int64(p->pDeleter, 2, iLast);
   794    784     sqlite3_step(p->pDeleter);
   795    785     p->rc = sqlite3_reset(p->pDeleter);
   796    786   }
................................................................................
   854    844     Fts5Structure **ppOut           /* OUT: Deserialized object */
   855    845   ){
   856    846     int rc = SQLITE_OK;
   857    847     int i = 0;
   858    848     int iLvl;
   859    849     int nLevel = 0;
   860    850     int nSegment = 0;
   861         -  int nByte;                      /* Bytes of space to allocate at pRet */
          851  +  sqlite3_int64 nByte;            /* Bytes of space to allocate at pRet */
   862    852     Fts5Structure *pRet = 0;        /* Structure object to return */
   863    853   
   864    854     /* Grab the cookie value */
   865    855     if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);
   866    856     i = 4;
   867    857   
   868    858     /* Read the total number of levels and segments from the start of the
   869    859     ** structure record.  */
   870    860     i += fts5GetVarint32(&pData[i], nLevel);
   871    861     i += fts5GetVarint32(&pData[i], nSegment);
          862  +  if( nLevel>FTS5_MAX_SEGMENT   || nLevel<0
          863  +   || nSegment>FTS5_MAX_SEGMENT || nSegment<0
          864  +  ){
          865  +    return FTS5_CORRUPT;
          866  +  }
   872    867     nByte = (
   873    868         sizeof(Fts5Structure) +                    /* Main structure */
   874    869         sizeof(Fts5StructureLevel) * (nLevel-1)    /* aLevel[] array */
   875    870     );
   876    871     pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);
   877    872   
   878    873     if( pRet ){
................................................................................
   887    882         int iSeg;
   888    883   
   889    884         if( i>=nData ){
   890    885           rc = FTS5_CORRUPT;
   891    886         }else{
   892    887           i += fts5GetVarint32(&pData[i], pLvl->nMerge);
   893    888           i += fts5GetVarint32(&pData[i], nTotal);
   894         -        assert( nTotal>=pLvl->nMerge );
          889  +        if( nTotal<pLvl->nMerge ) rc = FTS5_CORRUPT;
   895    890           pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc, 
   896    891               nTotal * sizeof(Fts5StructureSegment)
   897    892           );
          893  +        nSegment -= nTotal;
   898    894         }
   899    895   
   900    896         if( rc==SQLITE_OK ){
   901    897           pLvl->nSeg = nTotal;
   902    898           for(iSeg=0; iSeg<nTotal; iSeg++){
          899  +          Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
   903    900             if( i>=nData ){
   904    901               rc = FTS5_CORRUPT;
   905    902               break;
   906    903             }
   907         -          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
   908         -          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
   909         -          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
          904  +          i += fts5GetVarint32(&pData[i], pSeg->iSegid);
          905  +          i += fts5GetVarint32(&pData[i], pSeg->pgnoFirst);
          906  +          i += fts5GetVarint32(&pData[i], pSeg->pgnoLast);
          907  +          if( pSeg->pgnoLast<pSeg->pgnoFirst ){
          908  +            rc = FTS5_CORRUPT;
          909  +            break;
          910  +          }
   910    911           }
          912  +        if( iLvl>0 && pLvl[-1].nMerge && nTotal==0 ) rc = FTS5_CORRUPT;
          913  +        if( iLvl==nLevel-1 && pLvl->nMerge ) rc = FTS5_CORRUPT;
   911    914         }
   912    915       }
          916  +    if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT;
          917  +
   913    918       if( rc!=SQLITE_OK ){
   914    919         fts5StructureRelease(pRet);
   915    920         pRet = 0;
   916    921       }
   917    922     }
   918    923   
   919    924     *ppOut = pRet;
................................................................................
   923    928   /*
   924    929   **
   925    930   */
   926    931   static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){
   927    932     if( *pRc==SQLITE_OK ){
   928    933       Fts5Structure *pStruct = *ppStruct;
   929    934       int nLevel = pStruct->nLevel;
   930         -    int nByte = (
          935  +    sqlite3_int64 nByte = (
   931    936           sizeof(Fts5Structure) +                  /* Main structure */
   932    937           sizeof(Fts5StructureLevel) * (nLevel+1)  /* aLevel[] array */
   933    938       );
   934    939   
   935         -    pStruct = sqlite3_realloc(pStruct, nByte);
          940  +    pStruct = sqlite3_realloc64(pStruct, nByte);
   936    941       if( pStruct ){
   937    942         memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));
   938    943         pStruct->nLevel++;
   939    944         *ppStruct = pStruct;
   940    945       }else{
   941    946         *pRc = SQLITE_NOMEM;
   942    947       }
................................................................................
   953    958     int iLvl, 
   954    959     int nExtra, 
   955    960     int bInsert
   956    961   ){
   957    962     if( *pRc==SQLITE_OK ){
   958    963       Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];
   959    964       Fts5StructureSegment *aNew;
   960         -    int nByte;
          965  +    sqlite3_int64 nByte;
   961    966   
   962    967       nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);
   963         -    aNew = sqlite3_realloc(pLvl->aSeg, nByte);
          968  +    aNew = sqlite3_realloc64(pLvl->aSeg, nByte);
   964    969       if( aNew ){
   965    970         if( bInsert==0 ){
   966    971           memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);
   967    972         }else{
   968    973           int nMove = pLvl->nSeg * sizeof(Fts5StructureSegment);
   969    974           memmove(&aNew[nExtra], aNew, nMove);
   970    975           memset(aNew, 0, sizeof(Fts5StructureSegment) * nExtra);
................................................................................
  1470   1475     int iLeafPg                     /* Leaf page number to load dlidx for */
  1471   1476   ){
  1472   1477     Fts5DlidxIter *pIter = 0;
  1473   1478     int i;
  1474   1479     int bDone = 0;
  1475   1480   
  1476   1481     for(i=0; p->rc==SQLITE_OK && bDone==0; i++){
  1477         -    int nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
         1482  +    sqlite3_int64 nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
  1478   1483       Fts5DlidxIter *pNew;
  1479   1484   
  1480         -    pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);
         1485  +    pNew = (Fts5DlidxIter*)sqlite3_realloc64(pIter, nByte);
  1481   1486       if( pNew==0 ){
  1482   1487         p->rc = SQLITE_NOMEM;
  1483   1488       }else{
  1484   1489         i64 iRowid = FTS5_DLIDX_ROWID(iSegid, i, iLeafPg);
  1485   1490         Fts5DlidxLvl *pLvl = &pNew->aLvl[i];
  1486   1491         pIter = pNew;
  1487   1492         memset(pLvl, 0, sizeof(Fts5DlidxLvl));
................................................................................
  1643   1648   */
  1644   1649   static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
  1645   1650     u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */
  1646   1651     int iOff = pIter->iLeafOffset;  /* Offset to read at */
  1647   1652     int nNew;                       /* Bytes of new data */
  1648   1653   
  1649   1654     iOff += fts5GetVarint32(&a[iOff], nNew);
  1650         -  if( iOff+nNew>pIter->pLeaf->nn ){
         1655  +  if( iOff+nNew>pIter->pLeaf->nn || nKeep>pIter->term.n ){
  1651   1656       p->rc = FTS5_CORRUPT;
  1652   1657       return;
  1653   1658     }
  1654   1659     pIter->term.n = nKeep;
  1655   1660     fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
         1661  +  assert( pIter->term.n<=pIter->term.nSpace );
  1656   1662     iOff += nNew;
  1657   1663     pIter->iTermLeafOffset = iOff;
  1658   1664     pIter->iTermLeafPgno = pIter->iLeafPgno;
  1659   1665     pIter->iLeafOffset = iOff;
  1660   1666   
  1661   1667     if( pIter->iPgidxOff>=pIter->pLeaf->nn ){
  1662   1668       pIter->iEndofDoclist = pIter->pLeaf->nn+1;
................................................................................
  1713   1719       pIter->iLeafPgno = pSeg->pgnoFirst-1;
  1714   1720       fts5SegIterNextPage(p, pIter);
  1715   1721     }
  1716   1722   
  1717   1723     if( p->rc==SQLITE_OK ){
  1718   1724       pIter->iLeafOffset = 4;
  1719   1725       assert_nc( pIter->pLeaf->nn>4 );
  1720         -    assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
         1726  +    assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
  1721   1727       pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
  1722   1728       fts5SegIterLoadTerm(p, pIter, 0);
  1723   1729       fts5SegIterLoadNPos(p, pIter);
  1724   1730     }
  1725   1731   }
  1726   1732   
  1727   1733   /*
................................................................................
  1769   1775       if( i>=n ) break;
  1770   1776       i += fts5GetVarint(&a[i], (u64*)&iDelta);
  1771   1777       pIter->iRowid += iDelta;
  1772   1778   
  1773   1779       /* If necessary, grow the pIter->aRowidOffset[] array. */
  1774   1780       if( iRowidOffset>=pIter->nRowidOffset ){
  1775   1781         int nNew = pIter->nRowidOffset + 8;
  1776         -      int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));
         1782  +      int *aNew = (int*)sqlite3_realloc64(pIter->aRowidOffset,nNew*sizeof(int));
  1777   1783         if( aNew==0 ){
  1778   1784           p->rc = SQLITE_NOMEM;
  1779   1785           break;
  1780   1786         }
  1781   1787         pIter->aRowidOffset = aNew;
  1782   1788         pIter->nRowidOffset = nNew;
  1783   1789       }
................................................................................
  2223   2229     const u8 *pTerm, int nTerm      /* Term to search for */
  2224   2230   ){
  2225   2231     int iOff;
  2226   2232     const u8 *a = pIter->pLeaf->p;
  2227   2233     int szLeaf = pIter->pLeaf->szLeaf;
  2228   2234     int n = pIter->pLeaf->nn;
  2229   2235   
  2230         -  int nMatch = 0;
  2231         -  int nKeep = 0;
  2232         -  int nNew = 0;
  2233         -  int iTermOff;
         2236  +  u32 nMatch = 0;
         2237  +  u32 nKeep = 0;
         2238  +  u32 nNew = 0;
         2239  +  u32 iTermOff;
  2234   2240     int iPgidx;                     /* Current offset in pgidx */
  2235   2241     int bEndOfPage = 0;
  2236   2242   
  2237   2243     assert( p->rc==SQLITE_OK );
  2238   2244   
  2239   2245     iPgidx = szLeaf;
  2240   2246     iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff);
................................................................................
  2250   2256       fts5FastGetVarint32(a, iOff, nNew);
  2251   2257       if( nKeep<nMatch ){
  2252   2258         goto search_failed;
  2253   2259       }
  2254   2260   
  2255   2261       assert( nKeep>=nMatch );
  2256   2262       if( nKeep==nMatch ){
  2257         -      int nCmp;
  2258         -      int i;
  2259         -      nCmp = MIN(nNew, nTerm-nMatch);
         2263  +      u32 nCmp;
         2264  +      u32 i;
         2265  +      nCmp = (u32)MIN(nNew, nTerm-nMatch);
  2260   2266         for(i=0; i<nCmp; i++){
  2261   2267           if( a[iOff+i]!=pTerm[nMatch+i] ) break;
  2262   2268         }
  2263   2269         nMatch += i;
  2264   2270   
  2265         -      if( nTerm==nMatch ){
         2271  +      if( (u32)nTerm==nMatch ){
  2266   2272           if( i==nNew ){
  2267   2273             goto search_success;
  2268   2274           }else{
  2269   2275             goto search_failed;
  2270   2276           }
  2271   2277         }else if( i<nNew && a[iOff+i]>pTerm[nMatch] ){
  2272   2278           goto search_failed;
................................................................................
  2302   2308         if( pIter->pLeaf==0 ) return;
  2303   2309         a = pIter->pLeaf->p;
  2304   2310         if( fts5LeafIsTermless(pIter->pLeaf)==0 ){
  2305   2311           iPgidx = pIter->pLeaf->szLeaf;
  2306   2312           iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);
  2307   2313           if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){
  2308   2314             p->rc = FTS5_CORRUPT;
         2315  +          return;
  2309   2316           }else{
  2310   2317             nKeep = 0;
  2311   2318             iTermOff = iOff;
  2312   2319             n = pIter->pLeaf->nn;
  2313   2320             iOff += fts5GetVarint32(&a[iOff], nNew);
  2314   2321             break;
  2315   2322           }
  2316   2323         }
  2317   2324       }while( 1 );
  2318   2325     }
  2319   2326   
  2320   2327    search_success:
  2321         -
  2322   2328     pIter->iLeafOffset = iOff + nNew;
         2329  +  if( pIter->iLeafOffset>n ){
         2330  +    p->rc = FTS5_CORRUPT;
         2331  +    return;
         2332  +  }
  2323   2333     pIter->iTermLeafOffset = pIter->iLeafOffset;
  2324   2334     pIter->iTermLeafPgno = pIter->iLeafPgno;
  2325   2335   
  2326   2336     fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);
  2327   2337     fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
  2328   2338   
  2329   2339     if( iPgidx>=n ){
................................................................................
  2422   2432     **
  2423   2433     **   1) an error has occurred, or
  2424   2434     **   2) the iterator points to EOF, or
  2425   2435     **   3) the iterator points to an entry with term (pTerm/nTerm), or
  2426   2436     **   4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points
  2427   2437     **      to an entry with a term greater than or equal to (pTerm/nTerm).
  2428   2438     */
  2429         -  assert( p->rc!=SQLITE_OK                                          /* 1 */
         2439  +  assert_nc( p->rc!=SQLITE_OK                                       /* 1 */
  2430   2440      || pIter->pLeaf==0                                               /* 2 */
  2431   2441      || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0          /* 3 */
  2432   2442      || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0)  /* 4 */
  2433   2443     );
  2434   2444   }
  2435   2445   
  2436   2446   /*
................................................................................
  2743   2753   */
  2744   2754   static void fts5MultiIterFree(Fts5Iter *pIter){
  2745   2755     if( pIter ){
  2746   2756       int i;
  2747   2757       for(i=0; i<pIter->nSeg; i++){
  2748   2758         fts5SegIterClear(&pIter->aSeg[i]);
  2749   2759       }
  2750         -    fts5StructureRelease(pIter->pStruct);
  2751   2760       fts5BufferFree(&pIter->poslist);
  2752   2761       sqlite3_free(pIter);
  2753   2762     }
  2754   2763   }
  2755   2764   
  2756   2765   static void fts5MultiIterAdvanced(
  2757   2766     Fts5Index *p,                   /* FTS5 backend to iterate within */
................................................................................
  3389   3398         nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);
  3390   3399       }
  3391   3400     }
  3392   3401     *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
  3393   3402     if( pNew==0 ) return;
  3394   3403     pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
  3395   3404     pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
  3396         -  pNew->pStruct = pStruct;
  3397   3405     pNew->pColset = pColset;
  3398         -  fts5StructureRef(pStruct);
  3399   3406     if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
  3400   3407       fts5IterSetOutputCb(&p->rc, pNew);
  3401   3408     }
  3402   3409   
  3403   3410     /* Initialize each of the component segment iterators. */
  3404   3411     if( p->rc==SQLITE_OK ){
  3405   3412       if( iLevel<0 ){
................................................................................
  3570   3577         int i;
  3571   3578         u32 mask;
  3572   3579         memset(aUsed, 0, sizeof(aUsed));
  3573   3580         for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
  3574   3581           for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
  3575   3582             int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;
  3576   3583             if( iId<=FTS5_MAX_SEGMENT ){
  3577         -            aUsed[(iId-1) / 32] |= 1 << ((iId-1) % 32);
         3584  +            aUsed[(iId-1) / 32] |= (u32)1 << ((iId-1) % 32);
  3578   3585             }
  3579   3586           }
  3580   3587         }
  3581   3588   
  3582   3589         for(i=0; aUsed[i]==0xFFFFFFFF; i++);
  3583   3590         mask = aUsed[i];
  3584         -      for(iSegid=0; mask & (1 << iSegid); iSegid++);
         3591  +      for(iSegid=0; mask & ((u32)1 << iSegid); iSegid++);
  3585   3592         iSegid += 1 + i*32;
  3586   3593   
  3587   3594   #ifdef SQLITE_DEBUG
  3588   3595         for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
  3589   3596           for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
  3590         -          assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
         3597  +          assert_nc( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
  3591   3598           }
  3592   3599         }
  3593         -      assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
         3600  +      assert_nc( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
  3594   3601   
  3595   3602         {
  3596   3603           sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);
  3597   3604           if( p->rc==SQLITE_OK ){
  3598   3605             u8 aBlob[2] = {0xff, 0xff};
  3599   3606             sqlite3_bind_int(pIdxSelect, 1, iSegid);
  3600   3607             sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);
  3601         -          assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
         3608  +          assert_nc( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
  3602   3609             p->rc = sqlite3_reset(pIdxSelect);
  3603   3610             sqlite3_bind_null(pIdxSelect, 2);
  3604   3611           }
  3605   3612         }
  3606   3613   #endif
  3607   3614       }
  3608   3615     }
................................................................................
  3664   3671   */
  3665   3672   static int fts5WriteDlidxGrow(
  3666   3673     Fts5Index *p,
  3667   3674     Fts5SegWriter *pWriter,
  3668   3675     int nLvl
  3669   3676   ){
  3670   3677     if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
  3671         -    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc(
         3678  +    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc64(
  3672   3679           pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl
  3673   3680       );
  3674   3681       if( aDlidx==0 ){
  3675   3682         p->rc = SQLITE_NOMEM;
  3676   3683       }else{
  3677   3684         int nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);
  3678   3685         memset(&aDlidx[pWriter->nDlidx], 0, nByte);
................................................................................
  3743   3750   */
  3744   3751   static void fts5WriteBtreeTerm(
  3745   3752     Fts5Index *p,                   /* FTS5 backend object */
  3746   3753     Fts5SegWriter *pWriter,         /* Writer object */
  3747   3754     int nTerm, const u8 *pTerm      /* First term on new page */
  3748   3755   ){
  3749   3756     fts5WriteFlushBtree(p, pWriter);
  3750         -  fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
  3751         -  pWriter->iBtPage = pWriter->writer.pgno;
         3757  +  if( p->rc==SQLITE_OK ){
         3758  +    fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
         3759  +    pWriter->iBtPage = pWriter->writer.pgno;
         3760  +  }
  3752   3761   }
  3753   3762   
  3754   3763   /*
  3755   3764   ** This function is called when flushing a leaf page that contains no
  3756   3765   ** terms at all to disk.
  3757   3766   */
  3758   3767   static void fts5WriteBtreeNoTerm(
................................................................................
  3895   3904     Fts5Index *p, 
  3896   3905     Fts5SegWriter *pWriter,
  3897   3906     int nTerm, const u8 *pTerm 
  3898   3907   ){
  3899   3908     int nPrefix;                    /* Bytes of prefix compression for term */
  3900   3909     Fts5PageWriter *pPage = &pWriter->writer;
  3901   3910     Fts5Buffer *pPgidx = &pWriter->writer.pgidx;
         3911  +  int nMin = MIN(pPage->term.n, nTerm);
  3902   3912   
  3903   3913     assert( p->rc==SQLITE_OK );
  3904   3914     assert( pPage->buf.n>=4 );
  3905   3915     assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );
  3906   3916   
  3907   3917     /* If the current leaf page is full, flush it to disk. */
  3908   3918     if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){
  3909   3919       if( pPage->buf.n>4 ){
  3910   3920         fts5WriteFlushLeaf(p, pWriter);
         3921  +      if( p->rc!=SQLITE_OK ) return;
  3911   3922       }
  3912   3923       fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);
  3913   3924     }
  3914   3925     
  3915   3926     /* TODO1: Updating pgidx here. */
  3916   3927     pPgidx->n += sqlite3Fts5PutVarint(
  3917   3928         &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx
................................................................................
  3936   3947         ** Usually, the previous term is available in pPage->term. The exception
  3937   3948         ** is if this is the first term written in an incremental-merge step.
  3938   3949         ** In this case the previous term is not available, so just write a
  3939   3950         ** copy of (pTerm/nTerm) into the parent node. This is slightly
  3940   3951         ** inefficient, but still correct.  */
  3941   3952         int n = nTerm;
  3942   3953         if( pPage->term.n ){
  3943         -        n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
         3954  +        n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);
  3944   3955         }
  3945   3956         fts5WriteBtreeTerm(p, pWriter, n, pTerm);
         3957  +      if( p->rc!=SQLITE_OK ) return;
  3946   3958         pPage = &pWriter->writer;
  3947   3959       }
  3948   3960     }else{
  3949         -    nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
         3961  +    nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);
  3950   3962       fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
  3951   3963     }
  3952   3964   
  3953   3965     /* Append the number of bytes of new data, then the term data itself
  3954   3966     ** to the page. */
  3955   3967     fts5BufferAppendVarint(&p->rc, &pPage->buf, nTerm - nPrefix);
  3956   3968     fts5BufferAppendBlob(&p->rc, &pPage->buf, nTerm - nPrefix, &pTerm[nPrefix]);
................................................................................
  3989   4001         fts5WriteDlidxAppend(p, pWriter, iRowid);
  3990   4002       }
  3991   4003   
  3992   4004       /* Write the rowid. */
  3993   4005       if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
  3994   4006         fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);
  3995   4007       }else{
  3996         -      assert( p->rc || iRowid>pWriter->iPrevRowid );
         4008  +      assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
  3997   4009         fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
  3998   4010       }
  3999   4011       pWriter->iPrevRowid = iRowid;
  4000   4012       pWriter->bFirstRowidInDoclist = 0;
  4001   4013       pWriter->bFirstRowidInPage = 0;
  4002   4014     }
  4003   4015   }
................................................................................
  4504   4516         const char *zTerm;          /* Buffer containing term */
  4505   4517         const u8 *pDoclist;         /* Pointer to doclist for this term */
  4506   4518         int nDoclist;               /* Size of doclist in bytes */
  4507   4519   
  4508   4520         /* Write the term for this entry to disk. */
  4509   4521         sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);
  4510   4522         fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);
         4523  +      if( p->rc!=SQLITE_OK ) break;
  4511   4524   
  4512   4525         assert( writer.bFirstRowidInPage==0 );
  4513   4526         if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
  4514   4527           /* The entire doclist will fit on the current leaf. */
  4515   4528           fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);
  4516   4529         }else{
  4517   4530           i64 iRowid = 0;
................................................................................
  4583   4596             }
  4584   4597           }
  4585   4598         }
  4586   4599   
  4587   4600         /* TODO2: Doclist terminator written here. */
  4588   4601         /* pBuf->p[pBuf->n++] = '\0'; */
  4589   4602         assert( pBuf->n<=pBuf->nSpace );
  4590         -      sqlite3Fts5HashScanNext(pHash);
         4603  +      if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);
  4591   4604       }
  4592   4605       sqlite3Fts5HashClear(pHash);
  4593   4606       fts5WriteFinish(p, &writer, &pgnoLast);
  4594   4607   
  4595   4608       /* Update the Fts5Structure. It is written back to the database by the
  4596   4609       ** fts5StructureRelease() call below.  */
  4597   4610       if( pStruct->nLevel==0 ){
................................................................................
  4627   4640   }
  4628   4641   
  4629   4642   static Fts5Structure *fts5IndexOptimizeStruct(
  4630   4643     Fts5Index *p, 
  4631   4644     Fts5Structure *pStruct
  4632   4645   ){
  4633   4646     Fts5Structure *pNew = 0;
  4634         -  int nByte = sizeof(Fts5Structure);
         4647  +  sqlite3_int64 nByte = sizeof(Fts5Structure);
  4635   4648     int nSeg = pStruct->nSegment;
  4636   4649     int i;
  4637   4650   
  4638   4651     /* Figure out if this structure requires optimization. A structure does
  4639   4652     ** not require optimization if either:
  4640   4653     **
  4641   4654     **  + it consists of fewer than two segments, or 
................................................................................
  5860   5873         int iOff;                   /* Offset of first term on leaf */
  5861   5874         int iRowidOff;              /* Offset of first rowid on leaf */
  5862   5875         int nTerm;                  /* Size of term on leaf in bytes */
  5863   5876         int res;                    /* Comparison of term and split-key */
  5864   5877   
  5865   5878         iOff = fts5LeafFirstTermOff(pLeaf);
  5866   5879         iRowidOff = fts5LeafFirstRowidOff(pLeaf);
  5867         -      if( iRowidOff>=iOff ){
         5880  +      if( iRowidOff>=iOff || iOff>=pLeaf->szLeaf ){
  5868   5881           p->rc = FTS5_CORRUPT;
  5869   5882         }else{
  5870   5883           iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);
  5871   5884           res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
  5872   5885           if( res==0 ) res = nTerm - nIdxTerm;
  5873   5886           if( res<0 ) p->rc = FTS5_CORRUPT;
  5874   5887         }
................................................................................
  6259   6272   ){
  6260   6273     i64 iRowid;                     /* Rowid for record being decoded */
  6261   6274     int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */
  6262   6275     const u8 *aBlob; int n;         /* Record to decode */
  6263   6276     u8 *a = 0;
  6264   6277     Fts5Buffer s;                   /* Build up text to return here */
  6265   6278     int rc = SQLITE_OK;             /* Return code */
  6266         -  int nSpace = 0;
         6279  +  sqlite3_int64 nSpace = 0;
  6267   6280     int eDetailNone = (sqlite3_user_data(pCtx)!=0);
  6268   6281   
  6269   6282     assert( nArg==2 );
  6270   6283     UNUSED_PARAM(nArg);
  6271   6284     memset(&s, 0, sizeof(Fts5Buffer));
  6272   6285     iRowid = sqlite3_value_int64(apVal[0]);
  6273   6286   
................................................................................
  6275   6288     ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
  6276   6289     ** buffer overreads even if the record is corrupt.  */
  6277   6290     n = sqlite3_value_bytes(apVal[1]);
  6278   6291     aBlob = sqlite3_value_blob(apVal[1]);
  6279   6292     nSpace = n + FTS5_DATA_ZERO_PADDING;
  6280   6293     a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
  6281   6294     if( a==0 ) goto decode_out;
  6282         -  memcpy(a, aBlob, n);
  6283         -
         6295  +  if( n>0 ) memcpy(a, aBlob, n);
  6284   6296   
  6285   6297     fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);
  6286   6298   
  6287   6299     fts5DebugRowid(&rc, &s, iRowid);
  6288   6300     if( bDlidx ){
  6289   6301       Fts5Data dlidx;
  6290   6302       Fts5DlidxLvl lvl;
................................................................................
  6371   6383         sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)"corrupt");
  6372   6384         goto decode_out;
  6373   6385       }else{
  6374   6386         iRowidOff = fts5GetU16(&a[0]);
  6375   6387         iPgidxOff = szLeaf = fts5GetU16(&a[2]);
  6376   6388         if( iPgidxOff<n ){
  6377   6389           fts5GetVarint32(&a[iPgidxOff], iTermOff);
         6390  +      }else if( iPgidxOff>n ){
         6391  +        rc = FTS5_CORRUPT;
         6392  +        goto decode_out;
  6378   6393         }
  6379   6394       }
  6380   6395   
  6381   6396       /* Decode the position list tail at the start of the page */
  6382   6397       if( iRowidOff!=0 ){
  6383   6398         iOff = iRowidOff;
  6384   6399       }else if( iTermOff!=0 ){
  6385   6400         iOff = iTermOff;
  6386   6401       }else{
  6387   6402         iOff = szLeaf;
  6388   6403       }
         6404  +    if( iOff>n ){
         6405  +      rc = FTS5_CORRUPT;
         6406  +      goto decode_out;
         6407  +    }
  6389   6408       fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
  6390   6409   
  6391   6410       /* Decode any more doclist data that appears on the page before the
  6392   6411       ** first term. */
  6393   6412       nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
  6394   6413       fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
  6395   6414   
  6396         -    while( iPgidxOff<n ){
         6415  +    while( iPgidxOff<n && rc==SQLITE_OK ){
  6397   6416         int bFirst = (iPgidxOff==szLeaf);     /* True for first term on page */
  6398   6417         int nByte;                            /* Bytes of data */
  6399   6418         int iEnd;
  6400   6419         
  6401   6420         iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nByte);
  6402   6421         iPgidxPrev += nByte;
  6403   6422         iOff = iPgidxPrev;
................................................................................
  6404   6423   
  6405   6424         if( iPgidxOff<n ){
  6406   6425           fts5GetVarint32(&a[iPgidxOff], nByte);
  6407   6426           iEnd = iPgidxPrev + nByte;
  6408   6427         }else{
  6409   6428           iEnd = szLeaf;
  6410   6429         }
         6430  +      if( iEnd>szLeaf ){
         6431  +        rc = FTS5_CORRUPT;
         6432  +        break;
         6433  +      }
  6411   6434   
  6412   6435         if( bFirst==0 ){
  6413   6436           iOff += fts5GetVarint32(&a[iOff], nByte);
         6437  +        if( nByte>term.n ){
         6438  +          rc = FTS5_CORRUPT;
         6439  +          break;
         6440  +        }
  6414   6441           term.n = nByte;
  6415   6442         }
  6416   6443         iOff += fts5GetVarint32(&a[iOff], nByte);
         6444  +      if( iOff+nByte>n ){
         6445  +        rc = FTS5_CORRUPT;
         6446  +        break;
         6447  +      }
  6417   6448         fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);
  6418   6449         iOff += nByte;
  6419   6450   
  6420   6451         sqlite3Fts5BufferAppendPrintf(
  6421   6452             &rc, &s, " term=%.*s", term.n, (const char*)term.p
  6422   6453         );
  6423   6454         iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff);

Changes to ext/fts5/fts5_main.c.

   625    625   /*
   626    626   ** Implementation of xOpen method.
   627    627   */
   628    628   static int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){
   629    629     Fts5Table *pTab = (Fts5Table*)pVTab;
   630    630     Fts5Config *pConfig = pTab->pConfig;
   631    631     Fts5Cursor *pCsr = 0;           /* New cursor object */
   632         -  int nByte;                      /* Bytes of space to allocate */
          632  +  sqlite3_int64 nByte;            /* Bytes of space to allocate */
   633    633     int rc;                         /* Return code */
   634    634   
   635    635     rc = fts5NewTransaction(pTab);
   636    636     if( rc==SQLITE_OK ){
   637    637       nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
   638         -    pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);
          638  +    pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
   639    639       if( pCsr ){
   640    640         Fts5Global *pGlobal = pTab->pGlobal;
   641    641         memset(pCsr, 0, nByte);
   642    642         pCsr->aColumnSize = (int*)&pCsr[1];
   643    643         pCsr->pNext = pGlobal->pCsr;
   644    644         pGlobal->pCsr = pCsr;
   645    645         pCsr->iCsrId = ++pGlobal->iNextId;
................................................................................
   902    902     return rc;
   903    903   } 
   904    904   
   905    905   static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
   906    906     Fts5Config *pConfig = pTab->pConfig;
   907    907     Fts5Sorter *pSorter;
   908    908     int nPhrase;
   909         -  int nByte;
          909  +  sqlite3_int64 nByte;
   910    910     int rc;
   911    911     const char *zRank = pCsr->zRank;
   912    912     const char *zRankArgs = pCsr->zRankArgs;
   913    913     
   914    914     nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
   915    915     nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
   916         -  pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);
          916  +  pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
   917    917     if( pSorter==0 ) return SQLITE_NOMEM;
   918    918     memset(pSorter, 0, nByte);
   919    919     pSorter->nIdx = nPhrase;
   920    920   
   921    921     /* TODO: It would be better to have some system for reusing statement
   922    922     ** handles here, rather than preparing a new one for each query. But that
   923    923     ** is not possible as SQLite reference counts the virtual table objects.
................................................................................
  1028   1028         sqlite3_stmt *pStmt = 0;
  1029   1029         rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
  1030   1030                                 SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
  1031   1031         sqlite3_free(zSql);
  1032   1032         assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
  1033   1033         if( rc==SQLITE_OK ){
  1034   1034           if( SQLITE_ROW==sqlite3_step(pStmt) ){
  1035         -          int nByte;
         1035  +          sqlite3_int64 nByte;
  1036   1036             pCsr->nRankArg = sqlite3_column_count(pStmt);
  1037   1037             nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;
  1038   1038             pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);
  1039   1039             if( rc==SQLITE_OK ){
  1040   1040               int i;
  1041   1041               for(i=0; i<pCsr->nRankArg; i++){
  1042   1042                 pCsr->apRankArg[i] = sqlite3_column_value(pStmt, i);
................................................................................
  1493   1493     int rc = SQLITE_OK;             /* Return code */
  1494   1494   
  1495   1495     /* A transaction must be open when this is called. */
  1496   1496     assert( pTab->ts.eState==1 );
  1497   1497   
  1498   1498     assert( pVtab->zErrMsg==0 );
  1499   1499     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 
         1500  +  assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER 
         1501  +       || sqlite3_value_type(apVal[0])==SQLITE_NULL 
  1503   1502     );
  1504   1503     assert( pTab->pConfig->pzErrmsg==0 );
  1505   1504     pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
  1506   1505   
  1507   1506     /* Put any active cursors into REQUIRE_SEEK state. */
  1508   1507     fts5TripCursors(pTab);
  1509   1508   
................................................................................
  1552   1551   
  1553   1552       /* DELETE */
  1554   1553       else if( nArg==1 ){
  1555   1554         i64 iDel = sqlite3_value_int64(apVal[0]);  /* Rowid to delete */
  1556   1555         rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);
  1557   1556       }
  1558   1557   
  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 */
         1558  +    /* INSERT or UPDATE */
  1572   1559       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 ){
         1560  +      int eType1 = sqlite3_value_numeric_type(apVal[1]);
         1561  +
         1562  +      if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){
         1563  +        rc = SQLITE_MISMATCH;
         1564  +      }
         1565  +
         1566  +      else if( eType0!=SQLITE_INTEGER ){     
         1567  +        /* If this is a REPLACE, first remove the current entry (if any) */
         1568  +        if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
         1569  +          i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */
         1570  +          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
         1571  +        }
         1572  +        fts5StorageInsert(&rc, pTab, apVal, pRowid);
         1573  +      }
         1574  +
         1575  +      /* UPDATE */
         1576  +      else{
         1577  +        i64 iOld = sqlite3_value_int64(apVal[0]);  /* Old rowid */
         1578  +        i64 iNew = sqlite3_value_int64(apVal[1]);  /* New rowid */
         1579  +        if( eType1==SQLITE_INTEGER && iOld!=iNew ){
         1580  +          if( eConflict==SQLITE_REPLACE ){
  1585   1581               rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
  1586         -          }
  1587         -          if( rc==SQLITE_OK ){
  1588         -            rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid);
         1582  +            if( rc==SQLITE_OK ){
         1583  +              rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
         1584  +            }
         1585  +            fts5StorageInsert(&rc, pTab, apVal, pRowid);
         1586  +          }else{
         1587  +            rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
         1588  +            if( rc==SQLITE_OK ){
         1589  +              rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
         1590  +            }
         1591  +            if( rc==SQLITE_OK ){
         1592  +              rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
         1593  +            }
  1589   1594             }
         1595  +        }else{
         1596  +          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
         1597  +          fts5StorageInsert(&rc, pTab, apVal, pRowid);
  1590   1598           }
  1591         -      }else{
  1592         -        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
  1593         -        fts5StorageInsert(&rc, pTab, apVal, pRowid);
  1594   1599         }
  1595   1600       }
  1596   1601     }
  1597   1602   
  1598   1603     pTab->pConfig->pzErrmsg = 0;
  1599   1604     return rc;
  1600   1605   }
................................................................................
  1772   1777   static int fts5CacheInstArray(Fts5Cursor *pCsr){
  1773   1778     int rc = SQLITE_OK;
  1774   1779     Fts5PoslistReader *aIter;       /* One iterator for each phrase */
  1775   1780     int nIter;                      /* Number of iterators/phrases */
  1776   1781     
  1777   1782     nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
  1778   1783     if( pCsr->aInstIter==0 ){
  1779         -    int nByte = sizeof(Fts5PoslistReader) * nIter;
         1784  +    sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nIter;
  1780   1785       pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);
  1781   1786     }
  1782   1787     aIter = pCsr->aInstIter;
  1783   1788   
  1784   1789     if( aIter ){
  1785   1790       int nInst = 0;                /* Number instances seen so far */
  1786   1791       int i;
................................................................................
  1807   1812             }
  1808   1813           }
  1809   1814           if( iBest<0 ) break;
  1810   1815   
  1811   1816           nInst++;
  1812   1817           if( nInst>=pCsr->nInstAlloc ){
  1813   1818             pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
  1814         -          aInst = (int*)sqlite3_realloc(
         1819  +          aInst = (int*)sqlite3_realloc64(
  1815   1820                 pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3
  1816   1821                 );
  1817   1822             if( aInst ){
  1818   1823               pCsr->aInst = aInst;
  1819   1824             }else{
  1820   1825               rc = SQLITE_NOMEM;
  1821   1826               break;
................................................................................
  2240   2245   */
  2241   2246   Fts5Index *sqlite3Fts5IndexFromCsrid(
  2242   2247     Fts5Global *pGlobal,            /* FTS5 global context for db handle */
  2243   2248     i64 iCsrId,                     /* Id of cursor to find */
  2244   2249     Fts5Config **ppConfig           /* OUT: Configuration object */
  2245   2250   ){
  2246   2251     Fts5Cursor *pCsr;
  2247         -  Fts5Table *pTab;
  2248         -
  2249   2252     pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);
  2250         -  pTab = (Fts5Table*)pCsr->base.pVtab;
  2251         -  *ppConfig = pTab->pConfig;
  2252         -
  2253         -  return pTab->pIndex;
         2253  +  if( pCsr ){
         2254  +    Fts5Table *pTab = (Fts5Table*)pCsr->base.pVtab;
         2255  +    *ppConfig = pTab->pConfig;
         2256  +    return pTab->pIndex;
         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.

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);
................................................................................
   132    132           zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName);
   133    133           break;
   134    134       }
   135    135   
   136    136       if( zSql==0 ){
   137    137         rc = SQLITE_NOMEM;
   138    138       }else{
   139         -      rc = sqlite3_prepare_v3(pC->db, zSql, -1,
   140         -                              SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
          139  +      int f = SQLITE_PREPARE_PERSISTENT;
          140  +      if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
          141  +      rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
   141    142         sqlite3_free(zSql);
   142    143         if( rc!=SQLITE_OK && pzErrMsg ){
   143    144           *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
   144    145         }
   145    146       }
   146    147     }
   147    148   
................................................................................
   277    278     Fts5Index *pIndex, 
   278    279     int bCreate, 
   279    280     Fts5Storage **pp,
   280    281     char **pzErr                    /* OUT: Error message */
   281    282   ){
   282    283     int rc = SQLITE_OK;
   283    284     Fts5Storage *p;                 /* New object */
   284         -  int nByte;                      /* Bytes of space to allocate */
          285  +  sqlite3_int64 nByte;            /* Bytes of space to allocate */
   285    286   
   286    287     nByte = sizeof(Fts5Storage)               /* Fts5Storage object */
   287    288           + pConfig->nCol * sizeof(i64);      /* Fts5Storage.aTotalSize[] */
   288         -  *pp = p = (Fts5Storage*)sqlite3_malloc(nByte);
          289  +  *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
   289    290     if( !p ) return SQLITE_NOMEM;
   290    291   
   291    292     memset(p, 0, nByte);
   292    293     p->aTotalSize = (i64*)&p[1];
   293    294     p->pConfig = pConfig;
   294    295     p->pIndex = pIndex;
   295    296   
   296    297     if( bCreate ){
   297    298       if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
   298    299         int nDefn = 32 + pConfig->nCol*10;
   299         -      char *zDefn = sqlite3_malloc(32 + pConfig->nCol * 10);
          300  +      char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 10);
   300    301         if( zDefn==0 ){
   301    302           rc = SQLITE_NOMEM;
   302    303         }else{
   303    304           int i;
   304    305           int iOff;
   305    306           sqlite3_snprintf(nDefn, zDefn, "id INTEGER PRIMARY KEY");
   306    307           iOff = (int)strlen(zDefn);
................................................................................
   583    584   }
   584    585   
   585    586   int sqlite3Fts5StorageRebuild(Fts5Storage *p){
   586    587     Fts5Buffer buf = {0,0,0};
   587    588     Fts5Config *pConfig = p->pConfig;
   588    589     sqlite3_stmt *pScan = 0;
   589    590     Fts5InsertCtx ctx;
   590         -  int rc;
          591  +  int rc, rc2;
   591    592   
   592    593     memset(&ctx, 0, sizeof(Fts5InsertCtx));
   593    594     ctx.pStorage = p;
   594    595     rc = sqlite3Fts5StorageDeleteAll(p);
   595    596     if( rc==SQLITE_OK ){
   596    597       rc = fts5StorageLoadTotals(p, 1);
   597    598     }
................................................................................
   622    623       p->nTotalRow++;
   623    624   
   624    625       if( rc==SQLITE_OK ){
   625    626         rc = fts5StorageInsertDocsize(p, iRowid, &buf);
   626    627       }
   627    628     }
   628    629     sqlite3_free(buf.p);
          630  +  rc2 = sqlite3_reset(pScan);
          631  +  if( rc==SQLITE_OK ) rc = rc2;
   629    632   
   630    633     /* Write the averages record */
   631    634     if( rc==SQLITE_OK ){
   632    635       rc = fts5StorageSaveTotals(p);
   633    636     }
   634    637     return rc;
   635    638   }
................................................................................
   871    874     int *aColSize;                  /* Array of size pConfig->nCol */
   872    875     i64 *aTotalSize;                /* Array of size pConfig->nCol */
   873    876     Fts5IntegrityCtx ctx;
   874    877     sqlite3_stmt *pScan;
   875    878   
   876    879     memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
   877    880     ctx.pConfig = p->pConfig;
   878         -  aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64)));
          881  +  aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
   879    882     if( !aTotalSize ) return SQLITE_NOMEM;
   880    883     aColSize = (int*)&aTotalSize[pConfig->nCol];
   881    884     memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
   882    885   
   883    886     /* Generate the expected index checksum based on the contents of the
   884    887     ** %_content table. This block stores the checksum in ctx.cksum. */
   885    888     rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);

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;
................................................................................
   374    374     if( idxNum==1 ){
   375    375       const char *zByte = (const char *)sqlite3_value_text(apVal[0]);
   376    376       int nByte = sqlite3_value_bytes(apVal[0]);
   377    377       pCsr->zInput = sqlite3_malloc(nByte+1);
   378    378       if( pCsr->zInput==0 ){
   379    379         rc = SQLITE_NOMEM;
   380    380       }else{
   381         -      memcpy(pCsr->zInput, zByte, nByte);
          381  +      if( nByte>0 ) memcpy(pCsr->zInput, zByte, nByte);
   382    382         pCsr->zInput[nByte] = 0;
   383    383         rc = pTab->tok.xTokenize(
   384    384             pTab->pTok, (void*)pCsr, 0, zByte, nByte, fts5tokCb
   385    385         );
   386    386       }
   387    387     }
   388    388   

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         -        int iCode;
          266  +        u32 iCode;
   266    267           int bToken;
   267    268           READ_UTF8(zCsr, zTerm, iCode);
   268    269           if( iCode<128 ){
   269    270             p->aTokenChar[iCode] = (unsigned char)bTokenChars;
   270    271           }else{
   271    272             bToken = p->aCategory[sqlite3Fts5UnicodeCategory(iCode)];
   272    273             assert( (bToken==0 || bToken==1) ); 
   273    274             assert( (bTokenChars==0 || bTokenChars==1) );
   274    275             if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
   275    276               int i;
   276    277               for(i=0; i<nNew; i++){
   277         -              if( aNew[i]>iCode ) break;
          278  +              if( (u32)aNew[i]>iCode ) break;
   278    279               }
   279    280               memmove(&aNew[i+1], &aNew[i], (nNew-i)*sizeof(int));
   280    281               aNew[i] = iCode;
   281    282               nNew++;
   282    283             }
   283    284           }
   284    285         }
................................................................................
   425    426   /*
   426    427   ** Return true if, for the purposes of tokenizing with the tokenizer
   427    428   ** passed as the first argument, codepoint iCode is considered a token 
   428    429   ** character (not a separator).
   429    430   */
   430    431   static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
   431    432     return (
   432         -    p->aCategory[sqlite3Fts5UnicodeCategory(iCode)]
          433  +    p->aCategory[sqlite3Fts5UnicodeCategory((u32)iCode)]
   433    434       ^ fts5UnicodeIsException(p, iCode)
   434    435     );
   435    436   }
   436    437   
   437    438   static int fts5UnicodeTokenize(
   438    439     Fts5Tokenizer *pTokenizer,
   439    440     void *pCtx,
................................................................................
   454    455     const char *pEnd = &aFold[nFold-6];
   455    456   
   456    457     UNUSED_PARAM(iUnused);
   457    458   
   458    459     /* Each iteration of this loop gobbles up a contiguous run of separators,
   459    460     ** then the next token.  */
   460    461     while( rc==SQLITE_OK ){
   461         -    int iCode;                    /* non-ASCII codepoint read from input */
          462  +    u32 iCode;                    /* non-ASCII codepoint read from input */
   462    463       char *zOut = aFold;
   463    464       int is;
   464    465       int ie;
   465    466   
   466    467       /* Skip any separator characters. */
   467    468       while( 1 ){
   468    469         if( zCsr>=zTerm ) goto tokenize_done;
................................................................................
   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);
................................................................................
  1280   1281           &aBuiltin[i].x,
  1281   1282           0
  1282   1283       );
  1283   1284     }
  1284   1285   
  1285   1286     return rc;
  1286   1287   }
  1287         -
  1288         -

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         -  char aChar[] = {
    51         -    '\0',      'a'|0x00,  'c'|0x00,  'e'|0x00,  'i'|0x00,  'n'|0x00,  
    52         -    'o'|0x00,  'u'|0x00,  'y'|0x00,  'y'|0x00,  'a'|0x00,  'c'|0x00,  
    53         -    'd'|0x00,  'e'|0x00,  'e'|0x00,  'g'|0x00,  'h'|0x00,  'i'|0x00,  
    54         -    'j'|0x00,  'k'|0x00,  'l'|0x00,  'n'|0x00,  'o'|0x00,  'r'|0x00,  
    55         -    's'|0x00,  't'|0x00,  'u'|0x00,  'u'|0x00,  'w'|0x00,  'y'|0x00,  
    56         -    'z'|0x00,  'o'|0x00,  'u'|0x00,  'a'|0x00,  'i'|0x00,  'o'|0x00,  
    57         -    'u'|0x00,  'u'|0x80,  'a'|0x80,  'g'|0x00,  'k'|0x00,  'o'|0x00,  
    58         -    'o'|0x80,  'j'|0x00,  'g'|0x00,  'n'|0x00,  'a'|0x80,  'a'|0x00,  
    59         -    'e'|0x00,  'i'|0x00,  'o'|0x00,  'r'|0x00,  'u'|0x00,  's'|0x00,  
    60         -    't'|0x00,  'h'|0x00,  'a'|0x00,  'e'|0x00,  'o'|0x80,  'o'|0x00,  
    61         -    'o'|0x80,  'y'|0x00,  '\0',      '\0',      '\0',      '\0',      
    62         -    '\0',      '\0',      '\0',      '\0',      'a'|0x00,  'b'|0x00,  
    63         -    'c'|0x80,  'd'|0x00,  'd'|0x00,  'e'|0x80,  'e'|0x00,  'e'|0x80,  
    64         -    'f'|0x00,  'g'|0x00,  'h'|0x00,  'h'|0x00,  'i'|0x00,  'i'|0x80,  
    65         -    'k'|0x00,  'l'|0x00,  'l'|0x80,  'l'|0x00,  'm'|0x00,  'n'|0x00,  
    66         -    'o'|0x80,  'p'|0x00,  'r'|0x00,  'r'|0x80,  'r'|0x00,  's'|0x00,  
    67         -    's'|0x80,  't'|0x00,  'u'|0x00,  'u'|0x80,  'v'|0x00,  'w'|0x00,  
    68         -    'w'|0x00,  'x'|0x00,  'y'|0x00,  'z'|0x00,  'h'|0x00,  't'|0x00,  
    69         -    'w'|0x00,  'y'|0x00,  'a'|0x00,  'a'|0x80,  'a'|0x80,  'a'|0x80,  
    70         -    'e'|0x00,  'e'|0x80,  'e'|0x80,  'i'|0x00,  'o'|0x00,  'o'|0x80,  
    71         -    'o'|0x80,  'o'|0x80,  'u'|0x00,  'u'|0x80,  'u'|0x80,  'y'|0x00,  
           50  +#define HIBIT ((unsigned char)0x80)
           51  +  unsigned char aChar[] = {
           52  +    '\0',      'a',       'c',       'e',       'i',       'n',       
           53  +    'o',       'u',       'y',       'y',       'a',       'c',       
           54  +    'd',       'e',       'e',       'g',       'h',       'i',       
           55  +    'j',       'k',       'l',       'n',       'o',       'r',       
           56  +    's',       't',       'u',       'u',       'w',       'y',       
           57  +    'z',       'o',       'u',       'a',       'i',       'o',       
           58  +    'u',       'u'|HIBIT, 'a'|HIBIT, 'g',       'k',       'o',       
           59  +    'o'|HIBIT, 'j',       'g',       'n',       'a'|HIBIT, 'a',       
           60  +    'e',       'i',       'o',       'r',       'u',       's',       
           61  +    't',       'h',       'a',       'e',       'o'|HIBIT, 'o',       
           62  +    'o'|HIBIT, 'y',       '\0',      '\0',      '\0',      '\0',      
           63  +    '\0',      '\0',      '\0',      '\0',      'a',       'b',       
           64  +    'c'|HIBIT, 'd',       'd',       'e'|HIBIT, 'e',       'e'|HIBIT, 
           65  +    'f',       'g',       'h',       'h',       'i',       'i'|HIBIT, 
           66  +    'k',       'l',       'l'|HIBIT, 'l',       'm',       'n',       
           67  +    'o'|HIBIT, 'p',       'r',       'r'|HIBIT, 'r',       's',       
           68  +    's'|HIBIT, 't',       'u',       'u'|HIBIT, 'v',       'w',       
           69  +    'w',       'x',       'y',       'z',       'h',       't',       
           70  +    'w',       'y',       'a',       'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT, 
           71  +    'e',       'e'|HIBIT, 'e'|HIBIT, 'i',       'o',       'o'|HIBIT, 
           72  +    'o'|HIBIT, 'o'|HIBIT, 'u',       'u'|HIBIT, 'u'|HIBIT, 'y',       
    72     73     };
    73     74   
    74     75     unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
    75     76     int iRes = 0;
    76     77     int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;
    77     78     int iLo = 0;
    78     79     while( iHi>=iLo ){
................................................................................
    95     96   ** is a diacritical modifier character.
    96     97   */
    97     98   int sqlite3Fts5UnicodeIsdiacritic(int c){
    98     99     unsigned int mask0 = 0x08029FDF;
    99    100     unsigned int mask1 = 0x000361F8;
   100    101     if( c<768 || c>817 ) return 0;
   101    102     return (c < 768+32) ?
   102         -      (mask0 & (1 << (c-768))) :
   103         -      (mask1 & (1 << (c-768-32)));
          103  +      (mask0 & ((unsigned int)1 << (c-768))) :
          104  +      (mask1 & ((unsigned int)1 << (c-768-32)));
   104    105   }
   105    106   
   106    107   
   107    108   /*
   108    109   ** Interpret the argument as a unicode codepoint. If the codepoint
   109    110   ** is an upper case character that has a lower case equivalent,
   110    111   ** return the codepoint corresponding to the lower case version.
................................................................................
   243    244     
   244    245     else if( c>=66560 && c<66600 ){
   245    246       ret = c + 40;
   246    247     }
   247    248   
   248    249     return ret;
   249    250   }
          251  +
   250    252   
   251    253   int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){ 
   252    254     aArray[0] = 1;
   253    255     switch( zCat[0] ){
   254    256       case 'C':
   255    257             switch( zCat[1] ){
   256    258               case 'c': aArray[1] = 1; break;
................................................................................
   725    727       89,    1434,  3226,  506,   474,   506,   506,   367,   1018,  1946,  
   726    728       1402,  954,   1402,  314,   90,    1082,  218,   2266,  666,   1210,  
   727    729       186,   570,   2042,  58,    5850,  154,   2010,  154,   794,   2266,  
   728    730       378,   2266,  3738,  39,    39,    39,    39,    39,    39,    17351, 
   729    731       34,    3074,  7692,  63,    63,    
   730    732     };
   731    733   
   732         -int sqlite3Fts5UnicodeCategory(int iCode) { 
          734  +int sqlite3Fts5UnicodeCategory(u32 iCode) { 
   733    735     int iRes = -1;
   734    736     int iHi;
   735    737     int iLo;
   736    738     int ret;
   737    739     u16 iKey;
   738    740   
   739    741     if( iCode>=(1<<20) ){

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.

   517    517               break;
   518    518   
   519    519             case FTS5_VOCAB_COL:
   520    520               if( eDetail==FTS5_DETAIL_FULL ){
   521    521                 int iCol = -1;
   522    522                 while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){
   523    523                   int ii = FTS5_POS2COLUMN(iPos);
   524         -                pCsr->aCnt[ii]++;
   525    524                   if( iCol!=ii ){
   526    525                     if( ii>=nCol ){
   527    526                       rc = FTS5_CORRUPT;
   528    527                       break;
   529    528                     }
   530    529                     pCsr->aDoc[ii]++;
   531    530                     iCol = ii;
   532    531                   }
          532  +                pCsr->aCnt[ii]++;
   533    533                 }
   534    534               }else if( eDetail==FTS5_DETAIL_COLUMNS ){
   535    535                 while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){
   536    536                   assert_nc( iPos>=0 && iPos<nCol );
   537    537                   if( iPos>=nCol ){
   538    538                     rc = FTS5_CORRUPT;
   539    539                     break;

Changes to ext/fts5/test/fts5aa.test.

    34     34     t1_docsize {CREATE TABLE 't1_docsize'(id INTEGER PRIMARY KEY, sz BLOB)}
    35     35     t1_config {CREATE TABLE 't1_config'(k PRIMARY KEY, v) WITHOUT ROWID}
    36     36   }
    37     37   
    38     38   do_execsql_test 1.1 {
    39     39     DROP TABLE t1;
    40     40     SELECT name, sql FROM sqlite_master;
    41         -} {
    42         -}
           41  +} {}
    43     42   
    44     43   #-------------------------------------------------------------------------
    45     44   #
    46     45   
    47     46   do_execsql_test 2.0 {
    48     47     CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%);
    49     48   }

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

Added ext/fts5/test/fts5circref.test.

            1  +# 2018 Dec 22
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script is testing the FTS5 module.
           13  +#
           14  +
           15  +source [file join [file dirname [info script]] fts5_common.tcl]
           16  +set testprefix fts5circref
           17  +
           18  +# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
           19  +ifcapable !fts5 {
           20  +  finish_test
           21  +  return
           22  +}
           23  +
           24  +do_execsql_test 1.0 {
           25  +  CREATE VIRTUAL TABLE tt USING fts5(a);
           26  +  SELECT name FROM sqlite_master ORDER BY 1;
           27  +} {
           28  +  tt tt_config tt_content tt_data tt_docsize tt_idx
           29  +}
           30  +db_save_and_close
           31  +
           32  +foreach {tn schema sql} {
           33  +  1 {
           34  +    CREATE TRIGGER tr1 AFTER INSERT ON tt_config BEGIN
           35  +      SELECT * FROM tt;
           36  +    END;
           37  +  } {
           38  +    INSERT INTO tt(tt, rank) VALUES('usermerge', 4);
           39  +  }
           40  +
           41  +  2 {
           42  +    CREATE TRIGGER tr1 AFTER INSERT ON tt_docsize BEGIN
           43  +      SELECT * FROM tt;
           44  +    END;
           45  +  } {
           46  +    INSERT INTO tt(a) VALUES('one two three');
           47  +  }
           48  +
           49  +  3 {
           50  +    CREATE TRIGGER tr1 AFTER INSERT ON tt_content BEGIN
           51  +      SELECT * FROM tt;
           52  +    END;
           53  +  } {
           54  +    INSERT INTO tt(a) VALUES('one two three');
           55  +  }
           56  +
           57  +  4 {
           58  +    CREATE TRIGGER tr1 AFTER INSERT ON tt_data BEGIN
           59  +      SELECT * FROM tt;
           60  +    END;
           61  +  } {
           62  +    INSERT INTO tt(a) VALUES('one two three');
           63  +  }
           64  +
           65  +  5 {
           66  +    CREATE TRIGGER tr1 AFTER INSERT ON tt_idx BEGIN
           67  +      SELECT * FROM tt;
           68  +    END;
           69  +  } {
           70  +    INSERT INTO tt(a) VALUES('one two three');
           71  +  }
           72  +} {
           73  +  db_restore_and_reopen
           74  +  do_execsql_test 1.1.$tn.1 $schema
           75  +  do_catchsql_test 1.1.$tn.2 $sql {1 {SQL logic error}}
           76  +  db close
           77  +}
           78  +
           79  +
           80  +finish_test

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);
    33     34       WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100)
    34     35         INSERT INTO t1 SELECT rnddoc(10) FROM ii;
    35     36     }
    36     37   }
    37     38   
    38         -if 1 {
    39         -
    40     39   # Create a simple FTS5 table containing 100 documents. Each document 
    41     40   # contains 10 terms, each of which start with the character "x".
    42     41   #
    43     42   do_test 1.0 { create_t1 } {}
    44     43   
    45     44   do_test 1.1 {
    46     45     # Pick out the rowid of the right-most b-tree leaf in the new segment.
................................................................................
   376    375       db eval {DELETE FROM t5_data WHERE rowid = $i}
   377    376       set r [catchsql { INSERT INTO t5(t5) VALUES('integrity-check')} ]
   378    377       if {$r != "1 {database disk image is malformed}"} { error $r }
   379    378       db eval ROLLBACK  
   380    379     }
   381    380   } {}
   382    381   
   383         -}
   384         -
   385    382   #------------------------------------------------------------------------
   386    383   # Corruption within the structure record.
   387    384   #
   388    385   reset_db
   389    386   do_execsql_test 8.1 {
   390    387     CREATE VIRTUAL TABLE t1 USING fts5(x, y);
   391    388     INSERT INTO t1 VALUES('one', 'two');
................................................................................
   412    409     append blob "450108"      ;# first segment
   413    410     execsql "REPLACE INTO t1_data VALUES(10, X'$blob')"
   414    411   } {}
   415    412   do_catchsql_test 9.2.2 {
   416    413     SELECT * FROM t1('one AND two');
   417    414   } {1 {database disk image is malformed}}
   418    415   
          416  +#-------------------------------------------------------------------------
          417  +reset_db
          418  +do_test 10.0 {
          419  +  sqlite3 db {}
          420  +  db deserialize [decode_hexdb {
          421  +| size 32768 pagesize 4096 filename c9.db
          422  +| page 1 offset 0
          423  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          424  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          425  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 04   ................
          426  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
          427  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          428  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          429  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          430  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          431  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          432  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          433  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          434  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          435  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          436  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          437  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          438  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          439  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          440  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          441  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          442  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          443  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          444  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          445  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          446  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          447  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          448  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          449  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          450  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          451  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          452  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          453  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          454  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          455  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          456  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          457  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          458  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          459  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          460  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          461  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          462  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          463  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          464  +| page 2 offset 4096
          465  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
          466  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
          467  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          468  +|   4048: 63 6b 01 02 02 04 02 66 74 02 06 36 b0 a0 10 21   ck.....ft..6...!
          469  +|   4064: d6 f7 07 46 96 d6 97 a6 05 01 03 00 10 03 03 0f   ...F............
          470  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
          471  +| page 3 offset 8192
          472  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
          473  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
          474  +| page 4 offset 12288
          475  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
          476  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          477  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          478  +| page 5 offset 16384
          479  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
          480  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
          481  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          482  +| page 6 offset 20480
          483  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          484  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          485  +| page 7 offset 24576
          486  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          487  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          488  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          489  +|   4080: 68 65 62 6c 65 74 31 74 31 43 52 45 41 54 45 20   heblet1t1CREATE 
          490  +| page 8 offset 28672
          491  +|      0: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31   VIRTUAL TABLE t1
          492  +|     16: 20 55 53 49 4e 47 20 66 74 73 35 28 63 6f 6e 74    USING fts5(cont
          493  +|     32: 65 6e 74 29 0d 00 00 00 03 0f bd 00 0f e8 0f ef   ent)............
          494  +|     48: 0f bd 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
          495  +| end c9.db
          496  +  }]
          497  +} {}
          498  +do_catchsql_test 10.1 {
          499  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
          500  +} {1 {database disk image is malformed}}
          501  +
          502  +#-------------------------------------------------------------------------
          503  +#
          504  +reset_db
          505  +do_test 11.0 {
          506  +  sqlite3 db {}
          507  +  db deserialize [decode_hexdb {
          508  +| size 28672 pagesize 4096 filename c10b.db
          509  +| page 1 offset 0
          510  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          511  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
          512  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
          513  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          514  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
          515  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
          516  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          517  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          518  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          519  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          520  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          521  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          522  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          523  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          524  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          525  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          526  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          527  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          528  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          529  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          530  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          531  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          532  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          533  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          534  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          535  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          536  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          537  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          538  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          539  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          540  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          541  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          542  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          543  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          544  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          545  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          546  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 44 d9   (id INTEGER PRD.
          547  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          548  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          549  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          550  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          551  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          552  +| page 2 offset 4096
          553  +|      0: 0d 00 00 00 06 0f 59 00 0f e8 0f ef 0f bd 0f b0   ......Y.........
          554  +|     16: 0f 73 0f 59 00 00 00 00 00 00 00 00 00 00 00 00   .s.Y............
          555  +|   3920: 00 00 00 00 00 00 00 00 00 13 84 80 80 80 80 04   ................
          556  +|   3936: 03 01 2a 0a 00 00 00 00 01 02 02 00 02 01 01 01   ..*.............
          557  +|   3952: 02 01 01 36 84 80 80 80 80 03 03 05 66 00 40 00   ...6........f.@.
          558  +|   3968: 00 00 01 00 00 00 29 07 30 61 63 74 69 76 65 04   ......).0active.
          559  +|   3984: 02 02 02 03 74 6f 6d 06 02 02 05 02 69 63 07 02   ....tom.....ic..
          560  +|   4000: 02 01 06 62 6f 6f 6d 65 72 05 02 02 04 0b 08 07   ...boomer.......
          561  +|   4016: 06 84 80 80 80 80 02 03 01 10 01 07 07 24 84 80   .............$..
          562  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          563  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
          564  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
          565  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
          566  +| page 3 offset 8192
          567  +|      0: 0a 00 00 00 02 0f f3 00 0f fa 0f f3 00 00 00 00   ................
          568  +|   4080: 00 00 00 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
          569  +| page 4 offset 12288
          570  +|      0: 0d 00 00 00 07 0f b6 00 0f f6 0f ec 0f e0 0f d5   ................
          571  +|     16: 0f ca 0f c1 0f b6 00 00 00 00 00 00 00 00 00 00   ................
          572  +|   4016: 00 00 00 00 00 00 09 07 03 00 19 61 74 6f 6d 69   ...........atomi
          573  +|   4032: 63 07 06 03 00 15 61 74 6f 6d 09 05 03 00 19 62   c.....atom.....b
          574  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
          575  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          576  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          577  +| page 5 offset 16384
          578  +|      0: 0d 00 00 00 07 0f d6 00 0f fa 0f f4 0f ee 0f e8   ................
          579  +|     16: 0f e2 0f dc 0f d6 00 00 00 00 00 00 00 00 00 00   ................
          580  +|   4048: 00 00 00 00 00 00 04 07 03 00 0e 01 04 06 03 00   ................
          581  +|   4064: 0e 01 04 05 03 00 0e 01 04 04 03 00 0e 01 04 03   ................
          582  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          583  +| page 6 offset 20480
          584  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          585  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          586  +| page 7 offset 24576
          587  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          588  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          589  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          590  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          591  +| end c10b.db
          592  +}]} {}
          593  +
          594  +# This returns SQLITE_CONSTRAINT instead of SQLITE_CORRUPT. The problem is
          595  +# that the corrupted structure-record leads fts5 to try to use a segment-id
          596  +# that is already in use. This is caught by the PRIMARY KEY constraint on
          597  +# the %_idx table.
          598  +#
          599  +do_catchsql_test 11.1 {
          600  +  UPDATE t1 SET content='abc' WHERE content='boomer';
          601  +} {1 {constraint failed}}
          602  +
          603  +#-------------------------------------------------------------------------
          604  +#
          605  +reset_db
          606  +do_test 12.0 {
          607  +  sqlite3 db {}
          608  +  db deserialize [decode_hexdb {
          609  +| size 28672 pagesize 4096 filename c2.db
          610  +| page 1 offset 0
          611  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          612  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          613  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
          614  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          615  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          616  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          617  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          618  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          619  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          620  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          621  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          622  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          623  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          624  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          625  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          626  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          627  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          628  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          629  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          630  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          631  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          632  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          633  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          634  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          635  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          636  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          637  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          638  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          639  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          640  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          641  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          642  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          643  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          644  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          645  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          646  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          647  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          648  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          649  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          650  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          651  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          652  +| page 2 offset 4096
          653  +|      0: 0d 00 00 00 03 0f bd 00 0f d8 0f ef 0f bd 00 00   ................
          654  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
          655  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          656  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
          657  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
          658  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 20 01 01 01 01   ...$....... ....
          659  +| page 3 offset 8192
          660  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
          661  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
          662  +| page 4 offset 12288
          663  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 3f e0   ..............?.
          664  +|     16: a0 30 30 01 b6 16 26 16 e6 46 f6 e0 80 20 30 01   .00...&..F... 0.
          665  +|     32: 76 16 26 16 67 40 80 10 30 01 76 16 26 16 36 b0   v.&.g@..0.v.&.6.
          666  +|     48: d0 00 00 00 30 fe e0 00 ff a0 ff 40 fe 00 00 00   ....0......@....
          667  +| page 5 offset 16384
          668  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
          669  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          670  +| page 6 offset 20480
          671  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          672  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          673  +| page 7 offset 24576
          674  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          675  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          676  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          677  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          678  +| end c2.db
          679  +}]} {}
          680  +
          681  +do_catchsql_test 11.1 {
          682  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
          683  +} {1 {vtable constructor failed: t1}}
          684  +
          685  +do_catchsql_test 11.2 {
          686  +  INSERT INTO t1(t1, rank) VALUES('merge', 500);
          687  +} {1 {vtable constructor failed: t1}}
          688  +
          689  +#-------------------------------------------------------------------------
          690  +#
          691  +reset_db
          692  +do_test 13.0 {
          693  +  sqlite3 db {}
          694  +  db deserialize [decode_hexdb {
          695  +| size 28672 pagesize 4096 filename c13.db
          696  +| page 1 offset 0
          697  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          698  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          699  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 04   ................
          700  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
          701  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          702  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          703  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          704  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          705  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          706  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          707  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          708  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          709  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          710  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          711  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          712  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          713  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          714  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          715  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          716  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          717  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          718  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          719  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          720  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          721  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          722  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          723  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          724  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 4f 69 64   ATE TABLE 't1Oid
          725  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          726  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          727  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          728  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          729  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          730  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          731  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          732  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          733  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          734  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          735  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          736  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          737  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          738  +| page 2 offset 4096
          739  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
          740  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
          741  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          742  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
          743  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
          744  +|   4080: 0a 03 00 24 00 eb 00 00 00 01 01 01 00 01 01 01   ...$............
          745  +| page 3 offset 8192
          746  +|      0: 01 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00   ................
          747  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
          748  +| page 4 offset 12288
          749  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
          750  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          751  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          752  +| page 5 offset 16384
          753  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f2 0f ee 00 00   ................
          754  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
          755  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          756  +| page 6 offset 20480
          757  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          758  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          759  +| page 7 offset 24576
          760  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          761  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          762  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          763  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          764  +| end c13.db
          765  +SELECT * FROM t1 WHERE t1 MATCH 'abandon';
          766  +}]} {}
          767  +
          768  +do_catchsql_test 13.1 {
          769  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon'; 
          770  +} {1 {vtable constructor failed: t1}}
          771  +
          772  +#-------------------------------------------------------------------------
          773  +reset_db
          774  +do_test 14.0 {
          775  +  sqlite3 db {}
          776  +  db deserialize [decode_hexdb {
          777  +| size 28672 pagesize 4096 filename c14b.db
          778  +| page 1 offset 0
          779  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          780  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
          781  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
          782  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          783  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
          784  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
          785  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          786  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          787  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          788  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          789  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          790  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          791  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          792  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          793  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          794  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          795  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          796  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          797  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          798  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          799  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          800  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          801  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          802  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          803  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          804  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          805  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          806  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          807  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          808  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          809  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          810  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          811  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          812  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          813  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          814  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          815  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          816  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          817  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          818  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          819  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          820  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          821  +| page 2 offset 4096
          822  +|      0: 0d 0f ef 00 04 0f 18 00 0f e8 0f 18 0f bd 0f 2c   ...............,
          823  +|   3856: 00 00 00 00 00 00 00 00 12 0a 03 00 2a 00 00 00   ............*...
          824  +|   3872: 00 01 02 02 00 02 01 01 01 02 01 01 81 09 88 80   ................
          825  +|   3888: 80 80 80 01 04 00 82 16 00 00 00 79 06 30 61 62   ...........y.0ab
          826  +|   3904: 61 63 6b 08 02 07 04 04 6e 64 6f 6e 08 02 05 02   ack.....ndon....
          827  +|   3920: 05 63 74 69 76 65 04 02 02 04 02 0b 02 04 6c 70   .ctive........lp
          828  +|   3936: 68 61 08 04 02 0a 02 03 74 6b 6d 06 02 02 03 02   ha......tkm.....
          829  +|   3952: 6f 6d 08 02 09 05 02 69 63 07 02 02 01 06 62 61   om.....ic.....ba
          830  +|   3968: 63 6b 75 70 08 02 04 02 05 6f 6f 6d 65 72 05 02   ckup.....oomer..
          831  +|   3984: 02 01 0c 63 68 61 6e 6e 65 62 6f 6f 6d 65 72 08   ...channeboomer.
          832  +|   4000: 02 08 07 01 6c 08 02 03 01 04 74 65 73 74 08 02   ....l.....test..
          833  +|   4016: 06 04 0a 09 0d 0a 08 07 07 0b 0a 11 06 24 84 80   .............$..
          834  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          835  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
          836  +|   4064: 6f 6e 03 02 02 03 9a 07 05 01 03 00 10 08 11 00   on..............
          837  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
          838  +| page 3 offset 8192
          839  +|      0: 0a 00 00 00 02 0f f3 00 0f fa 0f f3 00 00 00 00   ................
          840  +|   4080: 00 00 00 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
          841  +| page 4 offset 12288
          842  +|      0: 0d 00 00 00 08 0f 6a 00 0f f6 0f ec 0f e0 0f d5   ......j.........
          843  +|     16: 0f ca 0f c1 0f b6 0f 6a 00 00 00 00 00 00 00 00   .......j........
          844  +|   3936: 00 00 00 00 00 00 00 00 00 00 4a 08 04 00 81 19   ..........J.....
          845  +|   3952: 61 6c 70 68 61 20 63 68 61 6e 6e 65 6c 20 62 61   alpha channel ba
          846  +|   3968: 63 6b 75 70 20 61 62 61 6e 64 6f 6e 20 74 65 73   ckup abandon tes
          847  +|   3984: 74 20 61 62 61 63 6b 20 63 68 61 6e 6e 65 62 6f   t aback channebo
          848  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
          849  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
          850  +|   4032: 63 07 06 03 00 15 61 74 6b 6d 09 05 03 00 19 62   c.....atkm.....b
          851  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
          852  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          853  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          854  +| page 5 offset 16384
          855  +|      0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8   ................
          856  +|     16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00   ................
          857  +|   4048: 04 08 03 00 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
          858  +|   4064: 0e 01 04 05 03 00 0e 01 04 04 03 00 0e 01 04 03   ................
          859  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          860  +| page 6 offset 20480
          861  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          862  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          863  +| page 7 offset 24576
          864  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          865  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          866  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          867  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          868  +| end c14b.db
          869  +}]} {}
          870  +
          871  +do_catchsql_test 14.1 {
          872  +  INSERT INTO t1(t1) VALUES('optimize');
          873  +} {1 {database disk image is malformed}}
          874  +
          875  +#---------------------------------------------------------------------------
          876  +#
          877  +reset_db
          878  +do_test 15.0 {
          879  +  sqlite3 db {}
          880  +  db deserialize [decode_hexdb {
          881  +| size 32768 pagesize 4096 filename c16.db
          882  +| page 1 offset 0
          883  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          884  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          885  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
          886  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          887  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          888  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          889  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          890  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          891  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          892  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          893  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          894  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          895  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          896  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          897  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 00 0f f6 0f ec   ..!!...tabl.....
          898  +|   3680: 0f e0 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ..sizet1_docsize
          899  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          900  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          901  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          902  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          903  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          904  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          905  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          906  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          907  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          908  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          909  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          910  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          911  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          912  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          913  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          914  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          915  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          916  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          917  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          918  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          919  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          920  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          921  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          922  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          923  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          924  +| page 2 offset 4096
          925  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
          926  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
          927  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          928  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
          929  +|   4064: 6f 6e 04 67 90 38 2a 07 05 01 03 00 10 03 03 0f   on.g.8*.........
          930  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
          931  +| page 3 offset 8192
          932  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
          933  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
          934  +| page 4 offset 12288
          935  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
          936  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          937  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          938  +| page 5 offset 16384
          939  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
          940  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
          941  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          942  +| page 6 offset 20480
          943  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          944  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          945  +| page 7 offset 24576
          946  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          947  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          948  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          949  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          950  +| page 8 offset 28672
          951  +|      0: 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74 31 5f   .......-tablet1_
          952  +|     16: 69 64 78 74 31 5f 69 64 78 03 43 52 45 41 54 45   idxt1_idx.CREATE
          953  +|     32: 20 54 41 42 4c 45 20 27 74 31 5f 66 17 42 03 30    TABLE 't1_f.B.0
          954  +|     48: 01 00 00 10 10 04 02 02 00 00 00 00 00 00 00 00   ................
          955  +|     64: 70 00 00 00 00 00 00 00 00 00 00 00 70 00 00 00   p...........p...
          956  +| end c16.db
          957  +}]} {}
          958  +
          959  +do_catchsql_test 15.1 {
          960  +  INSERT INTO t1(t1) VALUES('integrity-check');
          961  +} {1 {database disk image is malformed}}
          962  +
          963  +#---------------------------------------------------------------------------
          964  +#
          965  +reset_db
          966  +do_test 16.0 {
          967  +  sqlite3 db {}
          968  +  db deserialize [decode_hexdb {
          969  +| size 28672 pagesize 4096 filename c17.db
          970  +| page 1 offset 0
          971  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          972  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          973  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
          974  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          975  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          976  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          977  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          978  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          979  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          980  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          981  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          982  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          983  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          984  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          985  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          986  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          987  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          988  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          989  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          990  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          991  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          992  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          993  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          994  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          995  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          996  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          997  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          998  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          999  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1000  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1001  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1002  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1003  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1004  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1005  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1006  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1007  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1008  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1009  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1010  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1011  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1012  +| page 2 offset 4096
         1013  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1014  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1015  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1016  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1017  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1018  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 41 01   ...$..........A.
         1019  +| page 3 offset 8192
         1020  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         1021  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1022  +| page 4 offset 12288
         1023  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1024  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1025  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1026  +| page 5 offset 16384
         1027  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1028  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1029  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1030  +| page 6 offset 20480
         1031  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1032  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1033  +| page 7 offset 24576
         1034  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1035  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1036  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1037  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1038  +| end c17.db
         1039  +}]} {}
         1040  +
         1041  +do_catchsql_test 16.1 {
         1042  +INSERT INTO t1(t1) VALUES('integrity-check');
         1043  +} {1 {vtable constructor failed: t1}}
         1044  +
         1045  +#--------------------------------------------------------------------------
         1046  +reset_db
         1047  +do_test 17.0 {
         1048  +  sqlite3 db {}
         1049  +  db deserialize [decode_hexdb {
         1050  +| size 28672 pagesize 4096 filename c18.db
         1051  +| page 1 offset 0
         1052  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1053  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         1054  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
         1055  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1056  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
         1057  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1058  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1059  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1060  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1061  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1062  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1063  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1064  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1065  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1066  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1067  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1068  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1069  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1070  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1071  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1072  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1073  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1074  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1075  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1076  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1077  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1078  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1079  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1080  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1081  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1082  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1083  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1084  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1085  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1086  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1087  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1088  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1089  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1090  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1091  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1092  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1093  +| page 2 offset 4096
         1094  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1095  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1096  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1097  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1098  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1099  +|   4080: 0a 03 00 24 00 00 0a aa aa aa aa aa aa aa aa aa   ...$............
         1100  +| page 3 offset 8192
         1101  +|      0: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa   ................
         1102  +|     16: aa aa aa aa aa aa aa aa 00 00 10 10 10 00 10 10   ................
         1103  +|     32: 10 10 a0 00 00 00 10 ff a0 00 ff 52 05 64 95 25   ...........R.d.%
         1104  +|     48: 45 54 14 c2 05 44 14 24 c4 52 07 43 12 05 55 34   ET...D.$.R.C..U4
         1105  +|     64: 94 e4 72 06 67 47 33 52 86 36 f6 e7 46 56 e7 42   ..r.gG3R.6..FV.B
         1106  +|     80: 90 d0 00 00 00 30 fb d0 00 fe 80 fe f0 fb 00 00   .....0..........
         1107  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1108  +| page 4 offset 12288
         1109  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1110  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1111  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1112  +| page 5 offset 16384
         1113  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1114  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1115  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1116  +| page 6 offset 20480
         1117  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1118  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1119  +| page 7 offset 24576
         1120  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1121  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1122  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1123  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1124  +| end c18.db
         1125  +}]} {}
         1126  +
         1127  +do_catchsql_test 17.1 {
         1128  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
         1129  +} {1 {vtable constructor failed: t1}}
         1130  +
         1131  +#--------------------------------------------------------------------------
         1132  +reset_db
         1133  +do_test 18.0 {
         1134  +  sqlite3 db {}
         1135  +  db deserialize [decode_hexdb {
         1136  +| size 28672 pagesize 4096 filename c19b.db
         1137  +| page 1 offset 0
         1138  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1139  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
         1140  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         1141  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1142  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         1143  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         1144  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1145  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1146  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1147  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1148  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1149  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1150  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1151  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1152  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1153  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1154  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1155  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1156  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1157  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1158  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1159  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1160  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1161  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1162  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1163  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1164  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1165  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1166  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1167  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1168  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1169  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1170  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1171  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1172  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1173  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1174  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1175  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1176  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1177  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1178  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1179  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1180  +| page 2 offset 4096
         1181  +|      0: 0d 09 a6 00 06 09 22 00 0f e8 09 22 0f bd 0f 2c   ...............,
         1182  +|     16: 09 bd 09 3c 00 00 00 00 00 00 00 00 00 00 00 00   ...<............
         1183  +|   2336: 00 00 18 0a 03 00 36 00 00 00 00 01 04 04 00 04   ......6.........
         1184  +|   2352: 01 01 01 02 01 01 03 01 01 04 01 01 63 90 80 80   ............c...
         1185  +|   2368: 80 80 01 04 00 81 4a 00 00 00 56 06 30 61 62 61   ......J...V.0aba
         1186  +|   2384: 63 6b 08 01 04 04 6e 64 6f 6e 03 01 05 01 02 05   ck....ndon......
         1187  +|   2400: 63 74 69 76 65 08 01 02 04 6c 70 68 61 08 01 02   ctive....lpha...
         1188  +|   2416: 03 74 6f 6d 08 01 01 06 62 61 63 6b 75 70 08 01   .tom....backup..
         1189  +|   2432: 01 0c 63 68 61 6e 6e 65 62 6f 6f 6d 65 72 08 01   ..channeboomer..
         1190  +|   2448: 07 01 6c 08 01 01 04 74 65 73 74 08 01 04 09 0a   ..l....test.....
         1191  +|   2464: 09 08 07 0a 10 05 0f 18 00 17 30 00 00 00 00 01   ..........0.....
         1192  +|   2480: 03 03 00 03 01 01 01 02 01 01 03 01 01 8a 53 8c   ..............S.
         1193  +|   2496: 80 80 80 80 01 04 00 95 2a 00 00 05 35 0d 30 30   ........*...5.00
         1194  +|   2512: 31 30 66 66 61 30 30 30 66 66 61 05 02 1c 02 49   10ffa000ffa....I
         1195  +|   2528: 33 34 33 35 32 34 35 34 31 35 34 34 35 32 30 35   3435245415445205
         1196  +|   2544: 34 34 31 34 32 34 63 34 35 32 30 32 37 37 34 33   441424c452027743
         1197  +|   2560: 31 35 66 36 39 36 34 37 38 32 37 32 38 37 33 36   15f6964782728736
         1198  +|   2576: 35 36 37 36 39 36 34 32 63 32 30 37 34 36 35 37   56769642c2074657
         1199  +|   2592: 32 36 64 32 63 32 30 37 30 05 02 12 02 3b 36 31   26d2c2070....;61
         1200  +|   2608: 37 32 31 32 31 30 31 37 37 37 34 36 31 36 32 35   7212101777461625
         1201  +|   2624: 63 36 35 37 34 33 31 35 66 36 33 36 66 36 65 37   c6574315f636f6e7
         1202  +|   2640: 34 36 35 36 65 37 34 37 34 33 31 35 66 36 33 36   4656e7474315f636
         1203  +|   2656: 66 36 65 37 34 36 35 36 65 05 04 07 07 01 04 31   f6e74656e......1
         1204  +|   2672: 66 62 64 05 02 19 01 44 32 34 38 34 38 30 38 30   fbd....D24848080
         1205  +|   2688: 38 30 38 30 30 31 30 33 30 30 34 65 30 30 30 30   80800103004e0000
         1206  +|   2704: 30 30 31 65 30 36 33 30 36 31 36 32 36 31 36 33   001e063061626163
         1207  +|   2720: 36 62 30 31 30 32 30 32 30 34 30 32 36 36 37 34   6b01020204026674
         1208  +|   2736: 30 32 30 32 30 32 30 34 30 34 36 65 05 02 1a 02   02020204046e....
         1209  +|   2752: 03 66 65 72 05 02 1d 01 28 33 65 37 34 36 35 36   .fer....(3e74656
         1210  +|   2768: 65 37 34 32 39 30 64 30 30 30 30 30 30 30 33 30   e74290d000000030
         1211  +|   2784: 66 62 64 30 30 30 66 65 38 30 66 65 66 30 66 62   fbd000fe80fef0fb
         1212  +|   2800: 64 05 02 18 01 4a 34 31 35 32 35 39 32 30 34 62   d....J415259204b
         1213  +|   2816: 34 35 35 39 32 63 32 30 36 32 36 63 36 66 36 33   45592c20626c6f63
         1214  +|   2832: 36 62 32 30 34 32 34 63 34 66 34 32 32 39 33 61   6b20424c4f42293a
         1215  +|   2848: 30 31 30 36 31 37 31 31 31 31 30 38 36 33 37 34   0106171111086374
         1216  +|   2864: 36 31 36 32 36 63 36 35 37 34 33 31 37 34 33 31   61626c6574317431
         1217  +|   2880: 05 02 16 02 49 33 35 32 34 35 34 31 35 34 34 35   ....I35245415445
         1218  +|   2896: 32 30 35 36 34 39 35 32 35 34 35 35 34 31 34 63   205649525455414c
         1219  +|   2912: 32 30 35 34 34 31 34 32 34 63 34 35 32 30 37 34   205441424c452074
         1220  +|   2928: 33 31 6f 30 35 35 35 33 34 39 34 65 34 37 32 30   31o05553494e4720
         1221  +|   2944: 36 36 37 34 37 33 33 35 32 38 36 33 36 66 05 02   6674733528636f..
         1222  +|   2960: 17 02 49 35 32 30 35 34 34 31 34 32 34 63 34 35   ..I5205441424c45
         1223  +|   2976: 32 30 32 37 37 34 33 31 35 66 36 33 36 66 36 65   202774315f636f6e
         1224  +|   2992: 37 34 36 35 36 65 37 34 32 37 32 38 36 39 36 34   74656e7427286964
         1225  +|   3008: 32 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32   20494e5445474552
         1226  +|   3024: 32 30 35 30 35 32 34 39 34 64 34 31 05 02 0e 44   205052494d41...D
         1227  +|   3040: 29 62 30 35 30 37 31 37 32 31 32 31 30 31 38 31   )b05071721210181
         1228  +|   3056: 30 31 37 34 36 31 36 32 36 63 36 35 37 34 33 31   017461626c657431
         1229  +|   3072: 35 66 36 34 36 66 36 33 37 33 05 02 09 01 4a 35   5f646f6373....J5
         1230  +|   3088: 32 34 35 34 31 35 34 34 35 32 30 35 34 34 31 34   2454154452054414
         1231  +|   3104: 32 34 63 34 35 32 30 32 37 37 34 33 31 35 66 36   24c45202774315f6
         1232  +|   3120: 34 36 31 37 34 36 31 32 37 32 38 36 39 36 34 32   4617461272869642
         1233  +|   3136: 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32   0494e54454745522
         1234  +|   3152: 30 35 30 35 32 34 39 34 64 05 02 15 03 3a 35 39   05052494d....:59
         1235  +|   3168: 32 30 34 62 34 35 35 39 32 63 32 30 36 33 33 30   204b45592c206330
         1236  +|   3184: 32 39 36 39 30 33 30 37 31 37 31 39 31 39 30 31   2969030717191901
         1237  +|   3200: 38 31 32 64 37 34 36 31 36 32 36 63 36 35 37 34   812d7461626c6574
         1238  +|   3216: 33 31 35 66 36 39 79 79 05 02 0f 02 49 34 32 30   315f69yy....I420
         1239  +|   3232: 35 32 34 66 35 37 34 39 34 34 35 35 30 32 30 37   524f574944550207
         1240  +|   3248: 31 37 31 62 31 62 30 31 38 31 30 31 37 34 36 31   171b1b0181017461
         1241  +|   3264: 36 32 36 63 36 37 37 34 33 31 35 66 36 34 36 31   626c6774315f6461
         1242  +|   3280: 37 34 36 31 37 34 33 31 35 66 36 34 36 31 37 34   746174315f646174
         1243  +|   3296: 36 31 30 32 34 33 05 02 14 02 07 66 36 39 36 34   610243.....f6964
         1244  +|   3312: 37 38 05 02 11 01 4a 36 34 36 66 36 65 30 33 30   78....J646f6e030
         1245  +|   3328: 32 30 32 30 34 30 61 30 37 30 35 30 31 30 33 30   202040a070501030
         1246  +|   3344: 30 31 30 30 33 30 33 30 66 30 61 30 33 30 30 32   01003030f0a03002
         1247  +|   3360: 34 30 30 30 30 30 30 30 30 30 31 30 31 30 31 30   4000000000101010
         1248  +|   3376: 30 30 31 30 31 30 31 30 31 30 61 30 30 30 30 30   0010101010a00000
         1249  +|   3392: 30 05 02 1b 02 49 35 32 37 32 38 36 39 36 34 32   0....I5272869642
         1250  +|   3408: 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32   0494e54454745522
         1251  +|   3424: 30 35 30 35 32 34 39 34 64 34 31 35 32 35 39 32   05052494d4152592
         1252  +|   3440: 30 34 62 34 35 35 39 32 63 32 30 37 33 37 61 32   04b45592c20737a2
         1253  +|   3456: 30 34 32 34 63 34 66 34 32 32 39 35 35 30 34 05   0424c4f42295504.
         1254  +|   3472: 04 06 07 02 49 37 36 65 36 66 32 63 32 30 35 30   ....I76e6f2c2050
         1255  +|   3488: 35 32 34 39 34 64 34 31 35 32 35 39 32 30 34 62   52494d415259204b
         1256  +|   3504: 34 35 35 39 32 38 37 33 36 35 36 37 36 39 36 34   4559287365676964
         1257  +|   3520: 32 63 32 30 37 34 36 35 37 32 36 64 32 39 32 39   2c207465726d2929
         1258  +|   3536: 32 30 35 37 34 39 35 34 34 38 34 66 35 35 05 02   20574954484f55..
         1259  +|   3552: 13 02 49 39 37 61 36 35 37 34 33 31 35 66 36 34   ..I97a6574315f64
         1260  +|   3568: 36 66 36 33 37 33 36 39 37 61 36 35 30 35 34 33   6f6373697a650543
         1261  +|   3584: 35 32 34 35 34 31 35 34 34 35 32 30 35 34 34 31   5245415445205441
         1262  +|   3600: 34 32 34 63 34 35 32 30 32 37 37 34 33 31 35 66   424c45202774315f
         1263  +|   3616: 36 34 36 66 36 33 37 33 36 39 37 61 05 04 05 07   646f6373697a....
         1264  +|   3632: 01 0e 37 34 30 34 34 33 35 32 34 35 34 31 35 34   ..74044352454154
         1265  +|   3648: 05 04 08 07 02 49 36 32 39 32 30 35 37 34 39 35   .....I6292057495
         1266  +|   3664: 34 34 38 34 66 35 35 35 34 32 30 35 32 34 66 35   4484f555420524f5
         1267  +|   3680: 37 34 39 34 34 35 62 30 35 30 37 31 37 32 31 32   749445b050717212
         1268  +|   3696: 31 30 31 38 31 30 31 37 34 36 31 36 32 36 63 36   10181017461626c6
         1269  +|   3712: 35 37 34 33 31 35 66 36 34 36 66 36 33 37 33 05   574315f646f6373.
         1270  +|   3728: 02 04 01 06 62 61 63 6b 75 70 05 02 1e 02 05 65   ....backup.....e
         1271  +|   3744: 61 6d 65 72 05 02 02 02 05 6f 6f 6d 65 72 05 01   amer.....oomer..
         1272  +|   3760: 02 40 75 6d 6d 32 34 63 34 35 32 30 32 37 37 34   .@umm24c45202774
         1273  +|   3776: 33 31 35 66 36 33 36 66 36 65 36 36 36 39 36 37   315f636f6e666967
         1274  +|   3792: 32 37 32 38 36 62 32 30 35 30 35 32 34 39 34 64   27286b205052494d
         1275  +|   3808: 34 31 35 32 35 39 32 30 34 62 34 35 35 39 32 63   415259204b45592c
         1276  +|   3824: 32 30 05 02 03 01 04 79 65 6b 72 05 02 10 04 11   20.....yekr.....
         1277  +|   3840: 4e 41 09 49 08 2d 4f 4e 4e 2e 4f 3f 4e 0c 4f 4f   NA.I.-ONN.O?N.OO
         1278  +|   3856: 4e 4f 14 4e 0b 0a 09 45 0f ef 00 14 2a 00 00 00   NO.N...E....*...
         1279  +|   3872: 00 01 02 02 00 02 01 01 01 02 01 01 81 09 88 80   ................
         1280  +|   3888: 80 80 80 01 04 00 82 16 00 00 00 79 06 30 61 62   ...........y.0ab
         1281  +|   3904: 61 63 6b 08 02 07 04 04 6e 64 6f 6e 08 02 05 02   ack.....ndon....
         1282  +|   3920: 05 63 74 69 76 65 04 02 02 04 02 0b 02 04 6c 70   .ctive........lp
         1283  +|   3936: 68 61 08 04 02 0a 02 03 74 6b 6d 06 02 02 03 02   ha......tkm.....
         1284  +|   3952: 6f 6d 08 02 09 05 02 69 63 07 02 02 01 06 62 61   om.....ic.....ba
         1285  +|   3968: 63 6b 75 70 08 02 04 02 05 6f 6f 6d 65 72 05 02   ckup.....oomer..
         1286  +|   3984: 02 01 0c 63 68 61 6e 6e 65 62 6f 6f 6d 65 72 08   ...channeboomer.
         1287  +|   4000: 02 08 07 01 6c 08 02 03 01 04 74 65 73 74 08 02   ....l.....test..
         1288  +|   4016: 06 04 0a 09 0d 0a 08 07 07 0b 0a 11 06 24 84 80   .............$..
         1289  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1290  +|   4048: 63 6b 01 08 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1291  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 06 22 00   on..............
         1292  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         1293  +| page 3 offset 8192
         1294  +|      0: 0a 00 00 00 04 0f e5 00 0f fa 0f f3 0f ec 0f e5   ................
         1295  +|   4064: 00 00 00 00 00 06 04 01 0c 01 04 02 06 04 01 0c   ................
         1296  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         1297  +| page 4 offset 12288
         1298  +|      0: 0d 0f 68 00 06 08 98 00 0f f6 0f ec 0f d5 08 98   ..h.............
         1299  +|     16: 0f c1 0f b6 0f 68 0f 68 00 00 00 00 00 00 00 00   .....h.h........
         1300  +|   2192: 00 00 00 00 00 00 00 00 8d 4d 05 04 00 9b 1f 62   .........M.....b
         1301  +|   2208: 65 61 6d 65 72 20 62 75 6d 6d 32 34 63 34 35 32   eamer bumm24c452
         1302  +|   2224: 30 32 37 37 34 33 31 35 66 36 33 36 66 36 65 36   02774315f636f6e6
         1303  +|   2240: 36 36 39 36 37 32 37 32 38 36 62 32 30 35 30 35   6696727286b20505
         1304  +|   2256: 32 34 39 34 64 34 31 35 32 35 39 32 30 34 62 34   2494d415259204b4
         1305  +|   2272: 35 35 39 32 63 32 30 0a 37 36 32 39 32 30 35 37   5592c20.76292057
         1306  +|   2288: 34 39 35 34 34 38 34 66 35 35 35 34 32 30 35 32   4954484f55542052
         1307  +|   2304: 34 66 35 37 34 39 34 34 35 62 30 35 30 37 31 37   4f5749445b050717
         1308  +|   2320: 32 31 32 31 30 31 38 31 30 31 37 34 36 31 36 32   2121018101746162
         1309  +|   2336: 36 63 36 35 37 34 33 31 35 66 36 34 36 66 36 33   6c6574315f646f63
         1310  +|   2352: 37 33 0a 36 39 37 61 36 35 37 34 33 31 35 66 36   73.697a6574315f6
         1311  +|   2368: 34 36 66 36 33 37 33 36 39 37 61 36 35 30 35 34   46f6373697a65054
         1312  +|   2384: 33 35 32 34 35 34 31 35 34 34 35 32 30 35 34 34   3524541544520544
         1313  +|   2400: 31 34 32 34 63 34 35 32 30 32 37 37 34 33 31 35   1424c45202774315
         1314  +|   2416: 66 36 34 36 66 36 33 37 33 36 39 37 61 0a 36 35   f646f6373697a.65
         1315  +|   2432: 32 37 32 38 36 39 36 34 32 30 34 39 34 65 35 34   2728696420494e54
         1316  +|   2448: 34 35 34 37 34 35 35 32 32 30 35 30 35 32 34 39   4547455220505249
         1317  +|   2464: 34 64 34 31 35 32 35 39 32 30 34 62 34 35 35 39   4d415259204b4559
         1318  +|   2480: 32 63 32 30 37 33 37 61 32 30 34 32 34 63 34 66   2c20737a20424c4f
         1319  +|   2496: 34 32 32 39 35 35 30 34 0a 30 36 31 37 32 31 32   42295504.0617212
         1320  +|   2512: 31 30 31 37 37 37 34 36 31 36 32 35 63 36 35 37   101777461625c657
         1321  +|   2528: 34 33 31 35 66 36 33 36 66 36 65 37 34 36 35 36   4315f636f6e74656
         1322  +|   2544: 65 37 34 37 34 33 31 35 66 36 33 36 66 36 65 37   e7474315f636f6e7
         1323  +|   2560: 34 36 35 36 65 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   4656e...........
         1324  +|   2576: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1325  +|   2592: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1326  +|   2608: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1327  +|   2624: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1328  +|   2640: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1329  +|   2656: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 37 34 30   .............740
         1330  +|   2672: 34 34 33 35 32 34 35 34 31 35 34 0a 34 35 32 30   44352454154.4520
         1331  +|   2688: 35 34 34 31 34 32 34 63 34 35 32 30 32 37 37 34   5441424c45202774
         1332  +|   2704: 33 31 35 66 36 33 36 66 36 65 37 34 36 35 36 65   315f636f6e74656e
         1333  +|   2720: 37 34 32 37 32 38 36 39 36 34 32 30 34 39 34 65   742728696420494e
         1334  +|   2736: 35 34 34 35 34 37 34 35 35 32 32 30 35 30 35 62   544547455220505b
         1335  +|   2752: 30 35 30 37 31 37 32 31 32 31 30 31 38 31 30 31   0507172121018101
         1336  +|   2768: 37 34 36 31 36 32 36 63 36 35 37 34 33 31 35 66   7461626c6574315f
         1337  +|   2784: 36 34 36 66 36 33 37 33 0a 36 39 37 61 36 35 37   646f6373.697a657
         1338  +|   2800: 34 33 31 35 66 36 34 36 66 36 33 37 33 36 39 37   4315f646f6373697
         1339  +|   2816: 61 36 35 30 35 34 33 35 32 34 35 34 31 35 34 34   a650543524541544
         1340  +|   2832: 35 32 30 35 34 34 31 34 32 34 63 34 35 32 30 32   5205441424c45202
         1341  +|   2848: 37 37 34 33 31 35 66 36 34 36 66 36 33 37 33 36   774315f646f63736
         1342  +|   2864: 39 37 61 0a 36 35 32 37 32 38 36 39 36 34 32 30   97a.652728696420
         1343  +|   2880: 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32 30   494e544547455220
         1344  +|   2896: 35 30 35 32 34 39 34 64 34 31 35 32 35 39 32 30   5052494d41525920
         1345  +|   2912: 34 62 34 35 35 39 32 63 32 30 37 33 37 61 32 30   4b45592c20737a20
         1346  +|   2928: 34 32 34 63 34 66 34 32 32 39 35 35 30 34 0a 30   424c4f42295504.0
         1347  +|   2944: 36 31 37 32 31 32 31 30 31 37 37 37 34 36 31 36   6172121017774616
         1348  +|   2960: 32 35 63 36 35 37 34 33 31 35 66 36 33 36 66 36   25c6574315f636f6
         1349  +|   2976: 65 37 34 36 35 36 65 37 34 37 34 33 31 35 66 36   e74656e7474315f6
         1350  +|   2992: 33 36 66 36 65 37 34 36 35 36 65 0b 0b 0b 0b 0b   36f6e74656e.....
         1351  +|   3008: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1352  +|   3024: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1353  +|   3040: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1354  +|   3056: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1355  +|   3072: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1356  +|   3088: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1357  +|   3104: 0b 0b 0b 37 34 30 34 34 33 35 32 34 35 34 31 35   ...7404435245415
         1358  +|   3120: 34 0a 34 35 32 30 35 34 34 31 34 32 34 63 34 35   4.45205441424c45
         1359  +|   3136: 32 30 32 37 37 34 33 31 35 66 36 33 36 66 36 65   202774315f636f6e
         1360  +|   3152: 37 34 36 35 36 65 37 34 32 37 32 38 36 39 36 34   74656e7427286964
         1361  +|   3168: 32 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32   20494e5445474552
         1362  +|   3184: 32 30 35 30 35 32 34 39 34 64 34 31 0a 35 32 35   205052494d41.525
         1363  +|   3200: 39 32 30 34 62 34 35 35 39 32 63 32 30 36 33 33   9204b45592c20633
         1364  +|   3216: 30 32 39 36 39 30 33 30 37 31 37 31 39 31 39 30   0296903071719190
         1365  +|   3232: 31 38 31 32 64 37 34 36 31 36 32 36 63 36 35 37   1812d7461626c657
         1366  +|   3248: 34 33 31 35 66 36 39 c3 bf c3 bf 7e c3 bf c3 89   4315f69....~....
         1367  +|   3264: 4b 52 c2 81 35 66 36 39 36 34 37 38 0a 30 33 34   KR..5f696478.034
         1368  +|   3280: 33 35 32 34 35 34 31 35 34 34 35 32 30 35 34 34   3524541544520544
         1369  +|   3296: 31 34 32 34 63 34 35 32 30 32 37 37 34 33 31 35   1424c45202774315
         1370  +|   3312: 66 36 39 36 34 37 38 32 37 32 38 37 33 36 35 36   f696478272873656
         1371  +|   3328: 37 36 39 36 34 32 63 32 30 37 34 36 35 37 32 36   769642c207465726
         1372  +|   3344: 64 32 63 32 30 37 30 0a 36 37 36 65 36 66 32 63   d2c2070.676e6f2c
         1373  +|   3360: 32 30 35 30 35 32 34 39 34 64 34 31 35 32 35 39   205052494d415259
         1374  +|   3376: 32 30 34 62 34 35 35 39 32 38 37 33 36 35 36 37   204b455928736567
         1375  +|   3392: 36 39 36 34 32 63 32 30 37 34 36 35 37 32 36 64   69642c207465726d
         1376  +|   3408: 32 39 32 39 32 30 35 37 34 39 35 34 34 38 34 66   292920574954484f
         1377  +|   3424: 35 35 0a 35 34 32 30 35 32 34 66 35 37 34 39 34   55.5420524f57494
         1378  +|   3440: 34 35 35 30 32 30 37 31 37 31 62 31 62 30 31 38   4550207171b1b018
         1379  +|   3456: 31 30 31 37 34 36 31 36 32 36 63 36 37 37 34 33   1017461626c67743
         1380  +|   3472: 31 35 66 36 34 36 31 37 34 36 31 37 34 33 31 35   15f6461746174315
         1381  +|   3488: 66 36 34 36 31 37 34 36 31 30 32 34 33 0a 35 32   f646174610243.52
         1382  +|   3504: 34 35 34 31 35 34 34 35 32 30 35 34 34 31 34 32   4541544520544142
         1383  +|   3520: 34 63 34 35 32 30 32 37 37 34 33 31 35 66 36 34   4c45202774315f64
         1384  +|   3536: 36 31 37 34 36 31 32 37 32 38 36 39 36 34 32 30   6174612728696420
         1385  +|   3552: 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32 30   494e544547455220
         1386  +|   3568: 35 30 35 32 34 39 34 64 0a 34 31 35 32 35 39 32   5052494d.4152592
         1387  +|   3584: 30 34 62 34 35 35 39 32 63 32 30 36 32 36 63 36   04b45592c20626c6
         1388  +|   3600: 66 36 33 36 62 32 30 34 32 34 63 34 66 34 32 32   f636b20424c4f422
         1389  +|   3616: 39 33 61 30 31 30 36 31 37 31 31 31 31 30 38 36   93a0106171111086
         1390  +|   3632: 33 37 34 36 31 36 32 36 63 36 35 37 34 33 31 37   37461626c6574317
         1391  +|   3648: 34 33 31 0a 34 33 35 32 34 35 34 31 35 34 34 35   431.435245415445
         1392  +|   3664: 32 30 35 36 34 39 35 32 35 34 35 35 34 31 34 63   205649525455414c
         1393  +|   3680: 32 30 35 34 34 31 34 32 34 63 34 35 32 30 37 34   205441424c452074
         1394  +|   3696: 33 31 c3 94 30 35 35 35 33 34 39 34 65 34 37 32   31..05553494e472
         1395  +|   3712: 30 36 36 37 34 37 33 33 35 32 38 36 33 36 66 0a   06674733528636f.
         1396  +|   3728: 33 65 37 34 36 35 36 65 37 34 32 39 30 64 30 30   3e74656e74290d00
         1397  +|   3744: 30 30 30 30 30 33 30 66 62 64 30 30 30 66 65 38   0000030fbd000fe8
         1398  +|   3760: 30 66 65 66 30 66 62 64 0a 5b 31 66 62 64 5d 32   0fef0fbd.[1fbd]2
         1399  +|   3776: 34 38 34 38 30 38 30 38 30 38 30 30 31 30 33 30   4848080808001030
         1400  +|   3792: 30 34 65 30 30 30 30 30 30 31 65 30 36 33 30 36   04e0000001e06306
         1401  +|   3808: 31 36 32 36 31 36 33 36 62 30 31 30 32 30 32 30   16261636b0102020
         1402  +|   3824: 34 30 32 36 36 37 34 30 32 30 32 30 32 30 34 30   4026674020202040
         1403  +|   3840: 34 36 65 0a 36 34 36 66 36 65 30 33 30 32 30 32   46e.646f6e030202
         1404  +|   3856: 30 34 30 61 30 37 30 35 30 31 30 33 30 30 31 30   040a070501030010
         1405  +|   3872: 30 33 30 33 30 66 30 61 30 33 30 30 32 34 30 30   03030f0a03002400
         1406  +|   3888: 30 30 30 30 30 30 30 31 30 31 30 31 30 30 30 31   0000000101010001
         1407  +|   3904: 30 31 30 31 30 31 30 61 30 30 30 30 30 30 0a 30   0101010a000000.0
         1408  +|   3920: 31 30 66 66 61 30 30 30 66 66 61 0a 5b 32 66 65   10ffa000ffa.[2fe
         1409  +|   3936: 72 20 62 61 63 6b 75 70 0f ca 00 4e 81 1d 61 6c   r backup...N..al
         1410  +|   3952: 70 68 61 20 63 68 61 6e 6e 65 6c 20 c2 af 62 61   pha channel ..ba
         1411  +|   3968: 63 6b 75 70 20 61 62 61 6e 64 6f 6e 20 74 65 73   ckup abandon tes
         1412  +|   3984: 74 20 61 62 61 63 6b 20 63 68 61 6e 6e 65 62 6f   t aback channebo
         1413  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         1414  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         1415  +|   4032: 63 07 06 03 00 15 61 74 6b 6d 0f e0 00 0b 19 62   c.....atkm.....b
         1416  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
         1417  +|   4064: 00 00 00 0c 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1418  +|   4080: 17 61 66 21 66 74 08 01 03 00 17 61 62 61 63 6b   .af!ft.....aback
         1419  +| page 5 offset 16384
         1420  +|      0: 0d 0f ee 00 06 0f d6 00 0f fa 0f f4 0f e8 0f e2   ................
         1421  +|     16: 0f dc 0f d6 0f d0 0f d0 00 00 00 00 00 00 00 00   ................
         1422  +|   4048: 0f ee 00 06 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         1423  +|   4064: 0e 01 04 05 03 00 0e 1d 04 04 03 00 0e 01 00 00   ................
         1424  +|   4080: 00 06 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1425  +| page 6 offset 20480
         1426  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1427  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1428  +| page 7 offset 24576
         1429  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1430  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1431  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1432  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1433  +| end c19b.db
         1434  +}]} {}
         1435  +
         1436  +do_catchsql_test 18.1 {
         1437  +  INSERT INTO t1(t1) VALUES('optimize');
         1438  +} {1 {database disk image is malformed}}
         1439  +
         1440  +#--------------------------------------------------------------------------
         1441  +reset_db
         1442  +do_test 19.0 {
         1443  +  sqlite3 db {}
         1444  +  db deserialize [decode_hexdb {
         1445  +| size 28672 pagesize 4096 filename c20b.db
         1446  +| page 1 offset 0
         1447  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1448  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
         1449  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         1450  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1451  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         1452  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         1453  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1454  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1455  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1456  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1457  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1458  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1459  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1460  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1461  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1462  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1463  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1464  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1465  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1466  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1467  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1468  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1469  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1470  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1471  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1472  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1473  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1474  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1475  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1476  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1477  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1478  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1479  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1480  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1481  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1482  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1483  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1484  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1485  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1486  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1487  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1488  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1489  +| page 2 offset 4096
         1490  +|      0: 0d 0f 20 00 05 0e a0 00 0f e8 0e a0 0f bd 0f 34   .. ............4
         1491  +|     16: 0e b7 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         1492  +|   3744: 15 0a 03 00 30 00 00 00 00 01 03 03 00 03 01 01   ....0...........
         1493  +|   3760: 01 02 01 01 03 01 01 62 8c 80 80 80 80 01 04 00   .......b........
         1494  +|   3776: 81 48 00 00 00 55 06 30 61 62 61 63 6b 08 01 04   .H...U.0aback...
         1495  +|   3792: 04 6e 64 6f 6e 03 01 05 01 02 05 63 74 69 76 65   .ndon......ctive
         1496  +|   3808: 08 01 02 04 6c 70 68 61 08 01 02 03 74 6f 6d 08   ....lpha....tom.
         1497  +|   3824: 01 01 06 62 61 63 6b 75 70 08 01 02 05 6f 6f 6d   ...backup....oom
         1498  +|   3840: 65 72 08 01 01 07 63 68 61 6e 6e 65 6c 08 01 01   er....channel...
         1499  +|   3856: 04 74 65 73 74 08 01 04 09 0a 09 08 07 0a 09 0b   .test...........
         1500  +|   3872: 0f ef 00 14 2a 00 00 00 00 01 02 02 00 02 01 01   ....*...........
         1501  +|   3888: 01 02 01 01 81 01 88 80 80 80 80 01 04 00 82 06   ................
         1502  +|   3904: 00 00 00 72 06 30 61 62 61 63 6b 08 02 07 04 04   ...r.0aback.....
         1503  +|   3920: 6e 64 6f 6e 08 02 05 02 05 63 74 69 76 65 04 02   ndon.....ctive..
         1504  +|   3936: 02 04 02 0b 02 04 6c 70 68 61 08 04 02 0a 02 03   ......lpha......
         1505  +|   3952: 74 6f 6d 06 02 02 02 02 09 05 02 69 63 07 02 02   tom........ic...
         1506  +|   3968: 01 06 62 61 63 6b 75 70 08 02 04 02 05 6f 6f 66   ..backup.....oof
         1507  +|   3984: 65 72 05 02 02 04 03 6d 65 72 08 02 08 01 07 63   er.....mer.....c
         1508  +|   4000: 68 61 6e 6e 65 6c 08 02 03 01 04 74 65 73 74 08   hannel.....test.
         1509  +|   4016: 02 06 04 0a 09 0d 0a 0b 07 0b 0a 08 0c 24 84 80   .............$..
         1510  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1511  +|   4048: 63 6b 01 02 66 04 00 22 74 00 02 22 04 04 6e 64   ck..f...t.....nd
         1512  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 06 06 00   on..............
         1513  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         1514  +| page 3 offset 8192
         1515  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         1516  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         1517  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         1518  +| page 4 offset 12288
         1519  +|      0: 0d 0f e0 00 06 0f b6 00 0f f6 0f ec 0f d5 0f ca   ................
         1520  +|     16: 0f c1 0f b6 0f 70 0f 70 00 00 00 00 00 00 00 00   .....p.p........
         1521  +|   3952: 0f e0 00 46 81 0d 61 6c 70 68 61 20 63 68 61 6e   ...F..alpha chan
         1522  +|   3968: 6e 65 6c 20 62 61 63 6b 75 70 20 61 62 61 6e 64   nel backup aband
         1523  +|   3984: 6f 6e 20 74 65 73 74 20 61 62 61 63 6b 20 62 6f   on test aback bo
         1524  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         1525  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         1526  +|   4032: 63 07 06 03 00 15 61 74 6f 6d 09 05 03 00 19 62   c.....atom.....b
         1527  +|   4048: 6f 6f 66 65 72 09 04 03 00 19 61 63 74 69 76 65   oofer.....active
         1528  +|   4064: 00 00 00 0c 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1529  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1530  +| page 5 offset 16384
         1531  +|      0: 0d 0f ee 00 06 0f d6 00 0f fa 0f f4 0f e8 0f e2   ................
         1532  +|     16: 0f dc 0f d6 0f d0 0f d0 00 00 00 00 00 00 00 00   ................
         1533  +|   4048: 0f ee 00 06 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         1534  +|   4064: 0e 01 04 05 03 00 0e 01 04 04 03 00 0e 01 00 00   ................
         1535  +|   4080: 00 06 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1536  +| page 6 offset 20480
         1537  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1538  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1539  +| page 7 offset 24576
         1540  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1541  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1542  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1543  +|   4080: 86 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   .eck....optimize
         1544  +| end c20b.db
         1545  +}]} {}
         1546  +
         1547  +do_catchsql_test 19.1 {
         1548  +  INSERT INTO t1(t1) VALUES('optimize');
         1549  +} {1 {database disk image is malformed}}
         1550  +
         1551  +#--------------------------------------------------------------------------
         1552  +reset_db
         1553  +do_test 20.0 {
         1554  +  sqlite3 db {}
         1555  +  db deserialize [decode_hexdb {
         1556  +| size 28672 pagesize 4096 filename crash-cf347c523f793c.db
         1557  +| page 1 offset 0
         1558  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1559  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         1560  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
         1561  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1562  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
         1563  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1564  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1565  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1566  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1567  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1568  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1569  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1570  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1571  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1572  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1573  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1574  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1575  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1576  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1577  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1578  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1579  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1580  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1581  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1582  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1583  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1584  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1585  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1586  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1587  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1588  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1589  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1590  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1591  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1592  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1593  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1594  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1595  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1596  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1597  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1598  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1599  +| page 2 offset 4096
         1600  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1601  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1602  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1603  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
         1604  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1605  +|   4080: 0a 03 00 24 00 00 00 0e ee ee ee ee ee ee ee ee   ...$............
         1606  +| page 3 offset 8192
         1607  +|      0: ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee   ................
         1608  +|     16: ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee   ................
         1609  +|     32: ee ee ee ee ee ee ee ee ee ee ee ee 00 10 10 10   ................
         1610  +|     48: 00 10 10 10 10 a0 00 00 00 10 ff a0 00 ff 00 00   ................
         1611  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1612  +| page 4 offset 12288
         1613  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1614  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1615  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1616  +| page 5 offset 16384
         1617  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1618  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1619  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1620  +| page 6 offset 20480
         1621  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1622  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1623  +| page 7 offset 24576
         1624  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1625  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1626  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1627  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1628  +| end crash-cf347c523f793c.db
         1629  +}]} {}
         1630  +
         1631  +do_catchsql_test 20.1 {
         1632  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
         1633  +} {1 {vtable constructor failed: t1}}
         1634  +
         1635  +#-------------------------------------------------------------------------
         1636  +reset_db
         1637  +do_test 21.0 {
         1638  +  sqlite3 db {}
         1639  +  db deserialize [decode_hexdb {
         1640  +| size 28672 pagesize 4096 filename c22b.db
         1641  +| page 1 offset 0
         1642  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1643  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
         1644  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         1645  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1646  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         1647  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         1648  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1649  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1650  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1651  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1652  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1653  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1654  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1655  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1656  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1657  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1658  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1659  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1660  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1661  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1662  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1663  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1664  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1665  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1666  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1667  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1668  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1669  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1670  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1671  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1672  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1673  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1674  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1675  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1676  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1677  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1678  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1679  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1680  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1681  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1682  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1683  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1684  +| page 2 offset 4096
         1685  +|      0: 0d 0e 8e 00 06 0e 2f 00 0f e8 0e 2f 0f bd 0f 3b   ....../..../...;
         1686  +|     16: 0e a5 0e 49 00 00 00 00 00 00 00 00 00 00 00 00   ...I............
         1687  +|   3616: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18   ................
         1688  +|   3632: 0a 03 00 36 00 00 00 00 01 04 04 00 04 01 01 01   ...6............
         1689  +|   3648: 02 01 01 03 01 01 04 01 01 3e 90 80 80 80 80 01   .........>......
         1690  +|   3664: 04 00 81 00 00 00 00 36 06 30 62 61 63 6b 75 05   .......6.0backu.
         1691  +|   3680: 02 04 05 02 04 02 05 65 61 6d 65 72 05 02 02 05   .......eamer....
         1692  +|   3696: 02 02 02 05 6f 6f 6d 65 72 05 01 05 01 02 05 75   ....oomer......u
         1693  +|   3712: 6d 6d 65 72 05 02 03 05 02 03 04 0d 0d 0b 0f 27   mmer...........'
         1694  +|   3728: 00 17 30 00 00 00 00 01 03 03 00 03 01 01 01 02   ..0.............
         1695  +|   3744: 01 01 03 01 01 7b 8c 80 80 80 80 01 04 00 81 7a   ...............z
         1696  +|   3760: 00 00 00 6d 06 30 61 62 61 63 6b 0d 02 07 04 04   ...m.0aback.....
         1697  +|   3776: 6e 64 6f 6e 0d 02 05 02 05 63 74 69 76 65 09 02   ndon.....ctive..
         1698  +|   3792: 02 04 02 0b 02 04 6c 70 68 61 0d 04 02 0a 02 03   ......lpha......
         1699  +|   3808: 74 6f 6d 0b 02 02 02 02 09 05 02 69 63 0c 02 02   tom........ic...
         1700  +|   3824: 01 06 62 61 63 6b 75 70 0d 02 04 02 05 6f 6f 6d   ..backup.....oom
         1701  +|   3840: 65 72 0a 02 02 03 02 08 01 07 63 68 61 6e 6e 65   er........channe
         1702  +|   3856: 6c 0d 02 03 01 04 74 65 73 74 0d 02 06 04 0a 09   l.....test......
         1703  +|   3872: 0d 0a 0b 07 0b 0d 0c 0f ef 00 14 2a 00 00 00 00   ...........*....
         1704  +|   3888: 01 02 02 00 02 01 01 01 02 01 01 7b 88 80 80 80   ................
         1705  +|   3904: 80 01 04 00 81 7a 00 00 00 6d 06 30 61 62 61 63   .....z...m.0abac
         1706  +|   3920: 6b 08 02 07 04 04 6e 64 6f 6e 08 02 05 02 05 63   k.....ndon.....c
         1707  +|   3936: 74 69 76 65 04 02 02 04 02 0b 02 04 6c 70 68 61   tive........lpha
         1708  +|   3952: 08 04 02 0a 02 03 74 6f 6d 06 02 02 02 02 09 05   ......tom.......
         1709  +|   3968: 02 69 63 07 02 02 01 06 62 61 63 6b 75 70 08 02   .ic.....backup..
         1710  +|   3984: 04 02 05 6f 6f 6d 65 72 05 02 02 03 02 08 01 07   ...oomer........
         1711  +|   4000: 63 68 61 6e 6e 65 6c 08 02 03 01 04 74 65 73 74   channel.....test
         1712  +|   4016: 08 02 06 04 0a 09 0d 0a 0b 07 0b 0d 0c 24 84 80   .............$..
         1713  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1714  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1715  +|   4064: 6f 6e 03 02 02 08 0a 07 05 01 03 00 10 0d 23 00   on............#.
         1716  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         1717  +| page 3 offset 8192
         1718  +|      0: 0a 00 00 00 04 0f e5 00 0f fa 0f f3 0f ec 0f e5   ................
         1719  +|   4064: 00 00 00 00 00 06 04 01 0c 01 04 02 06 04 01 0c   ................
         1720  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         1721  +| page 4 offset 12288
         1722  +|      0: 0d 0f 5a 00 0d 0e ce 00 0f f6 0f ec 0f e0 0f d5   ..Z.............
         1723  +|     16: 0e e7 0f c1 0f b6 0f 70 0f 65 0e ce 0f 51 0f 46   .......p.e...Q.F
         1724  +|     32: 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         1725  +|   3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 0a   ................
         1726  +|   3792: 03 00 35 62 65 61 6d 65 72 20 62 75 6d 6d 65 72   ..5beamer bummer
         1727  +|   3808: 20 62 61 63 6b 75 29 17 05 03 00 35 62 65 61 6d    backu)....5beam
         1728  +|   3824: 65 72 20 62 75 6d 6d 65 72 20 62 61 63 6b 75 29   er bummer backu)
         1729  +|   3840: 44 0d 04 00 81 0d 61 6c 70 68 61 20 63 68 61 6e   D.....alpha chan
         1730  +|   3856: 6e 65 6c 20 62 61 63 6b 75 70 20 61 62 61 6e 64   nel backup aband
         1731  +|   3872: 6f 6e 20 74 65 73 74 20 61 62 61 63 6b 20 62 6f   on test aback bo
         1732  +|   3888: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         1733  +|   3904: 61 63 74 69 76 65 09 0c 03 00 19 61 74 6f 6d 69   active.....atomi
         1734  +|   3920: 63 07 0b 03 00 15 61 74 6f 6d 0f ca 00 0b 19 62   c.....atom.....b
         1735  +|   3936: 6f 6f 6d 65 72 09 09 03 00 19 61 63 74 69 76 65   oomer.....active
         1736  +|   3952: 44 08 04 00 81 0d 61 6c 70 68 61 20 63 68 61 6e   D.....alpha chan
         1737  +|   3968: 6e 65 6c 20 62 61 63 6b 75 70 20 61 62 61 6e 64   nel backup aband
         1738  +|   3984: 6f 6e 20 74 65 73 74 20 61 62 61 63 6b 20 62 6f   on test aback bo
         1739  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         1740  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         1741  +|   4032: 63 07 06 03 00 15 61 74 6f 6d 00 00 00 0b 19 62   c.....atom.....b
         1742  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
         1743  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1744  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1745  +| page 5 offset 16384
         1746  +|      0: 0d 00 00 00 0d 0f b2 00 0f fa 0f f4 0f ee 0f e8   ................
         1747  +|     16: 0f e2 0f dc 0f d6 0f d0 0f ca 0f c4 0f be 0f b8   ................
         1748  +|     32: 0f b2 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         1749  +|   4016: 00 00 04 0d 03 00 0e 0a 04 0c 03 00 0e 01 04 0b   ................
         1750  +|   4032: 03 00 0e 01 04 0a 03 00 0e 03 04 09 03 00 0e 01   ................
         1751  +|   4048: 04 08 03 00 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         1752  +|   4064: 0e 01 04 05 03 00 0e 03 04 04 03 00 0e 01 04 03   ................
         1753  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1754  +| page 6 offset 20480
         1755  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1756  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1757  +| page 7 offset 24576
         1758  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1759  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1760  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1761  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1762  +| end c22b.db
         1763  +}]} {}
         1764  +
         1765  +do_catchsql_test 21.1 {
         1766  +  DELETE FROM t1 WHERE t1 MATCH 'ab*ndon';
         1767  +} {1 {database disk image is malformed}}
         1768  +
         1769  +#-------------------------------------------------------------------------
         1770  +#
         1771  +reset_db
         1772  +do_test 22.0 {
         1773  +  sqlite3 db {}
         1774  +  db deserialize [decode_hexdb {
         1775  +| size 28672 pagesize 4096 filename c22b.db
         1776  +| page 1 offset 0
         1777  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1778  +|     16: 10 00 01 01 00 40 20 20 00 00 00 02 00 00 00 07   .....@  ........
         1779  +|     32: 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00   ................
         1780  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1781  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02   ................
         1782  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         1783  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1784  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1785  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1786  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1787  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1788  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1789  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1790  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1791  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1792  +|   3664: 07 17 21 21 01 81 01 74 41 62 6c 65 74 31 5f 64   ..!!...tAblet1_d
         1793  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1794  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1795  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1796  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1797  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1798  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1799  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1800  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1801  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1802  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1803  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1804  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1805  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1806  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1807  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1808  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1809  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1810  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1811  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1812  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1813  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1814  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1815  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1816  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1817  +|   4064: 75 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   uAL TABLE t1 USI
         1818  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1819  +| page 2 offset 4096
         1820  +|      0: 0d 0f 15 00 05 08 4e 00 0f e8 08 4e 0f bd 0f 29   ......N....N...)
         1821  +|     16: 08 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .e..............
         1822  +|   2112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 0a   ................
         1823  +|   2128: 03 00 30 00 00 00 00 01 03 02 01 03 01 01 01 02   ..0.............
         1824  +|   2144: 01 01 03 01 01 8d 28 8c 80 80 80 80 01 04 00 9a   ......(.........
         1825  +|   2160: 54 00 00 06 77 19 30 30 30 30 30 30 33 30 66 65   T...w.00000030fe
         1826  +|   2176: 65 30 30 30 66 66 61 30 66 66 34 30 66 65 65 05   e000ffa0ff40fee.
         1827  +|   2192: 02 19 02 0b 31 30 66 66 61 30 30 30 66 66 61 05   ....10ffa000ffa.
         1828  +|   2208: 06 13 18 09 02 25 33 34 33 35 32 34 35 34 31 35   .....%3435245415
         1829  +|   2224: 34 34 35 32 30 35 34 34 31 34 32 34 63 34 35 32   445205441424c452
         1830  +|   2240: 30 32 37 37 34 33 31 35 66 36 39 05 02 07 02 37   02774315f69....7
         1831  +|   2256: 34 30 33 30 33 30 30 30 65 30 31 30 34 30 32 30   40303000e0104020
         1832  +|   2272: 33 30 30 30 65 30 31 30 34 30 31 30 33 30 30 30   3000e01040103000
         1833  +|   2288: 65 30 31 30 61 30 30 30 30 30 30 30 31 30 66 66   e010a000000010ff
         1834  +|   2304: 34 30 30 30 66 66 34 05 02 1b 02 27 35 30 34 30   4000ff4....'5040
         1835  +|   2320: 39 30 63 30 31 30 32 30 64 30 30 30 30 30 30 30   90c01020d0000000
         1836  +|   2336: 33 30 66 65 30 30 30 30 66 66 36 30 66 65 63 30   30fe0000ff60fec0
         1837  +|   2352: 66 65 30 05 02 2c 27 02 66 30 05 02 16 02 1d 36   fe0..,'.f0.....6
         1838  +|   2368: 31 37 31 31 31 31 30 38 36 33 37 34 36 31 36 32   1711110863746162
         1839  +|   2384: 36 63 36 35 37 34 33 31 37 34 33 31 05 02 0d 02   6c6574317431....
         1840  +|   2400: 29 39 30 33 30 32 31 62 37 32 36 35 36 32 37 35   )903021b72656275
         1841  +|   2416: 36 34 36 31 37 34 36 31 37 34 33 31 35 66 36 34   6461746174315f64
         1842  +|   2432: 36 31 37 34 36 31 30 32 34 33 05 02 1f 02 43 61   6174610243....Ca
         1843  +|   2448: 30 33 30 33 30 30 31 62 36 31 36 32 36 31 36 65   0303001b6162616e
         1844  +|   2464: 36 34 36 66 36 65 30 38 30 32 30 33 30 30 31 37   646f6e0802030017
         1845  +|   2480: 36 31 36 32 36 31 36 36 37 34 30 38 30 31 30 33   6162616674080103
         1846  +|   2496: 30 30 31 37 36 31 36 32 36 31 36 33 36 62 30 64   0017616261636b0d
         1847  +|   2512: 30 30 05 02 18 34 1d 33 36 62 30 31 30 32 30 32   00...4.36b010202
         1848  +|   2528: 30 34 30 32 36 36 37 34 30 32 30 32 30 32 30 34   0402667402020204
         1849  +|   2544: 30 34 36 65 05 02 2e 02 33 62 30 33 31 62 30 31   046e....3b031b01
         1850  +|   2560: 37 36 36 35 37 32 37 33 36 39 36 66 36 65 30 34   76657273696f6e04
         1851  +|   2576: 30 64 30 30 30 30 30 30 30 33 30 66 64 36 30 30   0d000000030fd600
         1852  +|   2592: 30 66 66 34 30 66 65 31 30 66 64 36 05 02 1d 01   0ff40fe10fd6....
         1853  +|   2608: 04 31 66 62 64 05 04 10 18 01 01 32 05 02 14 02   .1fbd......2....
         1854  +|   2624: 43 34 38 34 38 30 38 30 38 30 38 30 30 31 30 33   C484808080800103
         1855  +|   2640: 30 30 34 65 30 30 30 30 30 30 31 65 30 36 33 30   004e0000001e0630
         1856  +|   2656: 36 31 36 32 36 31 36 33 36 62 30 31 30 32 30 32   616261636b010202
         1857  +|   2672: 30 34 30 32 36 36 37 34 30 32 30 32 30 32 30 34   0402667402020204
         1858  +|   2688: 30 34 36 65 05 04 11 18 02 01 66 05 02 2a 03 02   046e......f..*..
         1859  +|   2704: 65 72 05 02 31 01 08 33 35 32 38 36 33 36 66 05   er..1..3528636f.
         1860  +|   2720: 02 24 02 03 66 65 30 05 04 17 18 01 2b 34 31 35   .$..fe0.....+415
         1861  +|   2736: 32 35 39 32 30 34 62 34 35 35 39 32 63 32 30 36   259204b45592c206
         1862  +|   2752: 32 36 63 36 66 36 33 36 62 32 30 34 32 34 63 34   26c6f636b20424c4
         1863  +|   2768: 66 34 32 32 39 33 61 30 05 02 0c 2c 1f 31 30 36   f42293a0...,.106
         1864  +|   2784: 31 37 31 31 31 31 30 38 36 33 37 34 36 31 36 32   1711110863746162
         1865  +|   2800: 36 63 36 35 37 34 33 31 37 34 33 31 05 02 22 02   6c6574317431....
         1866  +|   2816: 40 33 35 32 34 35 34 31 35 34 34 35 32 30 35 36   @352454154452056
         1867  +|   2832: 34 39 35 32 35 34 37 35 34 31 34 63 32 30 35 34   49525475414c2054
         1868  +|   2848: 34 31 34 32 34 63 34 35 32 30 37 34 33 31 32 30   41424c4520743120
         1869  +|   2864: 35 35 35 33 34 39 34 65 34 37 32 30 36 36 37 34   5553494e47206674
         1870  +|   2880: 37 05 02 23 42 09 33 33 35 32 38 36 33 36 66 05   7..#B.33528636f.
         1871  +|   2896: 02 0e 02 03 66 65 65 05 02 1a 01 34 35 32 34 35   ....fee....45245
         1872  +|   2912: 34 31 35 34 34 35 32 30 35 34 34 31 34 32 34 63   415445205441424c
         1873  +|   2928: 34 35 32 30 32 37 37 34 33 31 35 66 36 34 36 31   45202774315f6461
         1874  +|   2944: 37 34 36 31 32 37 32 38 36 39 36 34 32 30 34 39   7461272869642049
         1875  +|   2960: 05 02 20 16 37 c3 b0 35 32 30 32 37 37 34 33 31   .. .7..520277431
         1876  +|   2976: 35 66 36 34 36 31 37 34 36 31 32 37 32 38 36 39   5f64617461272869
         1877  +|   2992: 36 34 32 30 34 39 34 65 35 34 34 35 34 37 34 35   6420494e54454745
         1878  +|   3008: 35 32 32 30 35 30 35 32 34 39 34 64 05 02 0b 03   52205052494d....
         1879  +|   3024: 48 35 39 32 30 34 62 34 35 35 39 32 63 32 30 36   H59204b45592c206
         1880  +|   3040: 33 33 30 32 39 36 39 30 33 30 30 30 31 35 37 35   3302969030001575
         1881  +|   3056: 33 31 31 39 32 36 64 37 34 36 31 36 32 36 63 36   311926d7461626c6
         1882  +|   3072: 35 37 34 33 31 35 66 36 39 36 34 37 38 37 34 33   574315f696478743
         1883  +|   3088: 31 35 66 36 39 36 34 37 38 05 02 06 02 38 34 32   15f696478....842
         1884  +|   3104: 30 35 32 34 66 35 37 34 39 34 34 35 35 30 32 30   0524f57494455020
         1885  +|   3120: 37 31 37 31 62 31 62 30 31 38 31 30 31 37 34 36   7171b1b018101746
         1886  +|   3136: 31 36 32 36 63 36 35 37 34 33 31 35 66 31 37 34   1626c6574315f174
         1887  +|   3152: 36 31 30 32 34 33 05 02 0a 02 03 66 66 34 05 02   610243.....ff4..
         1888  +|   3168: 1c 01 4a 36 34 36 66 36 65 30 33 30 32 30 32 30   ..J646f6e0302020
         1889  +|   3184: 34 30 61 30 37 30 35 30 31 30 33 30 30 31 30 30   40a0705010300100
         1890  +|   3200: 33 30 33 30 66 30 61 30 33 30 30 32 34 30 30 30   3030f0a030024000
         1891  +|   3216: 30 30 30 30 30 30 31 30 31 30 31 30 30 30 31 30   0000001010100010
         1892  +|   3232: 31 30 31 30 30 39 61 30 30 30 30 30 30 05 02 2f   101009a000000../
         1893  +|   3248: 42 09 31 30 61 30 30 30 30 30 30 05 02 28 08 43   B.10a000000..(.C
         1894  +|   3264: 74 30 32 30 32 30 34 30 61 30 37 30 35 30 31 30   t0202040a0705010
         1895  +|   3280: 33 30 30 31 30 30 33 30 33 30 66 30 61 30 33 30   3001003030f0a030
         1896  +|   3296: 30 32 34 30 30 30 30 30 30 30 30 30 31 30 31 30   0240000000001010
         1897  +|   3312: 31 30 30 30 31 30 31 30 31 30 31 30 61 30 30 30   100010101010a000
         1898  +|   3328: 30 30 30 05 02 12 02 49 37 36 65 36 66 32 63 32   000....I76e6f2c2
         1899  +|   3344: 30 35 30 35 32 34 39 34 64 34 31 35 32 35 39 32   05052494d4152592
         1900  +|   3360: 30 34 62 34 35 35 39 32 38 37 33 36 35 36 37 36   04b4559287365676
         1901  +|   3376: 39 36 34 32 63 32 30 37 34 36 35 37 32 36 64 32   9642c207465726d2
         1902  +|   3392: 39 32 39 32 30 35 37 34 39 35 34 34 38 34 66 35   92920574954484f5
         1903  +|   3408: 35 05 02 09 02 4c 39 37 61 36 35 37 34 33 31 35   5....L97a6574315
         1904  +|   3424: 66 36 34 36 66 36 33 37 33 36 39 37 61 36 35 30   f646f6373697a650
         1905  +|   3440: 35 34 33 35 32 34 35 34 31 35 34 34 35 32 30 35   5435245415445205
         1906  +|   3456: 34 38 36 39 36 34 32 30 34 39 34 65 35 34 34 35   48696420494e5445
         1907  +|   3472: 34 37 34 35 35 32 32 30 35 30 35 32 34 39 34 34   4745522050524944
         1908  +|   3488: 64 31 05 02 05 02 27 65 37 34 36 35 36 65 37 34   d1....'e74656e74
         1909  +|   3504: 32 39 30 64 30 30 30 30 30 30 30 33 30 66 62 64   290d000000030fbd
         1910  +|   3520: 30 30 30 62 65 38 30 66 65 66 30 66 62 64 05 02   000be80fef0fbd..
         1911  +|   3536: 0f 1e 0b 66 65 38 30 66 65 66 30 66 62 64 05 02   ...fe80fef0fbd..
         1912  +|   3552: 25 02 03 66 64 36 05 02 1e 01 4a 37 36 32 39 32   %..fd6....J76292
         1913  +|   3568: 30 35 37 34 39 35 34 34 38 34 66 35 35 35 34 32   0574954484f55542
         1914  +|   3584: 30 35 32 34 66 35 37 34 39 34 34 35 62 30 35 30   0524f5749445b050
         1915  +|   3600: 37 31 37 32 31 32 31 30 31 38 31 30 31 37 34 36   7172121018101746
         1916  +|   3616: 31 36 32 36 63 36 35 37 34 33 31 35 66 36 34 36   1626c6574315f646
         1917  +|   3632: 66 36 33 37 33 05 02 04 02 21 38 32 37 32 38 37   f6373....!827287
         1918  +|   3648: 33 36 35 36 37 36 39 36 34 32 63 32 30 37 34 36   3656769642c20746
         1919  +|   3664: 35 37 32 36 64 32 63 32 30 37 30 05 02 08 01 01   5726d2c2070.....
         1920  +|   3680: 61 05 02 2b 01 06 62 61 63 6b 75 70 05 02 32 02   a..+..backup..2.
         1921  +|   3696: 05 65 61 6d 65 72 05 02 02 02 05 6f 6f 6d 65 72   .eamer.....oomer
         1922  +|   3712: 05 01 02 40 75 6d 6d 32 34 63 34 35 32 30 32 37   ...@umm24c452027
         1923  +|   3728: 37 34 33 31 35 66 36 33 36 66 36 65 36 36 36 39   74315f636f6e6669
         1924  +|   3744: 36 37 32 37 32 38 36 62 32 30 35 30 35 32 34 39   6727286b20505249
         1925  +|   3760: 34 64 34 31 35 32 35 39 32 30 34 62 34 35 35 39   4d415259204b4559
         1926  +|   3776: 32 63 32 30 05 02 03 01 15 65 35 34 34 35 34 37   2c20.....e544547
         1927  +|   3792: 34 35 35 32 32 30 35 30 35 32 34 39 34 64 05 02   4552205052494d..
         1928  +|   3808: 21 01 02 66 61 05 02 15 04 1d 12 2a 3c 2c 07 22   !..fa......*<,..
         1929  +|   3824: 2e 48 22 38 0a 06 49 06 07 0d 09 30 24 45 0e 08   .H.8..I....0$E..
         1930  +|   3840: 39 3c 4d 3d 08 4f 0e 48 4e 51 2c 10 08 4f 26 06   9<M=.O.HNQ,..O&.
         1931  +|   3856: 0b 0a 09 45 1a 0f ef 00 14 2a 00 00 00 00 01 02   ...E.....*......
         1932  +|   3872: 01 01 02 01 01 01 02 01 01 81 0c 88 80 80 80 80   ................
         1933  +|   3888: 01 04 00 82 1c 00 00 00 7c 08 30 61 62 61 6e 64   ........|.0aband
         1934  +|   3904: 6f 6e 08 02 05 02 05 63 74 69 76 65 04 02 02 04   on.....ctive....
         1935  +|   3920: 02 0b 02 04 6c 70 68 61 08 04 02 0a 02 03 74 6b   ....lpha......tk
         1936  +|   3936: 6d 06 02 02 03 02 6f 6d 08 02 09 05 02 69 63 07   m.....om.....ic.
         1937  +|   3952: 02 02 01 06 62 61 63 6b 75 70 08 02 04 02 05 6f   ....backup.....o
         1938  +|   3968: 6f 6d 65 72 05 02 02 01 0c 63 68 61 6e 6e 65 62   omer.....channeb
         1939  +|   3984: 6f 6f 6d 65 72 08 02 08 07 01 6c 08 02 03 01 06   oomer.....l.....
         1940  +|   4000: 73 74 61 61 63 6b 08 02 07 01 03 74 65 62 08 02   staack.....teb..
         1941  +|   4016: 06 04 0c 0d 0a 08 07 07 0b 0a 11 06 0b 24 84 80   .............$..
         1942  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1943  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
         1944  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 08 41 00   on............A.
         1945  +|   4080: 00 00 11 24 00 00 00 00 01 01 00 01 01 01 01 01   ...$............
         1946  +| page 3 offset 8192
         1947  +|      0: 0a 00 00 00 03 0f ec 00 ff 00 0f f3 0f ec 00 00   ................
         1948  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         1949  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         1950  +| page 4 offset 12288
         1951  +|      0: 0d 0f ca 00 08 07 e1 00 0f f6 0f ec 0f e0 0f d5   ................
         1952  +|     16: 07 e1 0f c1 0f b6 0f 6a 00 00 00 00 00 00 00 00   .......j........
         1953  +|   2016: 00 8f 06 05 04 00 9e 11 62 65 61 6d 65 72 20 62   ........beamer b
         1954  +|   2032: 75 6d 6d 32 34 63 34 35 32 30 32 37 37 34 33 31   umm24c4520277431
         1955  +|   2048: 35 66 36 33 36 66 36 65 36 36 36 39 36 37 32 37   5f636f6e66696727
         1956  +|   2064: 32 38 36 62 32 30 35 30 35 32 34 39 34 64 34 31   286b205052494d41
         1957  +|   2080: 35 32 35 39 32 30 34 62 34 35 35 39 32 63 32 30   5259204b45592c20
         1958  +|   2096: 0a 37 36 32 39 32 30 35 37 34 39 35 34 34 38 34   .762920574954484
         1959  +|   2112: 66 35 35 35 34 32 30 35 32 34 66 35 37 34 39 34   f555420524f57494
         1960  +|   2128: 34 35 62 30 35 30 37 31 37 32 31 32 31 30 31 38   45b0507172121018
         1961  +|   2144: 31 30 31 37 34 36 31 36 32 36 63 36 35 37 34 33   1017461626c65743
         1962  +|   2160: 31 35 66 36 34 36 66 36 33 37 33 0a 36 39 37 61   15f646f6373.697a
         1963  +|   2176: 36 35 37 34 33 31 35 66 36 34 36 66 36 33 37 33   6574315f646f6373
         1964  +|   2192: 36 39 37 61 36 35 30 35 34 33 35 32 34 35 34 31   697a650543524541
         1965  +|   2208: 35 34 34 35 32 30 35 34 38 36 39 36 34 32 30 34   5445205486964204
         1966  +|   2224: 39 34 65 35 34 34 35 34 37 34 35 35 32 32 30 35   94e5445474552205
         1967  +|   2240: 30 35 32 34 39 34 34 64 31 0a 35 32 35 39 32 30   0524944d1.525920
         1968  +|   2256: 34 62 34 35 35 39 32 63 32 30 36 33 33 30 32 39   4b45592c20633029
         1969  +|   2272: 36 39 30 33 30 30 30 31 35 37 35 33 31 31 39 32   6903000157531192
         1970  +|   2288: 36 64 37 34 36 31 36 32 36 63 36 35 37 34 33 31   6d7461626c657431
         1971  +|   2304: 35 66 36 39 36 34 37 38 37 34 33 31 35 66 36 39   5f69647874315f69
         1972  +|   2320: 36 34 37 38 0a 30 33 34 33 35 32 34 35 34 31 35   6478.03435245415
         1973  +|   2336: 34 34 35 32 30 35 34 34 31 34 32 34 63 34 35 32   445205441424c452
         1974  +|   2352: 30 32 37 37 34 33 31 35 66 36 39 01 0e 37 38 32   02774315f69..782
         1975  +|   2368: 37 32 38 37 33 36 35 36 37 36 39 36 34 32 63 32   72873656769642c2
         1976  +|   2384: 30 37 34 36 35 37 32 36 64 32 63 32 30 37 30 0a   07465726d2c2070.
         1977  +|   2400: 36 37 36 65 36 66 32 63 32 30 35 30 35 32 34 39   676e6f2c20505249
         1978  +|   2416: 34 64 34 31 35 32 35 39 32 30 34 62 34 35 35 39   4d415259204b4559
         1979  +|   2432: 32 38 37 33 36 35 36 37 36 39 36 34 32 63 32 30   2873656769642c20
         1980  +|   2448: 37 34 36 35 37 32 36 64 32 39 32 39 32 30 35 37   7465726d29292057
         1981  +|   2464: 34 39 35 34 34 38 34 66 35 35 0a 35 34 32 30 35   4954484f55.54205
         1982  +|   2480: 32 34 66 35 37 34 39 34 34 35 35 30 32 30 37 31   24f5749445502071
         1983  +|   2496: 37 31 62 31 62 30 31 38 31 30 31 37 34 36 31 36   71b1b01810174616
         1984  +|   2512: 32 36 63 36 35 37 34 33 31 35 66 31 37 34 36 31   26c6574315f17461
         1985  +|   2528: 30 32 34 33 0a 35 32 34 35 34 31 35 34 34 35 32   0243.52454154452
         1986  +|   2544: 30 35 34 34 31 34 32 34 63 34 c3 b0 35 32 30 32   05441424c4..5202
         1987  +|   2560: 37 37 34 33 31 35 66 36 34 36 31 37 34 36 31 32   774315f646174612
         1988  +|   2576: 37 32 38 36 39 36 34 32 30 34 39 34 65 35 34 34   728696420494e544
         1989  +|   2592: 35 34 37 34 35 35 32 32 30 35 30 35 32 34 39 34   5474552205052494
         1990  +|   2608: 64 0a 34 31 35 32 35 39 32 30 34 62 34 35 35 39   d.415259204b4559
         1991  +|   2624: 32 63 32 30 36 32 36 63 36 66 36 33 36 62 32 30   2c20626c6f636b20
         1992  +|   2640: 34 32 34 63 34 66 34 32 32 39 33 61 30 21 30 36   424c4f42293a0!06
         1993  +|   2656: 31 37 31 31 31 31 30 38 36 33 37 34 36 31 36 32   1711110863746162
         1994  +|   2672: 36 63 36 35 37 34 33 31 37 34 33 31 0a 34 33 35   6c6574317431.435
         1995  +|   2688: 32 34 35 34 31 35 34 34 35 32 30 35 36 34 39 35   2454154452056495
         1996  +|   2704: 32 35 34 37 35 34 31 34 63 32 30 35 34 34 31 34   25475414c2054414
         1997  +|   2720: 32 34 63 34 35 32 30 37 34 33 31 32 30 35 35 35   24c4520743120555
         1998  +|   2736: 33 34 39 34 65 34 37 32 30 36 36 37 34 37 33 33   3494e47206674733
         1999  +|   2752: 35 32 38 36 33 36 66 0a 36 65 37 34 36 35 36 65   528636f.6e74656e
         2000  +|   2768: 37 34 32 39 30 64 30 30 30 30 30 30 30 33 30 66   74290d000000030f
         2001  +|   2784: 62 64 30 30 30 62 65 38 30 66 65 66 30 66 62 64   bd000be80fef0fbd
         2002  +|   2800: 0a 5b 31 66 62 64 5d 32 34 38 34 38 30 38 30 38   .[1fbd]248480808
         2003  +|   2816: 30 38 30 30 31 30 33 30 30 34 65 30 30 30 30 30   0800103004e00000
         2004  +|   2832: 30 31 65 30 36 33 30 36 31 36 32 36 31 36 33 36   01e0630616261636
         2005  +|   2848: 62 30 31 30 32 30 32 30 34 30 32 36 36 37 34 30   b010202040266740
         2006  +|   2864: 32 30 32 30 32 30 34 30 34 36 65 0a 36 34 36 66   2020204046e.646f
         2007  +|   2880: 36 65 30 54 30 32 30 32 30 34 30 61 30 37 30 35   6e0T0202040a0705
         2008  +|   2896: 30 31 30 33 30 30 31 30 30 33 30 33 30 66 30 61   0103001003030f0a
         2009  +|   2912: 30 33 30 30 32 34 30 30 30 30 30 30 30 30 30 31   0300240000000001
         2010  +|   2928: 30 31 30 31 30 30 30 31 30 31 30 31 30 31 30 61   010100010101010a
         2011  +|   2944: 30 30 30 30 30 30 0a 30 31 30 66 66 61 30 30 30   000000.010ffa000
         2012  +|   2960: 66 66 61 0a 5b 32 21 66 61 5d 30 35 30 34 30 39   ffa.[2!fa]050409
         2013  +|   2976: 30 63 30 31 30 32 30 64 30 30 30 30 30 30 30 33   0c01020d00000003
         2014  +|   2992: 30 66 65 30 30 30 30 66 66 36 30 66 65 63 30 66   0fe0000ff60fec0f
         2015  +|   3008: 66 30 0a 5b 33 66 65 30 5d 30 61 30 33 30 33 30   f0.[3fe0]0a03030
         2016  +|   3024: 30 31 62 36 31 36 32 36 31 36 65 36 34 36 66 36   01b6162616e646f6
         2017  +|   3040: 65 30 38 30 32 30 33 30 30 31 37 36 31 36 32 36   e080203001761626
         2018  +|   3056: 31 36 36 37 34 30 38 30 31 30 33 30 30 31 37 36   1667408010300176
         2019  +|   3072: 31 36 32 36 31 36 33 36 62 30 64 30 30 0a 30 30   16261636b0d00.00
         2020  +|   3088: 30 30 30 33 30 66 65 65 30 30 30 66 66 61 30 66   00030fee000ffa0f
         2021  +|   3104: 66 34 30 66 65 65 0a 5b 34 66 65 65 5d 30 34 30   f40fee.[4fee]040
         2022  +|   3120: 33 30 33 30 30 30 65 30 31 30 34 30 32 30 33 30   303000e010402030
         2023  +|   3136: 30 30 65 30 31 30 34 30 31 30 33 30 30 30 65 30   00e01040103000e0
         2024  +|   3152: 31 30 61 30 30 30 30 30 30 30 31 30 66 66 34 30   10a000000010ff40
         2025  +|   3168: 30 30 66 66 34 0a 5b 35 66 66 34 5d 30 62 30 33   00ff4.[5ff4]0b03
         2026  +|   3184: 31 62 30 31 37 36 36 35 37 32 37 33 36 39 36 66   1b0176657273696f
         2027  +|   3200: 36 65 30 34 30 64 30 30 30 30 30 30 30 33 30 66   6e040d000000030f
         2028  +|   3216: 64 36 30 30 30 66 66 34 30 66 65 31 30 66 64 36   d6000ff40fe10fd6
         2029  +|   3232: 0a 5b 36 66 64 36 5d 30 39 30 33 30 32 31 62 37   .[6fd6]0903021b7
         2030  +|   3248: 32 36 35 36 32 37 35 36 34 36 31 37 34 36 31 37   2656275646174617
         2031  +|   3264: 34 33 31 35 66 36 34 36 31 37 34 36 31 30 32 34   4315f64617461024
         2032  +|   3280: 33 0a 35 32 34 35 34 31 35 34 34 35 32 30 35 34   3.52454154452054
         2033  +|   3296: 34 31 34 32 34 63 34 35 32 30 32 37 37 34 33 31   41424c4520277431
         2034  +|   3312: 35 66 36 34 36 31 37 34 36 31 32 37 32 38 36 39   5f64617461272869
         2035  +|   3328: 36 34 32 30 34 39 c2 81 65 35 34 34 35 34 37 34   642049..e5445474
         2036  +|   3344: 35 35 32 32 30 35 30 35 32 34 39 34 64 0a 34 31   552205052494d.41
         2037  +|   3360: 35 32 35 39 32 30 34 62 34 35 35 39 32 63 32 30   5259204b45592c20
         2038  +|   3376: 36 32 36 63 36 66 36 33 36 62 32 30 34 32 34 63   626c6f636b20424c
         2039  +|   3392: 34 66 34 32 32 39 33 61 30 31 30 36 31 37 31 31   4f42293a01061711
         2040  +|   3408: 31 31 30 38 36 33 37 34 36 31 36 32 36 63 36 35   1108637461626c65
         2041  +|   3424: 37 34 33 31 37 34 33 31 0a 34 33 35 32 34 35 34   74317431.4352454
         2042  +|   3440: 31 35 34 34 35 32 30 35 36 34 39 35 32 35 34 37   1544520564952547
         2043  +|   3456: 35 34 31 34 63 32 30 35 34 34 31 34 32 34 63 34   5414c205441424c4
         2044  +|   3472: 35 32 30 37 34 33 31 32 30 35 35 35 33 34 39 34   5207431205553494
         2045  +|   3488: 65 34 37 32 30 36 36 37 34 37 3b 33 35 32 38 36   e472066747;35286
         2046  +|   3504: 33 36 66 0a 36 65 37 34 36 35 36 65 37 34 32 39   36f.6e74656e7429
         2047  +|   3520: 30 64 30 30 30 30 30 30 30 33 30 66 62 64 30 30   0d000000030fbd00
         2048  +|   3536: 30 66 65 38 30 66 65 66 30 66 62 64 0a 5b 31 66   0fe80fef0fbd.[1f
         2049  +|   3552: 62 64 5d 32 34 38 34 38 30 38 30 38 30 38 30 30   bd]2484808080800
         2050  +|   3568: 31 30 33 30 30 34 65 30 30 30 30 30 30 31 65 30   103004e0000001e0
         2051  +|   3584: 36 33 30 36 31 36 32 36 31 36 33 36 62 30 31 30   630616261636b010
         2052  +|   3600: 32 30 32 30 34 30 32 36 36 37 34 30 32 30 32 30   2020402667402020
         2053  +|   3616: 32 30 34 30 34 36 65 0a 36 34 36 66 36 65 30 33   204046e.646f6e03
         2054  +|   3632: 30 32 30 32 30 34 30 61 30 37 30 35 30 31 30 33   0202040a07050103
         2055  +|   3648: 30 30 31 30 30 33 30 33 30 66 30 61 30 33 30 30   001003030f0a0300
         2056  +|   3664: 32 34 30 30 30 30 30 30 30 30 30 31 30 31 30 31   2400000000010101
         2057  +|   3680: 30 30 30 31 30 31 30 31 30 31 30 61 30 30 30 30   00010101010a0000
         2058  +|   3696: 30 30 0a 30 31 30 66 66 61 30 30 30 66 66 61 0a   00.010ffa000ffa.
         2059  +|   3712: 5b 32 66 29 61 5d 30 35 30 34 30 39 30 63 30 31   [2f)a]0504090c01
         2060  +|   3728: 30 32 30 64 30 30 30 30 30 30 30 33 30 66 65 30   020d000000030fe0
         2061  +|   3744: 30 30 30 66 66 36 30 66 65 63 30 66 65 30 0a 5b   000ff60fec0fe0.[
         2062  +|   3760: 33 66 65 30 5d 30 61 30 33 30 33 30 30 31 62 36   3fe0]0a0303001b6
         2063  +|   3776: 31 36 32 36 31 36 65 36 34 36 66 36 65 30 38 30   162616e646f6e080
         2064  +|   3792: 32 30 33 30 30 31 37 36 31 36 32 36 31 36 36 37   2030017616261667
         2065  +|   3808: 34 30 38 30 31 30 33 30 33 36 62 30 31 30 32 30   4080103036b01020
         2066  +|   3824: 32 30 34 30 32 36 36 37 34 30 32 30 32 30 32 30   2040266740202020
         2067  +|   3840: 34 30 34 36 65 0a 36 34 36 66 36 65 30 33 30 32   4046e.646f6e0302
         2068  +|   3856: 30 32 30 34 30 61 30 37 30 35 30 31 30 33 30 30   02040a0705010300
         2069  +|   3872: 31 30 30 33 30 33 30 66 30 61 30 33 30 30 32 34   1003030f0a030024
         2070  +|   3888: 30 30 30 30 30 30 30 30 30 31 30 31 30 31 30 30   0000000001010100
         2071  +|   3904: 30 31 30 31 30 31 30 30 39 61 30 30 30 30 30 30   010101009a000000
         2072  +|   3920: 0a 30 31 30 66 66 61 30 30 30 66 66 61 0a 5b 32   .010ffa000ffa.[2
         2073  +|   3936: 66 65 72 20 62 61 63 6b 75 70 4a 08 04 00 81 19   fer backupJ.....
         2074  +|   3952: 61 6c 70 68 61 20 63 68 61 6e 6e 65 6c 20 62 61   alpha channel ba
         2075  +|   3968: 63 6b 75 70 20 61 62 61 6e 64 6f 6e 20 74 65 62   ckup abandon teb
         2076  +|   3984: 20 73 74 61 61 63 6b 20 63 68 61 6e 6e 65 62 6f    staack channebo
         2077  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         2078  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         2079  +|   4032: 63 07 06 03 00 15 61 74 6b 6d 00 00 00 0b 19 62   c.....atkm.....b
         2080  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
         2081  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         2082  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         2083  +| page 5 offset 16384
         2084  +|      0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8   ................
         2085  +|     16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00   ................
         2086  +|   4048: 04 08 03 00 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         2087  +|   4064: 0e 01 04 05 03 00 0e 31 04 04 03 00 0e 01 04 03   .......1........
         2088  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         2089  +| page 6 offset 20480
         2090  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         2091  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         2092  +| page 7 offset 24576
         2093  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         2094  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         2095  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         2096  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         2097  +| end c22b.db
         2098  +}]} {}
         2099  +
         2100  +
         2101  +do_catchsql_test 22.1 {
         2102  +  INSERT INTO t1(t1) VALUES('optimize');
         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  +} {0 {}}
         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  +
   419   4054   sqlite3_fts5_may_be_corrupt 0
   420   4055   finish_test
         4056  +

Added ext/fts5/test/fts5interrupt.test.

            1  +# 2019 Jan 4
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script is testing the FTS5 module.
           13  +#
           14  +
           15  +source [file join [file dirname [info script]] fts5_common.tcl]
           16  +set testprefix fts5interrupt
           17  +
           18  +# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
           19  +ifcapable !fts5 {
           20  +  finish_test
           21  +  return
           22  +}
           23  +
           24  +do_execsql_test 1.0 {
           25  +  CREATE VIRTUAL TABLE t1 USING fts5(a);
           26  +  INSERT INTO t1(t1, rank) VALUES('pgsz', 40);
           27  +}
           28  +db_save_and_close
           29  +
           30  +proc progress_handler {args} {
           31  +  incr ::progress_handler_delay -1
           32  +  if {$::progress_handler_delay<=0} { return 1 } 
           33  +  return 0
           34  +}
           35  +
           36  +foreach {tn sql} {
           37  +  1 { INSERT INTO t1(rowid, a) VALUES(0, 'z z z z') }
           38  +  2 { COMMIT }
           39  +} {
           40  +  set bDone 0
           41  +  for {set i 1} {$bDone==0} {incr i} {
           42  +    do_test 1.$tn.$i {
           43  +      db_restore_and_reopen
           44  +      execsql {
           45  +        BEGIN;
           46  +          INSERT INTO t1(rowid, a) VALUES(1, 'a b c d');
           47  +          INSERT INTO t1(rowid, a) VALUES(2, 'd e f g');
           48  +          INSERT INTO t1(rowid, a) VALUES(3, 'h i j k');
           49  +          INSERT INTO t1(rowid, a) VALUES(4, 'l m n o');
           50  +      }
           51  +  
           52  +      set ::progress_handler_delay $i
           53  +      db progress 1 progress_handler
           54  +      set res [catchsql $sql]
           55  +      db close
           56  +      if {$res=="0 {}"} {
           57  +        set bDone 1
           58  +      } else {
           59  +        if {$res!="1 interrupted"} { error "got: $res" }
           60  +      }
           61  +      set {} {}
           62  +    } {}
           63  +  }
           64  +}
           65  +
           66  +finish_test
           67  +

Changes to ext/fts5/test/fts5unicode3.test.

    17     17   # If SQLITE_ENABLE_FTS5 is defined, omit this file.
    18     18   ifcapable !fts5 {
    19     19     finish_test
    20     20     return
    21     21   }
    22     22   
    23     23   proc fts3_unicode_path {file} {
    24         -  file join [file dirname [info script]] .. .. fts3 unicode $file
           24  +  file join .. [file dirname [info script]] .. .. fts3 unicode $file
    25     25   }
    26     26   
    27     27   source [fts3_unicode_path parseunicode.tcl]
    28     28   set testprefix fts5unicode3
    29     29   
    30     30   set CF [fts3_unicode_path CaseFolding.txt]
    31     31   set UD [fts3_unicode_path UnicodeData.txt]

Changes to ext/fts5/test/fts5update.test.

   110    110     for {set i 0} {$i < 1000} {incr i} {
   111    111       execsql { UPDATE x2 SET x=x WHERE rowid=2 }
   112    112     }
   113    113   } {}
   114    114   do_execsql_test 2.2.integrity {
   115    115     INSERT INTO x2(x2) VALUES('integrity-check');
   116    116   }
          117  +
          118  +#-------------------------------------------------------------------------
          119  +#
          120  +do_execsql_test 3.0 {
          121  +  CREATE VIRTUAL TABLE x3 USING fts5(x, detail=%DETAIL%);
          122  +  INSERT INTO x3 VALUES('one');
          123  +  INSERT INTO x3 VALUES('two');
          124  +  INSERT INTO x3 VALUES('one');
          125  +  INSERT INTO x3 VALUES('two');
          126  +  INSERT INTO x3 VALUES('one');
          127  +}
          128  +
          129  +do_test 3.1 {
          130  +  db eval { SELECT * FROM x3('one') } {
          131  +    db eval {
          132  +      INSERT INTO x3(x3) VALUES('optimize');
          133  +    }
          134  +  }
          135  +} {}
          136  +
          137  +do_execsql_test 4.0 {
          138  +  CREATE VIRTUAL TABLE x4 USING fts5(a, detail=%DETAIL%);
          139  +  INSERT INTO x4 VALUES('one two three');
          140  +  INSERT INTO x4(rowid, a) VALUES('2', 'one two three');
          141  +  INSERT INTO x4(rowid, a) VALUES('3.0', 'one two three');
          142  +}
          143  +do_catchsql_test 4.1 {
          144  +  INSERT INTO x4(rowid, a) VALUES('four', 'one two three');
          145  +} {1 {datatype mismatch}}
          146  +
          147  +do_catchsql_test 4.2 {
          148  +  UPDATE x4 SET rowid = 'four' WHERE rowid=1;
          149  +} {1 {datatype mismatch}}
          150  +
   117    151   
   118    152   }
          153  +
          154  +reset_db
          155  +do_catchsql_test 4.0 { CREATE VIRTUAL TABLE t1 USING fts5(a,b,c); } {0 {}}
          156  +do_catchsql_test 4.1 { DELETE FROM t1 WHERE t1 MATCH 'f*'; } {0 {}}
   119    157   finish_test

Changes to ext/fts5/test/fts5vocab.test.

    75     75   } {
    76     76     0 term {} 0 {} 0
    77     77     1 col {} 0 {} 0
    78     78     2 doc {} 0 {} 0
    79     79     3 cnt {} 0 {} 0
    80     80   }
    81     81   
    82         -do_execsql_test 1.2.1 { SELECT * FROM v1 } { }
    83         -do_execsql_test 1.2.2 { SELECT * FROM v2 } { }
           82  +do_execsql_test 1.2.1 { SELECT * FROM v1 } {}
           83  +do_execsql_test 1.2.2 { SELECT * FROM v2 } {}
    84     84   
    85     85   do_execsql_test 1.3 {
    86     86     INSERT INTO t1 VALUES('x y z');
    87     87     INSERT INTO t1 VALUES('x x x');
    88     88   }
    89     89   
    90     90   do_execsql_test 1.4.1 {

Changes to ext/fts5/test/fts5vocab2.test.

    76     76     four  2 b 0
    77     77     three 2 a 0
    78     78   }
    79     79   
    80     80   do_execsql_test 1.5 {
    81     81     DELETE FROM t1;
    82     82     SELECT * FROM v1;
    83         -} {
    84         -}
           83  +} {}
    85     84   
    86     85   #-------------------------------------------------------------------------
    87     86   #
    88     87   do_execsql_test 2.0 {
    89     88     DROP TABLE IF EXISTS t1;
    90     89     DROP TABLE IF EXISTS v1;
    91     90   
................................................................................
   139    138     four  2 b {}
   140    139     three 2 a {}
   141    140   }
   142    141   
   143    142   do_execsql_test 2.5 {
   144    143     DELETE FROM t1;
   145    144     SELECT * FROM v1;
   146         -} {
   147         -}
          145  +} {}
   148    146   
   149    147   #-------------------------------------------------------------------------
   150    148   #
   151    149   do_execsql_test 3.0 {
   152    150     DROP TABLE IF EXISTS t1;
   153    151     DROP TABLE IF EXISTS v1;
   154    152   
................................................................................
   198    196     four  2 {} {}
   199    197     three 2 {} {}
   200    198   }
   201    199   
   202    200   do_execsql_test 3.5 {
   203    201     DELETE FROM t1;
   204    202     SELECT * FROM v1;
   205         -} {
          203  +} {}
          204  +
          205  +#-------------------------------------------------------------------------
          206  +#
          207  +reset_db
          208  +do_execsql_test 4.0 {
          209  +  CREATE VIRTUAL TABLE v1 USING fts5vocab(nosuchtable, col);
          210  +}
          211  +
          212  +do_catchsql_test 4.1 {
          213  +  SELECT * FROM v1 WHERE term=='nosuchterm';
          214  +} {1 {no such fts5 table: main.nosuchtable}}
          215  +
          216  +do_execsql_test 4.2.1 {
          217  +  CREATE TABLE nosuchtable(nosuchtable, y, z);
          218  +}
          219  +do_catchsql_test 4.2.2 {
          220  +  SELECT * FROM v1 WHERE term=='nosuchterm';
          221  +} {1 {no such fts5 table: main.nosuchtable}}
          222  +
          223  +ifcapable fts3 {
          224  +  do_execsql_test 4.3.1 {
          225  +    DROP TABLE nosuchtable;
          226  +    CREATE VIRTUAL TABLE nosuchtable USING fts3(a, b);
          227  +  } {}
          228  +  do_catchsql_test 4.3.2 {
          229  +    SELECT * FROM v1 WHERE term=='nosuchterm';
          230  +  } {1 {no such fts5 table: main.nosuchtable}}
          231  +  do_catchsql_test 4.3.3 {
          232  +    INSERT INTO nosuchtable VALUES('id', '*id');
          233  +    SELECT * FROM v1 WHERE term=='nosuchterm';
          234  +  } {1 {no such fts5 table: main.nosuchtable}}
   206    235   }
   207    236   
   208    237   finish_test

Changes to ext/misc/amatch.c.

   615    615     if( strcmp(zFrom,"")==0 && strcmp(zTo,"?")==0 ){
   616    616       if( p->rIns==0 || p->rIns>rCost ) p->rIns = rCost;
   617    617     }else
   618    618     if( strcmp(zFrom,"?")==0 && strcmp(zTo,"")==0 ){
   619    619       if( p->rDel==0 || p->rDel>rCost ) p->rDel = rCost;
   620    620     }else
   621    621     {
   622         -    pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );
          622  +    pRule = sqlite3_malloc64( sizeof(*pRule) + nFrom + nTo );
   623    623       if( pRule==0 ){
   624    624         rc = SQLITE_NOMEM;
   625    625       }else{
   626    626         memset(pRule, 0, sizeof(*pRule));
   627    627         pRule->zFrom = &pRule->zTo[nTo+1];
   628    628         pRule->nFrom = (amatch_len)nFrom;
   629    629         memcpy(pRule->zFrom, zFrom, nFrom+1);
................................................................................
   734    734   **
   735    735   **     "abc"   becomes   abc
   736    736   **     'xyz'   becomes   xyz
   737    737   **     [pqr]   becomes   pqr
   738    738   **     `mno`   becomes   mno
   739    739   */
   740    740   static char *amatchDequote(const char *zIn){
   741         -  int nIn;                        /* Size of input string, in bytes */
          741  +  sqlite3_int64 nIn;              /* Size of input string, in bytes */
   742    742     char *zOut;                     /* Output (dequoted) string */
   743    743   
   744         -  nIn = (int)strlen(zIn);
   745         -  zOut = sqlite3_malloc(nIn+1);
          744  +  nIn = strlen(zIn);
          745  +  zOut = sqlite3_malloc64(nIn+1);
   746    746     if( zOut ){
   747    747       char q = zIn[0];              /* Quote character (if any ) */
   748    748   
   749    749       if( q!='[' && q!= '\'' && q!='"' && q!='`' ){
   750    750         memcpy(zOut, zIn, nIn+1);
   751    751       }else{
   752    752         int iOut = 0;               /* Index of next byte to write to output */
................................................................................
  1065   1065                pWord->rCost, pWord->zWord, pWord->zCost);
  1066   1066   #endif
  1067   1067         pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost);
  1068   1068         assert( pOther==0 ); (void)pOther;
  1069   1069       }
  1070   1070       return;
  1071   1071     }
  1072         -  pWord = sqlite3_malloc( sizeof(*pWord) + nBase + nTail - 1 );
         1072  +  pWord = sqlite3_malloc64( sizeof(*pWord) + nBase + nTail - 1 );
  1073   1073     if( pWord==0 ) return;
  1074   1074     memset(pWord, 0, sizeof(*pWord));
  1075   1075     pWord->rCost = rCost;
  1076   1076     pWord->iSeq = pCur->nWord++;
  1077   1077     amatchWriteCost(pWord);
  1078   1078     pWord->nMatch = (short)nMatch;
  1079   1079     pWord->pNext = pCur->pAllWords;

Changes to ext/misc/closure.c.

   418    418   **
   419    419   **     "abc"   becomes   abc
   420    420   **     'xyz'   becomes   xyz
   421    421   **     [pqr]   becomes   pqr
   422    422   **     `mno`   becomes   mno
   423    423   */
   424    424   static char *closureDequote(const char *zIn){
   425         -  int nIn;                        /* Size of input string, in bytes */
          425  +  sqlite3_int64 nIn;              /* Size of input string, in bytes */
   426    426     char *zOut;                     /* Output (dequoted) string */
   427    427   
   428         -  nIn = (int)strlen(zIn);
   429         -  zOut = sqlite3_malloc(nIn+1);
          428  +  nIn = strlen(zIn);
          429  +  zOut = sqlite3_malloc64(nIn+1);
   430    430     if( zOut ){
   431    431       char q = zIn[0];              /* Quote character (if any ) */
   432    432   
   433    433       if( q!='[' && q!= '\'' && q!='"' && q!='`' ){
   434    434         memcpy(zOut, zIn, nIn+1);
   435    435       }else{
   436    436         int iOut = 0;               /* Index of next byte to write to output */

Changes to ext/misc/csv.c.

   617    617     pNew->tstFlags = tstFlags;
   618    618   #endif
   619    619     if( bHeader!=1 ){
   620    620       pNew->iStart = 0;
   621    621     }else if( pNew->zData ){
   622    622       pNew->iStart = (int)sRdr.iIn;
   623    623     }else{
   624         -    pNew->iStart = ftell(sRdr.in);
          624  +    pNew->iStart = (int)(ftell(sRdr.in) - sRdr.nIn + sRdr.iIn);
   625    625     }
   626    626     csv_reader_reset(&sRdr);
   627    627     rc = sqlite3_declare_vtab(db, CSV_SCHEMA);
   628    628     if( rc ){
   629    629       csv_errmsg(&sRdr, "bad schema: '%s' - %s", CSV_SCHEMA, sqlite3_errmsg(db));
   630    630       goto csvtab_connect_error;
   631    631     }

Changes to ext/misc/dbdump.c.

   191    191     rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
   192    192     sqlite3_free(zSql);
   193    193     if( rc ) return 0;
   194    194     while( sqlite3_step(pStmt)==SQLITE_ROW ){
   195    195       if( nCol>=nAlloc-2 ){
   196    196         char **azNew;
   197    197         nAlloc = nAlloc*2 + nCol + 10;
   198         -      azNew = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));
          198  +      azNew = sqlite3_realloc64(azCol, nAlloc*sizeof(azCol[0]));
   199    199         if( azNew==0 ) goto col_oom;
   200    200         azCol = azNew;
   201    201         azCol[0] = 0;
   202    202       }
   203    203       azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
   204    204       if( azCol[nCol]==0 ) goto col_oom;
   205    205       if( sqlite3_column_int(pStmt, 5) ){

Changes to ext/misc/eval.c.

    40     40       size_t sz = strlen(z);
    41     41       if( (sqlite3_int64)sz+p->nUsed+p->szSep+1 > p->nAlloc ){
    42     42         char *zNew;
    43     43         p->nAlloc = p->nAlloc*2 + sz + p->szSep + 1;
    44     44         /* Using sqlite3_realloc64() would be better, but it is a recent
    45     45         ** addition and will cause a segfault if loaded by an older version
    46     46         ** of SQLite.  */
    47         -      zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc(p->z, (int)p->nAlloc) : 0;
           47  +      zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc64(p->z, p->nAlloc) : 0;
    48     48         if( zNew==0 ){
    49     49           sqlite3_free(p->z);
    50     50           memset(p, 0, sizeof(*p));
    51     51           return 1;
    52     52         }
    53     53         p->z = zNew;
    54     54       }

Changes to ext/misc/fileio.c.

   117    117   #define FSDIR_COLUMN_DATA     3     /* File content */
   118    118   #define FSDIR_COLUMN_PATH     4     /* Path to top of search */
   119    119   #define FSDIR_COLUMN_DIR      5     /* Path is relative to this directory */
   120    120   
   121    121   
   122    122   /*
   123    123   ** Set the result stored by context ctx to a blob containing the 
   124         -** contents of file zName.
          124  +** contents of file zName.  Or, leave the result unchanged (NULL)
          125  +** if the file does not exist or is unreadable.
          126  +**
          127  +** If the file exceeds the SQLite blob size limit, through an
          128  +** SQLITE_TOOBIG error.
          129  +**
          130  +** Throw an SQLITE_IOERR if there are difficulties pulling the file
          131  +** off of disk.
   125    132   */
   126    133   static void readFileContents(sqlite3_context *ctx, const char *zName){
   127    134     FILE *in;
   128         -  long nIn;
          135  +  sqlite3_int64 nIn;
   129    136     void *pBuf;
          137  +  sqlite3 *db;
          138  +  int mxBlob;
   130    139   
   131    140     in = fopen(zName, "rb");
   132         -  if( in==0 ) return;
          141  +  if( in==0 ){
          142  +    /* File does not exist or is unreadable. Leave the result set to NULL. */
          143  +    return;
          144  +  }
   133    145     fseek(in, 0, SEEK_END);
   134    146     nIn = ftell(in);
   135    147     rewind(in);
   136         -  pBuf = sqlite3_malloc( nIn );
   137         -  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
   138         -    sqlite3_result_blob(ctx, pBuf, nIn, sqlite3_free);
          148  +  db = sqlite3_context_db_handle(ctx);
          149  +  mxBlob = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1);
          150  +  if( nIn>mxBlob ){
          151  +    sqlite3_result_error_code(ctx, SQLITE_TOOBIG);
          152  +    fclose(in);
          153  +    return;
          154  +  }
          155  +  pBuf = sqlite3_malloc64( nIn );
          156  +  if( pBuf==0 ){
          157  +    sqlite3_result_error_nomem(ctx);
          158  +    fclose(in);
          159  +    return;
          160  +  }
          161  +  if( 1==fread(pBuf, nIn, 1, in) ){
          162  +    sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
   139    163     }else{
          164  +    sqlite3_result_error_code(ctx, SQLITE_IOERR);
   140    165       sqlite3_free(pBuf);
   141    166     }
   142    167     fclose(in);
   143    168   }
   144    169   
   145    170   /*
   146    171   ** Implementation of the "readfile(X)" SQL function.  The entire content
................................................................................
   642    667     pCur->iRowid++;
   643    668     if( S_ISDIR(m) ){
   644    669       /* Descend into this directory */
   645    670       int iNew = pCur->iLvl + 1;
   646    671       FsdirLevel *pLvl;
   647    672       if( iNew>=pCur->nLvl ){
   648    673         int nNew = iNew+1;
   649         -      int nByte = nNew*sizeof(FsdirLevel);
   650         -      FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc(pCur->aLvl, nByte);
          674  +      sqlite3_int64 nByte = nNew*sizeof(FsdirLevel);
          675  +      FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc64(pCur->aLvl, nByte);
   651    676         if( aNew==0 ) return SQLITE_NOMEM;
   652    677         memset(&aNew[pCur->nLvl], 0, sizeof(FsdirLevel)*(nNew-pCur->nLvl));
   653    678         pCur->aLvl = aNew;
   654    679         pCur->nLvl = nNew;
   655    680       }
   656    681       pCur->iLvl = iNew;
   657    682       pLvl = &pCur->aLvl[iNew];
................................................................................
   723    748         mode_t m = pCur->sStat.st_mode;
   724    749         if( S_ISDIR(m) ){
   725    750           sqlite3_result_null(ctx);
   726    751   #if !defined(_WIN32) && !defined(WIN32)
   727    752         }else if( S_ISLNK(m) ){
   728    753           char aStatic[64];
   729    754           char *aBuf = aStatic;
   730         -        int nBuf = 64;
          755  +        sqlite3_int64 nBuf = 64;
   731    756           int n;
   732    757   
   733    758           while( 1 ){
   734    759             n = readlink(pCur->zPath, aBuf, nBuf);
   735    760             if( n<nBuf ) break;
   736    761             if( aBuf!=aStatic ) sqlite3_free(aBuf);
   737    762             nBuf = nBuf*2;
   738         -          aBuf = sqlite3_malloc(nBuf);
          763  +          aBuf = sqlite3_malloc64(nBuf);
   739    764             if( aBuf==0 ){
   740    765               sqlite3_result_error_nomem(ctx);
   741    766               return SQLITE_NOMEM;
   742    767             }
   743    768           }
   744    769   
   745    770           sqlite3_result_text(ctx, aBuf, n, SQLITE_TRANSIENT);

Changes to ext/misc/fuzzer.c.

   333    333     if( iRuleset<0 || iRuleset>FUZZER_MX_RULEID ){
   334    334       *pzErr = sqlite3_mprintf("%s: ruleset must be between 0 and %d", 
   335    335           p->zClassName, FUZZER_MX_RULEID
   336    336       );
   337    337       rc = SQLITE_ERROR;    
   338    338     }else{
   339    339   
   340         -    pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );
          340  +    pRule = sqlite3_malloc64( sizeof(*pRule) + nFrom + nTo );
   341    341       if( pRule==0 ){
   342    342         rc = SQLITE_NOMEM;
   343    343       }else{
   344    344         memset(pRule, 0, sizeof(*pRule));
   345    345         pRule->zFrom = pRule->zTo;
   346    346         pRule->zFrom += nTo + 1;
   347    347         pRule->nFrom = (fuzzer_len)nFrom;
................................................................................
   443    443   **
   444    444   **     "abc"   becomes   abc
   445    445   **     'xyz'   becomes   xyz
   446    446   **     [pqr]   becomes   pqr
   447    447   **     `mno`   becomes   mno
   448    448   */
   449    449   static char *fuzzerDequote(const char *zIn){
   450         -  int nIn;                        /* Size of input string, in bytes */
          450  +  sqlite3_int64 nIn;              /* Size of input string, in bytes */
   451    451     char *zOut;                     /* Output (dequoted) string */
   452    452   
   453         -  nIn = (int)strlen(zIn);
   454         -  zOut = sqlite3_malloc(nIn+1);
          453  +  nIn = strlen(zIn);
          454  +  zOut = sqlite3_malloc64(nIn+1);
   455    455     if( zOut ){
   456    456       char q = zIn[0];              /* Quote character (if any ) */
   457    457   
   458    458       if( q!='[' && q!= '\'' && q!='"' && q!='`' ){
   459    459         memcpy(zOut, zIn, nIn+1);
   460    460       }else{
   461    461         int iOut = 0;               /* Index of next byte to write to output */
................................................................................
   509    509   
   510    510     if( argc!=4 ){
   511    511       *pzErr = sqlite3_mprintf(
   512    512           "%s: wrong number of CREATE VIRTUAL TABLE arguments", zModule
   513    513       );
   514    514       rc = SQLITE_ERROR;
   515    515     }else{
   516         -    int nModule;                  /* Length of zModule, in bytes */
          516  +    sqlite3_int64 nModule;        /* Length of zModule, in bytes */
   517    517   
   518         -    nModule = (int)strlen(zModule);
   519         -    pNew = sqlite3_malloc( sizeof(*pNew) + nModule + 1);
          518  +    nModule = strlen(zModule);
          519  +    pNew = sqlite3_malloc64( sizeof(*pNew) + nModule + 1);
   520    520       if( pNew==0 ){
   521    521         rc = SQLITE_NOMEM;
   522    522       }else{
   523    523         char *zTab;                 /* Dequoted name of fuzzer data table */
   524    524   
   525    525         memset(pNew, 0, sizeof(*pNew));
   526    526         pNew->zClassName = (char*)&pNew[1];
................................................................................
   868    868     const char *zWord,
   869    869     fuzzer_cost rBaseCost
   870    870   ){
   871    871     fuzzer_stem *pNew;
   872    872     fuzzer_rule *pRule;
   873    873     unsigned int h;
   874    874   
   875         -  pNew = sqlite3_malloc( sizeof(*pNew) + (int)strlen(zWord) + 1 );
          875  +  pNew = sqlite3_malloc64( sizeof(*pNew) + strlen(zWord) + 1 );
   876    876     if( pNew==0 ) return 0;
   877    877     memset(pNew, 0, sizeof(*pNew));
   878    878     pNew->zBasis = (char*)&pNew[1];
   879    879     pNew->nBasis = (fuzzer_len)strlen(zWord);
   880    880     memcpy(pNew->zBasis, zWord, pNew->nBasis+1);
   881    881     pRule = pCur->pVtab->pRule;
   882    882     while( fuzzerSkipRule(pRule, pNew, pCur->iRuleset) ){

Changes to ext/misc/json1.c.

   687    687     const char *zContent      /* Content */
   688    688   ){
   689    689     u32 nNew;
   690    690     JsonNode *pNew;
   691    691     assert( pParse->nNode>=pParse->nAlloc );
   692    692     if( pParse->oom ) return -1;
   693    693     nNew = pParse->nAlloc*2 + 10;
   694         -  pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);
          694  +  pNew = sqlite3_realloc64(pParse->aNode, sizeof(JsonNode)*nNew);
   695    695     if( pNew==0 ){
   696    696       pParse->oom = 1;
   697    697       return -1;
   698    698     }
   699    699     pParse->nAlloc = nNew;
   700    700     pParse->aNode = pNew;
   701    701     assert( pParse->nNode<pParse->nAlloc );
................................................................................
   961    961   
   962    962   /*
   963    963   ** Compute the parentage of all nodes in a completed parse.
   964    964   */
   965    965   static int jsonParseFindParents(JsonParse *pParse){
   966    966     u32 *aUp;
   967    967     assert( pParse->aUp==0 );
   968         -  aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );
          968  +  aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode );
   969    969     if( aUp==0 ){
   970    970       pParse->oom = 1;
   971    971       return SQLITE_NOMEM;
   972    972     }
   973    973     jsonParseFillInParentage(pParse, 0, 0);
   974    974     return SQLITE_OK;
   975    975   }
................................................................................
  1023   1023       }
  1024   1024     }
  1025   1025     if( pMatch ){
  1026   1026       pMatch->nErr = 0;
  1027   1027       pMatch->iHold = iMaxHold+1;
  1028   1028       return pMatch;
  1029   1029     }
  1030         -  p = sqlite3_malloc( sizeof(*p) + nJson + 1 );
         1030  +  p = sqlite3_malloc64( sizeof(*p) + nJson + 1 );
  1031   1031     if( p==0 ){
  1032   1032       sqlite3_result_error_nomem(pCtx);
  1033   1033       return 0;
  1034   1034     }
  1035   1035     memset(p, 0, sizeof(*p));
  1036   1036     p->zJson = (char*)&p[1];
  1037   1037     memcpy((char*)p->zJson, zJson, nJson+1);

Changes to ext/misc/memstat.c.

   139    139     rc = sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pStmt, 0);
   140    140     if( rc ){
   141    141       sqlite3_finalize(pStmt);
   142    142       return rc;
   143    143     }
   144    144     while( sqlite3_step(pStmt)==SQLITE_ROW ){
   145    145       char **az, *z;
   146         -    az = sqlite3_realloc(pCur->azDb, sizeof(char*)*(pCur->nDb+1));
          146  +    az = sqlite3_realloc64(pCur->azDb, sizeof(char*)*(pCur->nDb+1));
   147    147       if( az==0 ){
   148    148         memstatClearSchema(pCur);
   149    149         return SQLITE_NOMEM;
   150    150       }
   151    151       pCur->azDb = az;
   152    152       z = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
   153    153       if( z==0 ){

Changes to ext/misc/mmapwarm.c.

   101    101   
   102    102       rc2 = sqlite3_exec(db, "END", 0, 0, 0);
   103    103       if( rc==SQLITE_OK ) rc = rc2;
   104    104     }
   105    105   
   106    106     return rc;
   107    107   }
   108         -

Changes to ext/misc/nextchar.c.

    81     81     int i;
    82     82     for(i=0; i<p->nUsed; i++){
    83     83       if( p->aResult[i]==c ) return;
    84     84     }
    85     85     if( p->nUsed+1 > p->nAlloc ){
    86     86       unsigned int *aNew;
    87     87       int n = p->nAlloc*2 + 30;
    88         -    aNew = sqlite3_realloc(p->aResult, n*sizeof(unsigned int));
           88  +    aNew = sqlite3_realloc64(p->aResult, n*sizeof(unsigned int));
    89     89       if( aNew==0 ){
    90     90         p->mallocFailed = 1;
    91     91         return;
    92     92       }else{
    93     93         p->aResult = aNew;
    94     94         p->nAlloc = n;
    95     95       }
................................................................................
   265    265       return;
   266    266     }
   267    267     findNextChars(&c);
   268    268     if( c.mallocFailed ){
   269    269       sqlite3_result_error_nomem(context);
   270    270     }else{
   271    271       unsigned char *pRes;
   272         -    pRes = sqlite3_malloc( c.nUsed*4 + 1 );
          272  +    pRes = sqlite3_malloc64( c.nUsed*4 + 1 );
   273    273       if( pRes==0 ){
   274    274         sqlite3_result_error_nomem(context);
   275    275       }else{
   276    276         int i;
   277    277         int n = 0;
   278    278         for(i=0; i<c.nUsed; i++){
   279    279           n += writeUtf8(pRes+n, c.aResult[i]);

Changes to ext/misc/percentile.c.

   147    147       sqlite3_result_error(pCtx, "Inf input to percentile()", -1);
   148    148       return;
   149    149     }
   150    150   
   151    151     /* Allocate and store the Y */
   152    152     if( p->nUsed>=p->nAlloc ){
   153    153       unsigned n = p->nAlloc*2 + 250;
   154         -    double *a = sqlite3_realloc(p->a, sizeof(double)*n);
          154  +    double *a = sqlite3_realloc64(p->a, sizeof(double)*n);
   155    155       if( a==0 ){
   156    156         sqlite3_free(p->a);
   157    157         memset(p, 0, sizeof(*p));
   158    158         sqlite3_result_error_nomem(pCtx);
   159    159         return;
   160    160       }
   161    161       p->nAlloc = n;

Added ext/misc/prefixes.c.

            1  +/*
            2  +** 2018-04-19
            3  +**
            4  +** The author disclaims copyright to this source code.  In place of
            5  +** a legal notice, here is a blessing:
            6  +**
            7  +**    May you do good and not evil.
            8  +**    May you find forgiveness for yourself and forgive others.
            9  +**    May you share freely, never taking more than you give.
           10  +**
           11  +*************************************************************************
           12  +**
           13  +** This file implements a table-valued function:
           14  +**
           15  +**      prefixes('abcdefg')
           16  +**
           17  +** The function has a single (non-HIDDEN) column named prefix that takes
           18  +** on all prefixes of the string in its argument, including an empty string
           19  +** and the input string itself.  The order of prefixes is from longest
           20  +** to shortest.
           21  +*/
           22  +#if !defined(SQLITEINT_H)
           23  +#include "sqlite3ext.h"
           24  +#endif
           25  +SQLITE_EXTENSION_INIT1
           26  +#include <string.h>
           27  +#include <assert.h>
           28  +
           29  +/* prefixes_vtab is a subclass of sqlite3_vtab which is
           30  +** underlying representation of the virtual table
           31  +*/
           32  +typedef struct prefixes_vtab prefixes_vtab;
           33  +struct prefixes_vtab {
           34  +  sqlite3_vtab base;  /* Base class - must be first */
           35  +  /* No additional fields are necessary */
           36  +};
           37  +
           38  +/* prefixes_cursor is a subclass of sqlite3_vtab_cursor which will
           39  +** serve as the underlying representation of a cursor that scans
           40  +** over rows of the result
           41  +*/
           42  +typedef struct prefixes_cursor prefixes_cursor;
           43  +struct prefixes_cursor {
           44  +  sqlite3_vtab_cursor base;  /* Base class - must be first */
           45  +  sqlite3_int64 iRowid;      /* The rowid */
           46  +  char *zStr;                /* Original string to be prefixed */
           47  +  int nStr;                  /* Length of the string in bytes */
           48  +};
           49  +
           50  +/*
           51  +** The prefixesConnect() method is invoked to create a new
           52  +** template virtual table.
           53  +**
           54  +** Think of this routine as the constructor for prefixes_vtab objects.
           55  +**
           56  +** All this routine needs to do is:
           57  +**
           58  +**    (1) Allocate the prefixes_vtab object and initialize all fields.
           59  +**
           60  +**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
           61  +**        result set of queries against the virtual table will look like.
           62  +*/
           63  +static int prefixesConnect(
           64  +  sqlite3 *db,
           65  +  void *pAux,
           66  +  int argc, const char *const*argv,
           67  +  sqlite3_vtab **ppVtab,
           68  +  char **pzErr
           69  +){
           70  +  prefixes_vtab *pNew;
           71  +  int rc;
           72  +
           73  +  rc = sqlite3_declare_vtab(db,
           74  +           "CREATE TABLE prefixes(prefix TEXT, original_string TEXT HIDDEN)"
           75  +       );
           76  +  if( rc==SQLITE_OK ){
           77  +    pNew = sqlite3_malloc( sizeof(*pNew) );
           78  +    *ppVtab = (sqlite3_vtab*)pNew;
           79  +    if( pNew==0 ) return SQLITE_NOMEM;
           80  +    memset(pNew, 0, sizeof(*pNew));
           81  +  }
           82  +  return rc;
           83  +}
           84  +
           85  +/*
           86  +** This method is the destructor for prefixes_vtab objects.
           87  +*/
           88  +static int prefixesDisconnect(sqlite3_vtab *pVtab){
           89  +  prefixes_vtab *p = (prefixes_vtab*)pVtab;
           90  +  sqlite3_free(p);
           91  +  return SQLITE_OK;
           92  +}
           93  +
           94  +/*
           95  +** Constructor for a new prefixes_cursor object.
           96  +*/
           97  +static int prefixesOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
           98  +  prefixes_cursor *pCur;
           99  +  pCur = sqlite3_malloc( sizeof(*pCur) );
          100  +  if( pCur==0 ) return SQLITE_NOMEM;
          101  +  memset(pCur, 0, sizeof(*pCur));
          102  +  *ppCursor = &pCur->base;
          103  +  return SQLITE_OK;
          104  +}
          105  +
          106  +/*
          107  +** Destructor for a prefixes_cursor.
          108  +*/
          109  +static int prefixesClose(sqlite3_vtab_cursor *cur){
          110  +  prefixes_cursor *pCur = (prefixes_cursor*)cur;
          111  +  sqlite3_free(pCur->zStr);
          112  +  sqlite3_free(pCur);
          113  +  return SQLITE_OK;
          114  +}
          115  +
          116  +
          117  +/*
          118  +** Advance a prefixes_cursor to its next row of output.
          119  +*/
          120  +static int prefixesNext(sqlite3_vtab_cursor *cur){
          121  +  prefixes_cursor *pCur = (prefixes_cursor*)cur;
          122  +  pCur->iRowid++;
          123  +  return SQLITE_OK;
          124  +}
          125  +
          126  +/*
          127  +** Return values of columns for the row at which the prefixes_cursor
          128  +** is currently pointing.
          129  +*/
          130  +static int prefixesColumn(
          131  +  sqlite3_vtab_cursor *cur,   /* The cursor */
          132  +  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */
          133  +  int i                       /* Which column to return */
          134  +){
          135  +  prefixes_cursor *pCur = (prefixes_cursor*)cur;
          136  +  switch( i ){
          137  +    case 0:
          138  +      sqlite3_result_text(ctx, pCur->zStr, pCur->nStr - (int)pCur->iRowid,
          139  +                          0); 
          140  +      break;
          141  +    default:
          142  +      sqlite3_result_text(ctx, pCur->zStr, pCur->nStr, 0);
          143  +      break;
          144  +  }
          145  +  return SQLITE_OK;
          146  +}
          147  +
          148  +/*
          149  +** Return the rowid for the current row.  In this implementation, the
          150  +** rowid is the same as the output value.
          151  +*/
          152  +static int prefixesRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
          153  +  prefixes_cursor *pCur = (prefixes_cursor*)cur;
          154  +  *pRowid = pCur->iRowid;
          155  +  return SQLITE_OK;
          156  +}
          157  +
          158  +/*
          159  +** Return TRUE if the cursor has been moved off of the last
          160  +** row of output.
          161  +*/
          162  +static int prefixesEof(sqlite3_vtab_cursor *cur){
          163  +  prefixes_cursor *pCur = (prefixes_cursor*)cur;
          164  +  return pCur->iRowid>pCur->nStr;
          165  +}
          166  +
          167  +/*
          168  +** This method is called to "rewind" the prefixes_cursor object back
          169  +** to the first row of output.  This method is always called at least
          170  +** once prior to any call to prefixesColumn() or prefixesRowid() or 
          171  +** prefixesEof().
          172  +*/
          173  +static int prefixesFilter(
          174  +  sqlite3_vtab_cursor *pVtabCursor, 
          175  +  int idxNum, const char *idxStr,
          176  +  int argc, sqlite3_value **argv
          177  +){
          178  +  prefixes_cursor *pCur = (prefixes_cursor *)pVtabCursor;
          179  +  sqlite3_free(pCur->zStr);
          180  +  if( argc>0 ){
          181  +    pCur->zStr = sqlite3_mprintf("%s", sqlite3_value_text(argv[0]));
          182  +    pCur->nStr = pCur->zStr ? (int)strlen(pCur->zStr) : 0;
          183  +  }else{
          184  +    pCur->zStr = 0;
          185  +    pCur->nStr = 0;
          186  +  }
          187  +  pCur->iRowid = 0;
          188  +  return SQLITE_OK;
          189  +}
          190  +
          191  +/*
          192  +** SQLite will invoke this method one or more times while planning a query
          193  +** that uses the virtual table.  This routine needs to create
          194  +** a query plan for each invocation and compute an estimated cost for that
          195  +** plan.
          196  +*/
          197  +static int prefixesBestIndex(
          198  +  sqlite3_vtab *tab,
          199  +  sqlite3_index_info *pIdxInfo
          200  +){
          201  +  /* Search for a usable equality constraint against column 1 
          202  +  ** (original_string) and use it if at all possible */
          203  +  int i;
          204  +  const struct sqlite3_index_constraint *p;
          205  +
          206  +  for(i=0, p=pIdxInfo->aConstraint; i<pIdxInfo->nConstraint; i++, p++){
          207  +    if( p->iColumn!=1 ) continue;
          208  +    if( p->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
          209  +    if( !p->usable ) continue;
          210  +    pIdxInfo->aConstraintUsage[i].argvIndex = 1;
          211  +    pIdxInfo->aConstraintUsage[i].omit = 1;
          212  +    pIdxInfo->estimatedCost = (double)10;
          213  +    pIdxInfo->estimatedRows = 10;
          214  +    return SQLITE_OK;
          215  +  }
          216  +  pIdxInfo->estimatedCost = (double)1000000000;
          217  +  pIdxInfo->estimatedRows = 1000000000;
          218  +  return SQLITE_OK;
          219  +}
          220  +
          221  +/*
          222  +** This following structure defines all the methods for the 
          223  +** virtual table.
          224  +*/
          225  +static sqlite3_module prefixesModule = {
          226  +  /* iVersion    */ 0,
          227  +  /* xCreate     */ 0,
          228  +  /* xConnect    */ prefixesConnect,
          229  +  /* xBestIndex  */ prefixesBestIndex,
          230  +  /* xDisconnect */ prefixesDisconnect,
          231  +  /* xDestroy    */ 0,
          232  +  /* xOpen       */ prefixesOpen,
          233  +  /* xClose      */ prefixesClose,
          234  +  /* xFilter     */ prefixesFilter,
          235  +  /* xNext       */ prefixesNext,
          236  +  /* xEof        */ prefixesEof,
          237  +  /* xColumn     */ prefixesColumn,
          238  +  /* xRowid      */ prefixesRowid,
          239  +  /* xUpdate     */ 0,
          240  +  /* xBegin      */ 0,
          241  +  /* xSync       */ 0,
          242  +  /* xCommit     */ 0,
          243  +  /* xRollback   */ 0,
          244  +  /* xFindMethod */ 0,
          245  +  /* xRename     */ 0,
          246  +  /* xSavepoint  */ 0,
          247  +  /* xRelease    */ 0,
          248  +  /* xRollbackTo */ 0,
          249  +  /* xShadowName */ 0
          250  +};
          251  +
          252  +/*
          253  +** This is a copy of the SQLITE_SKIP_UTF8(zIn) macro in sqliteInt.h.
          254  +**
          255  +** Assuming zIn points to the first byte of a UTF-8 character,
          256  +** advance zIn to point to the first byte of the next UTF-8 character.
          257  +*/
          258  +#define PREFIX_SKIP_UTF8(zIn) {                        \
          259  +  if( (*(zIn++))>=0xc0 ){                              \
          260  +    while( (*zIn & 0xc0)==0x80 ){ zIn++; }             \
          261  +  }                                                    \
          262  +}
          263  +
          264  +/*
          265  +** Implementation of function prefix_length(). This function accepts two
          266  +** strings as arguments and returns the length in characters (not bytes), 
          267  +** of the longest prefix shared by the two strings. For example:
          268  +**
          269  +**   prefix_length('abcdxxx', 'abcyy') == 3
          270  +**   prefix_length('abcdxxx', 'bcyyy') == 0
          271  +**   prefix_length('abcdxxx', 'ab')    == 2
          272  +**   prefix_length('ab',      'abcd')  == 2
          273  +**
          274  +** This function assumes the input is well-formed utf-8. If it is not,
          275  +** it is possible for this function to return -1.
          276  +*/
          277  +static void prefixLengthFunc(
          278  +  sqlite3_context *ctx,
          279  +  int nVal,
          280  +  sqlite3_value **apVal
          281  +){
          282  +  int nByte;                      /* Number of bytes to compare */
          283  +  int nRet = 0;                   /* Return value */
          284  +  const unsigned char *zL = sqlite3_value_text(apVal[0]);
          285  +  const unsigned char *zR = sqlite3_value_text(apVal[1]);
          286  +  int nL = sqlite3_value_bytes(apVal[0]);
          287  +  int nR = sqlite3_value_bytes(apVal[1]);
          288  +  int i;
          289  +
          290  +  nByte = (nL > nR ? nL : nR);
          291  +  for(i=0; i<nByte; i++){
          292  +    if( zL[i]!=zR[i] ) break;
          293  +    if( (zL[i] & 0xC0)!=0x80 ) nRet++;
          294  +  }
          295  +
          296  +  if( (zL[i] & 0xC0)==0x80 ) nRet--;
          297  +  sqlite3_result_int(ctx, nRet);
          298  +}
          299  +
          300  +#ifdef _WIN32
          301  +__declspec(dllexport)
          302  +#endif
          303  +int sqlite3_prefixes_init(
          304  +  sqlite3 *db, 
          305  +  char **pzErrMsg, 
          306  +  const sqlite3_api_routines *pApi
          307  +){
          308  +  int rc = SQLITE_OK;
          309  +  SQLITE_EXTENSION_INIT2(pApi);
          310  +  rc = sqlite3_create_module(db, "prefixes", &prefixesModule, 0);
          311  +  if( rc==SQLITE_OK ){
          312  +    rc = sqlite3_create_function(
          313  +        db, "prefix_length", 2, SQLITE_UTF8, 0, prefixLengthFunc, 0, 0
          314  +    );
          315  +  }
          316  +  return rc;
          317  +}

Changes to ext/misc/regexp.c.

   221    221       if( in.i+pRe->nInit>in.mx ) return 0;
   222    222     }
   223    223   
   224    224     if( pRe->nState<=(sizeof(aSpace)/(sizeof(aSpace[0])*2)) ){
   225    225       pToFree = 0;
   226    226       aStateSet[0].aState = aSpace;
   227    227     }else{
   228         -    pToFree = sqlite3_malloc( sizeof(ReStateNumber)*2*pRe->nState );
          228  +    pToFree = sqlite3_malloc64( sizeof(ReStateNumber)*2*pRe->nState );
   229    229       if( pToFree==0 ) return -1;
   230    230       aStateSet[0].aState = pToFree;
   231    231     }
   232    232     aStateSet[1].aState = &aStateSet[0].aState[pRe->nState];
   233    233     pNext = &aStateSet[1];
   234    234     pNext->nState = 0;
   235    235     re_add_state(pNext, 0);
................................................................................
   333    333   }
   334    334   
   335    335   /* Resize the opcode and argument arrays for an RE under construction.
   336    336   */
   337    337   static int re_resize(ReCompiled *p, int N){
   338    338     char *aOp;
   339    339     int *aArg;
   340         -  aOp = sqlite3_realloc(p->aOp, N*sizeof(p->aOp[0]));
          340  +  aOp = sqlite3_realloc64(p->aOp, N*sizeof(p->aOp[0]));
   341    341     if( aOp==0 ) return 1;
   342    342     p->aOp = aOp;
   343         -  aArg = sqlite3_realloc(p->aArg, N*sizeof(p->aArg[0]));
          343  +  aArg = sqlite3_realloc64(p->aArg, N*sizeof(p->aArg[0]));
   344    344     if( aArg==0 ) return 1;
   345    345     p->aArg = aArg;
   346    346     p->nAlloc = N;
   347    347     return 0;
   348    348   }
   349    349   
   350    350   /* Insert a new opcode and argument into an RE under construction.  The

Changes to ext/misc/unionvtab.c.

   246    246   /*
   247    247   ** If *pRc is other than SQLITE_OK when this function is called, it
   248    248   ** always returns NULL. Otherwise, it attempts to allocate and return
   249    249   ** a pointer to nByte bytes of zeroed memory. If the memory allocation
   250    250   ** is attempted but fails, NULL is returned and *pRc is set to 
   251    251   ** SQLITE_NOMEM.
   252    252   */
   253         -static void *unionMalloc(int *pRc, int nByte){
          253  +static void *unionMalloc(int *pRc, sqlite3_int64 nByte){
   254    254     void *pRet;
   255    255     assert( nByte>0 );
   256    256     if( *pRc==SQLITE_OK ){
   257         -    pRet = sqlite3_malloc(nByte);
          257  +    pRet = sqlite3_malloc64(nByte);
   258    258       if( pRet ){
   259    259         memset(pRet, 0, nByte);
   260    260       }else{
   261    261         *pRc = SQLITE_NOMEM;
   262    262       }
   263    263     }else{
   264    264       pRet = 0;
................................................................................
   272    272   ** a copy of the nul-terminated string passed as the second argument.
   273    273   ** If the allocation is attempted but fails, NULL is returned and *pRc is 
   274    274   ** set to SQLITE_NOMEM.
   275    275   */
   276    276   static char *unionStrdup(int *pRc, const char *zIn){
   277    277     char *zRet = 0;
   278    278     if( zIn ){
   279         -    int nByte = (int)strlen(zIn) + 1;
          279  +    sqlite3_int64 nByte = strlen(zIn) + 1;
   280    280       zRet = unionMalloc(pRc, nByte);
   281    281       if( zRet ){
   282    282         memcpy(zRet, zIn, nByte);
   283    283       }
   284    284     }
   285    285     return zRet;
   286    286   }
................................................................................
   935    935         sqlite3_int64 iMin = sqlite3_column_int64(pStmt, 2);
   936    936         sqlite3_int64 iMax = sqlite3_column_int64(pStmt, 3);
   937    937         UnionSrc *pSrc;
   938    938   
   939    939         /* Grow the pTab->aSrc[] array if required. */
   940    940         if( nAlloc<=pTab->nSrc ){
   941    941           int nNew = nAlloc ? nAlloc*2 : 8;
   942         -        UnionSrc *aNew = (UnionSrc*)sqlite3_realloc(
          942  +        UnionSrc *aNew = (UnionSrc*)sqlite3_realloc64(
   943    943               pTab->aSrc, nNew*sizeof(UnionSrc)
   944    944           );
   945    945           if( aNew==0 ){
   946    946             rc = SQLITE_NOMEM;
   947    947             break;
   948    948           }else{
   949    949             memset(&aNew[pTab->nSrc], 0, (nNew-pTab->nSrc)*sizeof(UnionSrc));

Changes to ext/misc/vfslog.c.

   272    272     if( nName>8 && strcmp(zFilename+nName-8,"-journal")==0 ){
   273    273       nName -= 8;
   274    274       isJournal = 1;
   275    275     }else if( nName>12 
   276    276            && sqlite3_strglob("-mj??????9??", zFilename+nName-12)==0 ){
   277    277       return 0;  /* Do not log master journal files */
   278    278     }
   279         -  pTemp = sqlite3_malloc( sizeof(*pLog)*2 + nName + 60 );
          279  +  pTemp = sqlite3_malloc64( sizeof(*pLog)*2 + nName + 60 );
   280    280     if( pTemp==0 ) return 0;
   281    281     pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
   282    282     sqlite3_mutex_enter(pMutex);
   283    283     for(pLog=allLogs; pLog; pLog=pLog->pNext){
   284    284       if( pLog->nFilename==nName && !memcmp(pLog->zFilename, zFilename, nName) ){
   285    285         break;
   286    286       }

Changes to ext/misc/zipfile.c.

   354    354     if( argc>3 ){
   355    355       zFile = argv[3];
   356    356       nFile = (int)strlen(zFile)+1;
   357    357     }
   358    358   
   359    359     rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA);
   360    360     if( rc==SQLITE_OK ){
   361         -    pNew = (ZipfileTab*)sqlite3_malloc(nByte+nFile);
          361  +    pNew = (ZipfileTab*)sqlite3_malloc64((sqlite3_int64)nByte+nFile);
   362    362       if( pNew==0 ) return SQLITE_NOMEM;
   363    363       memset(pNew, 0, nByte+nFile);
   364    364       pNew->db = db;
   365    365       pNew->aBuffer = (u8*)&pNew[1];
   366    366       if( zFile ){
   367    367         pNew->zFile = (char*)&pNew->aBuffer[ZIPFILE_BUFFER_SIZE];
   368    368         memcpy(pNew->zFile, zFile, nFile);
................................................................................
   802    802       aRead = pTab->aBuffer;
   803    803       rc = zipfileReadData(pFile, aRead, ZIPFILE_CDS_FIXED_SZ, iOff, pzErr);
   804    804     }else{
   805    805       aRead = (u8*)&aBlob[iOff];
   806    806     }
   807    807   
   808    808     if( rc==SQLITE_OK ){
   809         -    int nAlloc;
          809  +    sqlite3_int64 nAlloc;
   810    810       ZipfileEntry *pNew;
   811    811   
   812    812       int nFile = zipfileGetU16(&aRead[ZIPFILE_CDS_NFILE_OFF]);
   813    813       int nExtra = zipfileGetU16(&aRead[ZIPFILE_CDS_NFILE_OFF+2]);
   814    814       nExtra += zipfileGetU16(&aRead[ZIPFILE_CDS_NFILE_OFF+4]);
   815    815   
   816    816       nAlloc = sizeof(ZipfileEntry) + nExtra;
   817    817       if( aBlob ){
   818    818         nAlloc += zipfileGetU32(&aRead[ZIPFILE_CDS_SZCOMPRESSED_OFF]);
   819    819       }
   820    820   
   821         -    pNew = (ZipfileEntry*)sqlite3_malloc(nAlloc);
          821  +    pNew = (ZipfileEntry*)sqlite3_malloc64(nAlloc);
   822    822       if( pNew==0 ){
   823    823         rc = SQLITE_NOMEM;
   824    824       }else{
   825    825         memset(pNew, 0, sizeof(ZipfileEntry));
   826    826         rc = zipfileReadCDS(aRead, &pNew->cds);
   827    827         if( rc!=SQLITE_OK ){
   828    828           *pzErr = sqlite3_mprintf("failed to read CDS at offset %lld", iOff);
................................................................................
   977    977   ** case.
   978    978   */
   979    979   static int zipfileDeflate(
   980    980     const u8 *aIn, int nIn,         /* Input */
   981    981     u8 **ppOut, int *pnOut,         /* Output */
   982    982     char **pzErr                    /* OUT: Error message */
   983    983   ){
   984         -  int nAlloc = (int)compressBound(nIn);
          984  +  sqlite3_int64 nAlloc = compressBound(nIn);
   985    985     u8 *aOut;
   986    986     int rc = SQLITE_OK;
   987    987   
   988         -  aOut = (u8*)sqlite3_malloc(nAlloc);
          988  +  aOut = (u8*)sqlite3_malloc64(nAlloc);
   989    989     if( aOut==0 ){
   990    990       rc = SQLITE_NOMEM;
   991    991     }else{
   992    992       int res;
   993    993       z_stream str;
   994    994       memset(&str, 0, sizeof(str));
   995    995       str.next_in = (Bytef*)aIn;
................................................................................
  1054   1054           int szFinal = pCDS->szUncompressed;
  1055   1055           if( szFinal>0 ){
  1056   1056             u8 *aBuf;
  1057   1057             u8 *aFree = 0;
  1058   1058             if( pCsr->pCurrent->aData ){
  1059   1059               aBuf = pCsr->pCurrent->aData;
  1060   1060             }else{
  1061         -            aBuf = aFree = sqlite3_malloc(sz);
         1061  +            aBuf = aFree = sqlite3_malloc64(sz);
  1062   1062               if( aBuf==0 ){
  1063   1063                 rc = SQLITE_NOMEM;
  1064   1064               }else{
  1065   1065                 FILE *pFile = pCsr->pFile;
  1066   1066                 if( pFile==0 ){
  1067   1067                   pFile = ((ZipfileTab*)(pCsr->base.pVtab))->pWriteFd;
  1068   1068                 }
................................................................................
  1893   1893     ZipfileBuffer body;
  1894   1894     ZipfileBuffer cds;
  1895   1895   };
  1896   1896   
  1897   1897   static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
  1898   1898     if( pBuf->n+nByte>pBuf->nAlloc ){
  1899   1899       u8 *aNew;
  1900         -    int nNew = pBuf->n ? pBuf->n*2 : 512;
         1900  +    sqlite3_int64 nNew = pBuf->n ? pBuf->n*2 : 512;
  1901   1901       int nReq = pBuf->n + nByte;
  1902   1902   
  1903   1903       while( nNew<nReq ) nNew = nNew*2;
  1904         -    aNew = sqlite3_realloc(pBuf->a, nNew);
         1904  +    aNew = sqlite3_realloc64(pBuf->a, nNew);
  1905   1905       if( aNew==0 ) return SQLITE_NOMEM;
  1906   1906       pBuf->a = aNew;
  1907         -    pBuf->nAlloc = nNew;
         1907  +    pBuf->nAlloc = (int)nNew;
  1908   1908     }
  1909   1909     return SQLITE_OK;
  1910   1910   }
  1911   1911   
  1912   1912   /*
  1913   1913   ** xStep() callback for the zipfile() aggregate. This can be called in
  1914   1914   ** any of the following ways:
................................................................................
  2091   2091   
  2092   2092   /*
  2093   2093   ** xFinalize() callback for zipfile aggregate function.
  2094   2094   */
  2095   2095   void zipfileFinal(sqlite3_context *pCtx){
  2096   2096     ZipfileCtx *p;
  2097   2097     ZipfileEOCD eocd;
  2098         -  int nZip;
         2098  +  sqlite3_int64 nZip;
  2099   2099     u8 *aZip;
  2100   2100   
  2101   2101     p = (ZipfileCtx*)sqlite3_aggregate_context(pCtx, sizeof(ZipfileCtx));
  2102   2102     if( p==0 ) return;
  2103   2103     if( p->nEntry>0 ){
  2104   2104       memset(&eocd, 0, sizeof(eocd));
  2105   2105       eocd.nEntry = (u16)p->nEntry;
  2106   2106       eocd.nEntryTotal = (u16)p->nEntry;
  2107   2107       eocd.nSize = p->cds.n;
  2108   2108       eocd.iOffset = p->body.n;
  2109   2109   
  2110   2110       nZip = p->body.n + p->cds.n + ZIPFILE_EOCD_FIXED_SZ;
  2111         -    aZip = (u8*)sqlite3_malloc(nZip);
         2111  +    aZip = (u8*)sqlite3_malloc64(nZip);
  2112   2112       if( aZip==0 ){
  2113   2113         sqlite3_result_error_nomem(pCtx);
  2114   2114       }else{
  2115   2115         memcpy(aZip, p->body.a, p->body.n);
  2116   2116         memcpy(&aZip[p->body.n], p->cds.a, p->cds.n);
  2117   2117         zipfileSerializeEOCD(&eocd, &aZip[p->body.n + p->cds.n]);
  2118         -      sqlite3_result_blob(pCtx, aZip, nZip, zipfileFree);
         2118  +      sqlite3_result_blob(pCtx, aZip, (int)nZip, zipfileFree);
  2119   2119       }
  2120   2120     }
  2121   2121   
  2122   2122     sqlite3_free(p->body.a);
  2123   2123     sqlite3_free(p->cds.a);
  2124   2124   }
  2125   2125   

Changes to ext/rbu/rbu_common.tcl.

    82     82       sqlite3 tmpdb $rbu
    83     83       tmpdb eval { DELETE FROM rbu_state WHERE k==10 }
    84     84       tmpdb close
    85     85     }
    86     86     set rc
    87     87   }
    88     88   
    89         -proc do_rbu_vacuum_test {tn step} {
    90         -  forcedelete state.db
    91         -  uplevel [list do_test $tn.1 {
    92         -    if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db }
           89  +proc do_rbu_vacuum_test {tn step {statedb state.db}} {
           90  +  forcedelete $statedb
           91  +  if {$statedb=="" && $step==1} breakpoint
           92  +  uplevel [list do_test $tn.1 [string map [list %state% $statedb] {
           93  +    if {$step==0} { sqlite3rbu_vacuum rbu test.db {%state%}}
    93     94       while 1 {
    94         -      if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db }
           95  +      if {$step==1} { sqlite3rbu_vacuum rbu test.db {%state%}}
    95     96         set state [rbu state]
    96     97         check_prestep_state test.db $state
    97     98         set rc [rbu step]
    98     99         check_poststep_state $rc test.db $state
    99    100         if {$rc!="SQLITE_OK"} break
   100    101         if {$step==1} { rbu close }
   101    102       }
   102    103       rbu close
   103         -  } {SQLITE_DONE}]
          104  +  }] {SQLITE_DONE}]
   104    105   
   105    106     uplevel [list do_execsql_test $tn.2 {
   106    107       PRAGMA integrity_check
   107    108     } ok]
   108    109   }
   109    110   

Changes to ext/rbu/rbuvacuum2.test.

    12     12   # This file contains tests for the RBU module. More specifically, it
    13     13   # contains tests to ensure that the sqlite3rbu_vacuum() API works as
    14     14   # expected.
    15     15   #
    16     16   
    17     17   source [file join [file dirname [info script]] rbu_common.tcl]
    18     18   
    19         -foreach step {0 1} {
    20         -  set ::testprefix rbuvacuum2-$step
           19  +foreach {step} {0 1} {
           20  +foreach {ttt state} {
           21  +  s state.db t test.db-vacuum n {}
           22  +} {
           23  +  set ::testprefix rbuvacuum2-$step$ttt
    21     24     
    22     25     #-------------------------------------------------------------------------
    23     26     # Test that a database that contains fts3 tables can be vacuumed.
    24     27     #
    25     28     ifcapable fts3 {
    26     29       reset_db
    27     30       do_execsql_test 1.1 {
    28     31         CREATE VIRTUAL TABLE t1 USING fts3(z, y);
    29     32         INSERT INTO t1 VALUES('fix this issue', 'at some point');
    30     33       }
    31     34     
    32         -    do_rbu_vacuum_test 1.2 $step
           35  +    do_rbu_vacuum_test 1.2 $step $state
    33     36     
    34     37       do_execsql_test 1.3 {
    35     38         SELECT * FROM t1;
    36     39       } {{fix this issue} {at some point}}
    37     40     
    38     41       do_execsql_test 1.4 {
    39     42         SELECT rowid FROM t1 WHERE t1 MATCH 'fix';
................................................................................
    42     45       do_execsql_test 1.5 {
    43     46         INSERT INTO t1 VALUES('a b c', 'd e f');
    44     47         INSERT INTO t1 VALUES('l h i', 'd e f');
    45     48         DELETE FROM t1 WHERE docid = 2;
    46     49         INSERT INTO t1 VALUES('a b c', 'x y z');
    47     50       }
    48     51   
    49         -    do_rbu_vacuum_test 1.6 $step
           52  +    do_rbu_vacuum_test 1.6 $step $state
    50     53       do_execsql_test 1.7 {
    51     54         INSERT INTO t1(t1) VALUES('integrity-check');
    52     55         SELECT * FROM t1;
    53     56       } {
    54     57         {fix this issue} {at some point}
    55     58         {l h i} {d e f}
    56     59         {a b c} {x y z}
................................................................................
    63     66     ifcapable fts5 {
    64     67       reset_db
    65     68       do_execsql_test 2.1 {
    66     69         CREATE VIRTUAL TABLE t1 USING fts5(z, y);
    67     70         INSERT INTO t1 VALUES('fix this issue', 'at some point');
    68     71       }
    69     72     
    70         -    do_rbu_vacuum_test 2.2 $step
           73  +    do_rbu_vacuum_test 2.2 $step $state
    71     74     
    72     75       do_execsql_test 2.3 {
    73     76         SELECT * FROM t1;
    74     77       } {{fix this issue} {at some point}}
    75     78     
    76     79       do_execsql_test 2.4 {
    77     80         SELECT rowid FROM t1 ('fix');
................................................................................
    80     83       do_execsql_test 2.5 {
    81     84         INSERT INTO t1 VALUES('a b c', 'd e f');
    82     85         INSERT INTO t1 VALUES('l h i', 'd e f');
    83     86         DELETE FROM t1 WHERE rowid = 2;
    84     87         INSERT INTO t1 VALUES('a b c', 'x y z');
    85     88       }
    86     89   
    87         -    do_rbu_vacuum_test 2.6 $step
           90  +    do_rbu_vacuum_test 2.6 $step $state
    88     91       do_execsql_test 2.7 {
    89     92         INSERT INTO t1(t1) VALUES('integrity-check');
    90     93         SELECT * FROM t1;
    91     94       } {
    92     95         {fix this issue} {at some point}
    93     96         {l h i} {d e f}
    94     97         {a b c} {x y z}
................................................................................
   103    106       do_execsql_test 3.1 {
   104    107         CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
   105    108         INSERT INTO rt VALUES(1, 45, 55);
   106    109         INSERT INTO rt VALUES(2, 50, 60);
   107    110         INSERT INTO rt VALUES(3, 55, 65);
   108    111       }
   109    112     
   110         -    do_rbu_vacuum_test 3.2 $step
          113  +    do_rbu_vacuum_test 3.2 $step $state
   111    114     
   112    115       do_execsql_test 3.3 {
   113    116         SELECT * FROM rt;
   114    117       } {1 45.0 55.0 2 50.0 60.0 3 55.0 65.0}
   115    118     
   116    119       do_execsql_test 3.4.1 {
   117    120         SELECT rowid FROM rt WHERE x2>51 AND x1 < 51
   118    121       } {1 2}
   119    122       do_execsql_test 3.4.2 {
   120    123         SELECT rowid FROM rt WHERE x2>59 AND x1 < 59
   121    124       } {2 3}
   122    125   
   123         -    do_rbu_vacuum_test 3.5 $step
          126  +    do_rbu_vacuum_test 3.5 $step $state
   124    127   
   125    128       do_execsql_test 3.6.1 {
   126    129         SELECT rowid FROM rt WHERE x2>51 AND x1 < 51
   127    130       } {1 2}
   128    131       do_execsql_test 3.6.2 {
   129    132         SELECT rowid FROM rt WHERE x2>59 AND x1 < 59
   130    133       } {2 3}
................................................................................
   143    146         SELECT * FROM sqlite_master;
   144    147       } {
   145    148       table t1 t1 2 {CREATE TABLE t1(a, b, c)}
   146    149       view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t1}
   147    150       trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END}
   148    151       }
   149    152   
   150         -    do_rbu_vacuum_test 4.3 $step
          153  +    do_rbu_vacuum_test 4.3 $step $state
   151    154       do_execsql_test 4.4 {
   152    155         SELECT * FROM sqlite_master;
   153    156       } {
   154    157       table t1 t1 2 {CREATE TABLE t1(a, b, c)}
   155    158       view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t1}
   156    159       trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END}
   157    160       }
   158    161     }
          162  +}
   159    163   }
   160    164     
   161    165   #-------------------------------------------------------------------------
   162    166   # Test that passing a NULL value as the second argument to 
   163    167   # sqlite3rbu_vacuum() causes it to:
   164    168   #
   165    169   #   * Use <database>-vacuum as the state db, and
................................................................................
   227    231   do_test 6.3 {
   228    232     sqlite3rbu_vacuum rbu test.db test.db2
   229    233     while {[rbu step]!="SQLITE_DONE"} { rbu step }
   230    234     rbu close
   231    235     execsql { PRAGMA integrity_check }
   232    236   } {ok}
   233    237   
          238  +do_test 6.4 {
          239  +  sqlite3rbu_vacuum rbu test.db test.db-vactmp
          240  +  list [catch { rbu close } msg] $msg
          241  +} {1 SQLITE_MISUSE}
          242  +
   234    243   finish_test

Added ext/rbu/rbuvacuum3.test.

            1  +# 2019 Jan 3
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file contains tests for the RBU module. More specifically, it
           13  +# contains tests to ensure that the sqlite3rbu_vacuum() API works as
           14  +# expected.
           15  +#
           16  +
           17  +source [file join [file dirname [info script]] rbu_common.tcl]
           18  +set testprefix rbuvacuum3
           19  +
           20  +do_execsql_test 1.0 {
           21  +  CREATE TABLE t1(a PRIMARY KEY, b, c);
           22  +  CREATE INDEX i1b ON t1(b);
           23  +  CREATE INDEX i1c ON t1(c);
           24  +  
           25  +  WITH s(i) AS (
           26  +    VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
           27  +  )
           28  +  INSERT INTO t1 SELECT i, randomblob(100), randomblob(100) FROM s;
           29  +}
           30  +
           31  +forcedelete state.db
           32  +do_test 1.1 {
           33  +  sqlite3rbu_vacuum rbu test.db state.db
           34  +  while {1} {
           35  +    set rc [rbu step]
           36  +    if {$rc!="SQLITE_OK"} break
           37  +    rbu savestate
           38  +  }
           39  +  rbu close
           40  +} {SQLITE_DONE}
           41  +
           42  +do_test 1.2 {
           43  +  sqlite3rbu_vacuum rbu test.db state.db
           44  +  while {1} {
           45  +    set rc [rbu step]
           46  +    if {$rc!="SQLITE_OK"} break
           47  +    rbu savestate
           48  +  }
           49  +  rbu close
           50  +} {SQLITE_DONE}
           51  +
           52  +do_test 1.3 {
           53  +  while {1} {
           54  +    sqlite3rbu_vacuum rbu test.db state.db
           55  +    set rc [rbu step]
           56  +    if {$rc!="SQLITE_OK"} break
           57  +    rbu savestate
           58  +    rbu close
           59  +  }
           60  +  rbu close
           61  +} {SQLITE_DONE}
           62  +
           63  +finish_test

Changes to ext/rbu/sqlite3rbu.c.

  2473   2473           zExtra = &p->zRbu[5];
  2474   2474           while( *zExtra ){
  2475   2475             if( *zExtra++=='?' ) break;
  2476   2476           }
  2477   2477           if( *zExtra=='\0' ) zExtra = 0;
  2478   2478         }
  2479   2479   
  2480         -      zTarget = sqlite3_mprintf("file:%s-vacuum?rbu_memory=1%s%s", 
         2480  +      zTarget = sqlite3_mprintf("file:%s-vactmp?rbu_memory=1%s%s", 
  2481   2481             sqlite3_db_filename(p->dbRbu, "main"),
  2482   2482             (zExtra==0 ? "" : "&"), (zExtra==0 ? "" : zExtra)
  2483   2483         );
  2484   2484   
  2485   2485         if( zTarget==0 ){
  2486   2486           p->rc = SQLITE_NOMEM;
  2487   2487           return;
................................................................................
  3739   3739   ** Open a handle to begin or resume an RBU VACUUM operation.
  3740   3740   */
  3741   3741   sqlite3rbu *sqlite3rbu_vacuum(
  3742   3742     const char *zTarget, 
  3743   3743     const char *zState
  3744   3744   ){
  3745   3745     if( zTarget==0 ){ return rbuMisuseError(); }
         3746  +  if( zState ){
         3747  +    int n = strlen(zState);
         3748  +    if( n>=7 && 0==memcmp("-vactmp", &zState[n-7], 7) ){
         3749  +      return rbuMisuseError();
         3750  +    }
         3751  +  }
  3746   3752     /* TODO: Check that both arguments are non-NULL */
  3747   3753     return openRbuHandle(0, zTarget, zState);
  3748   3754   }
  3749   3755   
  3750   3756   /*
  3751   3757   ** Return the database handle used by pRbu.
  3752   3758   */
................................................................................
  3935   3941     p->rc = rc;
  3936   3942     rbuSaveState(p, p->eStage);
  3937   3943     rc = p->rc;
  3938   3944   
  3939   3945     if( p->eStage==RBU_STAGE_OAL ){
  3940   3946       assert( rc!=SQLITE_DONE );
  3941   3947       if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0);
  3942         -    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "BEGIN IMMEDIATE", 0, 0, 0);
         3948  +    if( rc==SQLITE_OK ){ 
         3949  +      const char *zBegin = rbuIsVacuum(p) ? "BEGIN" : "BEGIN IMMEDIATE";
         3950  +      rc = sqlite3_exec(p->dbRbu, zBegin, 0, 0, 0);
         3951  +    }
  3943   3952       if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0,0);
  3944   3953     }
  3945   3954   
  3946   3955     p->rc = rc;
  3947   3956     return rc;
  3948   3957   }
  3949   3958   

Changes to ext/rbu/sqlite3rbu.h.

   329    329   ** The vacuum can be resumed by calling this function to open a new RBU
   330    330   ** handle specifying the same target and state databases.
   331    331   **
   332    332   ** If the second argument passed to this function is NULL, then the
   333    333   ** name of the state database is "<database>-vacuum", where <database>
   334    334   ** is the name of the target database file. In this case, on UNIX, if the
   335    335   ** state database is not already present in the file-system, it is created
   336         -** with the same permissions as the target db is made.
          336  +** with the same permissions as the target db is made. 
          337  +**
          338  +** With an RBU vacuum, it is an SQLITE_MISUSE error if the name of the 
          339  +** state database ends with "-vactmp". This name is reserved for internal 
          340  +** use.
   337    341   **
   338    342   ** This function does not delete the state database after an RBU vacuum
   339    343   ** is completed, even if it created it. However, if the call to
   340    344   ** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents
   341    345   ** of the state tables within the state database are zeroed. This way,
   342    346   ** the next call to sqlite3rbu_vacuum() opens a handle that starts a 
   343    347   ** new RBU vacuum operation.

Changes to ext/rbu/test_rbu.c.

   269    269     if( objc!=3 && objc!=4 ){
   270    270       Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB ?STATE-DB?");
   271    271       return TCL_ERROR;
   272    272     }
   273    273     zCmd = Tcl_GetString(objv[1]);
   274    274     zTarget = Tcl_GetString(objv[2]);
   275    275     if( objc==4 ) zStateDb = Tcl_GetString(objv[3]);
          276  +  if( zStateDb && zStateDb[0]=='\0' ) zStateDb = 0;
   276    277   
   277    278     pRbu = sqlite3rbu_vacuum(zTarget, zStateDb);
   278    279     Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);
   279    280     Tcl_SetObjResult(interp, objv[1]);
   280    281     return TCL_OK;
   281    282   }
   282    283   

Changes to ext/rtree/geopoly.c.

   391    391   ** Additional arguments are added as attributes to the <polyline>.
   392    392   */
   393    393   static void geopolySvgFunc(
   394    394     sqlite3_context *context,
   395    395     int argc,
   396    396     sqlite3_value **argv
   397    397   ){
   398         -  GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
          398  +  GeoPoly *p;
          399  +  if( argc<1 ) return;
          400  +  p = geopolyFuncParam(context, argv[0], 0);
   399    401     if( p ){
   400    402       sqlite3 *db = sqlite3_context_db_handle(context);
   401    403       sqlite3_str *x = sqlite3_str_new(db);
   402    404       int i;
   403    405       char cSep = '\'';
   404    406       sqlite3_str_appendf(x, "<polyline points=");
   405    407       for(i=0; i<p->nVertex; i++){

Changes to ext/rtree/rtree.c.

   125    125     u8 nDim;                    /* Number of dimensions */
   126    126     u8 nDim2;                   /* Twice the number of dimensions */
   127    127     u8 eCoordType;              /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */
   128    128     u8 nBytesPerCell;           /* Bytes consumed per cell */
   129    129     u8 inWrTrans;               /* True if inside write transaction */
   130    130     u8 nAux;                    /* # of auxiliary columns in %_rowid */
   131    131     u8 nAuxNotNull;             /* Number of initial not-null aux columns */
          132  +#ifdef SQLITE_DEBUG
          133  +  u8 bCorrupt;                /* Shadow table corruption detected */
          134  +#endif
   132    135     int iDepth;                 /* Current depth of the r-tree structure */
   133    136     char *zDb;                  /* Name of database containing r-tree table */
   134    137     char *zName;                /* Name of r-tree table */ 
   135    138     u32 nBusy;                  /* Current number of users of this structure */
   136    139     i64 nRowEst;                /* Estimated number of rows in this table */
   137    140     u32 nCursor;                /* Number of open cursors */
   138    141     u32 nNodeRef;               /* Number RtreeNodes with positive nRef */
................................................................................
   184    187   # define RTREE_ZERO 0
   185    188   #else
   186    189     typedef double RtreeDValue;              /* High accuracy coordinate */
   187    190     typedef float RtreeValue;                /* Low accuracy coordinate */
   188    191   # define RTREE_ZERO 0.0
   189    192   #endif
   190    193   
          194  +/*
          195  +** Set the Rtree.bCorrupt flag
          196  +*/
          197  +#ifdef SQLITE_DEBUG
          198  +# define RTREE_IS_CORRUPT(X) ((X)->bCorrupt = 1)
          199  +#else
          200  +# define RTREE_IS_CORRUPT(X)
          201  +#endif
          202  +
   191    203   /*
   192    204   ** When doing a search of an r-tree, instances of the following structure
   193    205   ** record intermediate results from the tree walk.
   194    206   **
   195    207   ** The id is always a node-id.  For iLevel>=1 the id is the node-id of
   196    208   ** the node that the RtreeSearchPoint represents.  When iLevel==0, however,
   197    209   ** the id is of the parent node and the cell that RtreeSearchPoint
................................................................................
   550    562     p->isDirty = 1;
   551    563   }
   552    564   
   553    565   /*
   554    566   ** Given a node number iNode, return the corresponding key to use
   555    567   ** in the Rtree.aHash table.
   556    568   */
   557         -static int nodeHash(i64 iNode){
   558         -  return iNode % HASHSIZE;
          569  +static unsigned int nodeHash(i64 iNode){
          570  +  return ((unsigned)iNode) % HASHSIZE;
   559    571   }
   560    572   
   561    573   /*
   562    574   ** Search the node hash table for node iNode. If found, return a pointer
   563    575   ** to it. Otherwise, return 0.
   564    576   */
   565    577   static RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){
................................................................................
   596    608   ** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0),
   597    609   ** indicating that node has not yet been assigned a node number. It is
   598    610   ** assigned a node number when nodeWrite() is called to write the
   599    611   ** node contents out to the database.
   600    612   */
   601    613   static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
   602    614     RtreeNode *pNode;
   603         -  pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
          615  +  pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode) + pRtree->iNodeSize);
   604    616     if( pNode ){
   605    617       memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
   606    618       pNode->zData = (u8 *)&pNode[1];
   607    619       pNode->nRef = 1;
   608    620       pRtree->nNodeRef++;
   609    621       pNode->pParent = pParent;
   610    622       pNode->isDirty = 1;
................................................................................
   619    631   static void nodeBlobReset(Rtree *pRtree){
   620    632     if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){
   621    633       sqlite3_blob *pBlob = pRtree->pNodeBlob;
   622    634       pRtree->pNodeBlob = 0;
   623    635       sqlite3_blob_close(pBlob);
   624    636     }
   625    637   }
          638  +
          639  +/*
          640  +** Check to see if pNode is the same as pParent or any of the parents
          641  +** of pParent.
          642  +*/
          643  +static int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){
          644  +  do{
          645  +    if( pNode==pParent ) return 1;
          646  +    pParent = pParent->pParent;
          647  +  }while( pParent );
          648  +  return 0;
          649  +}
   626    650   
   627    651   /*
   628    652   ** Obtain a reference to an r-tree node.
   629    653   */
   630    654   static int nodeAcquire(
   631    655     Rtree *pRtree,             /* R-tree structure */
   632    656     i64 iNode,                 /* Node number to load */
................................................................................
   638    662   
   639    663     /* Check if the requested node is already in the hash table. If so,
   640    664     ** increase its reference count and return it.
   641    665     */
   642    666     if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
   643    667       assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
   644    668       if( pParent && !pNode->pParent ){
          669  +      if( nodeInParentChain(pNode, pParent) ){
          670  +        RTREE_IS_CORRUPT(pRtree);
          671  +        return SQLITE_CORRUPT_VTAB;
          672  +      }
   645    673         pParent->nRef++;
   646    674         pNode->pParent = pParent;
   647    675       }
   648    676       pNode->nRef++;
   649    677       *ppNode = pNode;
   650    678       return SQLITE_OK;
   651    679     }
................................................................................
   668    696       sqlite3_free(zTab);
   669    697     }
   670    698     if( rc ){
   671    699       nodeBlobReset(pRtree);
   672    700       *ppNode = 0;
   673    701       /* If unable to open an sqlite3_blob on the desired row, that can only
   674    702       ** be because the shadow tables hold erroneous data. */
   675         -    if( rc==SQLITE_ERROR ) rc = SQLITE_CORRUPT_VTAB;
          703  +    if( rc==SQLITE_ERROR ){
          704  +      rc = SQLITE_CORRUPT_VTAB;
          705  +      RTREE_IS_CORRUPT(pRtree);
          706  +    }
   676    707     }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){
   677         -    pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
          708  +    pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode)+pRtree->iNodeSize);
   678    709       if( !pNode ){
   679    710         rc = SQLITE_NOMEM;
   680    711       }else{
   681    712         pNode->pParent = pParent;
   682    713         pNode->zData = (u8 *)&pNode[1];
   683    714         pNode->nRef = 1;
   684    715         pRtree->nNodeRef++;
   685    716         pNode->iNode = iNode;
   686    717         pNode->isDirty = 0;
   687    718         pNode->pNext = 0;
   688    719         rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,
   689    720                                pRtree->iNodeSize, 0);
   690         -      nodeReference(pParent);
   691    721       }
   692    722     }
   693    723   
   694    724     /* If the root node was just loaded, set pRtree->iDepth to the height
   695    725     ** of the r-tree structure. A height of zero means all data is stored on
   696    726     ** the root node. A height of one means the children of the root node
   697    727     ** are the leaves, and so on. If the depth as specified on the root node
   698    728     ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt.
   699    729     */
   700    730     if( pNode && iNode==1 ){
   701    731       pRtree->iDepth = readInt16(pNode->zData);
   702    732       if( pRtree->iDepth>RTREE_MAX_DEPTH ){
   703    733         rc = SQLITE_CORRUPT_VTAB;
          734  +      RTREE_IS_CORRUPT(pRtree);
   704    735       }
   705    736     }
   706    737   
   707    738     /* If no error has occurred so far, check if the "number of entries"
   708    739     ** field on the node is too large. If so, set the return code to 
   709    740     ** SQLITE_CORRUPT_VTAB.
   710    741     */
   711    742     if( pNode && rc==SQLITE_OK ){
   712    743       if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
   713    744         rc = SQLITE_CORRUPT_VTAB;
          745  +      RTREE_IS_CORRUPT(pRtree);
   714    746       }
   715    747     }
   716    748   
   717    749     if( rc==SQLITE_OK ){
   718    750       if( pNode!=0 ){
          751  +      nodeReference(pParent);
   719    752         nodeHashInsert(pRtree, pNode);
   720    753       }else{
   721    754         rc = SQLITE_CORRUPT_VTAB;
          755  +      RTREE_IS_CORRUPT(pRtree);
   722    756       }
   723    757       *ppNode = pNode;
   724    758     }else{
   725    759       if( pNode ){
   726    760         pRtree->nNodeRef--;
   727    761         sqlite3_free(pNode);
   728    762       }
................................................................................
   940    974   */
   941    975   static void rtreeRelease(Rtree *pRtree){
   942    976     pRtree->nBusy--;
   943    977     if( pRtree->nBusy==0 ){
   944    978       pRtree->inWrTrans = 0;
   945    979       assert( pRtree->nCursor==0 );
   946    980       nodeBlobReset(pRtree);
   947         -    assert( pRtree->nNodeRef==0 );
          981  +    assert( pRtree->nNodeRef==0 || pRtree->bCorrupt );
   948    982       sqlite3_finalize(pRtree->pWriteNode);
   949    983       sqlite3_finalize(pRtree->pDeleteNode);
   950    984       sqlite3_finalize(pRtree->pReadRowid);
   951    985       sqlite3_finalize(pRtree->pWriteRowid);
   952    986       sqlite3_finalize(pRtree->pDeleteRowid);
   953    987       sqlite3_finalize(pRtree->pReadParent);
   954    988       sqlite3_finalize(pRtree->pWriteParent);
................................................................................
   999   1033   ** Rtree virtual table module xOpen method.
  1000   1034   */
  1001   1035   static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
  1002   1036     int rc = SQLITE_NOMEM;
  1003   1037     Rtree *pRtree = (Rtree *)pVTab;
  1004   1038     RtreeCursor *pCsr;
  1005   1039   
  1006         -  pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor));
         1040  +  pCsr = (RtreeCursor *)sqlite3_malloc64(sizeof(RtreeCursor));
  1007   1041     if( pCsr ){
  1008   1042       memset(pCsr, 0, sizeof(RtreeCursor));
  1009   1043       pCsr->base.pVtab = pVTab;
  1010   1044       rc = SQLITE_OK;
  1011   1045       pRtree->nCursor++;
  1012   1046     }
  1013   1047     *ppCursor = (sqlite3_vtab_cursor *)pCsr;
................................................................................
  1272   1306     assert( nCell<200 );
  1273   1307     for(ii=0; ii<nCell; ii++){
  1274   1308       if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
  1275   1309         *piIndex = ii;
  1276   1310         return SQLITE_OK;
  1277   1311       }
  1278   1312     }
         1313  +  RTREE_IS_CORRUPT(pRtree);
  1279   1314     return SQLITE_CORRUPT_VTAB;
  1280   1315   }
  1281   1316   
  1282   1317   /*
  1283   1318   ** Return the index of the cell containing a pointer to node pNode
  1284   1319   ** in its parent. If pNode is the root node, return -1.
  1285   1320   */
................................................................................
  1365   1400     RtreeDValue rScore,   /* Score for the new search point */
  1366   1401     u8 iLevel             /* Level for the new search point */
  1367   1402   ){
  1368   1403     int i, j;
  1369   1404     RtreeSearchPoint *pNew;
  1370   1405     if( pCur->nPoint>=pCur->nPointAlloc ){
  1371   1406       int nNew = pCur->nPointAlloc*2 + 8;
  1372         -    pNew = sqlite3_realloc(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));
         1407  +    pNew = sqlite3_realloc64(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));
  1373   1408       if( pNew==0 ) return 0;
  1374   1409       pCur->aPoint = pNew;
  1375   1410       pCur->nPointAlloc = nNew;
  1376   1411     }
  1377   1412     i = pCur->nPoint++;
  1378   1413     pNew = pCur->aPoint + i;
  1379   1414     pNew->rScore = rScore;
................................................................................
  1767   1802       }
  1768   1803     }else{
  1769   1804       /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array 
  1770   1805       ** with the configured constraints. 
  1771   1806       */
  1772   1807       rc = nodeAcquire(pRtree, 1, 0, &pRoot);
  1773   1808       if( rc==SQLITE_OK && argc>0 ){
  1774         -      pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc);
         1809  +      pCsr->aConstraint = sqlite3_malloc64(sizeof(RtreeConstraint)*argc);
  1775   1810         pCsr->nConstraint = argc;
  1776   1811         if( !pCsr->aConstraint ){
  1777   1812           rc = SQLITE_NOMEM;
  1778   1813         }else{
  1779   1814           memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);
  1780   1815           memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));
  1781   1816           assert( (idxStr==0 && argc==0)
................................................................................
  1912   1947   
  1913   1948       if( p->usable
  1914   1949       && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2)
  1915   1950           || p->op==SQLITE_INDEX_CONSTRAINT_MATCH)
  1916   1951       ){
  1917   1952         u8 op;
  1918   1953         switch( p->op ){
  1919         -        case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
  1920         -        case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;
  1921         -        case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
  1922         -        case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
  1923         -        case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
  1924         -        default:
  1925         -          assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );
  1926         -          op = RTREE_MATCH; 
  1927         -          break;
         1954  +        case SQLITE_INDEX_CONSTRAINT_EQ:    op = RTREE_EQ;    break;
         1955  +        case SQLITE_INDEX_CONSTRAINT_GT:    op = RTREE_GT;    break;
         1956  +        case SQLITE_INDEX_CONSTRAINT_LE:    op = RTREE_LE;    break;
         1957  +        case SQLITE_INDEX_CONSTRAINT_LT:    op = RTREE_LT;    break;
         1958  +        case SQLITE_INDEX_CONSTRAINT_GE:    op = RTREE_GE;    break;
         1959  +        case SQLITE_INDEX_CONSTRAINT_MATCH: op = RTREE_MATCH; break;
         1960  +        default:                            op = 0;           break;
  1928   1961         }
  1929         -      zIdxStr[iIdx++] = op;
  1930         -      zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');
  1931         -      pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);
  1932         -      pIdxInfo->aConstraintUsage[ii].omit = 1;
         1962  +      if( op ){
         1963  +        zIdxStr[iIdx++] = op;
         1964  +        zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');
         1965  +        pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);
         1966  +        pIdxInfo->aConstraintUsage[ii].omit = 1;
         1967  +      }
  1933   1968       }
  1934   1969     }
  1935   1970   
  1936   1971     pIdxInfo->idxNum = 2;
  1937   1972     pIdxInfo->needToFreeIdxStr = 1;
  1938   1973     if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){
  1939   1974       return SQLITE_NOMEM;
................................................................................
  2134   2169   */
  2135   2170   static int AdjustTree(
  2136   2171     Rtree *pRtree,                    /* Rtree table */
  2137   2172     RtreeNode *pNode,                 /* Adjust ancestry of this node. */
  2138   2173     RtreeCell *pCell                  /* This cell was just inserted */
  2139   2174   ){
  2140   2175     RtreeNode *p = pNode;
         2176  +  int cnt = 0;
  2141   2177     while( p->pParent ){
  2142   2178       RtreeNode *pParent = p->pParent;
  2143   2179       RtreeCell cell;
  2144   2180       int iCell;
  2145   2181   
  2146         -    if( nodeParentIndex(pRtree, p, &iCell) ){
         2182  +    if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell)  ){
         2183  +      RTREE_IS_CORRUPT(pRtree);
  2147   2184         return SQLITE_CORRUPT_VTAB;
  2148   2185       }
  2149   2186   
  2150   2187       nodeGetCell(pRtree, pParent, iCell, &cell);
  2151   2188       if( !cellContains(pRtree, &cell, pCell) ){
  2152   2189         cellUnion(pRtree, &cell, pCell);
  2153   2190         nodeOverwriteCell(pRtree, pParent, &cell, iCell);
................................................................................
  2336   2373     int *aSpare;
  2337   2374     int ii;
  2338   2375   
  2339   2376     int iBestDim = 0;
  2340   2377     int iBestSplit = 0;
  2341   2378     RtreeDValue fBestMargin = RTREE_ZERO;
  2342   2379   
  2343         -  int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
         2380  +  sqlite3_int64 nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
  2344   2381   
  2345         -  aaSorted = (int **)sqlite3_malloc(nByte);
         2382  +  aaSorted = (int **)sqlite3_malloc64(nByte);
  2346   2383     if( !aaSorted ){
  2347   2384       return SQLITE_NOMEM;
  2348   2385     }
  2349   2386   
  2350   2387     aSpare = &((int *)&aaSorted[pRtree->nDim])[pRtree->nDim*nCell];
  2351   2388     memset(aaSorted, 0, nByte);
  2352   2389     for(ii=0; ii<pRtree->nDim; ii++){
................................................................................
  2459   2496   
  2460   2497     RtreeCell leftbbox;
  2461   2498     RtreeCell rightbbox;
  2462   2499   
  2463   2500     /* Allocate an array and populate it with a copy of pCell and 
  2464   2501     ** all cells from node pLeft. Then zero the original node.
  2465   2502     */
  2466         -  aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1));
         2503  +  aCell = sqlite3_malloc64((sizeof(RtreeCell)+sizeof(int))*(nCell+1));
  2467   2504     if( !aCell ){
  2468   2505       rc = SQLITE_NOMEM;
  2469   2506       goto splitnode_out;
  2470   2507     }
  2471   2508     aiUsed = (int *)&aCell[nCell+1];
  2472   2509     memset(aiUsed, 0, sizeof(int)*(nCell+1));
  2473   2510     for(i=0; i<nCell; i++){
................................................................................
  2607   2644         for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);
  2608   2645         if( !pTest ){
  2609   2646           rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);
  2610   2647         }
  2611   2648       }
  2612   2649       rc = sqlite3_reset(pRtree->pReadParent);
  2613   2650       if( rc==SQLITE_OK ) rc = rc2;
  2614         -    if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB;
         2651  +    if( rc==SQLITE_OK && !pChild->pParent ){
         2652  +      RTREE_IS_CORRUPT(pRtree);
         2653  +      rc = SQLITE_CORRUPT_VTAB;
         2654  +    }
  2615   2655       pChild = pChild->pParent;
  2616   2656     }
  2617   2657     return rc;
  2618   2658   }
  2619   2659   
  2620   2660   static int deleteCell(Rtree *, RtreeNode *, int, int);
  2621   2661   
................................................................................
  2747   2787   
  2748   2788     nCell = NCELL(pNode)+1;
  2749   2789     n = (nCell+1)&(~1);
  2750   2790   
  2751   2791     /* Allocate the buffers used by this operation. The allocation is
  2752   2792     ** relinquished before this function returns.
  2753   2793     */
  2754         -  aCell = (RtreeCell *)sqlite3_malloc(n * (
         2794  +  aCell = (RtreeCell *)sqlite3_malloc64(n * (
  2755   2795       sizeof(RtreeCell)     +         /* aCell array */
  2756   2796       sizeof(int)           +         /* aOrder array */
  2757   2797       sizeof(int)           +         /* aSpare array */
  2758   2798       sizeof(RtreeDValue)             /* aDistance array */
  2759   2799     ));
  2760   2800     if( !aCell ){
  2761   2801       return SQLITE_NOMEM;
................................................................................
  2920   2960   
  2921   2961     /* Obtain a reference to the leaf node that contains the entry 
  2922   2962     ** about to be deleted. 
  2923   29