/ Check-in [ad816d01]
Login

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

Overview
Comment:Merge in recent fixes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nulls-last
Files: files | file ages | folders
SHA3-256: ad816d01d4bd3908ff2c574d79d1a29b6d732df308f2f1b1cdf7c0bc7c1bd7cf
User & Date: drh 2019-08-26 20:41:33
Context
2019-08-27
19:59
Add support for "ORDER BY ... NULLS FIRST" and "ORDER BY ... NULLS LAST". Use this to fix ticket [f8a7060e]. check-in: 94085fb3 user: dan tags: trunk
2019-08-26
20:41
Merge in recent fixes from trunk. Closed-Leaf check-in: ad816d01 user: drh tags: nulls-last
14:57
Tweak the shell tool ".recover" command so that it can recover rows that consist of a rowid and no fields. check-in: 279ac7fd user: dan tags: trunk
2019-08-23
20:33
Move some things in parse.y so that TK_COLUMN and TK_AGG_COLUMN are assigned the same values as they are on trunk for a very small speedup. check-in: d26fdfa3 user: dan tags: nulls-last
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_index.c.

  4993   4993           int nCopy;
  4994   4994           u8 *aCopy;
  4995   4995   
  4996   4996           i64 iPrev = 0;
  4997   4997           Fts5PoslistWriter writer;
  4998   4998           memset(&writer, 0, sizeof(writer));
  4999   4999   
         5000  +        /* See the earlier comment in this function for an explanation of why
         5001  +        ** corrupt input position lists might cause the output to consume
         5002  +        ** at most 20 bytes of unexpected space. */
  5000   5003           fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
  5001   5004           fts5BufferZero(&tmp);
  5002         -        sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);
         5005  +        sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist + 10 + 10);
  5003   5006           if( p->rc ) break;
  5004   5007   
  5005   5008           sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
  5006   5009           sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
  5007   5010           assert_nc( iPos1>=0 && iPos2>=0 );
  5008   5011   
  5009   5012           if( iPos1<iPos2 ){

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

  9362   9362   do_catchsql_test 63.2 {
  9363   9363     INSERT INTO t1(t1) VALUES('optimize');
  9364   9364   } {/*malformed database schema*/}
  9365   9365   
  9366   9366   do_catchsql_test 63.3 {
  9367   9367     SELECT * FROM t1 WHERE b MATCH 'thead*thead*theSt*';
  9368   9368   } {/*malformed database schema*/}
         9369  +
         9370  +#---------------------------------------------------------------------------
         9371  +do_test 64.0 {
         9372  +  sqlite3 db {}
         9373  +  db deserialize [decode_hexdb {
         9374  +.open --hexdb
         9375  +| size 28672 pagesize 4096 filename crash-4470f0b94422f7.db
         9376  +| page 1 offset 0
         9377  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         9378  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06   .....@  ........
         9379  +|     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
         9380  +|     96: 00 00 00 00 0d 00 00 00 06 0d e2 00 0f c4 0f 6a   ...............j
         9381  +|    112: 0e fc 0e 9d 0e 3d 0d e2 00 00 00 00 00 01 00 00   .....=..........
         9382  +|   3552: 00 00 59 06 06 17 21 21 01 7f 74 61 62 6c 65 74   ..Y...!!..tablet
         9383  +|   3568: 74 74 5f 63 6f 6e 66 69 67 74 74 74 5f 63 6f 6e   tt_configttt_con
         9384  +|   3584: 66 69 67 06 43 52 45 41 54 45 20 54 41 42 4c 45   fig.CREATE TABLE
         9385  +|   3600: 20 27 74 74 74 5f 63 6f 6e 66 69 67 27 28 6b 20    'ttt_config'(k 
         9386  +|   3616: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20   PRIMARY KEY, v) 
         9387  +|   3632: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5e 05 07   WITHOUT ROWID^..
         9388  +|   3648: 17 23 23 01 81 03 74 61 62 6c 65 74 74 74 5f 64   .##...tablettt_d
         9389  +|   3664: 6f 63 73 69 7a 65 74 74 74 5f 64 6f 63 73 69 7a   ocsizettt_docsiz
         9390  +|   3680: 65 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27   e.CREATE TABLE '
         9391  +|   3696: 74 74 74 5f 64 6f 63 73 69 7a 65 27 28 69 64 20   ttt_docsize'(id 
         9392  +|   3712: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         9393  +|   3728: 4b 45 59 2c 20 73 7a 20 42 4c 4f 42 29 5d 04 07   KEY, sz BLOB)]..
         9394  +|   3744: 17 23 23 01 81 01 74 61 62 6c 65 74 74 74 5f 63   .##...tablettt_c
         9395  +|   3760: 6f 6e 74 65 6e 74 74 74 74 5f 63 6f 6e 74 65 6e   ontentttt_conten
         9396  +|   3776: 74 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 27   t.CREATE TABLE '
         9397  +|   3792: 74 74 74 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   ttt_content'(id 
         9398  +|   3808: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         9399  +|   3824: 4b 45 59 2c 20 63 30 2c 20 63 31 29 6c 03 07 17   KEY, c0, c1)l...
         9400  +|   3840: 1b 1b 01 81 2f 74 61 62 6c 65 74 74 74 5f 69 64   ..../tablettt_id
         9401  +|   3856: 78 74 74 74 5f 69 64 78 03 43 52 45 41 54 45 20   xttt_idx.CREATE 
         9402  +|   3872: 54 41 42 4c 45 20 27 74 74 74 5f 69 64 78 27 28   TABLE 'ttt_idx'(
         9403  +|   3888: 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67 6e   segid, term, pgn
         9404  +|   3904: 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28 73   o, PRIMARY KEY(s
         9405  +|   3920: 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49 54   egid, term)) WIT
         9406  +|   3936: 48 4f 55 54 20 52 4f 57 49 44 58 02 07 17 1d 1d   HOUT ROWIDX.....
         9407  +|   3952: 01 81 03 74 61 62 6c 65 74 74 74 5f 64 61 74 61   ...tablettt_data
         9408  +|   3968: 74 74 74 5f 64 61 74 61 02 43 52 45 41 54 45 20   ttt_data.CREATE 
         9409  +|   3984: 54 41 42 4c 45 20 27 74 74 74 5f 64 61 74 61 27   TABLE 'ttt_data'
         9410  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         9411  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         9412  +|   4032: 4c 4f 42 29 3a 01 06 17 13 13 08 5f 74 61 62 6c   LOB):......_tabl
         9413  +|   4048: 65 74 74 74 74 74 74 43 52 45 41 54 45 20 56 49   ettttttCREATE VI
         9414  +|   4064: 52 54 55 41 4c 20 54 41 42 4c 45 20 74 74 74 20   RTUAL TABLE ttt 
         9415  +|   4080: 55 53 49 4e 47 20 66 74 73 35 28 61 2c 20 62 29   USING fts5(a, b)
         9416  +| page 2 offset 4096
         9417  +|      0: 0d 0f 44 00 05 0e 81 00 0f 1a 0e 81 0f af 0f 58   ..D............X
         9418  +|     16: 0e 98 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         9419  +|   3712: 00 15 0a 03 00 30 00 00 00 00 01 03 03 00 03 01   .....0..........
         9420  +|   3728: 01 01 02 01 01 03 01 01 81 24 8c 80 80 80 80 01   .........$......
         9421  +|   3744: 04 00 82 4c 00 00 00 9b 02 30 65 03 1a 02 05 05   ...L.....0e.....
         9422  +|   3760: 07 05 01 01 04 03 03 08 03 03 01 2e 02 05 05 07   ................
         9423  +|   3776: 05 07 05 07 05 01 01 04 03 03 08 03 03 08 03 03   ................
         9424  +|   3792: 07 f3 03 02 01 65 03 1e 03 05 05 04 05 05 01 00   .....e..........
         9425  +|   3808: 03 06 04 04 06 04 03 01 36 03 05 05 04 06 05 04   ........6.......
         9426  +|   3824: 06 05 04 05 05 01 01 03 06 04 04 06 04 04 06 04   ................
         9427  +|   3840: 04 06 04 03 03 01 65 03 14 04 05 06 f5 05 01 01   ......e.........
         9428  +|   3856: 02 08 09 01 20 04 05 07 05 07 05 07 05 05 01 00   .... ...........
         9429  +|   3872: 02 08 0a 0a 0a 04 01 65 03 02 0a 01 06 0a 0a 0a   .......e........
         9430  +|   3888: 05 01 65 03 06 01 01 0a 01 0a 01 01 0a 0a 0a 04   ..e.............
         9431  +|   3904: 2b 31 21 0b 0f ef 00 14 2a 00 00 00 00 01 02 02   +1!.....*.......
         9432  +|   3920: 00 02 01 01 01 02 01 01 50 88 80 80 80 80 01 04   ........P.......
         9433  +|   3936: 00 81 24 00 00 00 47 02 30 65 02 1a 02 05 05 07   ..$...G.0e......
         9434  +|   3952: 05 01 01 04 03 03 08 03 03 02 01 65 02 1e 03 05   ...........e....
         9435  +|   3968: 05 04 05 05 01 01 03 06 04 04 06 04 03 03 01 65   ...............e
         9436  +|   3984: 02 14 04 05 07 05 05 01 01 02 08 0a 04 01 65 02   ..............e.
         9437  +|   4000: 02 0a 05 01 65 02 06 01 01 0a 04 12 14 0f 06 31   ....e..........1
         9438  +|   4016: 84 80 80 80 80 01 03 00 68 00 00 00 2b 02 30 65   ........h...+.0e
         9439  +|   4032: 01 10 02 05 05 01 01 04 03 03 02 01 65 01 12 03   ............e...
         9440  +|   4048: 05 05 01 01 03 06 04 03 03 01 65 01 0e 04 05 05   ..........e.....
         9441  +|   4064: 01 01 02 08 04 0d 0e 06 01 03 00 12 04 4c 4c 00   .............LL.
         9442  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         9443  +| page 3 offset 8192
         9444  +|      0: 0a 00 00 00 03 0f ec 00 0f 00 00 00 00 00 00 00   ................
         9445  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         9446  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         9447  +| page 4 offset 12288
         9448  +|      0: 0d 00 00 00 04 0e 1a 00 0f c7 0f 5b 0e ef 0e 1a   ...........[....
         9449  +|   3600: 00 00 00 00 00 00 00 00 00 00 81 52 04 06 00 81   ...........R....
         9450  +|   3616: 5d 81 55 65 20 65 65 20 65 65 65 20 65 20 65 65   ].Ue ee eee e ee
         9451  +|   3632: 20 65 65 65 20 65 20 65 65 20 65 65 65 66 20 65    eee e ee eeef e
         9452  +|   3648: 65 20 65 65 65 20 65 20 65 65 20 65 65 65 20 65   e eee e ee eee e
         9453  +|   3664: 20 65 65 20 65 65 65 65 20 65 65 20 65 65 65 20    ee eeee ee eee 
         9454  +|   3680: 65 20 65 65 20 65 65 65 20 65 20 65 65 20 65 65   e ee eee e ee ee
         9455  +|   3696: 65 65 20 65 65 20 65 65 65 20 65 20 65 65 20 65   ee ee eee e ee e
         9456  +|   3712: 65 65 20 65 20 65 65 20 65 65 65 65 65 65 20 65   ee e ee eeeeee e
         9457  +|   3728: 65 20 65 20 65 20 65 20 65 65 20 65 65 65 20 65   e e e e ee eee e
         9458  +|   3744: 65 20 65 65 65 65 65 20 65 65 20 65 20 65 1f 65   e eeeee ee e e.e
         9459  +|   3760: 20 65 65 20 65 65 65 20 65 65 20 65 65 65 65 65    ee eee ee eeeee
         9460  +|   3776: 20 65 65 20 65 20 65 20 65 20 65 65 20 65 65 65    ee e e e ee eee
         9461  +|   3792: 20 65 65 20 65 65 65 65 65 20 65 65 20 65 20 65    ee eeeee ee e e
         9462  +|   3808: 20 65 20 65 65 20 65 65 65 20 65 65 20 65 65 6a    e ee eee ee eej
         9463  +|   3824: 03 03 ff 75 71 65 20 65 65 1f 65 65 65 20 65 20   ...uqe ee.eee e 
         9464  +|   3840: 65 65 20 65 65 65 20 65 20 65 65 20 65 65 65 65   ee eee e ee eeee
         9465  +|   3856: 20 65 65 20 65 65 65 20 65 20 65 65 20 65 65 65    ee eee e ee eee
         9466  +|   3872: 20 65 20 65 65 20 65 65 65 65 65 65 20 65 65 20    e ee eeeeee ee 
         9467  +|   3888: 65 20 65 20 65 20 65 65 20 65 65 65 20 65 65 20   e e e ee eee ee 
         9468  +|   3904: 65 65 65 65 65 20 65 65 20 65 20 65 20 65 20 65   eeeee ee e e e e
         9469  +|   3920: 65 20 65 65 65 20 65 65 20 65 65 6a 02 04 00 75   e eee ee eej...u
         9470  +|   3936: 40 65 20 65 65 20 65 65 65 20 65 20 65 65 20 65   @e ee eee e ee e
         9471  +|   3952: 65 65 20 65 20 65 65 20 65 65 65 65 20 65 65 20   ee e ee eeee ee 
         9472  +|   3968: 65 65 65 20 65 20 65 65 20 65 65 65 20 65 20 65   eee e ee eee e e
         9473  +|   3984: 65 20 65 65 65 65 65 65 20 65 65 20 65 20 65 20   e eeeeee ee e e 
         9474  +|   4000: 65 20 65 65 20 65 65 65 20 65 65 20 65 65 65 65   e ee eee ee eeee
         9475  +|   4016: 65 20 65 65 20 65 20 65 20 65 20 65 65 20 65 65   e ee e e e ee ee
         9476  +|   4032: 65 20 65 65 20 65 65 37 01 04 00 41 3f 65 20 65   e ee ee7...A?e e
         9477  +|   4048: 65 20 65 65 65 20 65 20 65 65 20 65 65 65 20 65   e eee e ee eee e
         9478  +|   4064: 20 65 65 20 65 65 65 65 65 65 20 65 65 20 65 20    ee eeeeee ee e 
         9479  +|   4080: 65 20 65 20 65 65 20 65 65 65 20 65 65 20 65 65   e e ee eee ee ee
         9480  +| page 5 offset 16384
         9481  +|      0: 0d 00 00 00 04 0f e4 00 0f f9 0f f2 0f eb 0f e4   ................
         9482  +|   4064: 00 00 00 00 05 04 03 00 10 21 21 05 03 03 00 10   .........!!.....
         9483  +|   4080: 11 11 05 02 03 00 10 11 11 05 01 03 00 10 09 09   ................
         9484  +| page 6 offset 20480
         9485  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         9486  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         9487  +| end crash-4470f0b94422f7.db
         9488  +}]} {}
         9489  +
         9490  +do_catchsql_test 64.1 {
         9491  +  SELECT * FROM ttt('e*');
         9492  +} {1 {database disk image is malformed}}
         9493  +
  9369   9494   
  9370   9495   sqlite3_fts5_may_be_corrupt 0
  9371   9496   finish_test
  9372   9497   

Changes to src/btree.c.

  6988   6988     assert( CORRUPT_DB || pPg->hdrOffset==0 );    /* Never called on page 1 */
  6989   6989     if( iEnd<=iFirst ) return 0;
  6990   6990     for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
  6991   6991     pEnd = pCArray->apEnd[k];
  6992   6992     while( 1 /*Exit by break*/ ){
  6993   6993       int sz, rc;
  6994   6994       u8 *pSlot;
  6995         -    sz = cachedCellSize(pCArray, i);
         6995  +    assert( pCArray->szCell[i]!=0 );
         6996  +    sz = pCArray->szCell[i];
  6996   6997       if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
  6997   6998         if( (pData - pBegin)<sz ) return 1;
  6998   6999         pData -= sz;
  6999   7000         pSlot = pData;
  7000   7001       }
  7001   7002       /* pSlot and pCArray->apCell[i] will never overlap on a well-formed
  7002   7003       ** database.  But they might for a corrupt database.  Hence use memmove()
................................................................................
  7149   7150       int iCell = (iOld + pPg->aiOvfl[i]) - iNew;
  7150   7151       if( iCell>=0 && iCell<nNew ){
  7151   7152         pCellptr = &pPg->aCellIdx[iCell * 2];
  7152   7153         if( nCell>iCell ){
  7153   7154           memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
  7154   7155         }
  7155   7156         nCell++;
         7157  +      cachedCellSize(pCArray, iCell+iNew);
  7156   7158         if( pageInsertArray(
  7157   7159               pPg, pBegin, &pData, pCellptr,
  7158   7160               iCell+iNew, 1, pCArray
  7159   7161         ) ) goto editpage_fail;
  7160   7162       }
  7161   7163     }
  7162   7164   

Changes to src/expr.c.

  1629   1629       sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
  1630   1630                       pColumns->nId, n);
  1631   1631       goto vector_append_error;
  1632   1632     }
  1633   1633   
  1634   1634     for(i=0; i<pColumns->nId; i++){
  1635   1635       Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
         1636  +    assert( pSubExpr!=0 || db->mallocFailed );
         1637  +    assert( pSubExpr==0 || pSubExpr->iTable==0 );
         1638  +    if( pSubExpr==0 ) continue;
         1639  +    pSubExpr->iTable = pColumns->nId;
  1636   1640       pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
  1637   1641       if( pList ){
  1638   1642         assert( pList->nExpr==iFirst+i+1 );
  1639   1643         pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;
  1640   1644         pColumns->a[i].zName = 0;
  1641   1645       }
  1642   1646     }
................................................................................
  2875   2879   ** or EXISTS operator:
  2876   2880   **
  2877   2881   **     (SELECT a FROM b)          -- subquery
  2878   2882   **     EXISTS (SELECT a FROM b)   -- EXISTS subquery
  2879   2883   **
  2880   2884   ** The pExpr parameter is the SELECT or EXISTS operator to be coded.
  2881   2885   **
  2882         -** The register that holds the result.  For a multi-column SELECT, 
         2886  +** Return the register that holds the result.  For a multi-column SELECT, 
  2883   2887   ** the result is stored in a contiguous array of registers and the
  2884   2888   ** return value is the register of the left-most result column.
  2885   2889   ** Return 0 if an error occurs.
  2886   2890   */
  2887   2891   #ifndef SQLITE_OMIT_SUBQUERY
  2888   2892   int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
  2889   2893     int addrOnce = 0;           /* Address of OP_Once at top of subroutine */
................................................................................
  3922   3926       }
  3923   3927       case TK_SELECT_COLUMN: {
  3924   3928         int n;
  3925   3929         if( pExpr->pLeft->iTable==0 ){
  3926   3930           pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
  3927   3931         }
  3928   3932         assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
  3929         -      if( pExpr->iTable
  3930         -       && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) 
         3933  +      if( pExpr->iTable!=0
         3934  +       && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
  3931   3935         ){
  3932   3936           sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
  3933   3937                                   pExpr->iTable, n);
  3934   3938         }
  3935   3939         return pExpr->pLeft->iTable + pExpr->iColumn;
  3936   3940       }
  3937   3941       case TK_IN: {

Changes to src/shell.c.in.

  1285   1285       sqlite3_result_error(context,
  1286   1286         "edit() cannot reopen temp file after edit", -1);
  1287   1287       goto edit_func_end;
  1288   1288     }
  1289   1289     fseek(f, 0, SEEK_END);
  1290   1290     sz = ftell(f);
  1291   1291     rewind(f);
  1292         -  p = sqlite3_malloc64( sz+(bBin==0) );
         1292  +  p = sqlite3_malloc64( sz+1 );
  1293   1293     if( p==0 ){
  1294   1294       sqlite3_result_error_nomem(context);
  1295   1295       goto edit_func_end;
  1296   1296     }
  1297   1297     x = fread(p, 1, (size_t)sz, f);
  1298   1298     fclose(f);
  1299   1299     f = 0;
................................................................................
  1762   1762   static void eqp_render_level(ShellState *p, int iEqpId){
  1763   1763     EQPGraphRow *pRow, *pNext;
  1764   1764     int n = strlen30(p->sGraph.zPrefix);
  1765   1765     char *z;
  1766   1766     for(pRow = eqp_next_row(p, iEqpId, 0); pRow; pRow = pNext){
  1767   1767       pNext = eqp_next_row(p, iEqpId, pRow);
  1768   1768       z = pRow->zText;
  1769         -    utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix, pNext ? "|--" : "`--", z);
         1769  +    utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix,
         1770  +                pNext ? "|--" : "`--", z);
  1770   1771       if( n<(int)sizeof(p->sGraph.zPrefix)-7 ){
  1771   1772         memcpy(&p->sGraph.zPrefix[n], pNext ? "|  " : "   ", 4);
  1772   1773         eqp_render_level(p, pRow->iEqpId);
  1773   1774         p->sGraph.zPrefix[n] = 0;
  1774   1775       }
  1775   1776     }
  1776   1777   }
................................................................................
  1953   1954             j--;
  1954   1955           }
  1955   1956           z[j++] = c;
  1956   1957         }
  1957   1958         while( j>0 && IsSpace(z[j-1]) ){ j--; }
  1958   1959         z[j] = 0;
  1959   1960         if( strlen30(z)>=79 ){
  1960         -        for(i=j=0; (c = z[i])!=0; i++){  /* Copy changes from z[i] back to z[j] */
         1961  +        for(i=j=0; (c = z[i])!=0; i++){ /* Copy from z[i] back to z[j] */
  1961   1962             if( c==cEnd ){
  1962   1963               cEnd = 0;
  1963   1964             }else if( c=='"' || c=='\'' || c=='`' ){
  1964   1965               cEnd = c;
  1965   1966             }else if( c=='[' ){
  1966   1967               cEnd = ']';
  1967   1968             }else if( c=='-' && z[i+1]=='-' ){
................................................................................
  2532   2533       raw_printf(pArg->out, "Fullscan Steps:                      %d\n", iCur);
  2533   2534       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
  2534   2535       raw_printf(pArg->out, "Sort Operations:                     %d\n", iCur);
  2535   2536       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
  2536   2537       raw_printf(pArg->out, "Autoindex Inserts:                   %d\n", iCur);
  2537   2538       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
  2538   2539       raw_printf(pArg->out, "Virtual Machine Steps:               %d\n", iCur);
  2539         -    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE, bReset);
         2540  +    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
  2540   2541       raw_printf(pArg->out, "Reprepare operations:                %d\n", iCur);
  2541   2542       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_RUN, bReset);
  2542   2543       raw_printf(pArg->out, "Number of times run:                 %d\n", iCur);
  2543   2544       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_MEMUSED, bReset);
  2544   2545       raw_printf(pArg->out, "Memory used by prepared stmt:        %d\n", iCur);
  2545   2546     }
  2546   2547   
................................................................................
  3455   3456   ** start of the description of what that command does.
  3456   3457   */
  3457   3458   static const char *(azHelp[]) = {
  3458   3459   #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
  3459   3460     ".archive ...             Manage SQL archives",
  3460   3461     "   Each command must have exactly one of the following options:",
  3461   3462     "     -c, --create               Create a new archive",
  3462         -  "     -u, --update               Add files or update files with changed mtime",
  3463         -  "     -i, --insert               Like -u but always add even if mtime unchanged",
         3463  +  "     -u, --update               Add or update files with changed mtime",
         3464  +  "     -i, --insert               Like -u but always add even if unchanged",
  3464   3465     "     -t, --list                 List contents of archive",
  3465   3466     "     -x, --extract              Extract files from archive",
  3466   3467     "   Optional arguments:",
  3467   3468     "     -v, --verbose              Print each filename as it is processed",
  3468         -  "     -f FILE, --file FILE       Operate on archive FILE (default is current db)",
  3469         -  "     -a FILE, --append FILE     Operate on FILE opened using the apndvfs VFS",
  3470         -  "     -C DIR, --directory DIR    Change to directory DIR to read/extract files",
         3469  +  "     -f FILE, --file FILE       Use archive FILE (default is current db)",
         3470  +  "     -a FILE, --append FILE     Open FILE using the apndvfs VFS",
         3471  +  "     -C DIR, --directory DIR    Read/extract files from directory DIR",
  3471   3472     "     -n, --dryrun               Show the SQL that would have occurred",
  3472   3473     "   Examples:",
  3473         -  "     .ar -cf archive.sar foo bar  # Create archive.sar from files foo and bar",
  3474         -  "     .ar -tf archive.sar          # List members of archive.sar",
  3475         -  "     .ar -xvf archive.sar         # Verbosely extract files from archive.sar",
         3474  +  "     .ar -cf ARCHIVE foo bar  # Create ARCHIVE from files foo and bar",
         3475  +  "     .ar -tf ARCHIVE          # List members of ARCHIVE",
         3476  +  "     .ar -xvf ARCHIVE         # Verbosely extract files from ARCHIVE",
  3476   3477     "   See also:",
  3477   3478     "      http://sqlite.org/cli.html#sqlar_archive_support",
  3478   3479   #endif
  3479   3480   #ifndef SQLITE_OMIT_AUTHORIZATION
  3480   3481     ".auth ON|OFF             Show authorizer callbacks",
  3481   3482   #endif
  3482   3483     ".backup ?DB? FILE        Backup DB (default \"main\") to FILE",
  3483   3484     "       --append            Use the appendvfs",
  3484         -  "       --async             Write to FILE without a journal and without fsync()",
         3485  +  "       --async             Write to FILE without journal and fsync()",
  3485   3486     ".bail on|off             Stop after hitting an error.  Default OFF",
  3486   3487     ".binary on|off           Turn binary output on or off.  Default OFF",
  3487   3488     ".cd DIRECTORY            Change the working directory to DIRECTORY",
  3488   3489     ".changes on|off          Show number of rows changed by SQL",
  3489   3490     ".check GLOB              Fail if output since .testcase does not match",
  3490   3491     ".clone NEWDB             Clone data into NEWDB from the existing database",
  3491   3492     ".databases               List names and files of attached databases",
................................................................................
  3497   3498     "     --newlines             Allow unescaped newline characters in output",
  3498   3499     "   TABLE is a LIKE pattern for the tables to dump",
  3499   3500     ".echo on|off             Turn command echo on or off",
  3500   3501     ".eqp on|off|full|...     Enable or disable automatic EXPLAIN QUERY PLAN",
  3501   3502     "   Other Modes:",
  3502   3503   #ifdef SQLITE_DEBUG
  3503   3504     "      test                  Show raw EXPLAIN QUERY PLAN output",
  3504         -  "      trace                 Like \"full\" but also enable \"PRAGMA vdbe_trace\"",
         3505  +  "      trace                 Like \"full\" but enable \"PRAGMA vdbe_trace\"",
  3505   3506   #endif
  3506   3507     "      trigger               Like \"full\" but also show trigger bytecode",
  3507         -  ".excel                   Display the output of next command in a spreadsheet",
         3508  +  ".excel                   Display the output of next command in spreadsheet",
  3508   3509     ".exit ?CODE?             Exit this program with return-code CODE",
  3509         -  ".expert                  EXPERIMENTAL. Suggest indexes for specified queries",
         3510  +  ".expert                  EXPERIMENTAL. Suggest indexes for queries",
  3510   3511   /* Because explain mode comes on automatically now, the ".explain" mode
  3511         -** is removed from the help screen.  It is still supported for legacy, however */
  3512         -/*".explain ?on|off|auto?   Turn EXPLAIN output mode on or off or to automatic",*/
         3512  +** is removed from the help screen. It is still supported for legacy, however */
         3513  +/*".explain ?on|off|auto?   Turn EXPLAIN output mode on or off",*/
  3513   3514     ".filectrl CMD ...        Run various sqlite3_file_control() operations",
  3514   3515     "                           Run \".filectrl\" with no arguments for details",
  3515   3516     ".fullschema ?--indent?   Show schema and the content of sqlite_stat tables",
  3516   3517     ".headers on|off          Turn display of headers on or off",
  3517   3518     ".help ?-all? ?PATTERN?   Show help text for PATTERN",
  3518   3519     ".import FILE TABLE       Import data from FILE into TABLE",
  3519   3520   #ifndef SQLITE_OMIT_TEST_CONTROL
................................................................................
  3552   3553     "       -e    Invoke system text editor",
  3553   3554     "       -x    Open in a spreadsheet",
  3554   3555     ".open ?OPTIONS? ?FILE?   Close existing database and reopen FILE",
  3555   3556     "     Options:",
  3556   3557     "        --append        Use appendvfs to append database to the end of FILE",
  3557   3558   #ifdef SQLITE_ENABLE_DESERIALIZE
  3558   3559     "        --deserialize   Load into memory useing sqlite3_deserialize()",
  3559         -  "        --hexdb         Load the output of \"dbtotxt\" as an in-memory database",
         3560  +  "        --hexdb         Load the output of \"dbtotxt\" as an in-memory db",
  3560   3561     "        --maxsize N     Maximum size for --hexdb or --deserialized database",
  3561   3562   #endif
  3562   3563     "        --new           Initialize FILE to an empty database",
  3563   3564     "        --readonly      Open FILE readonly",
  3564   3565     "        --zip           FILE is a ZIP archive",
  3565   3566     ".output ?FILE?           Send output to FILE or stdout if FILE is omitted",
  3566   3567     "     If FILE begins with '|' then open it as a pipe.",
  3567   3568     ".parameter CMD ...       Manage SQL parameter bindings",
  3568   3569     "   clear                   Erase all bindings",
  3569   3570     "   init                    Initialize the TEMP table that holds bindings",
  3570   3571     "   list                    List the current parameter bindings",
  3571   3572     "   set PARAMETER VALUE     Given SQL parameter PARAMETER a value of VALUE",
  3572         -  "                           PARAMETER should start with '$', ':', '@', or '?'",
         3573  +  "                           PARAMETER should start with one of: $ : @ ?",
  3573   3574     "   unset PARAMETER         Remove PARAMETER from the binding table",
  3574   3575     ".print STRING...         Print literal STRING",
  3575   3576   #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
  3576   3577     ".progress N              Invoke progress handler after every N opcodes",
  3577   3578     "   --limit N                 Interrupt after N progress callbacks",
  3578   3579     "   --once                    Do no more than one progress interrupt",
  3579   3580     "   --quiet|-q                No output except at interrupts",
................................................................................
  3580   3581     "   --reset                   Reset the count for each input and interrupt",
  3581   3582   #endif
  3582   3583     ".prompt MAIN CONTINUE    Replace the standard prompts",
  3583   3584     ".quit                    Exit this program",
  3584   3585     ".read FILE               Read input from FILE",
  3585   3586   #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
  3586   3587     ".recover                 Recover as much data as possible from corrupt db.",
         3588  +  "   --freelist-corrupt       Assume the freelist is corrupt",
         3589  +  "   --recovery-db NAME       Store recovery metadata in database file NAME",
         3590  +  "   --lost-and-found TABLE   Alternative name for the lost-and-found table",
  3587   3591   #endif
  3588   3592     ".restore ?DB? FILE       Restore content of DB (default \"main\") from FILE",
  3589   3593     ".save FILE               Write in-memory database into FILE",
  3590   3594     ".scanstats on|off        Turn sqlite3_stmt_scanstatus() metrics on or off",
  3591   3595     ".schema ?PATTERN?        Show the CREATE statements matching PATTERN",
  3592   3596     "     Options:",
  3593   3597     "         --indent            Try to pretty-print the schema",
................................................................................
  3611   3615     "     patchset FILE            Write a patchset into FILE",
  3612   3616     "   If ?NAME? is omitted, the first defined session is used.",
  3613   3617   #endif
  3614   3618     ".sha3sum ...             Compute a SHA3 hash of database content",
  3615   3619     "    Options:",
  3616   3620     "      --schema              Also hash the sqlite_master table",
  3617   3621     "      --sha3-224            Use the sha3-224 algorithm",
  3618         -  "      --sha3-256            Use the sha3-256 algorithm.  This is the default.",
         3622  +  "      --sha3-256            Use the sha3-256 algorithm (default)",
  3619   3623     "      --sha3-384            Use the sha3-384 algorithm",
  3620   3624     "      --sha3-512            Use the sha3-512 algorithm",
  3621   3625     "    Any other argument is a LIKE pattern for tables to hash",
  3622   3626   #ifndef SQLITE_NOHAVE_SYSTEM
  3623   3627     ".shell CMD ARGS...       Run CMD ARGS... in a system shell",
  3624   3628   #endif
  3625   3629     ".show                    Show the current values for various settings",
................................................................................
  5519   5523       }
  5520   5524       *pRc = rc;
  5521   5525     }
  5522   5526   }
  5523   5527   #endif /* !defined SQLITE_OMIT_VIRTUALTABLE */
  5524   5528   
  5525   5529   #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
  5526         -/*********************************************************************************
         5530  +/******************************************************************************
  5527   5531   ** The ".archive" or ".ar" command.
  5528   5532   */
  5529   5533   /*
  5530   5534   ** Structure representing a single ".ar" command.
  5531   5535   */
  5532   5536   typedef struct ArCommand ArCommand;
  5533   5537   struct ArCommand {
................................................................................
  5717   5721               }
  5718   5722               if( pOpt->bArg ){
  5719   5723                 if( i<(n-1) ){
  5720   5724                   zArg = &z[i+1];
  5721   5725                   i = n;
  5722   5726                 }else{
  5723   5727                   if( iArg>=(nArg-1) ){
  5724         -                  return arErrorMsg(pAr, "option requires an argument: %c",z[i]);
         5728  +                  return arErrorMsg(pAr, "option requires an argument: %c",
         5729  +                                    z[i]);
  5725   5730                   }
  5726   5731                   zArg = azArg[++iArg];
  5727   5732                 }
  5728   5733               }
  5729   5734               if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR;
  5730   5735             }
  5731   5736           }else if( z[2]=='\0' ){
................................................................................
  6105   6110     return rc;
  6106   6111   }
  6107   6112   
  6108   6113   /*
  6109   6114   ** Implementation of ".ar" dot command.
  6110   6115   */
  6111   6116   static int arDotCommand(
  6112         -  ShellState *pState,             /* Current shell tool state */
  6113         -  int fromCmdLine,                /* True if -A command-line option, not .ar cmd */
  6114         -  char **azArg,                   /* Array of arguments passed to dot command */
  6115         -  int nArg                        /* Number of entries in azArg[] */
         6117  +  ShellState *pState,          /* Current shell tool state */
         6118  +  int fromCmdLine,             /* True if -A command-line option, not .ar cmd */
         6119  +  char **azArg,                /* Array of arguments passed to dot command */
         6120  +  int nArg                     /* Number of entries in azArg[] */
  6116   6121   ){
  6117   6122     ArCommand cmd;
  6118   6123     int rc;
  6119   6124     memset(&cmd, 0, sizeof(cmd));
  6120   6125     cmd.fromCmdLine = fromCmdLine;
  6121   6126     rc = arParseCommand(azArg, nArg, &cmd);
  6122   6127     if( rc==SQLITE_OK ){
................................................................................
  6208   6213       close_db(cmd.db);
  6209   6214     }
  6210   6215     sqlite3_free(cmd.zSrcTable);
  6211   6216   
  6212   6217     return rc;
  6213   6218   }
  6214   6219   /* End of the ".archive" or ".ar" command logic
  6215         -**********************************************************************************/
         6220  +*******************************************************************************/
  6216   6221   #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */
  6217   6222   
  6218   6223   #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
  6219   6224   /*
  6220   6225   ** If (*pRc) is not SQLITE_OK when this function is called, it is a no-op.
  6221   6226   ** Otherwise, the SQL statement or statements in zSql are executed using
  6222   6227   ** database connection db and the error code written to *pRc before
................................................................................
  6600   6605         zRecoveryDb = azArg[i];
  6601   6606       }else
  6602   6607       if( n<=15 && memcmp("-lost-and-found", z, n)==0 && i<(nArg-1) ){
  6603   6608         i++;
  6604   6609         zLostAndFound = azArg[i];
  6605   6610       }
  6606   6611       else{
  6607         -      raw_printf(stderr, "unexpected option: %s\n", azArg[i]); 
  6608         -      raw_printf(stderr, "options are:\n");
  6609         -      raw_printf(stderr, "    --freelist-corrupt\n");
  6610         -      raw_printf(stderr, "    --recovery-db DATABASE\n");
  6611         -      raw_printf(stderr, "    --lost-and-found TABLE-NAME\n");
         6612  +      utf8_printf(stderr, "unexpected option: %s\n", azArg[i]); 
         6613  +      showHelp(pState->out, azArg[0]);
  6612   6614         return 1;
  6613   6615       }
  6614   6616     }
  6615   6617   
  6616   6618     shellExecPrintf(pState->db, &rc,
  6617   6619       /* Attach an in-memory database named 'recovery'. Create an indexed 
  6618   6620       ** cache of the sqlite_dbptr virtual table. */
................................................................................
  6706   6708       "      SELECT 0, i, (SELECT pgno FROM recovery.dbptr WHERE child=i)"
  6707   6709       "        UNION "
  6708   6710       "      SELECT i, p.parent, "
  6709   6711       "        (SELECT pgno FROM recovery.dbptr WHERE child=p.parent) FROM p"
  6710   6712       "    )"
  6711   6713       "    SELECT pgno FROM p WHERE (parent IS NULL OR pgno = orig)"
  6712   6714       ") "
  6713         -    "FROM pages WHERE maxlen > 0 AND i NOT IN freelist;"
         6715  +    "FROM pages WHERE maxlen IS NOT NULL AND i NOT IN freelist;"
  6714   6716       "UPDATE recovery.map AS o SET intkey = ("
  6715   6717       "  SELECT substr(data, 1, 1)==X'0D' FROM sqlite_dbpage WHERE pgno=o.pgno"
  6716   6718       ");"
  6717   6719   
  6718   6720       /* Extract data from page 1 and any linked pages into table
  6719   6721       ** recovery.schema. With the same schema as an sqlite_master table.  */
  6720   6722       "CREATE TABLE recovery.schema(type, name, tbl_name, rootpage, sql);"
................................................................................
  8463   8465           appendText(&sSelect, ".sqlite_master", 0);
  8464   8466         }
  8465   8467         sqlite3_finalize(pStmt);
  8466   8468   #ifndef SQLITE_OMIT_INTROSPECTION_PRAGMAS
  8467   8469         if( zName ){
  8468   8470           appendText(&sSelect,
  8469   8471              " UNION ALL SELECT shell_module_schema(name),"
  8470         -           " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0);
         8472  +           " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list",
         8473  +        0);
  8471   8474         }
  8472   8475   #endif
  8473   8476         appendText(&sSelect, ") WHERE ", 0);
  8474   8477         if( zName ){
  8475   8478           char *zQarg = sqlite3_mprintf("%Q", zName);
  8476   8479           int bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
  8477   8480                       strchr(zName, '[') != 0;
................................................................................
  8562   8565       */
  8563   8566       if( strcmp(azCmd[0],"changeset")==0 || strcmp(azCmd[0],"patchset")==0 ){
  8564   8567         FILE *out = 0;
  8565   8568         if( nCmd!=2 ) goto session_syntax_error;
  8566   8569         if( pSession->p==0 ) goto session_not_open;
  8567   8570         out = fopen(azCmd[1], "wb");
  8568   8571         if( out==0 ){
  8569         -        utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n", azCmd[1]);
         8572  +        utf8_printf(stderr, "ERROR: cannot open \"%s\" for writing\n",
         8573  +                    azCmd[1]);
  8570   8574         }else{
  8571   8575           int szChng;
  8572   8576           void *pChng;
  8573   8577           if( azCmd[0][0]=='c' ){
  8574   8578             rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);
  8575   8579           }else{
  8576   8580             rc = sqlite3session_patchset(pSession->p, &szChng, &pChng);
................................................................................
  8883   8887           }else
  8884   8888           if( strcmp(z,"debug")==0 ){
  8885   8889             bDebug = 1;
  8886   8890           }else
  8887   8891           {
  8888   8892             utf8_printf(stderr, "Unknown option \"%s\" on \"%s\"\n",
  8889   8893                         azArg[i], azArg[0]);
  8890         -          raw_printf(stderr, "Should be one of: --schema"
  8891         -                             " --sha3-224 --sha3-256 --sha3-384 --sha3-512\n");
         8894  +          showHelp(p->out, azArg[0]);
  8892   8895             rc = 1;
  8893   8896             goto meta_command_exit;
  8894   8897           }
  8895   8898         }else if( zLike ){
  8896   8899           raw_printf(stderr, "Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\n");
  8897   8900           rc = 1;
  8898   8901           goto meta_command_exit;
................................................................................
  9162   9165   #ifndef SQLITE_UNTESTABLE
  9163   9166     if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 ){
  9164   9167       static const struct {
  9165   9168          const char *zCtrlName;   /* Name of a test-control option */
  9166   9169          int ctrlCode;            /* Integer code for that option */
  9167   9170          const char *zUsage;      /* Usage notes */
  9168   9171       } aCtrl[] = {
  9169         -      { "always",             SQLITE_TESTCTRL_ALWAYS,        "BOOLEAN"            },
  9170         -      { "assert",             SQLITE_TESTCTRL_ASSERT,        "BOOLEAN"            },
  9171         -    /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, ""          },*/
  9172         -    /*{ "bitvec_test",        SQLITE_TESTCTRL_BITVEC_TEST,   ""                },*/
  9173         -      { "byteorder",          SQLITE_TESTCTRL_BYTEORDER,     ""                   },
  9174         -      { "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,"BOOLEAN"       },
  9175         -    /*{ "fault_install",      SQLITE_TESTCTRL_FAULT_INSTALL, ""                }, */
  9176         -      { "imposter",           SQLITE_TESTCTRL_IMPOSTER,   "SCHEMA ON/OFF ROOTPAGE"},
  9177         -      { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN"       },
  9178         -      { "localtime_fault",    SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN"           },
  9179         -      { "never_corrupt",      SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN"            },
  9180         -      { "optimizations",      SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK"       },
         9172  +      { "always",             SQLITE_TESTCTRL_ALWAYS,        "BOOLEAN"        },
         9173  +      { "assert",             SQLITE_TESTCTRL_ASSERT,        "BOOLEAN"        },
         9174  +    /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, ""       },*/
         9175  +    /*{ "bitvec_test",        SQLITE_TESTCTRL_BITVEC_TEST,   ""             },*/
         9176  +      { "byteorder",          SQLITE_TESTCTRL_BYTEORDER,     ""               },
         9177  +      { "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,"BOOLEAN"   },
         9178  +    /*{ "fault_install",      SQLITE_TESTCTRL_FAULT_INSTALL, ""             },*/
         9179  +      { "imposter",         SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"},
         9180  +      { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN"   },
         9181  +      { "localtime_fault",    SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN"       },
         9182  +      { "never_corrupt",      SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN"        },
         9183  +      { "optimizations",      SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK"   },
  9181   9184   #ifdef YYCOVERAGE
  9182         -      { "parser_coverage",    SQLITE_TESTCTRL_PARSER_COVERAGE, ""                 },
         9185  +      { "parser_coverage",    SQLITE_TESTCTRL_PARSER_COVERAGE, ""             },
  9183   9186   #endif
  9184         -      { "pending_byte",       SQLITE_TESTCTRL_PENDING_BYTE,  "OFFSET  "           },
  9185         -      { "prng_restore",       SQLITE_TESTCTRL_PRNG_RESTORE,  ""                   },
  9186         -      { "prng_save",          SQLITE_TESTCTRL_PRNG_SAVE,     ""                   },
  9187         -      { "prng_seed",          SQLITE_TESTCTRL_PRNG_SEED,     "SEED ?db?"          },
  9188         -      { "reserve",            SQLITE_TESTCTRL_RESERVE,       "BYTES-OF-RESERVE"   },
         9187  +      { "pending_byte",       SQLITE_TESTCTRL_PENDING_BYTE,  "OFFSET  "       },
         9188  +      { "prng_restore",       SQLITE_TESTCTRL_PRNG_RESTORE,  ""               },
         9189  +      { "prng_save",          SQLITE_TESTCTRL_PRNG_SAVE,     ""               },
         9190  +      { "prng_seed",          SQLITE_TESTCTRL_PRNG_SEED,     "SEED ?db?"      },
         9191  +      { "reserve",            SQLITE_TESTCTRL_RESERVE,      "BYTES-OF-RESERVE"},
  9189   9192       };
  9190   9193       int testctrl = -1;
  9191   9194       int iCtrl = -1;
  9192   9195       int rc2 = 0;    /* 0: usage.  1: %d  2: %x  3: no-output */
  9193   9196       int isOk = 0;
  9194   9197       int i, n2;
  9195   9198       const char *zCmd = 0;
................................................................................
  9324   9327               sqlite3_test_control(testctrl, p->out);
  9325   9328               isOk = 3;
  9326   9329             }
  9327   9330   #endif
  9328   9331         }
  9329   9332       }
  9330   9333       if( isOk==0 && iCtrl>=0 ){
  9331         -      utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd, aCtrl[iCtrl].zUsage);
         9334  +      utf8_printf(p->out, "Usage: .testctrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
  9332   9335         rc = 1;
  9333   9336       }else if( isOk==1 ){
  9334   9337         raw_printf(p->out, "%d\n", rc2);
  9335   9338       }else if( isOk==2 ){
  9336   9339         raw_printf(p->out, "0x%08x\n", rc2);
  9337   9340       }
  9338   9341     }else
................................................................................
  9441   9444       open_db(p, 0);
  9442   9445       if( strcmp(azArg[1],"login")==0 ){
  9443   9446         if( nArg!=4 ){
  9444   9447           raw_printf(stderr, "Usage: .user login USER PASSWORD\n");
  9445   9448           rc = 1;
  9446   9449           goto meta_command_exit;
  9447   9450         }
  9448         -      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], strlen30(azArg[3]));
         9451  +      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
         9452  +                                     strlen30(azArg[3]));
  9449   9453         if( rc ){
  9450   9454           utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]);
  9451   9455           rc = 1;
  9452   9456         }
  9453   9457       }else if( strcmp(azArg[1],"add")==0 ){
  9454   9458         if( nArg!=5 ){
  9455   9459           raw_printf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n");

Changes to src/sqliteInt.h.

  2469   2469   #if SQLITE_MAX_EXPR_DEPTH>0
  2470   2470     int nHeight;           /* Height of the tree headed by this node */
  2471   2471   #endif
  2472   2472     int iTable;            /* TK_COLUMN: cursor number of table holding column
  2473   2473                            ** TK_REGISTER: register number
  2474   2474                            ** TK_TRIGGER: 1 -> new, 0 -> old
  2475   2475                            ** EP_Unlikely:  134217728 times likelihood
         2476  +                         ** TK_SELECT_COLUMN: Number of columns on the LHS
  2476   2477                            ** TK_SELECT: 1st register of result vector */
  2477   2478     ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.
  2478   2479                            ** TK_VARIABLE: variable number (always >= 1).
  2479   2480                            ** TK_SELECT_COLUMN: column of the result vector */
  2480   2481     i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
  2481   2482     i16 iRightJoinTable;   /* If EP_FromJoin, the right table of the join */
  2482   2483     u8 op2;                /* TK_REGISTER/TK_TRUTH: original value of Expr.op

Changes to test/rowvalue7.test.

    51     51     UPDATE t1 SET (c,d) = (SELECT x,y,z FROM t2 WHERE w=a);
    52     52   } {1 {2 columns assigned 3 values}}
    53     53   
    54     54   do_catchsql_test 2.2 {
    55     55     UPDATE t1 SET (b,c,d) = (SELECT x,y FROM t2 WHERE w=a);
    56     56   } {1 {3 columns assigned 2 values}}
    57     57   
           58  +# 2019-08-26
           59  +# ticket https://www.sqlite.org/src/info/78acc9d40f0786e8
           60  +#
           61  +do_catchsql_test 3.0 {
           62  +  DROP TABLE IF EXISTS t1;
           63  +  CREATE TABLE t1(a,b);
           64  +  INSERT INTO t1 VALUES(1,2);
           65  +  UPDATE t1 SET (a,a,a,b)=(SELECT 99,100);
           66  +} {1 {4 columns assigned 2 values}}
           67  +
    58     68   finish_test