/ Check-in [da53f3d3]
Login

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

Overview
Comment:Merge patches and enhancements from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | reuse-subqueries
Files: files | file ages | folders
SHA3-256: da53f3d3ff26cc32d3a5ac788b6785baa3d1688e50d9354025a3130dc7e71a38
User & Date: drh 2018-12-28 19:23:20
Context
2018-12-28
21:32
Merge performance enhancements from trunk. check-in: 0f1b9ff9 user: drh tags: reuse-subqueries
19:23
Merge patches and enhancements from trunk. check-in: da53f3d3 user: drh tags: reuse-subqueries
18:09
Fix another problem with loading the structure record from a corrupt fts5 database. check-in: c4d44542 user: dan tags: trunk
2018-12-25
00:15
Increase the number of parameters to sqlite3WhereCodeOneLoopStart() to encourage the compiler to inline that routine within sqlite3WhereBegin(). This gives a performance improvement. check-in: 3c2ad0e9 user: drh tags: reuse-subqueries
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_unicode2.c.

   196    196       'f',       'g',       'h',       'h',       'i',       'i'|HIBIT, 
   197    197       'k',       'l',       'l'|HIBIT, 'l',       'm',       'n',       
   198    198       'o'|HIBIT, 'p',       'r',       'r'|HIBIT, 'r',       's',       
   199    199       's'|HIBIT, 't',       'u',       'u'|HIBIT, 'v',       'w',       
   200    200       'w',       'x',       'y',       'z',       'h',       't',       
   201    201       'w',       'y',       'a',       'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT, 
   202    202       'e',       'e'|HIBIT, 'e'|HIBIT, 'i',       'o',       'o'|HIBIT, 
   203         -    'o'|HIBIT, 'o'|HIBIT, 'u',       'u'|HIBIT, 'u'|HIBIT, 'y',  
          203  +    'o'|HIBIT, 'o'|HIBIT, 'u',       'u'|HIBIT, 'u'|HIBIT, 'y',       
   204    204     };
   205    205   
   206    206     unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
   207    207     int iRes = 0;
   208    208     int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;
   209    209     int iLo = 0;
   210    210     while( iHi>=iLo ){
................................................................................
   227    227   ** is a diacritical modifier character.
   228    228   */
   229    229   int sqlite3FtsUnicodeIsdiacritic(int c){
   230    230     unsigned int mask0 = 0x08029FDF;
   231    231     unsigned int mask1 = 0x000361F8;
   232    232     if( c<768 || c>817 ) return 0;
   233    233     return (c < 768+32) ?
   234         -      (mask0 & (1 << (c-768))) :
   235         -      (mask1 & (1 << (c-768-32)));
          234  +      (mask0 & ((unsigned int)1 << (c-768))) :
          235  +      (mask1 & ((unsigned int)1 << (c-768-32)));
   236    236   }
   237    237   
   238    238   
   239    239   /*
   240    240   ** Interpret the argument as a unicode codepoint. If the codepoint
   241    241   ** is an upper case character that has a lower case equivalent,
   242    242   ** return the codepoint corresponding to the lower case version.

Changes to ext/fts3/fts3_write.c.

  1405   1405     pReader->aDoclist = pNext;
  1406   1406     pReader->pOffsetList = 0;
  1407   1407   
  1408   1408     /* Check that the doclist does not appear to extend past the end of the
  1409   1409     ** b-tree node. And that the final byte of the doclist is 0x00. If either 
  1410   1410     ** of these statements is untrue, then the data structure is corrupt.
  1411   1411     */
  1412         -  if( (&pReader->aNode[pReader->nNode] - pReader->aDoclist)<pReader->nDoclist
         1412  +  if( pReader->nDoclist > pReader->nNode-(pReader->aDoclist-pReader->aNode)
  1413   1413      || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
  1414   1414     ){
  1415   1415       return FTS_CORRUPT_VTAB;
  1416   1416     }
  1417   1417     return SQLITE_OK;
  1418   1418   }
  1419   1419   

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

    59     59       incr i
    60     60   
    61     61       puts -nonewline [format "%5d" [expr ($iCode<<3) + $nRange-1]]
    62     62       puts -nonewline ", "
    63     63     }
    64     64     puts ""
    65     65     puts "  \};"
           66  +  puts "#define HIBIT ((char)0x80)"
    66     67     puts "  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;

Changes to ext/fts5/fts5Int.h.

   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_expr.c.

  2549   2549       return;
  2550   2550     }
  2551   2551     memset(aArr, 0, sizeof(aArr));
  2552   2552     sqlite3Fts5UnicodeCatParse("L*", aArr);
  2553   2553     sqlite3Fts5UnicodeCatParse("N*", aArr);
  2554   2554     sqlite3Fts5UnicodeCatParse("Co", aArr);
  2555   2555     iCode = sqlite3_value_int(apVal[0]);
  2556         -  sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory(iCode)]);
         2556  +  sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory((u32)iCode)]);
  2557   2557   }
  2558   2558   
  2559   2559   static void fts5ExprFold(
  2560   2560     sqlite3_context *pCtx,          /* Function call context */
  2561   2561     int nArg,                       /* Number of args */
  2562   2562     sqlite3_value **apVal           /* Function arguments */
  2563   2563   ){

Changes to ext/fts5/fts5_index.c.

   686    686           rc = sqlite3_blob_read(p->pReader, aOut, nByte, 0);
   687    687         }
   688    688         if( rc!=SQLITE_OK ){
   689    689           sqlite3_free(pRet);
   690    690           pRet = 0;
   691    691         }else{
   692    692           /* TODO1: Fix this */
   693         -        pRet->szLeaf = fts5GetU16(&pRet->p[2]);
   694    693           pRet->p[nByte] = 0x00;
          694  +        pRet->szLeaf = fts5GetU16(&pRet->p[2]);
   695    695         }
   696    696       }
   697    697       p->rc = rc;
   698    698       p->nRead++;
   699    699     }
   700    700   
   701    701     assert( (pRet==0)==(p->rc!=SQLITE_OK) );
................................................................................
   856    856     if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);
   857    857     i = 4;
   858    858   
   859    859     /* Read the total number of levels and segments from the start of the
   860    860     ** structure record.  */
   861    861     i += fts5GetVarint32(&pData[i], nLevel);
   862    862     i += fts5GetVarint32(&pData[i], nSegment);
          863  +  if( nLevel>FTS5_MAX_SEGMENT   || nLevel<0
          864  +   || nSegment>FTS5_MAX_SEGMENT || nSegment<0
          865  +  ){
          866  +    return FTS5_CORRUPT;
          867  +  }
   863    868     nByte = (
   864    869         sizeof(Fts5Structure) +                    /* Main structure */
   865    870         sizeof(Fts5StructureLevel) * (nLevel-1)    /* aLevel[] array */
   866    871     );
   867    872     pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);
   868    873   
   869    874     if( pRet ){
................................................................................
   888    893           );
   889    894           nSegment -= nTotal;
   890    895         }
   891    896   
   892    897         if( rc==SQLITE_OK ){
   893    898           pLvl->nSeg = nTotal;
   894    899           for(iSeg=0; iSeg<nTotal; iSeg++){
          900  +          Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
   895    901             if( i>=nData ){
   896    902               rc = FTS5_CORRUPT;
   897    903               break;
   898    904             }
   899         -          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
   900         -          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
   901         -          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
          905  +          i += fts5GetVarint32(&pData[i], pSeg->iSegid);
          906  +          i += fts5GetVarint32(&pData[i], pSeg->pgnoFirst);
          907  +          i += fts5GetVarint32(&pData[i], pSeg->pgnoLast);
          908  +          if( pSeg->pgnoLast<pSeg->pgnoFirst ){
          909  +            rc = FTS5_CORRUPT;
          910  +            break;
          911  +          }
   902    912           }
   903    913         }
   904    914       }
   905    915       if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT;
   906    916   
   907    917       if( rc!=SQLITE_OK ){
   908    918         fts5StructureRelease(pRet);
................................................................................
  1637   1647   */
  1638   1648   static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
  1639   1649     u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */
  1640   1650     int iOff = pIter->iLeafOffset;  /* Offset to read at */
  1641   1651     int nNew;                       /* Bytes of new data */
  1642   1652   
  1643   1653     iOff += fts5GetVarint32(&a[iOff], nNew);
  1644         -  if( iOff+nNew>pIter->pLeaf->nn ){
         1654  +  if( iOff+nNew>pIter->pLeaf->nn || nKeep>pIter->term.n ){
  1645   1655       p->rc = FTS5_CORRUPT;
  1646   1656       return;
  1647   1657     }
  1648   1658     pIter->term.n = nKeep;
  1649   1659     fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
         1660  +  assert( pIter->term.n<=pIter->term.nSpace );
  1650   1661     iOff += nNew;
  1651   1662     pIter->iTermLeafOffset = iOff;
  1652   1663     pIter->iTermLeafPgno = pIter->iLeafPgno;
  1653   1664     pIter->iLeafOffset = iOff;
  1654   1665   
  1655   1666     if( pIter->iPgidxOff>=pIter->pLeaf->nn ){
  1656   1667       pIter->iEndofDoclist = pIter->pLeaf->nn+1;
................................................................................
  1707   1718       pIter->iLeafPgno = pSeg->pgnoFirst-1;
  1708   1719       fts5SegIterNextPage(p, pIter);
  1709   1720     }
  1710   1721   
  1711   1722     if( p->rc==SQLITE_OK ){
  1712   1723       pIter->iLeafOffset = 4;
  1713   1724       assert_nc( pIter->pLeaf->nn>4 );
  1714         -    assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
         1725  +    assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
  1715   1726       pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
  1716   1727       fts5SegIterLoadTerm(p, pIter, 0);
  1717   1728       fts5SegIterLoadNPos(p, pIter);
  1718   1729     }
  1719   1730   }
  1720   1731   
  1721   1732   /*
................................................................................
  3564   3575         int i;
  3565   3576         u32 mask;
  3566   3577         memset(aUsed, 0, sizeof(aUsed));
  3567   3578         for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
  3568   3579           for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
  3569   3580             int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;
  3570   3581             if( iId<=FTS5_MAX_SEGMENT ){
  3571         -            aUsed[(iId-1) / 32] |= 1 << ((iId-1) % 32);
         3582  +            aUsed[(iId-1) / 32] |= (u32)1 << ((iId-1) % 32);
  3572   3583             }
  3573   3584           }
  3574   3585         }
  3575   3586   
  3576   3587         for(i=0; aUsed[i]==0xFFFFFFFF; i++);
  3577   3588         mask = aUsed[i];
  3578         -      for(iSegid=0; mask & (1 << iSegid); iSegid++);
         3589  +      for(iSegid=0; mask & ((u32)1 << iSegid); iSegid++);
  3579   3590         iSegid += 1 + i*32;
  3580   3591   
  3581   3592   #ifdef SQLITE_DEBUG
  3582   3593         for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
  3583   3594           for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
  3584   3595             assert_nc( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
  3585   3596           }
................................................................................
  3889   3900     Fts5Index *p, 
  3890   3901     Fts5SegWriter *pWriter,
  3891   3902     int nTerm, const u8 *pTerm 
  3892   3903   ){
  3893   3904     int nPrefix;                    /* Bytes of prefix compression for term */
  3894   3905     Fts5PageWriter *pPage = &pWriter->writer;
  3895   3906     Fts5Buffer *pPgidx = &pWriter->writer.pgidx;
         3907  +  int nMin = MIN(pPage->term.n, nTerm);
  3896   3908   
  3897   3909     assert( p->rc==SQLITE_OK );
  3898   3910     assert( pPage->buf.n>=4 );
  3899   3911     assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );
  3900   3912   
  3901   3913     /* If the current leaf page is full, flush it to disk. */
  3902   3914     if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){
................................................................................
  3930   3942         ** Usually, the previous term is available in pPage->term. The exception
  3931   3943         ** is if this is the first term written in an incremental-merge step.
  3932   3944         ** In this case the previous term is not available, so just write a
  3933   3945         ** copy of (pTerm/nTerm) into the parent node. This is slightly
  3934   3946         ** inefficient, but still correct.  */
  3935   3947         int n = nTerm;
  3936   3948         if( pPage->term.n ){
  3937         -        n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
         3949  +        n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);
  3938   3950         }
  3939   3951         fts5WriteBtreeTerm(p, pWriter, n, pTerm);
  3940   3952         pPage = &pWriter->writer;
  3941   3953       }
  3942   3954     }else{
  3943         -    nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
         3955  +    nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);
  3944   3956       fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
  3945   3957     }
  3946   3958   
  3947   3959     /* Append the number of bytes of new data, then the term data itself
  3948   3960     ** to the page. */
  3949   3961     fts5BufferAppendVarint(&p->rc, &pPage->buf, nTerm - nPrefix);
  3950   3962     fts5BufferAppendBlob(&p->rc, &pPage->buf, nTerm - nPrefix, &pTerm[nPrefix]);
................................................................................
  5854   5866         int iOff;                   /* Offset of first term on leaf */
  5855   5867         int iRowidOff;              /* Offset of first rowid on leaf */
  5856   5868         int nTerm;                  /* Size of term on leaf in bytes */
  5857   5869         int res;                    /* Comparison of term and split-key */
  5858   5870   
  5859   5871         iOff = fts5LeafFirstTermOff(pLeaf);
  5860   5872         iRowidOff = fts5LeafFirstRowidOff(pLeaf);
  5861         -      if( iRowidOff>=iOff ){
         5873  +      if( iRowidOff>=iOff || iOff>=pLeaf->szLeaf ){
  5862   5874           p->rc = FTS5_CORRUPT;
  5863   5875         }else{
  5864   5876           iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);
  5865   5877           res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
  5866   5878           if( res==0 ) res = nTerm - nIdxTerm;
  5867   5879           if( res<0 ) p->rc = FTS5_CORRUPT;
  5868   5880         }
................................................................................
  6269   6281     ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
  6270   6282     ** buffer overreads even if the record is corrupt.  */
  6271   6283     n = sqlite3_value_bytes(apVal[1]);
  6272   6284     aBlob = sqlite3_value_blob(apVal[1]);
  6273   6285     nSpace = n + FTS5_DATA_ZERO_PADDING;
  6274   6286     a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
  6275   6287     if( a==0 ) goto decode_out;
  6276         -  memcpy(a, aBlob, n);
  6277         -
         6288  +  if( n>0 ) memcpy(a, aBlob, n);
  6278   6289   
  6279   6290     fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);
  6280   6291   
  6281   6292     fts5DebugRowid(&rc, &s, iRowid);
  6282   6293     if( bDlidx ){
  6283   6294       Fts5Data dlidx;
  6284   6295       Fts5DlidxLvl lvl;

Changes to ext/fts5/fts5_test_tok.c.

   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.

   258    258     if( n>0 ){
   259    259       aNew = (int*)sqlite3_realloc(p->aiException, (n+p->nException)*sizeof(int));
   260    260       if( aNew ){
   261    261         int nNew = p->nException;
   262    262         const unsigned char *zCsr = (const unsigned char*)z;
   263    263         const unsigned char *zTerm = (const unsigned char*)&z[n];
   264    264         while( zCsr<zTerm ){
   265         -        int iCode;
          265  +        u32 iCode;
   266    266           int bToken;
   267    267           READ_UTF8(zCsr, zTerm, iCode);
   268    268           if( iCode<128 ){
   269    269             p->aTokenChar[iCode] = (unsigned char)bTokenChars;
   270    270           }else{
   271    271             bToken = p->aCategory[sqlite3Fts5UnicodeCategory(iCode)];
   272    272             assert( (bToken==0 || bToken==1) ); 
................................................................................
   425    425   /*
   426    426   ** Return true if, for the purposes of tokenizing with the tokenizer
   427    427   ** passed as the first argument, codepoint iCode is considered a token 
   428    428   ** character (not a separator).
   429    429   */
   430    430   static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
   431    431     return (
   432         -    p->aCategory[sqlite3Fts5UnicodeCategory(iCode)]
          432  +    p->aCategory[sqlite3Fts5UnicodeCategory((u32)iCode)]
   433    433       ^ fts5UnicodeIsException(p, iCode)
   434    434     );
   435    435   }
   436    436   
   437    437   static int fts5UnicodeTokenize(
   438    438     Fts5Tokenizer *pTokenizer,
   439    439     void *pCtx,
................................................................................
   454    454     const char *pEnd = &aFold[nFold-6];
   455    455   
   456    456     UNUSED_PARAM(iUnused);
   457    457   
   458    458     /* Each iteration of this loop gobbles up a contiguous run of separators,
   459    459     ** then the next token.  */
   460    460     while( rc==SQLITE_OK ){
   461         -    int iCode;                    /* non-ASCII codepoint read from input */
          461  +    u32 iCode;                    /* non-ASCII codepoint read from input */
   462    462       char *zOut = aFold;
   463    463       int is;
   464    464       int ie;
   465    465   
   466    466       /* Skip any separator characters. */
   467    467       while( 1 ){
   468    468         if( zCsr>=zTerm ) goto tokenize_done;

Changes to ext/fts5/fts5_unicode2.c.

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

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

    31     31       CREATE VIRTUAL TABLE t1 USING fts5(x);
    32     32       INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
    33     33       WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100)
    34     34         INSERT INTO t1 SELECT rnddoc(10) FROM ii;
    35     35     }
    36     36   }
    37     37   
    38         -if 1 {
    39         -
    40     38   # Create a simple FTS5 table containing 100 documents. Each document 
    41     39   # contains 10 terms, each of which start with the character "x".
    42     40   #
    43     41   do_test 1.0 { create_t1 } {}
    44     42   
    45     43   do_test 1.1 {
    46     44     # Pick out the rowid of the right-most b-tree leaf in the new segment.
................................................................................
   376    374       db eval {DELETE FROM t5_data WHERE rowid = $i}
   377    375       set r [catchsql { INSERT INTO t5(t5) VALUES('integrity-check')} ]
   378    376       if {$r != "1 {database disk image is malformed}"} { error $r }
   379    377       db eval ROLLBACK  
   380    378     }
   381    379   } {}
   382    380   
   383         -}
   384         -
   385    381   #------------------------------------------------------------------------
   386    382   # Corruption within the structure record.
   387    383   #
   388    384   reset_db
   389    385   do_execsql_test 8.1 {
   390    386     CREATE VIRTUAL TABLE t1 USING fts5(x, y);
   391    387     INSERT INTO t1 VALUES('one', 'two');
................................................................................
   764    760   |   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
   765    761   |   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
   766    762   |   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
   767    763   | end c13.db
   768    764   SELECT * FROM t1 WHERE t1 MATCH 'abandon';
   769    765   }]} {}
   770    766   
   771         -do_catchsql_test 14.1 {
          767  +do_catchsql_test 13.1 {
   772    768     SELECT * FROM t1 WHERE t1 MATCH 'abandon'; 
   773    769   } {1 {vtable constructor failed: t1}}
          770  +
          771  +#-------------------------------------------------------------------------
          772  +reset_db
          773  +do_test 14.0 {
          774  +  sqlite3 db {}
          775  +  db deserialize [decode_hexdb {
          776  +| size 28672 pagesize 4096 filename c14b.db
          777  +| page 1 offset 0
          778  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          779  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
          780  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
          781  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          782  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
          783  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
          784  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          785  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          786  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          787  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          788  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          789  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          790  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          791  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          792  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          793  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          794  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          795  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          796  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          797  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          798  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          799  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          800  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          801  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          802  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          803  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          804  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          805  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          806  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          807  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          808  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          809  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          810  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          811  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          812  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          813  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          814  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          815  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          816  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          817  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          818  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          819  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          820  +| page 2 offset 4096
          821  +|      0: 0d 0f ef 00 04 0f 18 00 0f e8 0f 18 0f bd 0f 2c   ...............,
          822  +|   3856: 00 00 00 00 00 00 00 00 12 0a 03 00 2a 00 00 00   ............*...
          823  +|   3872: 00 01 02 02 00 02 01 01 01 02 01 01 81 09 88 80   ................
          824  +|   3888: 80 80 80 01 04 00 82 16 00 00 00 79 06 30 61 62   ...........y.0ab
          825  +|   3904: 61 63 6b 08 02 07 04 04 6e 64 6f 6e 08 02 05 02   ack.....ndon....
          826  +|   3920: 05 63 74 69 76 65 04 02 02 04 02 0b 02 04 6c 70   .ctive........lp
          827  +|   3936: 68 61 08 04 02 0a 02 03 74 6b 6d 06 02 02 03 02   ha......tkm.....
          828  +|   3952: 6f 6d 08 02 09 05 02 69 63 07 02 02 01 06 62 61   om.....ic.....ba
          829  +|   3968: 63 6b 75 70 08 02 04 02 05 6f 6f 6d 65 72 05 02   ckup.....oomer..
          830  +|   3984: 02 01 0c 63 68 61 6e 6e 65 62 6f 6f 6d 65 72 08   ...channeboomer.
          831  +|   4000: 02 08 07 01 6c 08 02 03 01 04 74 65 73 74 08 02   ....l.....test..
          832  +|   4016: 06 04 0a 09 0d 0a 08 07 07 0b 0a 11 06 24 84 80   .............$..
          833  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          834  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
          835  +|   4064: 6f 6e 03 02 02 03 9a 07 05 01 03 00 10 08 11 00   on..............
          836  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
          837  +| page 3 offset 8192
          838  +|      0: 0a 00 00 00 02 0f f3 00 0f fa 0f f3 00 00 00 00   ................
          839  +|   4080: 00 00 00 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
          840  +| page 4 offset 12288
          841  +|      0: 0d 00 00 00 08 0f 6a 00 0f f6 0f ec 0f e0 0f d5   ......j.........
          842  +|     16: 0f ca 0f c1 0f b6 0f 6a 00 00 00 00 00 00 00 00   .......j........
          843  +|   3936: 00 00 00 00 00 00 00 00 00 00 4a 08 04 00 81 19   ..........J.....
          844  +|   3952: 61 6c 70 68 61 20 63 68 61 6e 6e 65 6c 20 62 61   alpha channel ba
          845  +|   3968: 63 6b 75 70 20 61 62 61 6e 64 6f 6e 20 74 65 73   ckup abandon tes
          846  +|   3984: 74 20 61 62 61 63 6b 20 63 68 61 6e 6e 65 62 6f   t aback channebo
          847  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
          848  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
          849  +|   4032: 63 07 06 03 00 15 61 74 6b 6d 09 05 03 00 19 62   c.....atkm.....b
          850  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
          851  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          852  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          853  +| page 5 offset 16384
          854  +|      0: 0d 00 00 00 08 0f d0 00 0f fa 0f f4 0f ee 0f e8   ................
          855  +|     16: 0f e2 0f dc 0f d6 0f d0 00 00 00 00 00 00 00 00   ................
          856  +|   4048: 04 08 03 00 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
          857  +|   4064: 0e 01 04 05 03 00 0e 01 04 04 03 00 0e 01 04 03   ................
          858  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          859  +| page 6 offset 20480
          860  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          861  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          862  +| page 7 offset 24576
          863  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          864  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          865  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          866  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          867  +| end c14b.db
          868  +}]} {}
          869  +
          870  +do_catchsql_test 14.1 {
          871  +  INSERT INTO t1(t1) VALUES('optimize');
          872  +} {1 {database disk image is malformed}}
          873  +
          874  +#---------------------------------------------------------------------------
          875  +#
          876  +reset_db
          877  +do_test 15.0 {
          878  +  sqlite3 db {}
          879  +  db deserialize [decode_hexdb {
          880  +| size 32768 pagesize 4096 filename c16.db
          881  +| page 1 offset 0
          882  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          883  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          884  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
          885  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          886  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          887  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          888  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          889  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          890  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          891  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          892  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          893  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          894  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          895  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          896  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 00 0f f6 0f ec   ..!!...tabl.....
          897  +|   3680: 0f e0 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ..sizet1_docsize
          898  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          899  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          900  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          901  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          902  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          903  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          904  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          905  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          906  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          907  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          908  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          909  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          910  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          911  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
          912  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
          913  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
          914  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
          915  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
          916  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
          917  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
          918  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
          919  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
          920  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
          921  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
          922  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
          923  +| page 2 offset 4096
          924  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
          925  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
          926  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
          927  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
          928  +|   4064: 6f 6e 04 67 90 38 2a 07 05 01 03 00 10 03 03 0f   on.g.8*.........
          929  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
          930  +| page 3 offset 8192
          931  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
          932  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
          933  +| page 4 offset 12288
          934  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
          935  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          936  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          937  +| page 5 offset 16384
          938  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
          939  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
          940  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
          941  +| page 6 offset 20480
          942  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
          943  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
          944  +| page 7 offset 24576
          945  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
          946  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
          947  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
          948  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
          949  +| page 8 offset 28672
          950  +|      0: 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74 31 5f   .......-tablet1_
          951  +|     16: 69 64 78 74 31 5f 69 64 78 03 43 52 45 41 54 45   idxt1_idx.CREATE
          952  +|     32: 20 54 41 42 4c 45 20 27 74 31 5f 66 17 42 03 30    TABLE 't1_f.B.0
          953  +|     48: 01 00 00 10 10 04 02 02 00 00 00 00 00 00 00 00   ................
          954  +|     64: 70 00 00 00 00 00 00 00 00 00 00 00 70 00 00 00   p...........p...
          955  +| end c16.db
          956  +}]} {}
          957  +
          958  +do_catchsql_test 15.1 {
          959  +  INSERT INTO t1(t1) VALUES('integrity-check');
          960  +} {1 {database disk image is malformed}}
          961  +
          962  +#---------------------------------------------------------------------------
          963  +#
          964  +reset_db
          965  +do_test 16.0 {
          966  +  sqlite3 db {}
          967  +  db deserialize [decode_hexdb {
          968  +| size 28672 pagesize 4096 filename c17.db
          969  +| page 1 offset 0
          970  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          971  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
          972  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
          973  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
          974  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
          975  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
          976  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
          977  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
          978  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
          979  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
          980  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
          981  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
          982  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
          983  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
          984  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
          985  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
          986  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
          987  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
          988  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
          989  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
          990  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
          991  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
          992  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
          993  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
          994  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
          995  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
          996  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
          997  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
          998  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
          999  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1000  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1001  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1002  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1003  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1004  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1005  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1006  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1007  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1008  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1009  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1010  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1011  +| page 2 offset 4096
         1012  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1013  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1014  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1015  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1016  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1017  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 41 01   ...$..........A.
         1018  +| page 3 offset 8192
         1019  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         1020  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1021  +| page 4 offset 12288
         1022  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1023  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1024  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1025  +| page 5 offset 16384
         1026  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1027  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1028  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1029  +| page 6 offset 20480
         1030  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1031  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1032  +| page 7 offset 24576
         1033  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1034  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1035  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1036  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1037  +| end c17.db
         1038  +}]} {}
         1039  +
         1040  +do_catchsql_test 16.1 {
         1041  +INSERT INTO t1(t1) VALUES('integrity-check');
         1042  +} {1 {vtable constructor failed: t1}}
         1043  +
         1044  +#--------------------------------------------------------------------------
         1045  +reset_db
         1046  +do_test 17.0 {
         1047  +  sqlite3 db {}
         1048  +  db deserialize [decode_hexdb {
         1049  +| size 28672 pagesize 4096 filename c18.db
         1050  +| page 1 offset 0
         1051  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1052  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         1053  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
         1054  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1055  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
         1056  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1057  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1058  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1059  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1060  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1061  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1062  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1063  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1064  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1065  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1066  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1067  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1068  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1069  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1070  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1071  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1072  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1073  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1074  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1075  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1076  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1077  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1078  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1079  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1080  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1081  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1082  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1083  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1084  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1085  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1086  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1087  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1088  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1089  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1090  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1091  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1092  +| page 2 offset 4096
         1093  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1094  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1095  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1096  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1097  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1098  +|   4080: 0a 03 00 24 00 00 0a aa aa aa aa aa aa aa aa aa   ...$............
         1099  +| page 3 offset 8192
         1100  +|      0: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa   ................
         1101  +|     16: aa aa aa aa aa aa aa aa 00 00 10 10 10 00 10 10   ................
         1102  +|     32: 10 10 a0 00 00 00 10 ff a0 00 ff 52 05 64 95 25   ...........R.d.%
         1103  +|     48: 45 54 14 c2 05 44 14 24 c4 52 07 43 12 05 55 34   ET...D.$.R.C..U4
         1104  +|     64: 94 e4 72 06 67 47 33 52 86 36 f6 e7 46 56 e7 42   ..r.gG3R.6..FV.B
         1105  +|     80: 90 d0 00 00 00 30 fb d0 00 fe 80 fe f0 fb 00 00   .....0..........
         1106  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1107  +| page 4 offset 12288
         1108  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1109  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1110  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1111  +| page 5 offset 16384
         1112  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1113  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1114  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1115  +| page 6 offset 20480
         1116  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1117  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1118  +| page 7 offset 24576
         1119  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1120  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1121  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1122  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1123  +| end c18.db
         1124  +}]} {}
         1125  +
         1126  +do_catchsql_test 17.1 {
         1127  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
         1128  +} {1 {vtable constructor failed: t1}}
         1129  +
         1130  +#--------------------------------------------------------------------------
         1131  +reset_db
         1132  +do_test 18.0 {
         1133  +  sqlite3 db {}
         1134  +  db deserialize [decode_hexdb {
         1135  +| size 28672 pagesize 4096 filename c19b.db
         1136  +| page 1 offset 0
         1137  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1138  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
         1139  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         1140  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1141  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         1142  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         1143  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1144  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1145  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1146  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1147  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1148  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1149  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1150  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1151  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1152  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1153  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1154  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1155  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1156  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1157  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1158  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1159  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1160  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1161  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1162  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1163  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1164  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1165  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1166  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1167  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1168  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1169  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1170  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1171  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1172  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1173  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1174  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1175  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1176  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1177  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1178  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1179  +| page 2 offset 4096
         1180  +|      0: 0d 09 a6 00 06 09 22 00 0f e8 09 22 0f bd 0f 2c   ...............,
         1181  +|     16: 09 bd 09 3c 00 00 00 00 00 00 00 00 00 00 00 00   ...<............
         1182  +|   2336: 00 00 18 0a 03 00 36 00 00 00 00 01 04 04 00 04   ......6.........
         1183  +|   2352: 01 01 01 02 01 01 03 01 01 04 01 01 63 90 80 80   ............c...
         1184  +|   2368: 80 80 01 04 00 81 4a 00 00 00 56 06 30 61 62 61   ......J...V.0aba
         1185  +|   2384: 63 6b 08 01 04 04 6e 64 6f 6e 03 01 05 01 02 05   ck....ndon......
         1186  +|   2400: 63 74 69 76 65 08 01 02 04 6c 70 68 61 08 01 02   ctive....lpha...
         1187  +|   2416: 03 74 6f 6d 08 01 01 06 62 61 63 6b 75 70 08 01   .tom....backup..
         1188  +|   2432: 01 0c 63 68 61 6e 6e 65 62 6f 6f 6d 65 72 08 01   ..channeboomer..
         1189  +|   2448: 07 01 6c 08 01 01 04 74 65 73 74 08 01 04 09 0a   ..l....test.....
         1190  +|   2464: 09 08 07 0a 10 05 0f 18 00 17 30 00 00 00 00 01   ..........0.....
         1191  +|   2480: 03 03 00 03 01 01 01 02 01 01 03 01 01 8a 53 8c   ..............S.
         1192  +|   2496: 80 80 80 80 01 04 00 95 2a 00 00 05 35 0d 30 30   ........*...5.00
         1193  +|   2512: 31 30 66 66 61 30 30 30 66 66 61 05 02 1c 02 49   10ffa000ffa....I
         1194  +|   2528: 33 34 33 35 32 34 35 34 31 35 34 34 35 32 30 35   3435245415445205
         1195  +|   2544: 34 34 31 34 32 34 63 34 35 32 30 32 37 37 34 33   441424c452027743
         1196  +|   2560: 31 35 66 36 39 36 34 37 38 32 37 32 38 37 33 36   15f6964782728736
         1197  +|   2576: 35 36 37 36 39 36 34 32 63 32 30 37 34 36 35 37   56769642c2074657
         1198  +|   2592: 32 36 64 32 63 32 30 37 30 05 02 12 02 3b 36 31   26d2c2070....;61
         1199  +|   2608: 37 32 31 32 31 30 31 37 37 37 34 36 31 36 32 35   7212101777461625
         1200  +|   2624: 63 36 35 37 34 33 31 35 66 36 33 36 66 36 65 37   c6574315f636f6e7
         1201  +|   2640: 34 36 35 36 65 37 34 37 34 33 31 35 66 36 33 36   4656e7474315f636
         1202  +|   2656: 66 36 65 37 34 36 35 36 65 05 04 07 07 01 04 31   f6e74656e......1
         1203  +|   2672: 66 62 64 05 02 19 01 44 32 34 38 34 38 30 38 30   fbd....D24848080
         1204  +|   2688: 38 30 38 30 30 31 30 33 30 30 34 65 30 30 30 30   80800103004e0000
         1205  +|   2704: 30 30 31 65 30 36 33 30 36 31 36 32 36 31 36 33   001e063061626163
         1206  +|   2720: 36 62 30 31 30 32 30 32 30 34 30 32 36 36 37 34   6b01020204026674
         1207  +|   2736: 30 32 30 32 30 32 30 34 30 34 36 65 05 02 1a 02   02020204046e....
         1208  +|   2752: 03 66 65 72 05 02 1d 01 28 33 65 37 34 36 35 36   .fer....(3e74656
         1209  +|   2768: 65 37 34 32 39 30 64 30 30 30 30 30 30 30 33 30   e74290d000000030
         1210  +|   2784: 66 62 64 30 30 30 66 65 38 30 66 65 66 30 66 62   fbd000fe80fef0fb
         1211  +|   2800: 64 05 02 18 01 4a 34 31 35 32 35 39 32 30 34 62   d....J415259204b
         1212  +|   2816: 34 35 35 39 32 63 32 30 36 32 36 63 36 66 36 33   45592c20626c6f63
         1213  +|   2832: 36 62 32 30 34 32 34 63 34 66 34 32 32 39 33 61   6b20424c4f42293a
         1214  +|   2848: 30 31 30 36 31 37 31 31 31 31 30 38 36 33 37 34   0106171111086374
         1215  +|   2864: 36 31 36 32 36 63 36 35 37 34 33 31 37 34 33 31   61626c6574317431
         1216  +|   2880: 05 02 16 02 49 33 35 32 34 35 34 31 35 34 34 35   ....I35245415445
         1217  +|   2896: 32 30 35 36 34 39 35 32 35 34 35 35 34 31 34 63   205649525455414c
         1218  +|   2912: 32 30 35 34 34 31 34 32 34 63 34 35 32 30 37 34   205441424c452074
         1219  +|   2928: 33 31 6f 30 35 35 35 33 34 39 34 65 34 37 32 30   31o05553494e4720
         1220  +|   2944: 36 36 37 34 37 33 33 35 32 38 36 33 36 66 05 02   6674733528636f..
         1221  +|   2960: 17 02 49 35 32 30 35 34 34 31 34 32 34 63 34 35   ..I5205441424c45
         1222  +|   2976: 32 30 32 37 37 34 33 31 35 66 36 33 36 66 36 65   202774315f636f6e
         1223  +|   2992: 37 34 36 35 36 65 37 34 32 37 32 38 36 39 36 34   74656e7427286964
         1224  +|   3008: 32 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32   20494e5445474552
         1225  +|   3024: 32 30 35 30 35 32 34 39 34 64 34 31 05 02 0e 44   205052494d41...D
         1226  +|   3040: 29 62 30 35 30 37 31 37 32 31 32 31 30 31 38 31   )b05071721210181
         1227  +|   3056: 30 31 37 34 36 31 36 32 36 63 36 35 37 34 33 31   017461626c657431
         1228  +|   3072: 35 66 36 34 36 66 36 33 37 33 05 02 09 01 4a 35   5f646f6373....J5
         1229  +|   3088: 32 34 35 34 31 35 34 34 35 32 30 35 34 34 31 34   2454154452054414
         1230  +|   3104: 32 34 63 34 35 32 30 32 37 37 34 33 31 35 66 36   24c45202774315f6
         1231  +|   3120: 34 36 31 37 34 36 31 32 37 32 38 36 39 36 34 32   4617461272869642
         1232  +|   3136: 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32   0494e54454745522
         1233  +|   3152: 30 35 30 35 32 34 39 34 64 05 02 15 03 3a 35 39   05052494d....:59
         1234  +|   3168: 32 30 34 62 34 35 35 39 32 63 32 30 36 33 33 30   204b45592c206330
         1235  +|   3184: 32 39 36 39 30 33 30 37 31 37 31 39 31 39 30 31   2969030717191901
         1236  +|   3200: 38 31 32 64 37 34 36 31 36 32 36 63 36 35 37 34   812d7461626c6574
         1237  +|   3216: 33 31 35 66 36 39 79 79 05 02 0f 02 49 34 32 30   315f69yy....I420
         1238  +|   3232: 35 32 34 66 35 37 34 39 34 34 35 35 30 32 30 37   524f574944550207
         1239  +|   3248: 31 37 31 62 31 62 30 31 38 31 30 31 37 34 36 31   171b1b0181017461
         1240  +|   3264: 36 32 36 63 36 37 37 34 33 31 35 66 36 34 36 31   626c6774315f6461
         1241  +|   3280: 37 34 36 31 37 34 33 31 35 66 36 34 36 31 37 34   746174315f646174
         1242  +|   3296: 36 31 30 32 34 33 05 02 14 02 07 66 36 39 36 34   610243.....f6964
         1243  +|   3312: 37 38 05 02 11 01 4a 36 34 36 66 36 65 30 33 30   78....J646f6e030
         1244  +|   3328: 32 30 32 30 34 30 61 30 37 30 35 30 31 30 33 30   202040a070501030
         1245  +|   3344: 30 31 30 30 33 30 33 30 66 30 61 30 33 30 30 32   01003030f0a03002
         1246  +|   3360: 34 30 30 30 30 30 30 30 30 30 31 30 31 30 31 30   4000000000101010
         1247  +|   3376: 30 30 31 30 31 30 31 30 31 30 61 30 30 30 30 30   0010101010a00000
         1248  +|   3392: 30 05 02 1b 02 49 35 32 37 32 38 36 39 36 34 32   0....I5272869642
         1249  +|   3408: 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32   0494e54454745522
         1250  +|   3424: 30 35 30 35 32 34 39 34 64 34 31 35 32 35 39 32   05052494d4152592
         1251  +|   3440: 30 34 62 34 35 35 39 32 63 32 30 37 33 37 61 32   04b45592c20737a2
         1252  +|   3456: 30 34 32 34 63 34 66 34 32 32 39 35 35 30 34 05   0424c4f42295504.
         1253  +|   3472: 04 06 07 02 49 37 36 65 36 66 32 63 32 30 35 30   ....I76e6f2c2050
         1254  +|   3488: 35 32 34 39 34 64 34 31 35 32 35 39 32 30 34 62   52494d415259204b
         1255  +|   3504: 34 35 35 39 32 38 37 33 36 35 36 37 36 39 36 34   4559287365676964
         1256  +|   3520: 32 63 32 30 37 34 36 35 37 32 36 64 32 39 32 39   2c207465726d2929
         1257  +|   3536: 32 30 35 37 34 39 35 34 34 38 34 66 35 35 05 02   20574954484f55..
         1258  +|   3552: 13 02 49 39 37 61 36 35 37 34 33 31 35 66 36 34   ..I97a6574315f64
         1259  +|   3568: 36 66 36 33 37 33 36 39 37 61 36 35 30 35 34 33   6f6373697a650543
         1260  +|   3584: 35 32 34 35 34 31 35 34 34 35 32 30 35 34 34 31   5245415445205441
         1261  +|   3600: 34 32 34 63 34 35 32 30 32 37 37 34 33 31 35 66   424c45202774315f
         1262  +|   3616: 36 34 36 66 36 33 37 33 36 39 37 61 05 04 05 07   646f6373697a....
         1263  +|   3632: 01 0e 37 34 30 34 34 33 35 32 34 35 34 31 35 34   ..74044352454154
         1264  +|   3648: 05 04 08 07 02 49 36 32 39 32 30 35 37 34 39 35   .....I6292057495
         1265  +|   3664: 34 34 38 34 66 35 35 35 34 32 30 35 32 34 66 35   4484f555420524f5
         1266  +|   3680: 37 34 39 34 34 35 62 30 35 30 37 31 37 32 31 32   749445b050717212
         1267  +|   3696: 31 30 31 38 31 30 31 37 34 36 31 36 32 36 63 36   10181017461626c6
         1268  +|   3712: 35 37 34 33 31 35 66 36 34 36 66 36 33 37 33 05   574315f646f6373.
         1269  +|   3728: 02 04 01 06 62 61 63 6b 75 70 05 02 1e 02 05 65   ....backup.....e
         1270  +|   3744: 61 6d 65 72 05 02 02 02 05 6f 6f 6d 65 72 05 01   amer.....oomer..
         1271  +|   3760: 02 40 75 6d 6d 32 34 63 34 35 32 30 32 37 37 34   .@umm24c45202774
         1272  +|   3776: 33 31 35 66 36 33 36 66 36 65 36 36 36 39 36 37   315f636f6e666967
         1273  +|   3792: 32 37 32 38 36 62 32 30 35 30 35 32 34 39 34 64   27286b205052494d
         1274  +|   3808: 34 31 35 32 35 39 32 30 34 62 34 35 35 39 32 63   415259204b45592c
         1275  +|   3824: 32 30 05 02 03 01 04 79 65 6b 72 05 02 10 04 11   20.....yekr.....
         1276  +|   3840: 4e 41 09 49 08 2d 4f 4e 4e 2e 4f 3f 4e 0c 4f 4f   NA.I.-ONN.O?N.OO
         1277  +|   3856: 4e 4f 14 4e 0b 0a 09 45 0f ef 00 14 2a 00 00 00   NO.N...E....*...
         1278  +|   3872: 00 01 02 02 00 02 01 01 01 02 01 01 81 09 88 80   ................
         1279  +|   3888: 80 80 80 01 04 00 82 16 00 00 00 79 06 30 61 62   ...........y.0ab
         1280  +|   3904: 61 63 6b 08 02 07 04 04 6e 64 6f 6e 08 02 05 02   ack.....ndon....
         1281  +|   3920: 05 63 74 69 76 65 04 02 02 04 02 0b 02 04 6c 70   .ctive........lp
         1282  +|   3936: 68 61 08 04 02 0a 02 03 74 6b 6d 06 02 02 03 02   ha......tkm.....
         1283  +|   3952: 6f 6d 08 02 09 05 02 69 63 07 02 02 01 06 62 61   om.....ic.....ba
         1284  +|   3968: 63 6b 75 70 08 02 04 02 05 6f 6f 6d 65 72 05 02   ckup.....oomer..
         1285  +|   3984: 02 01 0c 63 68 61 6e 6e 65 62 6f 6f 6d 65 72 08   ...channeboomer.
         1286  +|   4000: 02 08 07 01 6c 08 02 03 01 04 74 65 73 74 08 02   ....l.....test..
         1287  +|   4016: 06 04 0a 09 0d 0a 08 07 07 0b 0a 11 06 24 84 80   .............$..
         1288  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1289  +|   4048: 63 6b 01 08 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1290  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 06 22 00   on..............
         1291  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         1292  +| page 3 offset 8192
         1293  +|      0: 0a 00 00 00 04 0f e5 00 0f fa 0f f3 0f ec 0f e5   ................
         1294  +|   4064: 00 00 00 00 00 06 04 01 0c 01 04 02 06 04 01 0c   ................
         1295  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         1296  +| page 4 offset 12288
         1297  +|      0: 0d 0f 68 00 06 08 98 00 0f f6 0f ec 0f d5 08 98   ..h.............
         1298  +|     16: 0f c1 0f b6 0f 68 0f 68 00 00 00 00 00 00 00 00   .....h.h........
         1299  +|   2192: 00 00 00 00 00 00 00 00 8d 4d 05 04 00 9b 1f 62   .........M.....b
         1300  +|   2208: 65 61 6d 65 72 20 62 75 6d 6d 32 34 63 34 35 32   eamer bumm24c452
         1301  +|   2224: 30 32 37 37 34 33 31 35 66 36 33 36 66 36 65 36   02774315f636f6e6
         1302  +|   2240: 36 36 39 36 37 32 37 32 38 36 62 32 30 35 30 35   6696727286b20505
         1303  +|   2256: 32 34 39 34 64 34 31 35 32 35 39 32 30 34 62 34   2494d415259204b4
         1304  +|   2272: 35 35 39 32 63 32 30 0a 37 36 32 39 32 30 35 37   5592c20.76292057
         1305  +|   2288: 34 39 35 34 34 38 34 66 35 35 35 34 32 30 35 32   4954484f55542052
         1306  +|   2304: 34 66 35 37 34 39 34 34 35 62 30 35 30 37 31 37   4f5749445b050717
         1307  +|   2320: 32 31 32 31 30 31 38 31 30 31 37 34 36 31 36 32   2121018101746162
         1308  +|   2336: 36 63 36 35 37 34 33 31 35 66 36 34 36 66 36 33   6c6574315f646f63
         1309  +|   2352: 37 33 0a 36 39 37 61 36 35 37 34 33 31 35 66 36   73.697a6574315f6
         1310  +|   2368: 34 36 66 36 33 37 33 36 39 37 61 36 35 30 35 34   46f6373697a65054
         1311  +|   2384: 33 35 32 34 35 34 31 35 34 34 35 32 30 35 34 34   3524541544520544
         1312  +|   2400: 31 34 32 34 63 34 35 32 30 32 37 37 34 33 31 35   1424c45202774315
         1313  +|   2416: 66 36 34 36 66 36 33 37 33 36 39 37 61 0a 36 35   f646f6373697a.65
         1314  +|   2432: 32 37 32 38 36 39 36 34 32 30 34 39 34 65 35 34   2728696420494e54
         1315  +|   2448: 34 35 34 37 34 35 35 32 32 30 35 30 35 32 34 39   4547455220505249
         1316  +|   2464: 34 64 34 31 35 32 35 39 32 30 34 62 34 35 35 39   4d415259204b4559
         1317  +|   2480: 32 63 32 30 37 33 37 61 32 30 34 32 34 63 34 66   2c20737a20424c4f
         1318  +|   2496: 34 32 32 39 35 35 30 34 0a 30 36 31 37 32 31 32   42295504.0617212
         1319  +|   2512: 31 30 31 37 37 37 34 36 31 36 32 35 63 36 35 37   101777461625c657
         1320  +|   2528: 34 33 31 35 66 36 33 36 66 36 65 37 34 36 35 36   4315f636f6e74656
         1321  +|   2544: 65 37 34 37 34 33 31 35 66 36 33 36 66 36 65 37   e7474315f636f6e7
         1322  +|   2560: 34 36 35 36 65 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   4656e...........
         1323  +|   2576: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1324  +|   2592: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1325  +|   2608: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1326  +|   2624: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1327  +|   2640: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1328  +|   2656: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 37 34 30   .............740
         1329  +|   2672: 34 34 33 35 32 34 35 34 31 35 34 0a 34 35 32 30   44352454154.4520
         1330  +|   2688: 35 34 34 31 34 32 34 63 34 35 32 30 32 37 37 34   5441424c45202774
         1331  +|   2704: 33 31 35 66 36 33 36 66 36 65 37 34 36 35 36 65   315f636f6e74656e
         1332  +|   2720: 37 34 32 37 32 38 36 39 36 34 32 30 34 39 34 65   742728696420494e
         1333  +|   2736: 35 34 34 35 34 37 34 35 35 32 32 30 35 30 35 62   544547455220505b
         1334  +|   2752: 30 35 30 37 31 37 32 31 32 31 30 31 38 31 30 31   0507172121018101
         1335  +|   2768: 37 34 36 31 36 32 36 63 36 35 37 34 33 31 35 66   7461626c6574315f
         1336  +|   2784: 36 34 36 66 36 33 37 33 0a 36 39 37 61 36 35 37   646f6373.697a657
         1337  +|   2800: 34 33 31 35 66 36 34 36 66 36 33 37 33 36 39 37   4315f646f6373697
         1338  +|   2816: 61 36 35 30 35 34 33 35 32 34 35 34 31 35 34 34   a650543524541544
         1339  +|   2832: 35 32 30 35 34 34 31 34 32 34 63 34 35 32 30 32   5205441424c45202
         1340  +|   2848: 37 37 34 33 31 35 66 36 34 36 66 36 33 37 33 36   774315f646f63736
         1341  +|   2864: 39 37 61 0a 36 35 32 37 32 38 36 39 36 34 32 30   97a.652728696420
         1342  +|   2880: 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32 30   494e544547455220
         1343  +|   2896: 35 30 35 32 34 39 34 64 34 31 35 32 35 39 32 30   5052494d41525920
         1344  +|   2912: 34 62 34 35 35 39 32 63 32 30 37 33 37 61 32 30   4b45592c20737a20
         1345  +|   2928: 34 32 34 63 34 66 34 32 32 39 35 35 30 34 0a 30   424c4f42295504.0
         1346  +|   2944: 36 31 37 32 31 32 31 30 31 37 37 37 34 36 31 36   6172121017774616
         1347  +|   2960: 32 35 63 36 35 37 34 33 31 35 66 36 33 36 66 36   25c6574315f636f6
         1348  +|   2976: 65 37 34 36 35 36 65 37 34 37 34 33 31 35 66 36   e74656e7474315f6
         1349  +|   2992: 33 36 66 36 65 37 34 36 35 36 65 0b 0b 0b 0b 0b   36f6e74656e.....
         1350  +|   3008: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1351  +|   3024: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1352  +|   3040: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1353  +|   3056: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1354  +|   3072: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1355  +|   3088: 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b   ................
         1356  +|   3104: 0b 0b 0b 37 34 30 34 34 33 35 32 34 35 34 31 35   ...7404435245415
         1357  +|   3120: 34 0a 34 35 32 30 35 34 34 31 34 32 34 63 34 35   4.45205441424c45
         1358  +|   3136: 32 30 32 37 37 34 33 31 35 66 36 33 36 66 36 65   202774315f636f6e
         1359  +|   3152: 37 34 36 35 36 65 37 34 32 37 32 38 36 39 36 34   74656e7427286964
         1360  +|   3168: 32 30 34 39 34 65 35 34 34 35 34 37 34 35 35 32   20494e5445474552
         1361  +|   3184: 32 30 35 30 35 32 34 39 34 64 34 31 0a 35 32 35   205052494d41.525
         1362  +|   3200: 39 32 30 34 62 34 35 35 39 32 63 32 30 36 33 33   9204b45592c20633
         1363  +|   3216: 30 32 39 36 39 30 33 30 37 31 37 31 39 31 39 30   0296903071719190
         1364  +|   3232: 31 38 31 32 64 37 34 36 31 36 32 36 63 36 35 37   1812d7461626c657
         1365  +|   3248: 34 33 31 35 66 36 39 c3 bf c3 bf 7e c3 bf c3 89   4315f69....~....
         1366  +|   3264: 4b 52 c2 81 35 66 36 39 36 34 37 38 0a 30 33 34   KR..5f696478.034
         1367  +|   3280: 33 35 32 34 35 34 31 35 34 34 35 32 30 35 34 34   3524541544520544
         1368  +|   3296: 31 34 32 34 63 34 35 32 30 32 37 37 34 33 31 35   1424c45202774315
         1369  +|   3312: 66 36 39 36 34 37 38 32 37 32 38 37 33 36 35 36   f696478272873656
         1370  +|   3328: 37 36 39 36 34 32 63 32 30 37 34 36 35 37 32 36   769642c207465726
         1371  +|   3344: 64 32 63 32 30 37 30 0a 36 37 36 65 36 66 32 63   d2c2070.676e6f2c
         1372  +|   3360: 32 30 35 30 35 32 34 39 34 64 34 31 35 32 35 39   205052494d415259
         1373  +|   3376: 32 30 34 62 34 35 35 39 32 38 37 33 36 35 36 37   204b455928736567
         1374  +|   3392: 36 39 36 34 32 63 32 30 37 34 36 35 37 32 36 64   69642c207465726d
         1375  +|   3408: 32 39 32 39 32 30 35 37 34 39 35 34 34 38 34 66   292920574954484f
         1376  +|   3424: 35 35 0a 35 34 32 30 35 32 34 66 35 37 34 39 34   55.5420524f57494
         1377  +|   3440: 34 35 35 30 32 30 37 31 37 31 62 31 62 30 31 38   4550207171b1b018
         1378  +|   3456: 31 30 31 37 34 36 31 36 32 36 63 36 37 37 34 33   1017461626c67743
         1379  +|   3472: 31 35 66 36 34 36 31 37 34 36 31 37 34 33 31 35   15f6461746174315
         1380  +|   3488: 66 36 34 36 31 37 34 36 31 30 32 34 33 0a 35 32   f646174610243.52
         1381  +|   3504: 34 35 34 31 35 34 34 35 32 30 35 34 34 31 34 32   4541544520544142
         1382  +|   3520: 34 63 34 35 32 30 32 37 37 34 33 31 35 66 36 34   4c45202774315f64
         1383  +|   3536: 36 31 37 34 36 31 32 37 32 38 36 39 36 34 32 30   6174612728696420
         1384  +|   3552: 34 39 34 65 35 34 34 35 34 37 34 35 35 32 32 30   494e544547455220
         1385  +|   3568: 35 30 35 32 34 39 34 64 0a 34 31 35 32 35 39 32   5052494d.4152592
         1386  +|   3584: 30 34 62 34 35 35 39 32 63 32 30 36 32 36 63 36   04b45592c20626c6
         1387  +|   3600: 66 36 33 36 62 32 30 34 32 34 63 34 66 34 32 32   f636b20424c4f422
         1388  +|   3616: 39 33 61 30 31 30 36 31 37 31 31 31 31 30 38 36   93a0106171111086
         1389  +|   3632: 33 37 34 36 31 36 32 36 63 36 35 37 34 33 31 37   37461626c6574317
         1390  +|   3648: 34 33 31 0a 34 33 35 32 34 35 34 31 35 34 34 35   431.435245415445
         1391  +|   3664: 32 30 35 36 34 39 35 32 35 34 35 35 34 31 34 63   205649525455414c
         1392  +|   3680: 32 30 35 34 34 31 34 32 34 63 34 35 32 30 37 34   205441424c452074
         1393  +|   3696: 33 31 c3 94 30 35 35 35 33 34 39 34 65 34 37 32   31..05553494e472
         1394  +|   3712: 30 36 36 37 34 37 33 33 35 32 38 36 33 36 66 0a   06674733528636f.
         1395  +|   3728: 33 65 37 34 36 35 36 65 37 34 32 39 30 64 30 30   3e74656e74290d00
         1396  +|   3744: 30 30 30 30 30 33 30 66 62 64 30 30 30 66 65 38   0000030fbd000fe8
         1397  +|   3760: 30 66 65 66 30 66 62 64 0a 5b 31 66 62 64 5d 32   0fef0fbd.[1fbd]2
         1398  +|   3776: 34 38 34 38 30 38 30 38 30 38 30 30 31 30 33 30   4848080808001030
         1399  +|   3792: 30 34 65 30 30 30 30 30 30 31 65 30 36 33 30 36   04e0000001e06306
         1400  +|   3808: 31 36 32 36 31 36 33 36 62 30 31 30 32 30 32 30   16261636b0102020
         1401  +|   3824: 34 30 32 36 36 37 34 30 32 30 32 30 32 30 34 30   4026674020202040
         1402  +|   3840: 34 36 65 0a 36 34 36 66 36 65 30 33 30 32 30 32   46e.646f6e030202
         1403  +|   3856: 30 34 30 61 30 37 30 35 30 31 30 33 30 30 31 30   040a070501030010
         1404  +|   3872: 30 33 30 33 30 66 30 61 30 33 30 30 32 34 30 30   03030f0a03002400
         1405  +|   3888: 30 30 30 30 30 30 30 31 30 31 30 31 30 30 30 31   0000000101010001
         1406  +|   3904: 30 31 30 31 30 31 30 61 30 30 30 30 30 30 0a 30   0101010a000000.0
         1407  +|   3920: 31 30 66 66 61 30 30 30 66 66 61 0a 5b 32 66 65   10ffa000ffa.[2fe
         1408  +|   3936: 72 20 62 61 63 6b 75 70 0f ca 00 4e 81 1d 61 6c   r backup...N..al
         1409  +|   3952: 70 68 61 20 63 68 61 6e 6e 65 6c 20 c2 af 62 61   pha channel ..ba
         1410  +|   3968: 63 6b 75 70 20 61 62 61 6e 64 6f 6e 20 74 65 73   ckup abandon tes
         1411  +|   3984: 74 20 61 62 61 63 6b 20 63 68 61 6e 6e 65 62 6f   t aback channebo
         1412  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         1413  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         1414  +|   4032: 63 07 06 03 00 15 61 74 6b 6d 0f e0 00 0b 19 62   c.....atkm.....b
         1415  +|   4048: 6f 6f 6d 65 72 09 04 03 00 19 61 63 74 69 76 65   oomer.....active
         1416  +|   4064: 00 00 00 0c 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1417  +|   4080: 17 61 66 21 66 74 08 01 03 00 17 61 62 61 63 6b   .af!ft.....aback
         1418  +| page 5 offset 16384
         1419  +|      0: 0d 0f ee 00 06 0f d6 00 0f fa 0f f4 0f e8 0f e2   ................
         1420  +|     16: 0f dc 0f d6 0f d0 0f d0 00 00 00 00 00 00 00 00   ................
         1421  +|   4048: 0f ee 00 06 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         1422  +|   4064: 0e 01 04 05 03 00 0e 1d 04 04 03 00 0e 01 00 00   ................
         1423  +|   4080: 00 06 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1424  +| page 6 offset 20480
         1425  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1426  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1427  +| page 7 offset 24576
         1428  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1429  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1430  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1431  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1432  +| end c19b.db
         1433  +}]} {}
         1434  +
         1435  +do_catchsql_test 18.1 {
         1436  +  INSERT INTO t1(t1) VALUES('optimize');
         1437  +} {1 {database disk image is malformed}}
         1438  +
         1439  +#--------------------------------------------------------------------------
         1440  +reset_db
         1441  +do_test 19.0 {
         1442  +  sqlite3 db {}
         1443  +  db deserialize [decode_hexdb {
         1444  +| size 28672 pagesize 4096 filename c20b.db
         1445  +| page 1 offset 0
         1446  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1447  +|     16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 07   .....@  ........
         1448  +|     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         1449  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1450  +|     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
         1451  +|     96: 00 2e 30 38 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ..08...........m
         1452  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1453  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1454  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1455  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1456  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1457  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1458  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1459  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1460  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1461  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1462  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1463  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1464  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1465  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1466  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1467  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1468  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1469  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1470  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1471  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1472  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1473  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1474  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1475  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1476  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1477  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1478  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1479  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1480  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1481  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1482  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1483  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1484  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1485  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1486  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1487  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1488  +| page 2 offset 4096
         1489  +|      0: 0d 0f 20 00 05 0e a0 00 0f e8 0e a0 0f bd 0f 34   .. ............4
         1490  +|     16: 0e b7 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         1491  +|   3744: 15 0a 03 00 30 00 00 00 00 01 03 03 00 03 01 01   ....0...........
         1492  +|   3760: 01 02 01 01 03 01 01 62 8c 80 80 80 80 01 04 00   .......b........
         1493  +|   3776: 81 48 00 00 00 55 06 30 61 62 61 63 6b 08 01 04   .H...U.0aback...
         1494  +|   3792: 04 6e 64 6f 6e 03 01 05 01 02 05 63 74 69 76 65   .ndon......ctive
         1495  +|   3808: 08 01 02 04 6c 70 68 61 08 01 02 03 74 6f 6d 08   ....lpha....tom.
         1496  +|   3824: 01 01 06 62 61 63 6b 75 70 08 01 02 05 6f 6f 6d   ...backup....oom
         1497  +|   3840: 65 72 08 01 01 07 63 68 61 6e 6e 65 6c 08 01 01   er....channel...
         1498  +|   3856: 04 74 65 73 74 08 01 04 09 0a 09 08 07 0a 09 0b   .test...........
         1499  +|   3872: 0f ef 00 14 2a 00 00 00 00 01 02 02 00 02 01 01   ....*...........
         1500  +|   3888: 01 02 01 01 81 01 88 80 80 80 80 01 04 00 82 06   ................
         1501  +|   3904: 00 00 00 72 06 30 61 62 61 63 6b 08 02 07 04 04   ...r.0aback.....
         1502  +|   3920: 6e 64 6f 6e 08 02 05 02 05 63 74 69 76 65 04 02   ndon.....ctive..
         1503  +|   3936: 02 04 02 0b 02 04 6c 70 68 61 08 04 02 0a 02 03   ......lpha......
         1504  +|   3952: 74 6f 6d 06 02 02 02 02 09 05 02 69 63 07 02 02   tom........ic...
         1505  +|   3968: 01 06 62 61 63 6b 75 70 08 02 04 02 05 6f 6f 66   ..backup.....oof
         1506  +|   3984: 65 72 05 02 02 04 03 6d 65 72 08 02 08 01 07 63   er.....mer.....c
         1507  +|   4000: 68 61 6e 6e 65 6c 08 02 03 01 04 74 65 73 74 08   hannel.....test.
         1508  +|   4016: 02 06 04 0a 09 0d 0a 0b 07 0b 0a 08 0c 24 84 80   .............$..
         1509  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1510  +|   4048: 63 6b 01 02 66 04 00 22 74 00 02 22 04 04 6e 64   ck..f...t.....nd
         1511  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 06 06 00   on..............
         1512  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         1513  +| page 3 offset 8192
         1514  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         1515  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         1516  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         1517  +| page 4 offset 12288
         1518  +|      0: 0d 0f e0 00 06 0f b6 00 0f f6 0f ec 0f d5 0f ca   ................
         1519  +|     16: 0f c1 0f b6 0f 70 0f 70 00 00 00 00 00 00 00 00   .....p.p........
         1520  +|   3952: 0f e0 00 46 81 0d 61 6c 70 68 61 20 63 68 61 6e   ...F..alpha chan
         1521  +|   3968: 6e 65 6c 20 62 61 63 6b 75 70 20 61 62 61 6e 64   nel backup aband
         1522  +|   3984: 6f 6e 20 74 65 73 74 20 61 62 61 63 6b 20 62 6f   on test aback bo
         1523  +|   4000: 6f 6d 65 72 20 61 74 6f 6d 20 61 6c 70 68 61 20   omer atom alpha 
         1524  +|   4016: 61 63 74 69 76 65 09 07 03 00 19 61 74 6f 6d 69   active.....atomi
         1525  +|   4032: 63 07 06 03 00 15 61 74 6f 6d 09 05 03 00 19 62   c.....atom.....b
         1526  +|   4048: 6f 6f 66 65 72 09 04 03 00 19 61 63 74 69 76 65   oofer.....active
         1527  +|   4064: 00 00 00 0c 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1528  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1529  +| page 5 offset 16384
         1530  +|      0: 0d 0f ee 00 06 0f d6 00 0f fa 0f f4 0f e8 0f e2   ................
         1531  +|     16: 0f dc 0f d6 0f d0 0f d0 00 00 00 00 00 00 00 00   ................
         1532  +|   4048: 0f ee 00 06 0e 0a 04 07 03 00 0e 01 04 06 03 00   ................
         1533  +|   4064: 0e 01 04 05 03 00 0e 01 04 04 03 00 0e 01 00 00   ................
         1534  +|   4080: 00 06 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1535  +| page 6 offset 20480
         1536  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1537  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1538  +| page 7 offset 24576
         1539  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1540  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1541  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1542  +|   4080: 86 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   .eck....optimize
         1543  +| end c20b.db
         1544  +}]} {}
         1545  +
         1546  +do_catchsql_test 19.1 {
         1547  +  INSERT INTO t1(t1) VALUES('optimize');
         1548  +} {1 {database disk image is malformed}}
         1549  +
         1550  +#--------------------------------------------------------------------------
         1551  +reset_db
         1552  +do_test 20.0 {
         1553  +  sqlite3 db {}
         1554  +  db deserialize [decode_hexdb {
         1555  +| size 28672 pagesize 4096 filename crash-cf347c523f793c.db
         1556  +| page 1 offset 0
         1557  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1558  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         1559  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
         1560  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1561  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
         1562  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1563  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1564  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1565  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1566  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1567  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1568  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1569  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1570  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1571  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1572  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1573  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1574  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1575  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1576  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1577  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1578  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1579  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1580  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1581  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1582  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1583  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1584  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1585  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1586  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1587  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1588  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1589  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1590  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1591  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1592  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1593  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1594  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1595  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1596  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1597  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1598  +| page 2 offset 4096
         1599  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1600  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1601  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1602  +|   4048: 63 6b 01 02 02 04 02 66 74 02 02 02 04 04 6e 64   ck.....ft.....nd
         1603  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1604  +|   4080: 0a 03 00 24 00 00 00 0e ee ee ee ee ee ee ee ee   ...$............
         1605  +| page 3 offset 8192
         1606  +|      0: ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee   ................
         1607  +|     16: ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee   ................
         1608  +|     32: ee ee ee ee ee ee ee ee ee ee ee ee 00 10 10 10   ................
         1609  +|     48: 00 10 10 10 10 a0 00 00 00 10 ff a0 00 ff 00 00   ................
         1610  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1611  +| page 4 offset 12288
         1612  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1613  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1614  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1615  +| page 5 offset 16384
         1616  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1617  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1618  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1619  +| page 6 offset 20480
         1620  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1621  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1622  +| page 7 offset 24576
         1623  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1624  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1625  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1626  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1627  +| end crash-cf347c523f793c.db
         1628  +}]} {}
         1629  +
         1630  +do_catchsql_test 20.1 {
         1631  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
         1632  +} {1 {vtable constructor failed: t1}}
         1633  +
   774   1634   
   775   1635   sqlite3_fts5_may_be_corrupt 0
   776   1636   finish_test
   777   1637   

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/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 = 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/session/sqlite3session.h.

   544    544   **
   545    545   ** If argument pzTab is not NULL, then *pzTab is set to point to a
   546    546   ** nul-terminated utf-8 encoded string containing the name of the table
   547    547   ** affected by the current change. The buffer remains valid until either
   548    548   ** sqlite3changeset_next() is called on the iterator or until the 
   549    549   ** conflict-handler function returns. If pnCol is not NULL, then *pnCol is 
   550    550   ** set to the number of columns in the table affected by the change. If
   551         -** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change
          551  +** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change
   552    552   ** is an indirect change, or false (0) otherwise. See the documentation for
   553    553   ** [sqlite3session_indirect()] for a description of direct and indirect
   554    554   ** changes. Finally, if pOp is not NULL, then *pOp is set to one of 
   555    555   ** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the 
   556    556   ** type of change that the iterator currently points to.
   557    557   **
   558    558   ** If no error occurs, SQLITE_OK is returned. If an error does occur, an

Changes to src/build.c.

  2634   2634     }
  2635   2635   
  2636   2636     /* Remove the table entry from SQLite's internal schema and modify
  2637   2637     ** the schema cookie.
  2638   2638     */
  2639   2639     if( IsVirtual(pTab) ){
  2640   2640       sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);
         2641  +    sqlite3MayAbort(pParse);
  2641   2642     }
  2642   2643     sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
  2643   2644     sqlite3ChangeCookie(pParse, iDb);
  2644   2645     sqliteViewResetAll(db, iDb);
  2645   2646   }
  2646   2647   
  2647   2648   /*

Changes to src/select.c.

  5462   5462   */
  5463   5463   static struct SrcList_item *isSelfJoinView(
  5464   5464     SrcList *pTabList,           /* Search for self-joins in this FROM clause */
  5465   5465     struct SrcList_item *pThis   /* Search for prior reference to this subquery */
  5466   5466   ){
  5467   5467     struct SrcList_item *pItem;
  5468   5468     for(pItem = pTabList->a; pItem<pThis; pItem++){
         5469  +    Select *pS1;
  5469   5470       if( pItem->pSelect==0 ) continue;
  5470   5471       if( pItem->fg.viaCoroutine ) continue;
  5471   5472       if( pItem->zName==0 ) continue;
  5472   5473       if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
  5473   5474       if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
  5474         -    if( sqlite3ExprCompare(0, 
  5475         -          pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) 
  5476         -    ){
         5475  +    pS1 = pItem->pSelect;
         5476  +    if( pThis->pSelect->selId!=pS1->selId ){
         5477  +      /* The query flattener left two different CTE tables with identical
         5478  +      ** names in the same FROM clause. */
         5479  +      continue;
         5480  +    }
         5481  +    if( sqlite3ExprCompare(0, pThis->pSelect->pWhere, pS1->pWhere, -1) ){
  5477   5482         /* The view was modified by some other optimization such as
  5478   5483         ** pushDownWhereTerms() */
  5479   5484         continue;
  5480   5485       }
  5481   5486       return pItem;
  5482   5487     }
  5483   5488     return 0;

Changes to src/test_vfs.c.

   230    230     } aCode[] = {
   231    231       { SQLITE_OK,       "SQLITE_OK"     },
   232    232       { SQLITE_ERROR,    "SQLITE_ERROR"  },
   233    233       { SQLITE_IOERR,    "SQLITE_IOERR"  },
   234    234       { SQLITE_LOCKED,   "SQLITE_LOCKED" },
   235    235       { SQLITE_BUSY,     "SQLITE_BUSY"   },
   236    236       { SQLITE_READONLY, "SQLITE_READONLY"   },
          237  +    { SQLITE_READONLY_CANTINIT, "SQLITE_READONLY_CANTINIT"   },
   237    238     };
   238    239   
   239    240     const char *z;
   240    241     int i;
   241    242   
   242    243     z = Tcl_GetStringResult(p->interp);
   243    244     for(i=0; i<ArraySize(aCode); i++){
................................................................................
   915    916     if( rc==SQLITE_OK && p->mask&TESTVFS_SHMMAP_MASK && tvfsInjectIoerr(p) ){
   916    917       rc = SQLITE_IOERR;
   917    918     }
   918    919   
   919    920     if( rc==SQLITE_OK && isWrite && !pFd->pShm->aPage[iPage] ){
   920    921       tvfsAllocPage(pFd->pShm, iPage, pgsz);
   921    922     }
   922         -  *pp = (void volatile *)pFd->pShm->aPage[iPage];
          923  +  if( rc==SQLITE_OK || rc==SQLITE_READONLY ){
          924  +    *pp = (void volatile *)pFd->pShm->aPage[iPage];
          925  +  }
   923    926   
   924    927     return rc;
   925    928   }
   926    929   
   927    930   
   928    931   static int tvfsShmLock(
   929    932     sqlite3_file *pFile,
................................................................................
  1559   1562   
  1560   1563     return TCL_OK;
  1561   1564   
  1562   1565    bad_args:
  1563   1566     Tcl_WrongNumArgs(interp, 1, objv, "VFSNAME ?-noshm BOOL? ?-fullshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?");
  1564   1567     return TCL_ERROR;
  1565   1568   }
         1569  +
         1570  +extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
         1571  +extern const char *sqlite3ErrName(int);
         1572  +
         1573  +/*
         1574  +** tclcmd: vfs_shmlock DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N
         1575  +*/
         1576  +static int SQLITE_TCLAPI test_vfs_shmlock(
         1577  +  void * clientData,
         1578  +  Tcl_Interp *interp,
         1579  +  int objc,
         1580  +  Tcl_Obj *CONST objv[]
         1581  +){
         1582  +  const char *azArg1[] = {"shared", "exclusive", 0};
         1583  +  const char *azArg2[] = {"lock", "unlock", 0};
         1584  +  sqlite3 *db = 0;
         1585  +  int rc = SQLITE_OK;
         1586  +  const char *zDbname = 0;
         1587  +  int iArg1 = 0;
         1588  +  int iArg2 = 0;
         1589  +  int iOffset = 0;
         1590  +  int n = 0;
         1591  +  sqlite3_file *pFd;
         1592  +
         1593  +  if( objc!=7 ){
         1594  +    Tcl_WrongNumArgs(interp, 1, objv, 
         1595  +        "DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N"
         1596  +    );
         1597  +    return TCL_ERROR;
         1598  +  }
         1599  +
         1600  +  zDbname = Tcl_GetString(objv[2]);
         1601  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) 
         1602  +   || Tcl_GetIndexFromObj(interp, objv[3], azArg1, "ARG", 0, &iArg1) 
         1603  +   || Tcl_GetIndexFromObj(interp, objv[4], azArg2, "ARG", 0, &iArg2) 
         1604  +   || Tcl_GetIntFromObj(interp, objv[5], &iOffset)
         1605  +   || Tcl_GetIntFromObj(interp, objv[6], &n)
         1606  +  ){
         1607  +    return TCL_ERROR;
         1608  +  }
         1609  +
         1610  +  sqlite3_file_control(db, zDbname, SQLITE_FCNTL_FILE_POINTER, (void*)&pFd);
         1611  +  if( pFd==0 ){
         1612  +    return TCL_ERROR;
         1613  +  }
         1614  +  rc = pFd->pMethods->xShmLock(pFd, iOffset, n, 
         1615  +      (iArg1==0 ? SQLITE_SHM_SHARED : SQLITE_SHM_EXCLUSIVE)
         1616  +    | (iArg2==0 ? SQLITE_SHM_LOCK : SQLITE_SHM_UNLOCK)
         1617  +  );
         1618  +  Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
         1619  +  return TCL_OK;
         1620  +}
         1621  +
         1622  +static int SQLITE_TCLAPI test_vfs_set_readmark(
         1623  +  void * clientData,
         1624  +  Tcl_Interp *interp,
         1625  +  int objc,
         1626  +  Tcl_Obj *CONST objv[]
         1627  +){
         1628  +  sqlite3 *db = 0;
         1629  +  int rc = SQLITE_OK;
         1630  +  const char *zDbname = 0;
         1631  +  int iSlot = 0;
         1632  +  int iVal = -1;
         1633  +  sqlite3_file *pFd;
         1634  +  void volatile *pShm = 0;
         1635  +  u32 *aShm;
         1636  +  int iOff;
         1637  +
         1638  +  if( objc!=4 && objc!=5 ){
         1639  +    Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SLOT ?VALUE?");
         1640  +    return TCL_ERROR;
         1641  +  }
         1642  +
         1643  +  zDbname = Tcl_GetString(objv[2]);
         1644  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) 
         1645  +   || Tcl_GetIntFromObj(interp, objv[3], &iSlot)
         1646  +   || (objc==5 && Tcl_GetIntFromObj(interp, objv[4], &iVal))
         1647  +  ){
         1648  +    return TCL_ERROR;
         1649  +  }
         1650  +
         1651  +  sqlite3_file_control(db, zDbname, SQLITE_FCNTL_FILE_POINTER, (void*)&pFd);
         1652  +  if( pFd==0 ){
         1653  +    return TCL_ERROR;
         1654  +  }
         1655  +  rc = pFd->pMethods->xShmMap(pFd, 0, 32*1024, 0, &pShm);
         1656  +  if( rc!=SQLITE_OK ){
         1657  +    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
         1658  +    return TCL_ERROR;
         1659  +  }
         1660  +  if( pShm==0 ){
         1661  +    Tcl_AppendResult(interp, "*-shm is not yet mapped", 0);
         1662  +    return TCL_ERROR;
         1663  +  }
         1664  +  aShm = (u32*)pShm;
         1665  +  iOff = 12*2+1+iSlot;
         1666  +
         1667  +  if( objc==5 ){
         1668  +    aShm[iOff] = iVal;
         1669  +  }
         1670  +  Tcl_SetObjResult(interp, Tcl_NewIntObj(aShm[iOff]));
         1671  +
         1672  +  return TCL_OK;
         1673  +}
  1566   1674   
  1567   1675   int Sqlitetestvfs_Init(Tcl_Interp *interp){
  1568   1676     Tcl_CreateObjCommand(interp, "testvfs", testvfs_cmd, 0, 0);
         1677  +  Tcl_CreateObjCommand(interp, "vfs_shmlock", test_vfs_shmlock, 0, 0);
         1678  +  Tcl_CreateObjCommand(interp, "vfs_set_readmark", test_vfs_set_readmark, 0, 0);
  1569   1679     return TCL_OK;
  1570   1680   }
  1571   1681   
  1572   1682   #endif

Changes to src/treeview.c.

   134    134       sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
   135    135       if( pItem->zDatabase ){
   136    136         sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
   137    137       }else if( pItem->zName ){
   138    138         sqlite3_str_appendf(&x, " %s", pItem->zName);
   139    139       }
   140    140       if( pItem->pTab ){
   141         -      sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
          141  +      sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p",
          142  +           pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab);
   142    143       }
   143    144       if( pItem->zAlias ){
   144    145         sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
   145    146       }
   146    147       if( pItem->fg.jointype & JT_LEFT ){
   147    148         sqlite3_str_appendf(&x, " LEFT-JOIN");
   148    149       }

Changes to src/vdbe.c.

  6848   6848   ** P4 is the name of a virtual table in database P1.  Call the xDestroy method
  6849   6849   ** of that table.
  6850   6850   */
  6851   6851   case OP_VDestroy: {
  6852   6852     db->nVDestroy++;
  6853   6853     rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
  6854   6854     db->nVDestroy--;
         6855  +  assert( p->errorAction==OE_Abort && p->usesStmtJournal );
  6855   6856     if( rc ) goto abort_due_to_error;
  6856   6857     break;
  6857   6858   }
  6858   6859   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  6859   6860   
  6860   6861   #ifndef SQLITE_OMIT_VIRTUALTABLE
  6861   6862   /* Opcode: VOpen P1 * * P4 *

Changes to src/vdbeaux.c.

   363    363   /*
   364    364   ** Add a new OP_ opcode.
   365    365   **
   366    366   ** If the bPush flag is true, then make this opcode the parent for
   367    367   ** subsequent Explains until sqlite3VdbeExplainPop() is called.
   368    368   */
   369    369   void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
   370         -#if !defined(SQLITE_DEBUG)
          370  +#ifndef SQLITE_DEBUG
          371  +  /* Always include the OP_Explain opcodes if SQLITE_DEBUG is defined.
          372  +  ** But omit them (for performance) during production builds */
   371    373     if( pParse->explain==2 )
   372    374   #endif
   373    375     {
   374    376       char *zMsg;
   375    377       Vdbe *v;
   376    378       va_list ap;
   377    379       int iThis;
................................................................................
   612    614     VdbeOpIter sIter;
   613    615     memset(&sIter, 0, sizeof(sIter));
   614    616     sIter.v = v;
   615    617   
   616    618     while( (pOp = opIterNext(&sIter))!=0 ){
   617    619       int opcode = pOp->opcode;
   618    620       if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename 
          621  +     || opcode==OP_VDestroy
   619    622        || ((opcode==OP_Halt || opcode==OP_HaltIfNull) 
   620    623         && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
   621    624       ){
   622    625         hasAbort = 1;
   623    626         break;
   624    627       }
   625    628       if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;

Changes to test/btree02.test.

    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   load_static_extension db eval
    21     21   do_execsql_test btree02-100 {
    22     22     CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;
    23     23     WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)
    24         -    INSERT INTO t1(a,ax,b) SELECT printf('%02x',i), random(), i FROM c;
           24  +    INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c;
    25     25     CREATE INDEX t1a ON t1(a);
    26     26     CREATE TABLE t2(x,y);
    27     27     CREATE TABLE t3(cnt);
    28     28     WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4)
    29     29       INSERT INTO t3(cnt) SELECT i FROM c;
    30     30     SELECT count(*) FROM t1;
    31     31   } {10}
           32  +
           33  +proc showt1 {} {
           34  +  puts -nonewline "t1: "
           35  +  puts [db eval {SELECT printf('(%s,%s)',quote(a),quote(b)) FROM t1}]
           36  +}
           37  +
    32     38   do_test btree02-110 {
    33     39     db eval BEGIN
    34     40     set i 0
           41  +  # showt1
    35     42     db eval {SELECT a, ax, b, cnt FROM t1 CROSS JOIN t3 WHERE b IS NOT NULL} {
    36         -    if {$a==""} {set a 0}
    37         -    if {$b==""} {set b 0}    
           43  +    if {$a==""} continue
    38     44       db eval {INSERT INTO t2(x,y) VALUES($b,$cnt)}
    39     45       # puts "a,b,cnt = ($a,$b,$cnt)"
    40     46       incr i
    41     47       if {$i%2==1} {
    42     48         set bx [expr {$b+1000}]
    43         -      # puts "INSERT ($a),$bx"
           49  +      #  puts "INSERT ($a),$bx"
    44     50         db eval {INSERT INTO t1(a,ax,b) VALUES(printf('(%s)',$a),random(),$bx)}
           51  +      # showt1
    45     52       } else {
    46     53         # puts "DELETE a=$a"
    47     54         db eval {DELETE FROM t1 WHERE a=$a}
           55  +      # showt1
    48     56       }
    49     57       db eval {COMMIT; BEGIN}
    50     58     }  
    51     59     db one {COMMIT; SELECT count(*) FROM t1;}
    52         -} {27}
           60  +} {10}
    53     61   
    54     62   finish_test

Changes to test/csv01.test.

   210    210   # by Trent W. Buck.
   211    211   #
   212    212   do_execsql_test 4.4 {
   213    213     CREATE VIRTUAL TABLE temp.trent USING csv(data='1');
   214    214     SELECT * FROM trent;
   215    215   } {1}
   216    216   
          217  +# 2018-12-26
          218  +# Bug report on the mailing list
          219  +#
          220  +forcedelete csv01.csv
          221  +set fd [open csv01.csv w]
          222  +puts $fd "a,b,c,d\r\n1,2,3,4\r\none,two,three,four\r\n5,6,7,8"
          223  +close $fd
          224  +do_execsql_test 5.1 {
          225  +  CREATE VIRTUAL TABLE t5_1 USING csv(filename='csv01.csv');
          226  +  SELECT name FROM temp.pragma_table_info('t5_1');
          227  +} {c0 c1 c2 c3}
          228  +do_execsql_test 5.2 {
          229  +  SELECT *, '|' FROM t5_1;
          230  +} {a b c d | 1 2 3 4 | one two three four | 5 6 7 8 |}
          231  +do_execsql_test 5.3 {
          232  +  DROP TABLE t5_1;
          233  +  CREATE VIRTUAL TABLE t5_1 USING csv(filename='csv01.csv', header);
          234  +  SELECT name FROM temp.pragma_table_info('t5_1');
          235  +} {a b c d}
          236  +do_execsql_test 5.4 {
          237  +  SELECT *, '|' FROM t5_1;
          238  +} {1 2 3 4 | one two three four | 5 6 7 8 |}
          239  +
   217    240   finish_test

Changes to test/fts3corrupt4.test.

   162    162   do_catchsql_test 4.3 { 
   163    163     SELECT * FROM t1 WHERE t1 MATCH 'three'; 
   164    164   } {1 {database disk image is malformed}}
   165    165   do_execsql_test 4.4 {
   166    166     INSERT INTO t1(t1) VALUES('optimize');
   167    167   }
   168    168   
          169  +#-------------------------------------------------------------------------
          170  +reset_db
          171  +do_test 5.0 {
          172  +  sqlite3 db {}
          173  +  db deserialize [decode_hexdb {
          174  +| size 24576 pagesize 4096 filename c15.db
          175  +| page 1 offset 0
          176  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
          177  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 04   .....@  ........
          178  +|     32: 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 04   ................
          179  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
          180  +|     96: 00 00 00 00 0d 0e f9 00 06 0d ec 00 0f cd 0f 69   ...............i
          181  +|    112: 0f 01 0e 10 0e c6 0d ec 00 00 00 00 00 00 00 00   ................
          182  +|   3552: 00 00 00 00 00 00 00 00 00 00 00 00 22 06 06 17   ................
          183  +|   3568: 11 11 01 31 74 61 62 6c 65 74 32 74 32 06 43 52   ...1tablet2t2.CR
          184  +|   3584: 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 78 29   EATE TABLE t2(x)
          185  +|   3600: 81 33 04 07 17 1f 1f 01 82 35 74 61 62 6c 65 74   .3.......5tablet
          186  +|   3616: 31 5f 73 65 67 64 69 72 74 31 5f 73 65 67 64 69   1_segdirt1_segdi
          187  +|   3632: 72 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 27   r.CREATE TABLE '
          188  +|   3648: 74 31 5f 73 65 67 64 69 72 27 28 6c 65 76 65 6c   t1_segdir'(level
          189  +|   3664: 20 49 4e 54 45 47 45 52 2c 69 64 78 20 49 4e 54    INTEGER,idx INT
          190  +|   3680: 45 47 45 52 2c 73 74 61 72 74 5f 62 6c 6f 63 6b   EGER,start_block
          191  +|   3696: 20 49 4e 54 45 47 45 52 2c 6c 65 61 76 65 73 5f    INTEGER,leaves_
          192  +|   3712: 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 45   end_block INTEGE
          193  +|   3728: 52 2c 65 6e 64 5f 62 6c 6f 63 6b 20 49 4e 54 45   R,end_block INTE
          194  +|   3744: 47 45 52 2c 72 6f 6f 74 20 42 4c 4f 42 2c 50 52   GER,root BLOB,PR
          195  +|   3760: 49 4d 41 52 59 20 4b 45 59 28 6c 65 76 65 6c 2c   IMARY KEY(level,
          196  +|   3776: 20 69 64 78 29 29 31 05 06 17 45 1f 01 00 69 6e    idx))1...E...in
          197  +|   3792: 64 65 78 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e   dexsqlite_autoin
          198  +|   3808: 64 65 79 5f 74 31 5f 73 65 67 64 69 72 5f 31 74   dey_t1_segdir_1t
          199  +|   3824: 31 5f 73 65 67 64 69 72 05 00 00 00 08 00 00 00   1_segdir........
          200  +|   3840: 00 66 03 07 17 23 23 01 81 13 74 61 62 6c 65 74   .f...##...tablet
          201  +|   3856: 31 5f 73 65 67 6d 65 6e 74 73 74 31 5f 73 65 67   1_segmentst1_seg
          202  +|   3872: 6d 65 6e 74 73 03 43 52 45 41 54 45 20 54 41 42   ments.CREATE TAB
          203  +|   3888: 4c 45 20 27 74 31 5f 73 65 67 6d 65 6e 74 73 27   LE 't1_segments'
          204  +|   3904: 28 62 6c 6f 63 6b 69 64 20 49 4e 54 45 47 45 52   (blockid INTEGER
          205  +|   3920: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 6c    PRIMARY KEY, bl
          206  +|   3936: 6f 63 6b 20 42 4c 4f 42 29 62 02 07 17 21 21 01   ock BLOB)b...!!.
          207  +|   3952: 81 0f 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65 6e   ..tablet1_conten
          208  +|   3968: 74 74 31 5f 63 6f 6e 74 65 6e 74 02 43 52 45 41   tt1_content.CREA
          209  +|   3984: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
          210  +|   4000: 74 65 6e 74 27 28 64 6f 63 69 64 20 49 4e 54 45   tent'(docid INTE
          211  +|   4016: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c   GER PRIMARY KEY,
          212  +|   4032: 20 27 63 30 63 6f 6e 74 65 6e 74 27 29 31 01 06    'c0content')1..
          213  +|   4048: 17 11 11 08 51 74 61 62 6c 65 74 31 74 31 43 52   ....Qtablet1t1CR
          214  +|   4064: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
          215  +|   4080: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 33   LE t1 USING fts3
          216  +| page 2 offset 4096
          217  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
          218  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
          219  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
          220  +| page 3 offset 8192
          221  +|      0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
          222  +| page 4 offset 12288
          223  +|      0: 0d 00 00 00 01 0f d6 00 0f d6 00 00 00 00 00 00   ................
          224  +|   4048: 00 00 00 00 00 00 28 01 07 08 08 08 08 15 46 30   ......(.......F0
          225  +|   4064: 20 32 39 00 05 61 62 61 63 6b 03 01 02 00 03 02    29..aback......
          226  +|   4080: 66 74 03 02 02 00 03 04 6e 64 6f 60 30 30 20 00   ft......ndo`00 .
          227  +| page 5 offset 16384
          228  +|      0: a0 00 00 00 10 ff b0 00 ff fb 00 00 00 00 00 00   ................
          229  +|   4080: 00 00 00 00 00 00 00 00 00 00 00 04 04 08 08 09   ................
          230  +| page 6 offset 20480
          231  +|      0: 0d 00 00 00 05 0f b8 00 0f f4 0f e9 0f d6 0f c7   ................
          232  +|     16: 0f b8 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 64   ..'t1_content'(d
          233  +|     32: 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 49   ocid INTEGER PRI
          234  +|     48: 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 63 6f 6e   MARY KEY, 'c0con
          235  +|     64: 74 65 6e 74 27 29 31 01 06 17 11 11 08 51 74 61   tent')1......Qta
          236  +|     80: 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 56 49   blet1t1CREATE VI
          237  +|     96: 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55   RTUAL TABLE t1 U
          238  +|    112: 53 49 4e 47 20 66 74 73 33 0d 00 00 00 03 0f e0   SING fts3.......
          239  +|    128: 00 0f f6 0f ec 0f e0 00 00 00 00 00 00 00 00 00   ................
          240  +|   4016: 00 00 00 00 00 00 00 00 0d 05 02 23 61 75 74 6f   ...........#auto
          241  +|   4032: 6d 65 72 67 65 3d 35 0d 04 02 23 6d 65 72 67 65   merge=5...#merge
          242  +|   4048: 3d 31 30 30 2c 38 11 03 02 2b 69 6e 74 65 67 72   =100,8...+integr
          243  +|   4064: 69 74 79 2d 63 68 65 63 6b 09 02 02 1b 72 65 62   ity-check....reb
          244  +|   4080: 75 69 6c 64 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   uild....optimize
          245  +| end c15.db
          246  +}]} {}
          247  +
          248  +do_catchsql_test 5.1 {
          249  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
          250  +} {1 {database disk image is malformed}}
   169    251   
   170    252   finish_test

Changes to test/lock_common.tcl.

    11     11   # This file contains code used by several different test scripts. The
    12     12   # code in this file allows testfixture to control another process (or
    13     13   # processes) to test locking.
    14     14   #
    15     15   
    16     16   proc do_multiclient_test {varname script} {
    17     17   
    18         -  foreach code [list {
           18  +  foreach {tn code} [list 1 {
    19     19       if {[info exists ::G(valgrind)]} { db close ; continue }
    20     20       set ::code2_chan [launch_testfixture]
    21     21       set ::code3_chan [launch_testfixture]
    22     22       proc code2 {tcl} { testfixture $::code2_chan $tcl }
    23     23       proc code3 {tcl} { testfixture $::code3_chan $tcl }
    24         -    set tn 1
    25         -  } {
           24  +  } 2 {
    26     25       proc code2 {tcl} { uplevel #0 $tcl }
    27     26       proc code3 {tcl} { uplevel #0 $tcl }
    28         -    set tn 2
    29     27     }] {
           28  +    # Do not run multi-process tests with the unix-excl VFS.
           29  +    #
           30  +    if {$tn==1 && [permutation]=="unix-excl"} continue
           31  +
    30     32       faultsim_delete_and_reopen
    31     33   
    32     34       proc code1 {tcl} { uplevel #0 $tcl }
    33     35     
    34     36       # Open connections [db2] and [db3]. Depending on which iteration this
    35     37       # is, the connections may be created in this interpreter, or in 
    36     38       # interpreters running in other OS processes. As such, the [db2] and [db3]

Changes to test/permutations.test.

   433    433     wal.test wal2.test wal3.test wal4.test wal5.test
   434    434     wal64k.test wal6.test wal7.test wal8.test wal9.test
   435    435     walbak.test walbig.test walblock.test walcksum.test walcrash2.test
   436    436     walcrash3.test walcrash4.test walcrash.test walfault.test walhook.test
   437    437     walmode.test walnoshm.test waloverwrite.test walpersist.test 
   438    438     walprotocol2.test walprotocol.test walro2.test walrofault.test 
   439    439     walro.test walshared.test walslow.test walvfs.test
   440         -
          440  +  walfault2.test
   441    441     nockpt.test
          442  +
          443  +  snapshot2.test snapshot3.test snapshot4.test
          444  +  snapshot_fault.test snapshot.test snapshot_up.test
   442    445   } 
   443    446   
   444    447   test_suite "coverage-pager" -description {
   445    448     Coverage tests for file pager.c.
   446    449   } -files {
   447    450     pager1.test    pager2.test  pagerfault.test  pagerfault2.test
   448    451     walfault.test  walbak.test  journal2.test    tkt-9d68c883.test

Added test/shmlock.test.

            1  +# 2018 December 6
            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  +
           13  +set testdir [file dirname $argv0]
           14  +source $testdir/tester.tcl
           15  +
           16  +set testprefix shmlock
           17  +
           18  +ifcapable !wal {finish_test ; return }
           19  +
           20  +sqlite3 db2 test.db
           21  +sqlite3 db3 test.db
           22  +
           23  +do_execsql_test 1.0 {
           24  +  PRAGMA journal_mode = wal;
           25  +  CREATE TABLE t1(a, b);
           26  +  INSERT INTO t1 VALUES(1, 2);
           27  +} {wal}
           28  +do_test 1.1 { execsql { SELECT * FROM t1 } db2 } {1 2}
           29  +do_test 1.2 { execsql { SELECT * FROM t1 } db3 } {1 2}
           30  +
           31  +foreach {tn dbhandle cmd res} {
           32  +  1    db  {shared    lock   7 1}    OK
           33  +  2    db2 {exclusive lock   7 1}    BUSY
           34  +  3    db  {shared    unlock 7 1}    OK
           35  +  4    db2 {exclusive lock   7 1}    OK
           36  +  5    db  {shared    lock   7 1}    BUSY
           37  +  6    db  {exclusive lock   7 1}    BUSY
           38  +  7    db2 {exclusive unlock 7 1}    OK
           39  +
           40  +  8    db  {exclusive lock   0 8}    OK
           41  +  9    db  {exclusive unlock 0 8}    OK
           42  +  10   db2 {exclusive lock   0 8}    OK
           43  +  11   db2 {exclusive unlock 0 8}    OK
           44  +
           45  +  12   db  {shared    lock   0 1}    OK
           46  +  13   db2 {shared    lock   0 1}    OK
           47  +  14   db3 {shared    lock   0 1}    OK
           48  +  15   db3 {shared    unlock 0 1}    OK
           49  +  16   db3 {exclusive lock   0 1}    BUSY
           50  +  17   db2 {shared    unlock 0 1}    OK
           51  +  18   db3 {exclusive lock   0 1}    BUSY
           52  +  19   db  {shared    unlock 0 1}    OK
           53  +  20   db3 {exclusive lock   0 1}    OK
           54  +  21   db3 {exclusive unlock 0 1}    OK
           55  +
           56  +  22   db  {shared    lock   3 1}    OK
           57  +  23   db2 {exclusive lock   2 2}    BUSY
           58  +  24   db  {shared    lock   2 1}    OK
           59  +  25   db2 {exclusive lock   0 5}    BUSY
           60  +  26   db2 {exclusive lock   0 4}    BUSY
           61  +  27   db2 {exclusive lock   0 3}    BUSY
           62  +  28   db  {shared    unlock 3 1}    OK
           63  +  29   db2 {exclusive lock   2 2}    BUSY
           64  +  28   db  {shared    unlock 2 1}    OK
           65  +  29   db2 {exclusive lock   2 2}    OK
           66  +  29   db2 {exclusive unlock 2 2}    OK
           67  +} {
           68  +  do_test 1.3.$tn [list vfs_shmlock $dbhandle main {*}$cmd] "SQLITE_$res"
           69  +}
           70  +
           71  +db  close
           72  +db2 close
           73  +db3 close
           74  +
           75  +if {[permutation]=="unix-excl"} {
           76  +  do_test 2.0 {
           77  +    for {set i 0} {$i < 256} {incr i} { 
           78  +      sqlite3 db$i test.db 
           79  +      execsql { SELECT * FROM t1 } db$i
           80  +    }
           81  +    for {set i 0} {$i < 255} {incr i} { 
           82  +      set rc [vfs_shmlock db$i main shared lock 4 1]
           83  +      if {$rc != "SQLITE_OK"} { error $rc }
           84  +    }
           85  +
           86  +    vfs_shmlock db255 main shared lock 4 1
           87  +  } {SQLITE_BUSY}
           88  +
           89  +  do_test 2.1 { vfs_shmlock db255 main exclusive lock   4 1 } SQLITE_BUSY
           90  +  do_test 2.2 { vfs_shmlock db0   main shared    unlock 4 1 } SQLITE_OK
           91  +  do_test 2.3 { vfs_shmlock db255 main shared    lock   4 1 } SQLITE_OK
           92  +  do_test 2.4 { vfs_shmlock db255 main shared    unlock 4 1 } SQLITE_OK
           93  +  do_test 2.5 { vfs_shmlock db255 main exclusive lock   4 1 } SQLITE_BUSY
           94  +
           95  +  do_test 2.6 {
           96  +    for {set i 1} {$i < 255} {incr i} { 
           97  +      set rc [vfs_shmlock db255 main exclusive lock 4 1]
           98  +      if {$rc != "SQLITE_BUSY"} { error $rc }
           99  +      set rc [vfs_shmlock db$i main shared unlock 4 1]
          100  +      if {$rc != "SQLITE_OK"} { error $rc }
          101  +    }
          102  +
          103  +    vfs_shmlock db255 main exclusive lock 4 1
          104  +  } {SQLITE_OK}
          105  +
          106  +  vfs_shmlock db255 main exclusive unlock 4 1
          107  +
          108  +  for {set i 0} {$i < 256} {incr i} {
          109  +    db$i close
          110  +  }
          111  +}
          112  +
          113  +sqlite3 db0 test.db
          114  +sqlite3 db1 test.db
          115  +do_test 3.1 { execsql { SELECT * FROM t1 } db0 } {1 2}
          116  +do_test 3.2 { execsql { SELECT * FROM t1 } db1 } {1 2}
          117  +
          118  +set L(0) {n n n n n n n n}
          119  +set L(1) {n n n n n n n n}
          120  +proc random_lock_test {idx} {
          121  +  global L
          122  +  set iSlot [expr int(rand()*8)]
          123  +  if {[expr int(rand()*2)]} {
          124  +    # Unlock operation
          125  +    if {[lindex $L($idx) $iSlot]!="n"} {
          126  +      vfs_shmlock db$idx main [lindex $L($idx) $iSlot] unlock $iSlot 1
          127  +      lset L($idx) $iSlot n
          128  +    }
          129  +  } else {
          130  +    # Lock operation
          131  +    if {[lindex $L($idx) $iSlot]=="n"} {
          132  +      set locktype [lindex {e s} [expr int(rand()*2)]]
          133  +      set n 1
          134  +      if {$locktype=="e"} {
          135  +        for {set l $iSlot} {$l<8 && [lindex $L($idx) $l]=="n"} {incr l} {}
          136  +        set n [expr int(rand()*($l-$iSlot))+1]
          137  +        # puts "iSlot=$iSlot l=$l L=$L($idx)"
          138  +        # puts "$iSlot $n"
          139  +      }
          140  +      set res [vfs_shmlock db$idx main $locktype lock $iSlot $n]
          141  +
          142  +      set bBusy 0
          143  +      for {set i $iSlot} {$i<($iSlot+$n)} {incr i} {
          144  +        set other [lindex $L([expr ($idx+1)%2]) $i]
          145  +        if {($other!="n" && $locktype=="e")||($other=="e" && $locktype=="s")} {
          146  +          if {$res != "SQLITE_BUSY"} { error "BUSY not detected" }
          147  +          set bBusy 1
          148  +          break
          149  +        } 
          150  +      }
          151  +
          152  +      if {$bBusy==0} {
          153  +        if {$res != "SQLITE_OK"} { error "BUSY false-positive" }
          154  +        for {set i $iSlot} {$i<($iSlot+$n)} {incr i} {
          155  +          lset L($idx) $i $locktype
          156  +        }
          157  +      }
          158  +    }
          159  +  }
          160  +}
          161  +
          162  +set nStep 100000
          163  +for {set i 0} {$i < $nStep} {incr i} {
          164  +  random_lock_test 0
          165  +  random_lock_test 1
          166  +}
          167  +
          168  +db0 close
          169  +db1 close
          170  +
          171  +finish_test
          172  +
          173  +

Changes to test/snapshot_fault.test.

   217    217     db eval COMMIT
   218    218   } -body {
   219    219     sqlite3_snapshot_recover db main
   220    220   } -test {
   221    221     faultsim_test_result {0 {}} {1 SQLITE_IOERR}
   222    222   }
   223    223   
          224  +#-------------------------------------------------------------------------
          225  +# Test the handling of faults that occur within sqlite3_snapshot_get().
          226  +#
          227  +reset_db
          228  +do_execsql_test 5.0 {
          229  +  PRAGMA page_size = 512;
          230  +  PRAGMA journal_mode = wal;
          231  +  PRAGMA wal_autocheckpoint = 0;
          232  +  CREATE TABLE t1(zzz);
          233  +  INSERT INTO t1 VALUES(randomblob( 5000 ));
          234  +  PRAGMA user_version = 211;
          235  +} {wal 0}
          236  +faultsim_save_and_close
          237  +
          238  +do_faultsim_test 5 -prep {
          239  +  faultsim_restore_and_reopen
          240  +  execsql { SELECT count(*) FROM sqlite_master }
          241  +  execsql BEGIN
          242  +} -body {
          243  +  sqlite3_snapshot_get_blob db main
          244  +  set {} {}
          245  +} -test {
          246  +  execsql END
          247  +  faultsim_test_result {0 {}} {1 SQLITE_IOERR} {1 SQLITE_NOMEM}
          248  +}
   224    249   
   225    250   
   226    251   finish_test

Added test/vtabdrop.test.

            1  +# 2018 December 28
            2  +#
            3  +#    May you do good and not evil.
            4  +#    May you find forgiveness for yourself and forgive others.
            5  +#    May you share freely, never taking more than you give.
            6  +#
            7  +#***********************************************************************
            8  +#
            9  +# The tests in this file test edge cases surrounding DROP TABLE on 
           10  +# virtual tables.
           11  +#
           12  +
           13  +set testdir [file dirname $argv0]
           14  +source $testdir/tester.tcl
           15  +
           16  +ifcapable !vtab { finish_test ; return }
           17  +source $testdir/fts3_common.tcl
           18  +source $testdir/malloc_common.tcl
           19  +
           20  +set testprefix vtabdrop
           21  +
           22  +#-------------------------------------------------------------------------
           23  +# Test that if a DROP TABLE is executed against an rtree table, but the
           24  +# xDestroy() call fails, the rtree table is not dropped, the sqlite_master
           25  +# table is not modified and the internal schema remains intact.
           26  +# 
           27  +ifcapable rtree {
           28  +  do_execsql_test 1.0 {
           29  +    CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);
           30  +    CREATE TABLE t1(x, y);
           31  +    INSERT INTO t1 VALUES(1, 2);
           32  +  }
           33  +  
           34  +  do_test 1.1 {
           35  +    execsql {
           36  +      BEGIN;
           37  +        INSERT INTO t1 VALUES(3, 4);
           38  +    }
           39  +    db eval { SELECT * FROM t1 } {
           40  +      catchsql { DROP TABLE rt }
           41  +    }
           42  +    execsql COMMIT
           43  +  } {}
           44  +  
           45  +  do_execsql_test 1.2 {
           46  +    SELECT name FROM sqlite_master ORDER BY 1;
           47  +    SELECT * FROM t1;
           48  +    SELECT * FROM rt;
           49  +  } {rt rt_node rt_parent rt_rowid t1 1 2 3 4}
           50  +  
           51  +  db close
           52  +  sqlite3 db test.db
           53  +  
           54  +  do_execsql_test 1.3 {
           55  +    SELECT name FROM sqlite_master ORDER BY 1;
           56  +  } {rt rt_node rt_parent rt_rowid t1}
           57  +}
           58  +
           59  +#-------------------------------------------------------------------------
           60  +# Same as tests 1.*, except with fts5 instead of rtree.
           61  +# 
           62  +ifcapable fts5 {
           63  +  reset_db
           64  +  do_execsql_test 2.0 {
           65  +    CREATE VIRTUAL TABLE ft USING fts5(x);
           66  +    CREATE TABLE t1(x, y);
           67  +    INSERT INTO t1 VALUES(1, 2);
           68  +  }
           69  +  
           70  +  do_test 2.1 {
           71  +    execsql {
           72  +      BEGIN;
           73  +        INSERT INTO t1 VALUES(3, 4);
           74  +    }
           75  +    db eval { SELECT * FROM t1 } {
           76  +      catchsql { DROP TABLE ft }
           77  +    }
           78  +    execsql COMMIT
           79  +  } {}
           80  +  
           81  +  do_execsql_test 2.2 {
           82  +    SELECT name FROM sqlite_master ORDER BY 1;
           83  +  } {ft ft_config ft_content ft_data ft_docsize ft_idx t1}
           84  +  
           85  +  db close
           86  +  sqlite3 db test.db
           87  +  
           88  +  do_execsql_test 2.3 {
           89  +    SELECT name FROM sqlite_master ORDER BY 1;
           90  +  } {ft ft_config ft_content ft_data ft_docsize ft_idx t1}
           91  +}
           92  +
           93  +#-------------------------------------------------------------------------
           94  +# Same as tests 1.*, except with fts3 instead of rtree.
           95  +# 
           96  +ifcapable fts3 {
           97  +  reset_db
           98  +  do_execsql_test 2.0 {
           99  +    CREATE VIRTUAL TABLE ft USING fts3(x);
          100  +    CREATE TABLE t1(x, y);
          101  +    INSERT INTO t1 VALUES(1, 2);
          102  +  }
          103  +  
          104  +  do_test 2.1 {
          105  +    execsql {
          106  +      BEGIN;
          107  +        INSERT INTO t1 VALUES(3, 4);
          108  +    }
          109  +    db eval { SELECT * FROM t1 } {
          110  +      catchsql { DROP TABLE ft }
          111  +    }
          112  +    execsql COMMIT
          113  +  } {}
          114  +  
          115  +  do_execsql_test 2.2 {
          116  +    SELECT name FROM sqlite_master ORDER BY 1;
          117  +  } {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1}
          118  +  
          119  +  db close
          120  +  sqlite3 db test.db
          121  +  
          122  +  do_execsql_test 2.3 {
          123  +    SELECT name FROM sqlite_master ORDER BY 1;
          124  +  } {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1}
          125  +}
          126  +
          127  +finish_test

Changes to test/wal.test.

  1293   1293   #
  1294   1294   #   3. Using connection 1, checkpoint the database. Make sure all
  1295   1295   #      the data is present and the database is not corrupt.
  1296   1296   #
  1297   1297   # At one point, SQLite was failing to grow the mapping of the wal-index
  1298   1298   # file in step 3 and the checkpoint was corrupting the database file.
  1299   1299   #
  1300         -do_test wal-20.1 {
  1301         -  catch {db close}
  1302         -  forcedelete test.db test.db-wal test.db-journal
  1303         -  sqlite3 db test.db
  1304         -  execsql {
  1305         -    PRAGMA journal_mode = WAL;
  1306         -    CREATE TABLE t1(x);
  1307         -    INSERT INTO t1 VALUES(randomblob(900));
  1308         -    SELECT count(*) FROM t1;
  1309         -  }
  1310         -} {wal 1}
  1311         -do_test wal-20.2 {
  1312         -  set ::buddy [launch_testfixture]
  1313         -  testfixture $::buddy {
         1300  +if {[permutation]!="unix-excl"} {
         1301  +  do_test wal-20.1 {
         1302  +    catch {db close}
         1303  +    forcedelete test.db test.db-wal test.db-journal
         1304  +    sqlite3 db test.db
         1305  +    execsql {
         1306  +      PRAGMA journal_mode = WAL;
         1307  +      CREATE TABLE t1(x);
         1308  +      INSERT INTO t1 VALUES(randomblob(900));
         1309  +      SELECT count(*) FROM t1;
         1310  +    }
         1311  +  } {wal 1}
         1312  +  do_test wal-20.2 {
         1313  +    set ::buddy [launch_testfixture]
         1314  +    testfixture $::buddy {
         1315  +      sqlite3 db test.db
         1316  +      db transaction { db eval {
         1317  +        PRAGMA wal_autocheckpoint = 0;
         1318  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 2 */
         1319  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 4 */
         1320  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 8 */
         1321  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 16 */
         1322  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 32 */
         1323  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 64 */
         1324  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 128 */
         1325  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 256 */
         1326  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 512 */
         1327  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 1024 */
         1328  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 2048 */
         1329  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 4096 */
         1330  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 8192 */
         1331  +        INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 16384 */
         1332  +      } }
         1333  +    }
         1334  +  } {0}
         1335  +  do_test wal-20.3 {
         1336  +    close $::buddy
         1337  +    execsql { PRAGMA wal_checkpoint }
         1338  +    execsql { SELECT count(*) FROM t1 }
         1339  +  } {16384}
         1340  +  do_test wal-20.4 {
         1341  +    db close
  1314   1342       sqlite3 db test.db
  1315         -    db transaction { db eval {
  1316         -      PRAGMA wal_autocheckpoint = 0;
  1317         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 2 */
  1318         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 4 */
  1319         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 8 */
  1320         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 16 */
  1321         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 32 */
  1322         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 64 */
  1323         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 128 */
  1324         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 256 */
  1325         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 512 */
  1326         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 1024 */
  1327         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 2048 */
  1328         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 4096 */
  1329         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 8192 */
  1330         -      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 16384 */
  1331         -    } }
  1332         -  }
  1333         -} {0}
  1334         -do_test wal-20.3 {
  1335         -  close $::buddy
  1336         -  execsql { PRAGMA wal_checkpoint }
  1337         -  execsql { SELECT count(*) FROM t1 }
  1338         -} {16384}
  1339         -do_test wal-20.4 {
  1340         -  db close
  1341         -  sqlite3 db test.db
  1342         -  execsql { SELECT count(*) FROM t1 }
  1343         -} {16384}
  1344         -integrity_check wal-20.5
         1343  +    execsql { SELECT count(*) FROM t1 }
         1344  +  } {16384}
         1345  +  integrity_check wal-20.5
         1346  +}
  1345   1347   
  1346   1348   catch { db2 close }
  1347   1349   catch { db close }
  1348   1350   
  1349   1351   do_test wal-21.1 {
  1350   1352     faultsim_delete_and_reopen
  1351   1353     execsql { 

Added test/walfault2.test.

            1  +# 2010 May 03
            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 file is testing the operation of the library in
           13  +# "PRAGMA journal_mode=WAL" mode.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +source $testdir/malloc_common.tcl
           19  +source $testdir/lock_common.tcl
           20  +
           21  +ifcapable !wal {finish_test ; return }
           22  +set testprefix walfault2
           23  +
           24  +#-------------------------------------------------------------------------
           25  +# Inject faults while truncating the wal file.
           26  +#
           27  +do_execsql_test 1.0 {
           28  +  PRAGMA auto_vacuum = 0;
           29  +  CREATE TABLE t1(a, b);
           30  +  PRAGMA journal_mode = wal;
           31  +  WITH s(i) AS (
           32  +    SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
           33  +  )
           34  +  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
           35  +} {wal}
           36  +faultsim_save_and_close
           37  +
           38  +do_faultsim_test 1 -prep {
           39  +  faultsim_restore
           40  +  sqlite3 db file:test.db?psow=0 -uri 1
           41  +  file_control_powersafe_overwrite db 0
           42  +  execsql {
           43  +    PRAGMA wal_checkpoint;
           44  +    PRAGMA journal_size_limit = 10000;
           45  +    PRAGMA synchronous = full;
           46  +  }
           47  +} -body {
           48  +  execsql { INSERT INTO t1 VALUES(1,1) }
           49  +} -test {
           50  +  faultsim_test_result {0 {}}
           51  +}
           52  +
           53  +#-------------------------------------------------------------------------
           54  +# Inject faults while rewriting checksums.
           55  +#
           56  +reset_db
           57  +do_execsql_test 2.0 {
           58  +  PRAGMA auto_vacuum = 0;
           59  +  CREATE TABLE t1(a, b);
           60  +  PRAGMA journal_mode = wal;
           61  +  WITH s(i) AS (
           62  +    SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
           63  +  )
           64  +  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
           65  +} {wal}
           66  +faultsim_save_and_close
           67  +
           68  +do_faultsim_test 2 -prep {
           69  +  faultsim_restore_and_reopen
           70  +  execsql {
           71  +    PRAGMA cache_size = 2;
           72  +    BEGIN;
           73  +    UPDATE t1 SET a=randomblob(400);
           74  +    UPDATE t1 SET b=randomblob(400);
           75  +    UPDATE t1 SET a=randomblob(400);
           76  +    UPDATE t1 SET b=randomblob(400);
           77  +    UPDATE t1 SET a=randomblob(400);
           78  +    UPDATE t1 SET b=randomblob(400);
           79  +    UPDATE t1 SET a=randomblob(400);
           80  +    UPDATE t1 SET b=randomblob(400);
           81  +  }
           82  +} -body {
           83  +  execsql COMMIT
           84  +} -test {
           85  +  faultsim_test_result {0 {}}
           86  +}
           87  +
           88  +
           89  +
           90  +finish_test

Changes to test/walvfs.test.

    28     28   tvfs filter xSync
    29     29   set ::sync_count 0
    30     30   proc xSync {method file args} {
    31     31     if {[file tail $file]=="test.db-wal"} {
    32     32       incr ::sync_count
    33     33     }
    34     34   }
           35  +
    35     36   
    36     37   #-------------------------------------------------------------------------
    37     38   # Test that if IOCAP_SEQUENTIAL is set, the wal-header is not synced to
    38     39   # disk immediately after it is written.
    39     40   #
    40     41   sqlite3 db test.db -vfs tvfs
    41     42   do_execsql_test 1.0 {
................................................................................
   101    102       INSERT INTO t1 VALUES(randomblob(750));
   102    103     }
   103    104     file size test.db-wal
   104    105   } {8000}
   105    106   
   106    107   #-------------------------------------------------------------------------
   107    108   # Test that a checkpoint may be interrupted using sqlite3_interrupt().
          109  +# And that the error code is SQLITE_NOMEM, not SQLITE_INTERRUPT, if
          110  +# an OOM error occurs just before the sqlite3_interrupt() call.
   108    111   #
   109    112   reset_db
   110    113   db close
   111    114   sqlite3 db test.db -vfs tvfs
   112    115   tvfs filter {}
   113    116   
   114    117   do_execsql_test 3.0 {
................................................................................
   133    136     return SQLITE_OK
   134    137   }
   135    138   
   136    139   do_catchsql_test 3.1 {
   137    140     PRAGMA wal_checkpoint
   138    141   } {1 interrupted}
   139    142   
          143  +set ::cnt 2
          144  +proc xWrite {method file args} {
          145  +  if {[file tail $file]=="test.db"} {
          146  +    incr ::cnt -1
          147  +    if {$::cnt==0} {
          148  +      sqlite3_memdebug_fail 5 -repeat 0
          149  +      catchsql { SELECT 'a big long string!' }
          150  +      sqlite3_interrupt db
          151  +    }
          152  +  }
          153  +  return SQLITE_OK
          154  +}
          155  +
          156  +do_catchsql_test 3.2 {
          157  +  PRAGMA wal_checkpoint
          158  +} {1 {out of memory}}
          159  +
   140    160   #-------------------------------------------------------------------------
   141    161   #
   142    162   reset_db
   143    163   db close
   144    164   do_test 4.0 {
   145    165     sqlite3 db test.db -vfs tvfs
   146    166     execsql {
................................................................................
   178    198     }
   179    199     return SQLITE_OK
   180    200   }
   181    201   do_catchsql_test 4.2 {
   182    202     SELECT count(*) FROM t1
   183    203   } {1 {attempt to write a readonly database}}
   184    204   
          205  +#-------------------------------------------------------------------------
          206  +#
          207  +reset_db
          208  +db close 
          209  +sqlite3 db test.db -vfs tvfs
          210  +tvfs filter {}
          211  +do_execsql_test 5.0 {
          212  +  PRAGMA auto_vacuum = 0;
          213  +  PRAGMA page_size = 1024;
          214  +  CREATE TABLE t1(x);
          215  +  PRAGMA journal_mode = wal;
          216  +  WITH s(i) AS (
          217  +      SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
          218  +  )
          219  +  INSERT INTO t1 SELECT randomblob(750) FROM s;
          220  +} {wal}
          221  +
          222  +do_execsql_test 5.1 {
          223  +  SELECT count(*) FROM t1
          224  +} {20}
          225  +
          226  +do_test 5.2 {
          227  +  vfs_set_readmark db main 1 100
          228  +  vfs_set_readmark db main 2 100
          229  +  vfs_set_readmark db main 3 100
          230  +  vfs_set_readmark db main 4 100
          231  +} {100}
          232  +
          233  +do_execsql_test 5.3 {
          234  +  SELECT count(*) FROM t1
          235  +} {20}
          236  +
          237  +do_test 5.3 {
          238  +  list [vfs_set_readmark db main 1] \
          239  +       [vfs_set_readmark db main 2] \
          240  +       [vfs_set_readmark db main 3] \
          241  +       [vfs_set_readmark db main 4] 
          242  +} {24 100 100 100}
          243  +
          244  +tvfs script xShmLock
          245  +tvfs filter xShmLock
          246  +set ::cnt 20
          247  +proc xShmLock {args} {
          248  +  incr ::cnt -1
          249  +  if {$::cnt>0} { return SQLITE_BUSY }
          250  +  return SQLITE_OK
          251  +}
          252  +
          253  +do_test 5.4 {
          254  +  vfs_set_readmark db main 1 100
          255  +  execsql { SELECT count(*) FROM t1 }
          256  +} {20}
          257  +
          258  +vfs_set_readmark db main 1 100
          259  +vfs_set_readmark db main 2 100
          260  +vfs_set_readmark db main 3 100
          261  +vfs_set_readmark db main 4 100
          262  +
          263  +tvfs script xShmMapLock
          264  +tvfs filter {xShmLock xShmMap}
          265  +proc xShmMapLock {method args} {
          266  +  if {$method=="xShmMap"} {
          267  +    return "SQLITE_READONLY"
          268  +  }
          269  +  return SQLITE_BUSY
          270  +}
          271  +
          272  +sqlite3 db2 test.db -vfs tvfs
          273  +breakpoint
          274  +do_test 5.5 {
          275  +  list [catch { execsql { SELECT count(*) FROM t1 } db2 } msg] $msg
          276  +} {1 {attempt to write a readonly database}}
          277  +
          278  +tvfs filter {}
          279  +vfs_set_readmark db main 1 1
          280  +
          281  +do_test 5.6 {
          282  +  list [catch { execsql { SELECT count(*) FROM t1 } db2 } msg] $msg
          283  +} {0 20}
          284  +db2 close
          285  +db close
          286  +
          287  +#-------------------------------------------------------------------------
          288  +# Cause an SQLITE_PROTOCOL while attempting to restart the wal file.
          289  +#
          290  +reset_db
          291  +tvfs filter {}
          292  +db close
          293  +sqlite3 db test.db -vfs tvfs
          294  +do_execsql_test 6.0 {
          295  +  PRAGMA auto_vacuum = 0;
          296  +  PRAGMA page_size = 1024;
          297  +  CREATE TABLE t1(x);
          298  +  PRAGMA journal_mode = wal;
          299  +  WITH s(i) AS (
          300  +      SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
          301  +  )
          302  +  INSERT INTO t1 SELECT randomblob(750) FROM s;
          303  +} {wal}
          304  +
          305  +do_test 6.1 {
          306  +  execsql { PRAGMA wal_checkpoint } 
          307  +  set {} {}
          308  +} {}
          309  +
          310  +tvfs filter xShmLock
          311  +tvfs script xShmLock
          312  +set ::flag 0
          313  +proc xShmLock {method file handle spec} {
          314  +  if {$::flag && [lrange $spec 2 end]=="lock shared"} {
          315  +    return SQLITE_BUSY
          316  +  }
          317  +  if {$spec=="3 1 unlock shared"} {
          318  +    set ::flag 1
          319  +  }
          320  +  return SQLITE_OK
          321  +}
          322  +
          323  +puts "# WARNING: This next test takes around 12 seconds"
          324  +do_catchsql_test 6.2 {
          325  +  INSERT INTO t1 VALUES(1);
          326  +} {1 {locking protocol}}
          327  +
          328  +#-------------------------------------------------------------------------
          329  +# Check that a checkpoint fails if it cannot get the CHECKPOINTER lock
          330  +#
          331  +reset_db
          332  +tvfs filter {}
          333  +db close
          334  +sqlite3 db test.db -vfs tvfs
          335  +do_execsql_test 7.0 {
          336  +  PRAGMA auto_vacuum = 0;
          337  +  PRAGMA page_size = 1024;
          338  +  CREATE TABLE t1(x);
          339  +  PRAGMA journal_mode = wal;
          340  +  WITH s(i) AS (
          341  +      SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20
          342  +  )
          343  +  INSERT INTO t1 SELECT randomblob(750) FROM s;
          344  +} {wal}
          345  +
          346  +tvfs script xShmLock
          347  +tvfs filter xShmLock
          348  +proc xShmLock {method file handle spec} {
          349  +  if {$spec=="1 1 lock exclusive"} {
          350  +    return SQLITE_BUSY
          351  +  }
          352  +  return SQLITE_OK
          353  +}
          354  +
          355  +do_execsql_test 7.1 {
          356  +  PRAGMA wal_checkpoint
          357  +} {1 -1 -1}
          358  +
          359  +#-------------------------------------------------------------------------
          360  +# Check that the page cache is correctly flushed if a checkpointer using
          361  +# a version 2 VFS makes a checkpoint with an out-of-date cache.
          362  +#
          363  +reset_db
          364  +testvfs tvfs2 -iversion 2
          365  +db close
          366  +sqlite3 db test.db -vfs tvfs2
          367  +do_execsql_test 8.0 {
          368  +  PRAGMA auto_vacuum = 0;
          369  +  PRAGMA page_size = 1024;
          370  +  CREATE TABLE t1(x);
          371  +  PRAGMA journal_mode = wal;
          372  +  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20 )
          373  +  INSERT INTO t1 SELECT randomblob(75) FROM s;
          374  +} {wal}
          375  +
          376  +do_execsql_test 8.1 { SELECT count(*) FROM t1 } {20}
          377  +
          378  +do_test 8.2 {
          379  +  sqlite3 db2 test.db -vfs tvfs2
          380  +  execsql {
          381  +    INSERT INTO t1 VALUES(randomblob(75));
          382  +  } db2
          383  +  db2 close
          384  +} {}
          385  +
          386  +do_execsql_test 8.3 { 
          387  +  PRAGMA wal_checkpoint;
          388  +  SELECT count(*) FROM t1 
          389  +} {0 5 5 21}
          390  +tvfs2 delete
          391  +
          392  +#-------------------------------------------------------------------------
          393  +reset_db
          394  +db close
          395  +sqlite3 db test.db -vfs tvfs
          396  +do_execsql_test 9.0 {
          397  +  PRAGMA auto_vacuum = 0;
          398  +  PRAGMA page_size = 1024;
          399  +  CREATE TABLE t1(x);
          400  +  PRAGMA journal_mode = wal;
          401  +  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 20 )
          402  +  INSERT INTO t1 SELECT randomblob(75) FROM s;
          403  +} {wal}
          404  +
          405  +sqlite3 db2 test.db -vfs tvfs
          406  +tvfs filter {xShmMap xShmLock}
          407  +tvfs script xShmMap
          408  +proc xShmMap {method file handle args} {
          409  +  switch -- $method {
          410  +    xShmMap {
          411  +      return "SQLITE_READONLY_CANTINIT"
          412  +    }
          413  +    xShmLock {
          414  +      if {$args=="{3 1 lock shared}"} {
          415  +        return "SQLITE_IOERR"
          416  +      }
          417  +    }
          418  +  }
          419  +}
          420  +
          421  +do_test 9.1 {
          422  +  catchsql { SELECT count(*) FROM t1 } db2
          423  +} {1 {disk I/O error}}
          424  +
   185    425   db close
          426  +db2 close
   186    427   tvfs delete
   187    428   finish_test
          429  +

Changes to test/with1.test.

  1039   1039   #
  1040   1040   do_execsql_test 20.1 {
  1041   1041     WITH c(i)AS(VALUES(9)UNION SELECT~i FROM c)SELECT max(5)>i fROM c;
  1042   1042   } {0}
  1043   1043   do_execsql_test 20.2 {
  1044   1044     WITH c(i)AS(VALUES(5)UNIoN SELECT 0)SELECT min(1)-i fROM c;
  1045   1045   } {1}
         1046  +
         1047  +# 2018-12-26
         1048  +# Two different CTE tables with the same name appear in within a single FROM
         1049  +# clause due to the query-flattener optimization.  make sure this does not cause
         1050  +# problems.  This problem was discovered by Matt Denton.
         1051  +#
         1052  +do_execsql_test 21.1 {
         1053  +   WITH RECURSIVE t21(a,b) AS (
         1054  +    WITH t21(x) AS (VALUES(1))
         1055  +    SELECT x, x FROM t21 ORDER BY 1
         1056  +  )
         1057  +  SELECT * FROM t21 AS tA, t21 AS tB
         1058  +} {1 1 1 1}
         1059  +do_execsql_test 21.2 {
         1060  +  SELECT printf('',
         1061  +     EXISTS (WITH RECURSIVE Table0 AS (WITH Table0 AS (SELECT DISTINCT 1)
         1062  +                                       SELECT *, * FROM Table0 ORDER BY 1 DESC)
         1063  +             SELECT * FROM Table0  NATURAL JOIN  Table0));
         1064  +} {{}}
  1046   1065   
  1047   1066   finish_test

Changes to tool/dbtotxt.c.

   108    108       if( pgsz<512 || (pgsz&(pgsz-1))!=0 ){
   109    109         fprintf(stderr, "Invalid page size in header: %d\n", pgsz);
   110    110         exit(1);
   111    111       }
   112    112     }
   113    113     zBaseName = zInputFile;
   114    114     for(i=0; zInputFile[i]; i++){
   115         -    if( zInputFile[i]=='/' && zInputFile[i+1]!=0 ) zBaseName = zInputFile+1;
          115  +    if( zInputFile[i]=='/' && zInputFile[i+1]!=0 ) zBaseName = zInputFile+i+1;
   116    116     }
   117    117     printf("| size %d pagesize %d filename %s\n",(int)szFile,pgsz,zBaseName);
   118    118     for(i=0; i<szFile; i+=16){
   119    119       int got = (int)fread(aLine, 1, 16, in);
   120    120       if( got!=16 ){
   121    121         static int once = 1;
   122    122         if( once ){