/ Check-in [d9768de5]
Login

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

Overview
Comment:Merge recent trunk changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tempfiles-25
Files: files | file ages | folders
SHA1:d9768de502e34da42f3ad955947c23da50f57bce
User & Date: drh 2016-04-18 13:36:17
Context
2016-04-21
15:03
Merge updates from trunk. check-in: cc28106e user: drh tags: tempfiles-25
2016-04-18
13:36
Merge recent trunk changes. check-in: d9768de5 user: drh tags: tempfiles-25
13:30
sqlite3PCachePerecentDirty() should return 0 if the pcache is empty. check-in: 85f3d80e user: drh tags: tempfiles-25
13:09
The last parameter to pread64() and pwrite64() should be off64_t, not off_t. check-in: 3a7d7298 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/icu/icu.c.

   350    350   **
   351    351   **     lower('I', 'en_us') -> 'i'
   352    352   **     lower('I', 'tr_tr') -> 'ı' (small dotless i)
   353    353   **
   354    354   ** http://www.icu-project.org/userguide/posix.html#case_mappings
   355    355   */
   356    356   static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
   357         -  const UChar *zInput;
   358         -  UChar *zOutput = 0;
   359         -  int nInput;
   360         -  int nOut;
          357  +  const UChar *zInput;            /* Pointer to input string */
          358  +  UChar *zOutput = 0;             /* Pointer to output buffer */
          359  +  int nInput;                     /* Size of utf-16 input string in bytes */
          360  +  int nOut;                       /* Size of output buffer in bytes */
   361    361     int cnt;
          362  +  int bToUpper;                   /* True for toupper(), false for tolower() */
   362    363     UErrorCode status;
   363    364     const char *zLocale = 0;
   364    365   
   365    366     assert(nArg==1 || nArg==2);
          367  +  bToUpper = (sqlite3_user_data(p)!=0);
   366    368     if( nArg==2 ){
   367    369       zLocale = (const char *)sqlite3_value_text(apArg[1]);
   368    370     }
   369    371   
   370    372     zInput = sqlite3_value_text16(apArg[0]);
   371    373     if( !zInput ){
   372    374       return;
................................................................................
   382    384       if( zNew==0 ){
   383    385         sqlite3_free(zOutput);
   384    386         sqlite3_result_error_nomem(p);
   385    387         return;
   386    388       }
   387    389       zOutput = zNew;
   388    390       status = U_ZERO_ERROR;
   389         -    if( sqlite3_user_data(p) ){
          391  +    if( bToUpper ){
   390    392         nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);
   391    393       }else{
   392    394         nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);
   393    395       }
   394         -    if( !U_SUCCESS(status) ){
   395         -      if( status==U_BUFFER_OVERFLOW_ERROR ) continue;
   396         -      icuFunctionError(p,
   397         -          sqlite3_user_data(p) ? "u_strToUpper" : "u_strToLower", status);
   398         -      return;
          396  +
          397  +    if( U_SUCCESS(status) ){
          398  +      sqlite3_result_text16(p, zOutput, nOut, xFree);
          399  +    }else if( status==U_BUFFER_OVERFLOW_ERROR ){
          400  +      assert( cnt==0 );
          401  +      continue;
          402  +    }else{
          403  +      icuFunctionError(p, bToUpper ? "u_strToUpper" : "u_strToLower", status);
   399    404       }
          405  +    return;
   400    406     }
   401         -  sqlite3_result_text16(p, zOutput, nOut, xFree);
          407  +  assert( 0 );     /* Unreachable */
   402    408   }
   403    409   
   404    410   /*
   405    411   ** Collation sequence destructor function. The pCtx argument points to
   406    412   ** a UCollator structure previously allocated using ucol_open().
   407    413   */
   408    414   static void icuCollationDel(void *pCtx){

Changes to src/os.c.

    77     77   
    78     78   /*
    79     79   ** The following routines are convenience wrappers around methods
    80     80   ** of the sqlite3_file object.  This is mostly just syntactic sugar. All
    81     81   ** of this would be completely automatic if SQLite were coded using
    82     82   ** C++ instead of plain old C.
    83     83   */
    84         -int sqlite3OsClose(sqlite3_file *pId){
    85         -  int rc = SQLITE_OK;
           84  +void sqlite3OsClose(sqlite3_file *pId){
    86     85     if( pId->pMethods ){
    87         -    rc = pId->pMethods->xClose(pId);
           86  +    pId->pMethods->xClose(pId);
    88     87       pId->pMethods = 0;
    89     88     }
    90         -  return rc;
    91     89   }
    92     90   int sqlite3OsRead(sqlite3_file *id, void *pBuf, int amt, i64 offset){
    93     91     DO_OS_MALLOC_TEST(id);
    94     92     return id->pMethods->xRead(id, pBuf, amt, offset);
    95     93   }
    96     94   int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){
    97     95     DO_OS_MALLOC_TEST(id);
................................................................................
   301    299         *ppFile = pFile;
   302    300       }
   303    301     }else{
   304    302       rc = SQLITE_NOMEM_BKPT;
   305    303     }
   306    304     return rc;
   307    305   }
   308         -int sqlite3OsCloseFree(sqlite3_file *pFile){
   309         -  int rc = SQLITE_OK;
          306  +void sqlite3OsCloseFree(sqlite3_file *pFile){
   310    307     assert( pFile );
   311         -  rc = sqlite3OsClose(pFile);
          308  +  sqlite3OsClose(pFile);
   312    309     sqlite3_free(pFile);
   313         -  return rc;
   314    310   }
   315    311   
   316    312   /*
   317    313   ** This function is a wrapper around the OS specific implementation of
   318    314   ** sqlite3_os_init(). The purpose of the wrapper is to provide the
   319    315   ** ability to simulate a malloc failure, so that the handling of an
   320    316   ** error in sqlite3_os_init() by the upper layers can be tested.

Changes to src/os.h.

   156    156   ** Wrapper around OS specific sqlite3_os_init() function.
   157    157   */
   158    158   int sqlite3OsInit(void);
   159    159   
   160    160   /* 
   161    161   ** Functions for accessing sqlite3_file methods 
   162    162   */
   163         -int sqlite3OsClose(sqlite3_file*);
          163  +void sqlite3OsClose(sqlite3_file*);
   164    164   int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset);
   165    165   int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);
   166    166   int sqlite3OsTruncate(sqlite3_file*, i64 size);
   167    167   int sqlite3OsSync(sqlite3_file*, int);
   168    168   int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);
   169    169   int sqlite3OsLock(sqlite3_file*, int);
   170    170   int sqlite3OsUnlock(sqlite3_file*, int);
................................................................................
   201    201   int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*);
   202    202   
   203    203   /*
   204    204   ** Convenience functions for opening and closing files using 
   205    205   ** sqlite3_malloc() to obtain space for the file-handle structure.
   206    206   */
   207    207   int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);
   208         -int sqlite3OsCloseFree(sqlite3_file *);
          208  +void sqlite3OsCloseFree(sqlite3_file *);
   209    209   
   210    210   #endif /* _SQLITE_OS_H_ */

Changes to src/os_unix.c.

   401    401   #define osPread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)
   402    402   
   403    403   #if defined(USE_PREAD64)
   404    404     { "pread64",      (sqlite3_syscall_ptr)pread64,    0  },
   405    405   #else
   406    406     { "pread64",      (sqlite3_syscall_ptr)0,          0  },
   407    407   #endif
   408         -#define osPread64   ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)
          408  +#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
   409    409   
   410    410     { "write",        (sqlite3_syscall_ptr)write,      0  },
   411    411   #define osWrite     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
   412    412   
   413    413   #if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
   414    414     { "pwrite",       (sqlite3_syscall_ptr)pwrite,     0  },
   415    415   #else
................................................................................
   419    419                       aSyscall[12].pCurrent)
   420    420   
   421    421   #if defined(USE_PREAD64)
   422    422     { "pwrite64",     (sqlite3_syscall_ptr)pwrite64,   0  },
   423    423   #else
   424    424     { "pwrite64",     (sqlite3_syscall_ptr)0,          0  },
   425    425   #endif
   426         -#define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off_t))\
          426  +#define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
   427    427                       aSyscall[13].pCurrent)
   428    428   
   429    429     { "fchmod",       (sqlite3_syscall_ptr)fchmod,          0  },
   430    430   #define osFchmod    ((int(*)(int,mode_t))aSyscall[14].pCurrent)
   431    431   
   432    432   #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
   433    433     { "fallocate",    (sqlite3_syscall_ptr)posix_fallocate,  0 },

Changes to src/pager.h.

    64     64   ** Valid values for the second argument to sqlite3PagerLockingMode().
    65     65   */
    66     66   #define PAGER_LOCKINGMODE_QUERY      -1
    67     67   #define PAGER_LOCKINGMODE_NORMAL      0
    68     68   #define PAGER_LOCKINGMODE_EXCLUSIVE   1
    69     69   
    70     70   /*
    71         -** Numeric constants that encode the journalmode.  
           71  +** Numeric constants that encode the journalmode.
           72  +**
           73  +** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY)
           74  +** are exposed in the API via the "PRAGMA journal_mode" command and
           75  +** therefore cannot be changed without a compatibility break.
    72     76   */
    73     77   #define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */
    74     78   #define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */
    75     79   #define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */
    76     80   #define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */
    77     81   #define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */
    78     82   #define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */
................................................................................
    82     86   ** Flags that make up the mask passed to sqlite3PagerGet().
    83     87   */
    84     88   #define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */
    85     89   #define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */
    86     90   
    87     91   /*
    88     92   ** Flags for sqlite3PagerSetFlags()
           93  +**
           94  +** Value constraints (enforced via assert()):
           95  +**    PAGER_FULLFSYNC      == SQLITE_FullFSync
           96  +**    PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync
           97  +**    PAGER_CACHE_SPILL    == SQLITE_CacheSpill
    89     98   */
    90     99   #define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */
    91    100   #define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */
    92    101   #define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */
    93    102   #define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */
    94    103   #define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */
    95    104   #define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */

Changes to src/select.c.

  3783   3783     Expr *pWhere,         /* The WHERE clause of the outer query */
  3784   3784     int iCursor           /* Cursor number of the subquery */
  3785   3785   ){
  3786   3786     Expr *pNew;
  3787   3787     int nChng = 0;
  3788   3788     if( pWhere==0 ) return 0;
  3789   3789     if( (pSubq->selFlags & (SF_Aggregate|SF_Recursive))!=0 ){
         3790  +     testcase( pSubq->selFlags & SF_Aggregate );
         3791  +     testcase( pSubq->selFlags & SF_Recursive );
  3790   3792        return 0; /* restrictions (1) and (2) */
  3791   3793     }
  3792   3794     if( pSubq->pLimit!=0 ){
  3793   3795        return 0; /* restriction (3) */
  3794   3796     }
  3795   3797     while( pWhere->op==TK_AND ){
  3796   3798       nChng += pushDownWhereTerms(db, pSubq, pWhere->pRight, iCursor);
................................................................................
  5088   5090     ){
  5089   5091       p->selFlags &= ~SF_Distinct;
  5090   5092       pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);
  5091   5093       /* Notice that even thought SF_Distinct has been cleared from p->selFlags,
  5092   5094       ** the sDistinct.isTnct is still set.  Hence, isTnct represents the
  5093   5095       ** original setting of the SF_Distinct flag, not the current setting */
  5094   5096       assert( sDistinct.isTnct );
         5097  +
         5098  +#if SELECTTRACE_ENABLED
         5099  +    if( sqlite3SelectTrace & 0x400 ){
         5100  +      SELECTTRACE(0x400,pParse,p,("Transform DISTINCT into GROUP BY:\n"));
         5101  +      sqlite3TreeViewSelect(0, p, 0);
         5102  +    }
         5103  +#endif
  5095   5104     }
  5096   5105   
  5097   5106     /* If there is an ORDER BY clause, then create an ephemeral index to
  5098   5107     ** do the sorting.  But this sorting ephemeral index might end up
  5099   5108     ** being unused if the data can be extracted in pre-sorted order.
  5100   5109     ** If that is the case, then the OP_OpenEphemeral instruction will be
  5101   5110     ** changed to an OP_Noop once we figure out that the sorting index is

Changes to src/shell.c.

  1058   1058       }
  1059   1059       case MODE_Semi: {   /* .schema and .fullschema output */
  1060   1060         utf8_printf(p->out, "%s;\n", azArg[0]);
  1061   1061         break;
  1062   1062       }
  1063   1063       case MODE_Pretty: {  /* .schema and .fullschema with --indent */
  1064   1064         char *z;
  1065         -      int i,j;
         1065  +      int j;
  1066   1066         int nParen = 0;
  1067   1067         char cEnd = 0;
  1068   1068         char c;
  1069   1069         int nLine = 0;
  1070   1070         assert( nArg==1 );
  1071   1071         if( azArg[0]==0 ) break;
  1072   1072         if( sqlite3_strlike("CREATE VIEW%", azArg[0], 0)==0
................................................................................
  1085   1085             j--;
  1086   1086           }
  1087   1087           z[j++] = c;
  1088   1088         }
  1089   1089         while( j>0 && IsSpace(z[j-1]) ){ j--; }
  1090   1090         z[j] = 0;
  1091   1091         if( strlen30(z)>=79 ){
  1092         -        for(i=j=0; z[i]; i++){
  1093         -          char c = z[i];
         1092  +        for(i=j=0; (c = z[i])!=0; i++){
  1094   1093             if( c==cEnd ){
  1095   1094               cEnd = 0;
  1096   1095             }else if( c=='"' || c=='\'' || c=='`' ){
  1097   1096               cEnd = c;
  1098   1097             }else if( c=='[' ){
  1099   1098               cEnd = ']';
  1100   1099             }else if( c=='(' ){
................................................................................
  1730   1729   
  1731   1730       if( str_in_array(zOp, azNext) ){
  1732   1731         for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
  1733   1732       }
  1734   1733       if( str_in_array(zOp, azGoto) && p2op<p->nIndent
  1735   1734        && (abYield[p2op] || sqlite3_column_int(pSql, 2))
  1736   1735       ){
  1737         -      for(i=p2op+1; i<iOp; i++) p->aiIndent[i] += 2;
         1736  +      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
  1738   1737       }
  1739   1738     }
  1740   1739   
  1741   1740     p->iIndent = 0;
  1742   1741     sqlite3_free(abYield);
  1743   1742     sqlite3_reset(pSql);
  1744   1743   }
................................................................................
  1748   1747   */
  1749   1748   static void explain_data_delete(ShellState *p){
  1750   1749     sqlite3_free(p->aiIndent);
  1751   1750     p->aiIndent = 0;
  1752   1751     p->nIndent = 0;
  1753   1752     p->iIndent = 0;
  1754   1753   }
         1754  +
         1755  +/*
         1756  +** Disable and restore .wheretrace and .selecttrace settings.
         1757  +*/
         1758  +#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
         1759  +extern int sqlite3SelectTrace;
         1760  +static int savedSelectTrace;
         1761  +#endif
         1762  +#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
         1763  +extern int sqlite3WhereTrace;
         1764  +static int savedWhereTrace;
         1765  +#endif
         1766  +static void disable_debug_trace_modes(void){
         1767  +#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
         1768  +  savedSelectTrace = sqlite3SelectTrace;
         1769  +  sqlite3SelectTrace = 0;
         1770  +#endif
         1771  +#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
         1772  +  savedWhereTrace = sqlite3WhereTrace;
         1773  +  sqlite3WhereTrace = 0;
         1774  +#endif
         1775  +}
         1776  +static void restore_debug_trace_modes(void){
         1777  +#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
         1778  +  sqlite3SelectTrace = savedSelectTrace;
         1779  +#endif
         1780  +#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
         1781  +  sqlite3WhereTrace = savedWhereTrace;
         1782  +#endif
         1783  +}
         1784  +
         1785  +/*
         1786  +** Run a prepared statement
         1787  +*/
         1788  +static void exec_prepared_stmt(
         1789  +  ShellState *pArg,                                /* Pointer to ShellState */
         1790  +  sqlite3_stmt *pStmt,                             /* Statment to run */
         1791  +  int (*xCallback)(void*,int,char**,char**,int*)   /* Callback function */
         1792  +){
         1793  +  int rc;
         1794  +
         1795  +  /* perform the first step.  this will tell us if we
         1796  +  ** have a result set or not and how wide it is.
         1797  +  */
         1798  +  rc = sqlite3_step(pStmt);
         1799  +  /* if we have a result set... */
         1800  +  if( SQLITE_ROW == rc ){
         1801  +    /* if we have a callback... */
         1802  +    if( xCallback ){
         1803  +      /* allocate space for col name ptr, value ptr, and type */
         1804  +      int nCol = sqlite3_column_count(pStmt);
         1805  +      void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);
         1806  +      if( !pData ){
         1807  +        rc = SQLITE_NOMEM;
         1808  +      }else{
         1809  +        char **azCols = (char **)pData;      /* Names of result columns */
         1810  +        char **azVals = &azCols[nCol];       /* Results */
         1811  +        int *aiTypes = (int *)&azVals[nCol]; /* Result types */
         1812  +        int i, x;
         1813  +        assert(sizeof(int) <= sizeof(char *));
         1814  +        /* save off ptrs to column names */
         1815  +        for(i=0; i<nCol; i++){
         1816  +          azCols[i] = (char *)sqlite3_column_name(pStmt, i);
         1817  +        }
         1818  +        do{
         1819  +          /* extract the data and data types */
         1820  +          for(i=0; i<nCol; i++){
         1821  +            aiTypes[i] = x = sqlite3_column_type(pStmt, i);
         1822  +            if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
         1823  +              azVals[i] = "";
         1824  +            }else{
         1825  +              azVals[i] = (char*)sqlite3_column_text(pStmt, i);
         1826  +            }
         1827  +            if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
         1828  +              rc = SQLITE_NOMEM;
         1829  +              break; /* from for */
         1830  +            }
         1831  +          } /* end for */
         1832  +
         1833  +          /* if data and types extracted successfully... */
         1834  +          if( SQLITE_ROW == rc ){
         1835  +            /* call the supplied callback with the result row data */
         1836  +            if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){
         1837  +              rc = SQLITE_ABORT;
         1838  +            }else{
         1839  +              rc = sqlite3_step(pStmt);
         1840  +            }
         1841  +          }
         1842  +        } while( SQLITE_ROW == rc );
         1843  +        sqlite3_free(pData);
         1844  +      }
         1845  +    }else{
         1846  +      do{
         1847  +        rc = sqlite3_step(pStmt);
         1848  +      } while( rc == SQLITE_ROW );
         1849  +    }
         1850  +  }
         1851  +}
  1755   1852   
  1756   1853   /*
  1757   1854   ** Execute a statement or set of statements.  Print
  1758   1855   ** any result rows/columns depending on the current mode
  1759   1856   ** set via the supplied callback.
  1760   1857   **
  1761   1858   ** This is very similar to SQLite's built-in sqlite3_exec()
................................................................................
  1776   1873     const char *zLeftover;          /* Tail of unprocessed SQL */
  1777   1874   
  1778   1875     if( pzErrMsg ){
  1779   1876       *pzErrMsg = NULL;
  1780   1877     }
  1781   1878   
  1782   1879     while( zSql[0] && (SQLITE_OK == rc) ){
         1880  +    static const char *zStmtSql;
  1783   1881       rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
  1784   1882       if( SQLITE_OK != rc ){
  1785   1883         if( pzErrMsg ){
  1786   1884           *pzErrMsg = save_err_msg(db);
  1787   1885         }
  1788   1886       }else{
  1789   1887         if( !pStmt ){
  1790   1888           /* this happens for a comment or white-space */
  1791   1889           zSql = zLeftover;
  1792   1890           while( IsSpace(zSql[0]) ) zSql++;
  1793   1891           continue;
  1794   1892         }
         1893  +      zStmtSql = sqlite3_sql(pStmt);
         1894  +      while( IsSpace(zStmtSql[0]) ) zStmtSql++;
  1795   1895   
  1796   1896         /* save off the prepared statment handle and reset row count */
  1797   1897         if( pArg ){
  1798   1898           pArg->pStmt = pStmt;
  1799   1899           pArg->cnt = 0;
  1800   1900         }
  1801   1901   
  1802   1902         /* echo the sql statement if echo on */
  1803   1903         if( pArg && pArg->echoOn ){
  1804         -        const char *zStmtSql = sqlite3_sql(pStmt);
  1805   1904           utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
  1806   1905         }
  1807   1906   
  1808   1907         /* Show the EXPLAIN QUERY PLAN if .eqp is on */
  1809         -      if( pArg && pArg->autoEQP ){
         1908  +      if( pArg && pArg->autoEQP && sqlite3_strlike("EXPLAIN%",zStmtSql,0)!=0 ){
  1810   1909           sqlite3_stmt *pExplain;
  1811         -        char *zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s",
  1812         -                                     sqlite3_sql(pStmt));
         1910  +        char *zEQP;
         1911  +        disable_debug_trace_modes();
         1912  +        zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zStmtSql);
  1813   1913           rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
  1814   1914           if( rc==SQLITE_OK ){
  1815   1915             while( sqlite3_step(pExplain)==SQLITE_ROW ){
  1816   1916               raw_printf(pArg->out,"--EQP-- %d,",sqlite3_column_int(pExplain, 0));
  1817   1917               raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
  1818   1918               raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
  1819   1919               utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
  1820   1920             }
  1821   1921           }
  1822   1922           sqlite3_finalize(pExplain);
  1823   1923           sqlite3_free(zEQP);
         1924  +        if( pArg->autoEQP>=2 ){
         1925  +          /* Also do an EXPLAIN for ".eqp full" mode */
         1926  +          zEQP = sqlite3_mprintf("EXPLAIN %s", zStmtSql);
         1927  +          rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
         1928  +          if( rc==SQLITE_OK ){
         1929  +            pArg->cMode = MODE_Explain;
         1930  +            explain_data_prepare(pArg, pExplain);
         1931  +            exec_prepared_stmt(pArg, pExplain, xCallback);
         1932  +            explain_data_delete(pArg);
         1933  +          }
         1934  +          sqlite3_finalize(pExplain);
         1935  +          sqlite3_free(zEQP);
         1936  +        }
         1937  +        restore_debug_trace_modes();
  1824   1938         }
  1825   1939   
  1826   1940         if( pArg ){
  1827   1941           pArg->cMode = pArg->mode;
  1828   1942           if( pArg->autoExplain
  1829   1943            && sqlite3_column_count(pStmt)==8
  1830         -         && sqlite3_strlike("%EXPLAIN%", sqlite3_sql(pStmt),0)==0
         1944  +         && sqlite3_strlike("EXPLAIN%", zStmtSql,0)==0
  1831   1945           ){
  1832   1946             pArg->cMode = MODE_Explain;
  1833   1947           }
  1834   1948   
  1835   1949           /* If the shell is currently in ".explain" mode, gather the extra
  1836   1950           ** data required to add indents to the output.*/
  1837   1951           if( pArg->cMode==MODE_Explain ){
  1838   1952             explain_data_prepare(pArg, pStmt);
  1839   1953           }
  1840   1954         }
  1841   1955   
  1842         -      /* perform the first step.  this will tell us if we
  1843         -      ** have a result set or not and how wide it is.
  1844         -      */
  1845         -      rc = sqlite3_step(pStmt);
  1846         -      /* if we have a result set... */
  1847         -      if( SQLITE_ROW == rc ){
  1848         -        /* if we have a callback... */
  1849         -        if( xCallback ){
  1850         -          /* allocate space for col name ptr, value ptr, and type */
  1851         -          int nCol = sqlite3_column_count(pStmt);
  1852         -          void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);
  1853         -          if( !pData ){
  1854         -            rc = SQLITE_NOMEM;
  1855         -          }else{
  1856         -            char **azCols = (char **)pData;      /* Names of result columns */
  1857         -            char **azVals = &azCols[nCol];       /* Results */
  1858         -            int *aiTypes = (int *)&azVals[nCol]; /* Result types */
  1859         -            int i, x;
  1860         -            assert(sizeof(int) <= sizeof(char *));
  1861         -            /* save off ptrs to column names */
  1862         -            for(i=0; i<nCol; i++){
  1863         -              azCols[i] = (char *)sqlite3_column_name(pStmt, i);
  1864         -            }
  1865         -            do{
  1866         -              /* extract the data and data types */
  1867         -              for(i=0; i<nCol; i++){
  1868         -                aiTypes[i] = x = sqlite3_column_type(pStmt, i);
  1869         -                if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
  1870         -                  azVals[i] = "";
  1871         -                }else{
  1872         -                  azVals[i] = (char*)sqlite3_column_text(pStmt, i);
  1873         -                }
  1874         -                if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
  1875         -                  rc = SQLITE_NOMEM;
  1876         -                  break; /* from for */
  1877         -                }
  1878         -              } /* end for */
  1879         -
  1880         -              /* if data and types extracted successfully... */
  1881         -              if( SQLITE_ROW == rc ){
  1882         -                /* call the supplied callback with the result row data */
  1883         -                if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){
  1884         -                  rc = SQLITE_ABORT;
  1885         -                }else{
  1886         -                  rc = sqlite3_step(pStmt);
  1887         -                }
  1888         -              }
  1889         -            } while( SQLITE_ROW == rc );
  1890         -            sqlite3_free(pData);
  1891         -          }
  1892         -        }else{
  1893         -          do{
  1894         -            rc = sqlite3_step(pStmt);
  1895         -          } while( rc == SQLITE_ROW );
  1896         -        }
  1897         -      }
  1898         -
         1956  +      exec_prepared_stmt(pArg, pStmt, xCallback);
  1899   1957         explain_data_delete(pArg);
  1900   1958   
  1901   1959         /* print usage stats if stats on */
  1902   1960         if( pArg && pArg->statsOn ){
  1903   1961           display_stats(db, pArg, 0);
  1904   1962         }
  1905   1963   
................................................................................
  2081   2139     ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  2082   2140     ".databases             List names and files of attached databases\n"
  2083   2141     ".dbinfo ?DB?           Show status information about the database\n"
  2084   2142     ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
  2085   2143     "                         If TABLE specified, only dump tables matching\n"
  2086   2144     "                         LIKE pattern TABLE.\n"
  2087   2145     ".echo on|off           Turn command echo on or off\n"
  2088         -  ".eqp on|off            Enable or disable automatic EXPLAIN QUERY PLAN\n"
         2146  +  ".eqp on|off|full       Enable or disable automatic EXPLAIN QUERY PLAN\n"
  2089   2147     ".exit                  Exit this program\n"
  2090   2148     ".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"
  2091   2149     ".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n"
  2092   2150     ".headers on|off        Turn display of headers on or off\n"
  2093   2151     ".help                  Show this message\n"
  2094   2152     ".import FILE TABLE     Import data from FILE into TABLE\n"
  2095   2153     ".indexes ?TABLE?       Show names of all indexes\n"
................................................................................
  3251   3309         raw_printf(stderr, "Usage: .echo on|off\n");
  3252   3310         rc = 1;
  3253   3311       }
  3254   3312     }else
  3255   3313   
  3256   3314     if( c=='e' && strncmp(azArg[0], "eqp", n)==0 ){
  3257   3315       if( nArg==2 ){
  3258         -      p->autoEQP = booleanValue(azArg[1]);
         3316  +      if( strcmp(azArg[1],"full")==0 ){
         3317  +        p->autoEQP = 2;
         3318  +      }else{
         3319  +        p->autoEQP = booleanValue(azArg[1]);
         3320  +      }
  3259   3321       }else{
  3260         -      raw_printf(stderr, "Usage: .eqp on|off\n");
         3322  +      raw_printf(stderr, "Usage: .eqp on|off|full\n");
  3261   3323         rc = 1;
  3262   3324       }
  3263   3325     }else
  3264   3326   
  3265   3327     if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
  3266   3328       if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
  3267   3329       rc = 2;
................................................................................
  4014   4076       }else{
  4015   4077         rc = 0;
  4016   4078       }
  4017   4079     }else
  4018   4080   
  4019   4081   #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
  4020   4082     if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){
  4021         -    extern int sqlite3SelectTrace;
  4022   4083       sqlite3SelectTrace = integerValue(azArg[1]);
  4023   4084     }else
  4024   4085   #endif
  4025   4086   
  4026   4087   #if defined(SQLITE_ENABLE_SESSION)
  4027   4088     if( c=='s' && strncmp(azArg[0],"session",n)==0 && n>=3 ){
  4028   4089       OpenSession *pSession = &p->aSession[0];
................................................................................
  4274   4335       }
  4275   4336       x = system(zCmd);
  4276   4337       sqlite3_free(zCmd);
  4277   4338       if( x ) raw_printf(stderr, "System command returns %d\n", x);
  4278   4339     }else
  4279   4340   
  4280   4341     if( c=='s' && strncmp(azArg[0], "show", n)==0 ){
         4342  +    static const char *azBool[] = { "off", "on", "full", "unk" };
  4281   4343       int i;
  4282   4344       if( nArg!=1 ){
  4283   4345         raw_printf(stderr, "Usage: .show\n");
  4284   4346         rc = 1;
  4285   4347         goto meta_command_exit;
  4286   4348       }
  4287         -    utf8_printf(p->out, "%12.12s: %s\n","echo", p->echoOn ? "on" : "off");
  4288         -    utf8_printf(p->out, "%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off");
         4349  +    utf8_printf(p->out, "%12.12s: %s\n","echo", azBool[p->echoOn!=0]);
         4350  +    utf8_printf(p->out, "%12.12s: %s\n","eqp", azBool[p->autoEQP&3]);
  4289   4351       utf8_printf(p->out, "%12.12s: %s\n","explain",
  4290   4352            p->mode==MODE_Explain ? "on" : p->autoExplain ? "auto" : "off");
  4291         -    utf8_printf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off");
         4353  +    utf8_printf(p->out,"%12.12s: %s\n","headers", azBool[p->showHeader!=0]);
  4292   4354       utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
  4293   4355       utf8_printf(p->out, "%12.12s: ", "nullvalue");
  4294   4356         output_c_string(p->out, p->nullValue);
  4295   4357         raw_printf(p->out, "\n");
  4296   4358       utf8_printf(p->out,"%12.12s: %s\n","output",
  4297   4359               strlen30(p->outfile) ? p->outfile : "stdout");
  4298   4360       utf8_printf(p->out,"%12.12s: ", "colseparator");
  4299   4361         output_c_string(p->out, p->colSeparator);
  4300   4362         raw_printf(p->out, "\n");
  4301   4363       utf8_printf(p->out,"%12.12s: ", "rowseparator");
  4302   4364         output_c_string(p->out, p->rowSeparator);
  4303   4365         raw_printf(p->out, "\n");
  4304         -    utf8_printf(p->out, "%12.12s: %s\n","stats", p->statsOn ? "on" : "off");
         4366  +    utf8_printf(p->out, "%12.12s: %s\n","stats", azBool[p->statsOn!=0]);
  4305   4367       utf8_printf(p->out, "%12.12s: ", "width");
  4306   4368       for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {
  4307   4369         raw_printf(p->out, "%d ", p->colWidth[i]);
  4308   4370       }
  4309   4371       raw_printf(p->out, "\n");
  4310   4372     }else
  4311   4373   
................................................................................
  4712   4774           sqlite3_free(zVfsName);
  4713   4775         }
  4714   4776       }
  4715   4777     }else
  4716   4778   
  4717   4779   #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
  4718   4780     if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){
  4719         -    extern int sqlite3WhereTrace;
  4720   4781       sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;
  4721   4782     }else
  4722   4783   #endif
  4723   4784   
  4724   4785     if( c=='w' && strncmp(azArg[0], "width", n)==0 ){
  4725   4786       int j;
  4726   4787       assert( nArg<=ArraySize(azArg) );
................................................................................
  5380   5441         data.showHeader = 1;
  5381   5442       }else if( strcmp(z,"-noheader")==0 ){
  5382   5443         data.showHeader = 0;
  5383   5444       }else if( strcmp(z,"-echo")==0 ){
  5384   5445         data.echoOn = 1;
  5385   5446       }else if( strcmp(z,"-eqp")==0 ){
  5386   5447         data.autoEQP = 1;
         5448  +    }else if( strcmp(z,"-eqpfull")==0 ){
         5449  +      data.autoEQP = 2;
  5387   5450       }else if( strcmp(z,"-stats")==0 ){
  5388   5451         data.statsOn = 1;
  5389   5452       }else if( strcmp(z,"-scanstats")==0 ){
  5390   5453         data.scanstatsOn = 1;
  5391   5454       }else if( strcmp(z,"-backslash")==0 ){
  5392   5455         /* Undocumented command-line option: -backslash
  5393   5456         ** Causes C-style backslash escapes to be evaluated in SQL statements

Changes to src/sqliteInt.h.

  1346   1346   ** A macro to discover the encoding of a database.
  1347   1347   */
  1348   1348   #define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
  1349   1349   #define ENC(db)        ((db)->enc)
  1350   1350   
  1351   1351   /*
  1352   1352   ** Possible values for the sqlite3.flags.
         1353  +**
         1354  +** Value constraints (enforced via assert()):
         1355  +**      SQLITE_FullFSync     == PAGER_FULLFSYNC
         1356  +**      SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
         1357  +**      SQLITE_CacheSpill    == PAGER_CACHE_SPILL
  1353   1358   */
  1354   1359   #define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */
  1355   1360   #define SQLITE_InternChanges  0x00000002  /* Uncommitted Hash table changes */
  1356   1361   #define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */
  1357   1362   #define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */
  1358   1363   #define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */
  1359   1364   #define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */
................................................................................
  1480   1485   };
  1481   1486   
  1482   1487   /*
  1483   1488   ** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF
  1484   1489   ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And
  1485   1490   ** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There
  1486   1491   ** are assert() statements in the code to verify this.
         1492  +**
         1493  +** Value constraints (enforced via assert()):
         1494  +**     SQLITE_FUNC_MINMAX    ==  NC_MinMaxAgg      == SF_MinMaxAgg
         1495  +**     SQLITE_FUNC_LENGTH    ==  OPFLAG_LENGTHARG
         1496  +**     SQLITE_FUNC_TYPEOF    ==  OPFLAG_TYPEOFARG
         1497  +**     SQLITE_FUNC_CONSTANT  ==  SQLITE_DETERMINISTIC from the API
         1498  +**     SQLITE_FUNC_ENCMASK   depends on SQLITE_UTF* macros in the API
  1487   1499   */
  1488   1500   #define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
  1489   1501   #define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */
  1490   1502   #define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */
  1491   1503   #define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */
  1492   1504   #define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
  1493   1505   #define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */
................................................................................
  2479   2491   #define JT_OUTER     0x0020    /* The "OUTER" keyword is present */
  2480   2492   #define JT_ERROR     0x0040    /* unknown or unsupported join type */
  2481   2493   
  2482   2494   
  2483   2495   /*
  2484   2496   ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()
  2485   2497   ** and the WhereInfo.wctrlFlags member.
         2498  +**
         2499  +** Value constraints (enforced via assert()):
         2500  +**     WHERE_USE_LIMIT  == SF_FixedLimit
  2486   2501   */
  2487   2502   #define WHERE_ORDERBY_NORMAL   0x0000 /* No-op */
  2488   2503   #define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */
  2489   2504   #define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */
  2490   2505   #define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */
  2491   2506   #define WHERE_DUPLICATES_OK    0x0008 /* Ok to return a row more than once */
  2492   2507   #define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */
................................................................................
  2539   2554     int nErr;            /* Number of errors encountered while resolving names */
  2540   2555     u16 ncFlags;         /* Zero or more NC_* flags defined below */
  2541   2556   };
  2542   2557   
  2543   2558   /*
  2544   2559   ** Allowed values for the NameContext, ncFlags field.
  2545   2560   **
  2546         -** Note:  NC_MinMaxAgg must have the same value as SF_MinMaxAgg and
  2547         -** SQLITE_FUNC_MINMAX.
         2561  +** Value constraints (all checked via assert()):
         2562  +**    NC_HasAgg    == SF_HasAgg
         2563  +**    NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
  2548   2564   **
  2549   2565   */
  2550   2566   #define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
  2551         -#define NC_HasAgg    0x0002  /* One or more aggregate functions seen */
         2567  +#define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */
  2552   2568   #define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
  2553   2569   #define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
  2554         -#define NC_PartIdx   0x0010  /* True if resolving a partial index WHERE */
         2570  +#define NC_HasAgg    0x0010  /* One or more aggregate functions seen */
  2555   2571   #define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
  2556   2572   #define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
  2557   2573   
  2558   2574   /*
  2559   2575   ** An instance of the following structure contains all information
  2560   2576   ** needed to generate code for a single SELECT statement.
  2561   2577   **
................................................................................
  2596   2612     Expr *pOffset;         /* OFFSET expression. NULL means not used. */
  2597   2613     With *pWith;           /* WITH clause attached to this select. Or NULL. */
  2598   2614   };
  2599   2615   
  2600   2616   /*
  2601   2617   ** Allowed values for Select.selFlags.  The "SF" prefix stands for
  2602   2618   ** "Select Flag".
         2619  +**
         2620  +** Value constraints (all checked via assert())
         2621  +**     SF_HasAgg     == NC_HasAgg
         2622  +**     SF_MinMaxAgg  == NC_MinMaxAgg     == SQLITE_FUNC_MINMAX
         2623  +**     SF_FixedLimit == WHERE_USE_LIMIT
  2603   2624   */
  2604   2625   #define SF_Distinct       0x00001  /* Output should be DISTINCT */
  2605   2626   #define SF_All            0x00002  /* Includes the ALL keyword */
  2606   2627   #define SF_Resolved       0x00004  /* Identifiers have been resolved */
  2607         -#define SF_Aggregate      0x00008  /* Contains aggregate functions */
  2608         -#define SF_UsesEphemeral  0x00010  /* Uses the OpenEphemeral opcode */
  2609         -#define SF_Expanded       0x00020  /* sqlite3SelectExpand() called on this */
  2610         -#define SF_HasTypeInfo    0x00040  /* FROM subqueries have Table metadata */
  2611         -#define SF_Compound       0x00080  /* Part of a compound query */
  2612         -#define SF_Values         0x00100  /* Synthesized from VALUES clause */
  2613         -#define SF_MultiValue     0x00200  /* Single VALUES term with multiple rows */
  2614         -#define SF_NestedFrom     0x00400  /* Part of a parenthesized FROM clause */
  2615         -#define SF_MaybeConvert   0x00800  /* Need convertCompoundSelectToSubquery() */
         2628  +#define SF_Aggregate      0x00008  /* Contains agg functions or a GROUP BY */
         2629  +#define SF_HasAgg         0x00010  /* Contains aggregate functions */
         2630  +#define SF_UsesEphemeral  0x00020  /* Uses the OpenEphemeral opcode */
         2631  +#define SF_Expanded       0x00040  /* sqlite3SelectExpand() called on this */
         2632  +#define SF_HasTypeInfo    0x00080  /* FROM subqueries have Table metadata */
         2633  +#define SF_Compound       0x00100  /* Part of a compound query */
         2634  +#define SF_Values         0x00200  /* Synthesized from VALUES clause */
         2635  +#define SF_MultiValue     0x00400  /* Single VALUES term with multiple rows */
         2636  +#define SF_NestedFrom     0x00800  /* Part of a parenthesized FROM clause */
  2616   2637   #define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */
  2617   2638   #define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */
  2618   2639   #define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */
  2619         -#define SF_Converted      0x08000  /* By convertCompoundSelectToSubquery() */
  2620         -#define SF_IncludeHidden  0x10000  /* Include hidden columns in output */
         2640  +#define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */
         2641  +#define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */
         2642  +#define SF_IncludeHidden  0x20000  /* Include hidden columns in output */
  2621   2643   
  2622   2644   
  2623   2645   /*
  2624   2646   ** The results of a SELECT can be distributed in several ways, as defined
  2625   2647   ** by one of the following macros.  The "SRT" prefix means "SELECT Result
  2626   2648   ** Type".
  2627   2649   **
................................................................................
  2924   2946   struct AuthContext {
  2925   2947     const char *zAuthContext;   /* Put saved Parse.zAuthContext here */
  2926   2948     Parse *pParse;              /* The Parse structure */
  2927   2949   };
  2928   2950   
  2929   2951   /*
  2930   2952   ** Bitfield flags for P5 value in various opcodes.
         2953  +**
         2954  +** Value constraints (enforced via assert()):
         2955  +**    OPFLAG_LENGTHARG    == SQLITE_FUNC_LENGTH
         2956  +**    OPFLAG_TYPEOFARG    == SQLITE_FUNC_TYPEOF
         2957  +**    OPFLAG_BULKCSR      == BTREE_BULKLOAD
         2958  +**    OPFLAG_SEEKEQ       == BTREE_SEEK_EQ
         2959  +**    OPFLAG_FORDELETE    == BTREE_FORDELETE
         2960  +**    OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION
         2961  +**    OPFLAG_AUXDELETE    == BTREE_AUXDELETE
  2931   2962   */
  2932   2963   #define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */
  2933   2964                                        /* Also used in P2 (not P5) of OP_Delete */
  2934   2965   #define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */
  2935   2966   #define OPFLAG_LASTROWID     0x02    /* Set to update db->lastRowid */
  2936   2967   #define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */
  2937   2968   #define OPFLAG_APPEND        0x08    /* This is likely to be an append */

Changes to src/test_devsym.c.

   129    129   struct DevsymGlobal g = {0, 0, 512};
   130    130   
   131    131   /*
   132    132   ** Close an devsym-file.
   133    133   */
   134    134   static int devsymClose(sqlite3_file *pFile){
   135    135     devsym_file *p = (devsym_file *)pFile;
   136         -  return sqlite3OsClose(p->pReal);
          136  +  sqlite3OsClose(p->pReal);
          137  +  return SQLITE_OK;
   137    138   }
   138    139   
   139    140   /*
   140    141   ** Read data from an devsym-file.
   141    142   */
   142    143   static int devsymRead(
   143    144     sqlite3_file *pFile, 

Changes to src/test_journal.c.

   252    252     closeTransaction(p);
   253    253     enterJtMutex();
   254    254     if( p->zName ){
   255    255       for(pp=&g.pList; *pp!=p; pp=&(*pp)->pNext);
   256    256       *pp = p->pNext;
   257    257     }
   258    258     leaveJtMutex();
   259         -  return sqlite3OsClose(p->pReal);
          259  +  sqlite3OsClose(p->pReal);
          260  +  return SQLITE_OK;
   260    261   }
   261    262   
   262    263   /*
   263    264   ** Read data from an jt-file.
   264    265   */
   265    266   static int jtRead(
   266    267     sqlite3_file *pFile, 

Changes to src/test_syscall.c.

   104    104   static char *ts_getcwd(char *zPath, size_t nPath);
   105    105   static int ts_stat(const char *zPath, struct stat *p);
   106    106   static int ts_fstat(int fd, struct stat *p);
   107    107   static int ts_ftruncate(int fd, off_t n);
   108    108   static int ts_fcntl(int fd, int cmd, ... );
   109    109   static int ts_read(int fd, void *aBuf, size_t nBuf);
   110    110   static int ts_pread(int fd, void *aBuf, size_t nBuf, off_t off);
   111         -static int ts_pread64(int fd, void *aBuf, size_t nBuf, off_t off);
          111  +/* Note:  pread64() and pwrite64() actually use off64_t as the type on their
          112  +** last parameter.  But that datatype is not defined on many systems 
          113  +** (ex: Mac, OpenBSD).  So substitute a likely equivalent: sqlite3_uint64 */
          114  +static int ts_pread64(int fd, void *aBuf, size_t nBuf, sqlite3_uint64 off);
   112    115   static int ts_write(int fd, const void *aBuf, size_t nBuf);
   113    116   static int ts_pwrite(int fd, const void *aBuf, size_t nBuf, off_t off);
   114         -static int ts_pwrite64(int fd, const void *aBuf, size_t nBuf, off_t off);
          117  +static int ts_pwrite64(int fd, const void *aBuf, size_t nBuf, sqlite3_uint64 off);
   115    118   static int ts_fchmod(int fd, mode_t mode);
   116    119   static int ts_fallocate(int fd, off_t off, off_t len);
   117    120   static void *ts_mmap(void *, size_t, int, int, int, off_t);
   118    121   static void *ts_mremap(void*, size_t, size_t, int, ...);
   119    122   
   120    123   struct TestSyscallArray {
   121    124     const char *zName;
................................................................................
   151    154   #define orig_getcwd    ((char*(*)(char*,size_t))aSyscall[3].xOrig)
   152    155   #define orig_stat      ((int(*)(const char*,struct stat*))aSyscall[4].xOrig)
   153    156   #define orig_fstat     ((int(*)(int,struct stat*))aSyscall[5].xOrig)
   154    157   #define orig_ftruncate ((int(*)(int,off_t))aSyscall[6].xOrig)
   155    158   #define orig_fcntl     ((int(*)(int,int,...))aSyscall[7].xOrig)
   156    159   #define orig_read      ((ssize_t(*)(int,void*,size_t))aSyscall[8].xOrig)
   157    160   #define orig_pread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].xOrig)
   158         -#define orig_pread64   ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].xOrig)
          161  +#define orig_pread64   ((ssize_t(*)(int,void*,size_t,sqlite3_uint64))aSyscall[10].xOrig)
   159    162   #define orig_write     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].xOrig)
   160    163   #define orig_pwrite    ((ssize_t(*)(int,const void*,size_t,off_t))\
   161    164                          aSyscall[12].xOrig)
   162         -#define orig_pwrite64  ((ssize_t(*)(int,const void*,size_t,off_t))\
          165  +#define orig_pwrite64  ((ssize_t(*)(int,const void*,size_t,sqlite3_uint64))\
   163    166                          aSyscall[13].xOrig)
   164    167   #define orig_fchmod    ((int(*)(int,mode_t))aSyscall[14].xOrig)
   165    168   #define orig_fallocate ((int(*)(int,off_t,off_t))aSyscall[15].xOrig)
   166    169   #define orig_mmap      ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[16].xOrig)
   167    170   #define orig_mremap    ((void*(*)(void*,size_t,size_t,int,...))aSyscall[17].xOrig)
   168    171   
   169    172   /*
................................................................................
   322    325     }
   323    326     return orig_pread(fd, aBuf, nBuf, off);
   324    327   }
   325    328   
   326    329   /*
   327    330   ** A wrapper around pread64().
   328    331   */
   329         -static int ts_pread64(int fd, void *aBuf, size_t nBuf, off_t off){
          332  +static int ts_pread64(int fd, void *aBuf, size_t nBuf, sqlite3_uint64 off){
   330    333     if( tsIsFailErrno("pread64") ){
   331    334       return -1;
   332    335     }
   333    336     return orig_pread64(fd, aBuf, nBuf, off);
   334    337   }
   335    338   
   336    339   /*
................................................................................
   353    356     }
   354    357     return orig_pwrite(fd, aBuf, nBuf, off);
   355    358   }
   356    359   
   357    360   /*
   358    361   ** A wrapper around pwrite64().
   359    362   */
   360         -static int ts_pwrite64(int fd, const void *aBuf, size_t nBuf, off_t off){
          363  +static int ts_pwrite64(int fd, const void *aBuf, size_t nBuf, sqlite3_uint64 off){
   361    364     if( tsIsFailErrno("pwrite64") ){
   362    365       return -1;
   363    366     }
   364    367     return orig_pwrite64(fd, aBuf, nBuf, off);
   365    368   }
   366    369   
   367    370   /*

Changes to src/test_vfs.c.

   302    302   }
   303    303   
   304    304   
   305    305   /*
   306    306   ** Close an tvfs-file.
   307    307   */
   308    308   static int tvfsClose(sqlite3_file *pFile){
   309         -  int rc;
   310    309     TestvfsFile *pTestfile = (TestvfsFile *)pFile;
   311    310     TestvfsFd *pFd = pTestfile->pFd;
   312    311     Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;
   313    312   
   314    313     if( p->pScript && p->mask&TESTVFS_CLOSE_MASK ){
   315    314       tvfsExecTcl(p, "xClose", 
   316    315           Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0
................................................................................
   320    319     if( pFd->pShmId ){
   321    320       Tcl_DecrRefCount(pFd->pShmId);
   322    321       pFd->pShmId = 0;
   323    322     }
   324    323     if( pFile->pMethods ){
   325    324       ckfree((char *)pFile->pMethods);
   326    325     }
   327         -  rc = sqlite3OsClose(pFd->pReal);
          326  +  sqlite3OsClose(pFd->pReal);
   328    327     ckfree((char *)pFd);
   329    328     pTestfile->pFd = 0;
   330         -  return rc;
          329  +  return SQLITE_OK;
   331    330   }
   332    331   
   333    332   /*
   334    333   ** Read data from an tvfs-file.
   335    334   */
   336    335   static int tvfsRead(
   337    336     sqlite3_file *pFile, 

Changes to src/vdbesort.c.

   927    927   int sqlite3VdbeSorterInit(
   928    928     sqlite3 *db,                    /* Database connection (for malloc()) */
   929    929     int nField,                     /* Number of key fields in each record */
   930    930     VdbeCursor *pCsr                /* Cursor that holds the new sorter */
   931    931   ){
   932    932     int pgsz;                       /* Page size of main database */
   933    933     int i;                          /* Used to iterate through aTask[] */
   934         -  int mxCache;                    /* Cache size */
   935    934     VdbeSorter *pSorter;            /* The new sorter */
   936    935     KeyInfo *pKeyInfo;              /* Copy of pCsr->pKeyInfo with db==0 */
   937    936     int szKeyInfo;                  /* Size of pCsr->pKeyInfo in bytes */
   938    937     int sz;                         /* Size of pSorter in bytes */
   939    938     int rc = SQLITE_OK;
   940    939   #if SQLITE_MAX_WORKER_THREADS==0
   941    940   # define nWorker 0
................................................................................
   984    983       pSorter->db = db;
   985    984       for(i=0; i<pSorter->nTask; i++){
   986    985         SortSubtask *pTask = &pSorter->aTask[i];
   987    986         pTask->pSorter = pSorter;
   988    987       }
   989    988   
   990    989       if( !sqlite3TempInMemory(db) ){
          990  +      i64 mxCache;                /* Cache size in bytes*/
   991    991         u32 szPma = sqlite3GlobalConfig.szPma;
   992    992         pSorter->mnPmaSize = szPma * pgsz;
          993  +
   993    994         mxCache = db->aDb[0].pSchema->cache_size;
   994         -      if( mxCache<(int)szPma ) mxCache = (int)szPma;
   995         -      pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_PMASZ);
          995  +      if( mxCache<0 ){
          996  +        /* A negative cache-size value C indicates that the cache is abs(C)
          997  +        ** KiB in size.  */
          998  +        mxCache = mxCache * -1024;
          999  +      }else{
         1000  +        mxCache = mxCache * pgsz;
         1001  +      }
         1002  +      mxCache = MIN(mxCache, SQLITE_MAX_PMASZ);
         1003  +      pSorter->mxPmaSize = MAX(pSorter->mnPmaSize, (int)mxCache);
   996   1004   
   997   1005         /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
   998   1006         ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
   999   1007         ** large heap allocations.
  1000   1008         */
  1001   1009         if( sqlite3GlobalConfig.pScratch==0 ){
  1002   1010           assert( pSorter->iMemory==0 );

Changes to src/where.c.

  3877   3877     }
  3878   3878     if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0
  3879   3879      && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
  3880   3880      && pWInfo->eDistinct==WHERE_DISTINCT_NOOP
  3881   3881      && nRowEst
  3882   3882     ){
  3883   3883       Bitmask notUsed;
  3884         -    int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,
         3884  +    int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pDistinctSet, pFrom,
  3885   3885                    WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
  3886         -    if( rc==pWInfo->pResultSet->nExpr ){
         3886  +    if( rc==pWInfo->pDistinctSet->nExpr ){
  3887   3887         pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
  3888   3888       }
  3889   3889     }
  3890   3890     if( pWInfo->pOrderBy ){
  3891   3891       if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
  3892   3892         if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
  3893   3893           pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
................................................................................
  4094   4094   ** to use for OR clause processing.  The WHERE clause should use this
  4095   4095   ** specific cursor.  If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
  4096   4096   ** the first cursor in an array of cursors for all indices.  iIdxCur should
  4097   4097   ** be used to compute the appropriate cursor depending on which index is
  4098   4098   ** used.
  4099   4099   */
  4100   4100   WhereInfo *sqlite3WhereBegin(
  4101         -  Parse *pParse,        /* The parser context */
  4102         -  SrcList *pTabList,    /* FROM clause: A list of all tables to be scanned */
  4103         -  Expr *pWhere,         /* The WHERE clause */
  4104         -  ExprList *pOrderBy,   /* An ORDER BY (or GROUP BY) clause, or NULL */
  4105         -  ExprList *pResultSet, /* Result set of the query */
  4106         -  u16 wctrlFlags,       /* One of the WHERE_* flags defined in sqliteInt.h */
  4107         -  int iAuxArg           /* If WHERE_ONETABLE_ONLY is set, index cursor number,
  4108         -                        ** If WHERE_USE_LIMIT, then the limit amount */
         4101  +  Parse *pParse,          /* The parser context */
         4102  +  SrcList *pTabList,      /* FROM clause: A list of all tables to be scanned */
         4103  +  Expr *pWhere,           /* The WHERE clause */
         4104  +  ExprList *pOrderBy,     /* An ORDER BY (or GROUP BY) clause, or NULL */
         4105  +  ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
         4106  +  u16 wctrlFlags,         /* The WHERE_* flags defined in sqliteInt.h */
         4107  +  int iAuxArg             /* If WHERE_ONETABLE_ONLY is set, index cursor number
         4108  +                          ** If WHERE_USE_LIMIT, then the limit amount */
  4109   4109   ){
  4110   4110     int nByteWInfo;            /* Num. bytes allocated for WhereInfo struct */
  4111   4111     int nTabList;              /* Number of elements in pTabList */
  4112   4112     WhereInfo *pWInfo;         /* Will become the return value of this function */
  4113   4113     Vdbe *v = pParse->pVdbe;   /* The virtual database engine */
  4114   4114     Bitmask notReady;          /* Cursors that are not yet positioned */
  4115   4115     WhereLoopBuilder sWLB;     /* The WhereLoop builder */
................................................................................
  4176   4176       goto whereBeginError;
  4177   4177     }
  4178   4178     pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
  4179   4179     pWInfo->nLevel = nTabList;
  4180   4180     pWInfo->pParse = pParse;
  4181   4181     pWInfo->pTabList = pTabList;
  4182   4182     pWInfo->pOrderBy = pOrderBy;
  4183         -  pWInfo->pResultSet = pResultSet;
         4183  +  pWInfo->pDistinctSet = pDistinctSet;
  4184   4184     pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
  4185   4185     pWInfo->wctrlFlags = wctrlFlags;
  4186   4186     pWInfo->iLimit = iAuxArg;
  4187   4187     pWInfo->savedNQueryLoop = pParse->nQueryLoop;
  4188   4188     assert( pWInfo->eOnePass==ONEPASS_OFF );  /* ONEPASS defaults to OFF */
  4189   4189     pMaskSet = &pWInfo->sMaskSet;
  4190   4190     sWLB.pWInfo = pWInfo;
................................................................................
  4249   4249   #endif
  4250   4250   
  4251   4251     /* Analyze all of the subexpressions. */
  4252   4252     sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
  4253   4253     if( db->mallocFailed ) goto whereBeginError;
  4254   4254   
  4255   4255     if( wctrlFlags & WHERE_WANT_DISTINCT ){
  4256         -    if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
         4256  +    if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pDistinctSet) ){
  4257   4257         /* The DISTINCT marking is pointless.  Ignore it. */
  4258   4258         pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
  4259   4259       }else if( pOrderBy==0 ){
  4260   4260         /* Try to ORDER BY the result set to make distinct processing easier */
  4261   4261         pWInfo->wctrlFlags |= WHERE_DISTINCTBY;
  4262         -      pWInfo->pOrderBy = pResultSet;
         4262  +      pWInfo->pOrderBy = pDistinctSet;
  4263   4263       }
  4264   4264     }
  4265   4265   
  4266   4266     /* Construct the WhereLoop objects */
  4267   4267   #if defined(WHERETRACE_ENABLED)
  4268   4268     if( sqlite3WhereTrace & 0xffff ){
  4269   4269       sqlite3DebugPrintf("*** Optimizer Start *** (wctrlFlags: 0x%x",wctrlFlags);
................................................................................
  4334   4334       for(ii=0; ii<pWInfo->nLevel; ii++){
  4335   4335         whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);
  4336   4336       }
  4337   4337     }
  4338   4338   #endif
  4339   4339     /* Attempt to omit tables from the join that do not effect the result */
  4340   4340     if( pWInfo->nLevel>=2
  4341         -   && pResultSet!=0
         4341  +   && pDistinctSet!=0
  4342   4342      && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
  4343   4343     ){
  4344         -    Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
         4344  +    Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pDistinctSet);
  4345   4345       if( sWLB.pOrderBy ){
  4346   4346         tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
  4347   4347       }
  4348   4348       while( pWInfo->nLevel>=2 ){
  4349   4349         WhereTerm *pTerm, *pEnd;
  4350   4350         pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
  4351   4351         if( (pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0 ) break;

Changes to src/whereInt.h.

   404    404   ** An instance of this object holds the complete state of the query
   405    405   ** planner.
   406    406   */
   407    407   struct WhereInfo {
   408    408     Parse *pParse;            /* Parsing and code generating context */
   409    409     SrcList *pTabList;        /* List of tables in the join */
   410    410     ExprList *pOrderBy;       /* The ORDER BY clause or NULL */
   411         -  ExprList *pResultSet;     /* Result set. DISTINCT operates on these */
          411  +  ExprList *pDistinctSet;   /* DISTINCT over all these values */
   412    412     WhereLoop *pLoops;        /* List of all WhereLoop objects */
   413    413     Bitmask revMask;          /* Mask of ORDER BY terms that need reversing */
   414    414     LogEst nRowOut;           /* Estimated number of output rows */
   415    415     LogEst iLimit;            /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */
   416    416     u16 wctrlFlags;           /* Flags originally passed to sqlite3WhereBegin() */
   417    417     i8 nOBSat;                /* Number of ORDER BY terms satisfied by indices */
   418    418     u8 sorted;                /* True if really sorted (not just grouped) */
................................................................................
   488    488   
   489    489   
   490    490   /*
   491    491   ** Bitmasks for the operators on WhereTerm objects.  These are all
   492    492   ** operators that are of interest to the query planner.  An
   493    493   ** OR-ed combination of these values can be used when searching for
   494    494   ** particular WhereTerms within a WhereClause.
          495  +**
          496  +** Value constraints:
          497  +**     WO_EQ    == SQLITE_INDEX_CONSTRAINT_EQ
          498  +**     WO_LT    == SQLITE_INDEX_CONSTRAINT_LT
          499  +**     WO_LE    == SQLITE_INDEX_CONSTRAINT_LE
          500  +**     WO_GT    == SQLITE_INDEX_CONSTRAINT_GT
          501  +**     WO_GE    == SQLITE_INDEX_CONSTRAINT_GE
          502  +**     WO_MATCH == SQLITE_INDEX_CONSTRAINT_MATCH
   495    503   */
   496    504   #define WO_IN     0x0001
   497    505   #define WO_EQ     0x0002
   498    506   #define WO_LT     (WO_EQ<<(TK_LT-TK_EQ))
   499    507   #define WO_LE     (WO_EQ<<(TK_LE-TK_EQ))
   500    508   #define WO_GT     (WO_EQ<<(TK_GT-TK_EQ))
   501    509   #define WO_GE     (WO_EQ<<(TK_GE-TK_EQ))

Changes to test/sort5.test.

    37     37   
    38     38   do_execsql_test 1.2 {
    39     39     CREATE INDEX i1 ON t1(b);
    40     40   }
    41     41   
    42     42   db close
    43     43   tvfs delete
           44  +
           45  +#-------------------------------------------------------------------------
           46  +# Test that the PMA size is determined correctly. The PMA size should be
           47  +# roughly the same amount of memory allocated to the main pager cache, or
           48  +# 250 pages if this is larger.
           49  +#
           50  +testvfs tvfs
           51  +tvfs script tv_callback
           52  +tvfs filter {xOpen xWrite}
           53  +
           54  +proc tv_callback {method args} {
           55  +  global iTemp
           56  +  global F
           57  +  switch $method {
           58  +    xOpen {
           59  +      if {[lindex $args 0]==""} { return "temp[incr iTemp]" }
           60  +      return "SQLITE_OK"
           61  +    }
           62  +
           63  +    xWrite {
           64  +      foreach {filename id off amt} $args {}
           65  +      if {[info exists F($id)]==0 || $F($id)<($off + $amt)} {
           66  +        set F($id) [expr $off+$amt]
           67  +      }
           68  +    }
           69  +  }
           70  +}
           71  +
           72  +catch { db close }
           73  +forcedelete test.db
           74  +sqlite3 db test.db -vfs tvfs
           75  +execsql { CREATE TABLE t1(x) }
           76  +
           77  +# Each iteration of the following loop attempts to sort 10001 records
           78  +# each a bit over 100 bytes in size. In total a little more than 1MiB 
           79  +# of data.
           80  +#
           81  +breakpoint
           82  +foreach {tn pgsz cachesz bTemp} {
           83  +  2 1024   1000  1
           84  +
           85  +  1 4096   1000  0
           86  +  2 1024   1000  1
           87  +
           88  +  3 4096  -1000  1
           89  +  4 1024  -1000  1
           90  +
           91  +  5 4096  -9000  0
           92  +  6 1024  -9000  0
           93  +} {
           94  +  do_execsql_test 2.$tn.0 "
           95  +    PRAGMA page_size = $pgsz;
           96  +    VACUUM;
           97  +    PRAGMA cache_size = $cachesz;
           98  +  "
           99  +
          100  +  do_test 2.$tn.1 {
          101  +    set ::iTemp 0
          102  +    catch { array unset F }
          103  +    execsql {
          104  +      WITH x(i, j) AS (
          105  +        SELECT 1, randomblob(100)
          106  +        UNION ALL
          107  +        SELECT i+1, randomblob(100) FROM x WHERE i<10000
          108  +      )
          109  +      SELECT * FROM x ORDER BY j;
          110  +    }
          111  +    expr {[array names F]!=""}
          112  +  } $bTemp
          113  +}
          114  +
    44    115   finish_test
          116  +