/ Check-in [2c9e5436]
Login

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

Overview
Comment:Merge the latest enhancements from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: 2c9e5436bd9146f0d76eb58e75cb76109d074ff7
User & Date: drh 2015-11-19 19:48:24
Context
2015-12-02
20:22
Merge all recent trunk enhancements, especially the unix VFS changes. check-in: e1fb33c7 user: drh tags: apple-osx
2015-11-19
19:48
Merge the latest enhancements from trunk. check-in: 2c9e5436 user: drh tags: apple-osx
18:11
Fix problems with the way the IsHiddenColumn() macro is defined. check-in: 126b998c user: drh tags: trunk
2015-11-13
02:13
Merge fixes from trunk. check-in: f9060b2a user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to autoconf/Makefile.am.

     2      2   AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE
     3      3   
     4      4   lib_LTLIBRARIES = libsqlite3.la
     5      5   libsqlite3_la_SOURCES = sqlite3.c
     6      6   libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8
     7      7   
     8      8   bin_PROGRAMS = sqlite3
     9         -sqlite3_SOURCES = shell.c sqlite3.c sqlite3.h
    10         -sqlite3_LDADD = @READLINE_LIBS@
            9  +sqlite3_SOURCES = shell.c sqlite3.h
           10  +EXTRA_sqlite3_SOURCES = sqlite3.c
           11  +sqlite3_LDADD = @EXTRA_SHELL_OBJ@ @READLINE_LIBS@
           12  +sqlite3_DEPENDENCIES = @EXTRA_SHELL_OBJ@
    11     13   sqlite3_CFLAGS = $(AM_CFLAGS)
    12     14   
    13     15   include_HEADERS = sqlite3.h sqlite3ext.h
    14     16   
    15     17   EXTRA_DIST = sqlite3.1 tea
    16     18   pkgconfigdir = ${libdir}/pkgconfig
    17     19   pkgconfig_DATA = sqlite3.pc
    18     20   
    19     21   man_MANS = sqlite3.1

Changes to autoconf/configure.ac.

     1      1   
     2      2   #-----------------------------------------------------------------------
     3      3   # Supports the following non-standard switches.
     4      4   #
     5      5   #   --enable-threadsafe
     6      6   #   --enable-readline
            7  +#   --enable-editline
            8  +#   --enable-static-shell
     7      9   #   --enable-dynamic-extensions
     8     10   #
     9     11   
    10     12   AC_PREREQ(2.61)
    11     13   AC_INIT(sqlite, 3.7.5, http://www.sqlite.org)
    12     14   AC_CONFIG_SRCDIR([sqlite3.c])
    13     15   
................................................................................
   112    114     [--enable-json1], [include json1 support [default=no]])], 
   113    115     [], [enable_json1=no])
   114    116   if test x"$enable_json1" == "xyes"; then
   115    117     JSON1_FLAGS=-DSQLITE_ENABLE_JSON1
   116    118   fi
   117    119   AC_SUBST(JSON1_FLAGS)
   118    120   #-----------------------------------------------------------------------
          121  +
          122  +#-----------------------------------------------------------------------
          123  +#   --enable-static-shell
          124  +#
          125  +AC_ARG_ENABLE(static-shell, [AS_HELP_STRING(
          126  +  [--enable-static-shell], 
          127  +  [statically link libsqlite3 into shell tool [default=yes]])], 
          128  +  [], [enable_static_shell=yes])
          129  +if test x"$enable_static_shell" == "xyes"; then
          130  +  EXTRA_SHELL_OBJ=sqlite3.$OBJEXT
          131  +else
          132  +  EXTRA_SHELL_OBJ=libsqlite3.la
          133  +fi
          134  +AC_SUBST(EXTRA_SHELL_OBJ)
          135  +#-----------------------------------------------------------------------
   119    136   
   120    137   AC_CHECK_FUNCS(posix_fallocate)
   121    138   
   122    139   #-----------------------------------------------------------------------
   123    140   # UPDATE: Maybe it's better if users just set CFLAGS before invoking
   124    141   # configure. This option doesn't really add much...
   125    142   #

Changes to src/build.c.

  1045   1045   
  1046   1046     /* If an error occurs, we jump here */
  1047   1047   begin_table_error:
  1048   1048     sqlite3DbFree(db, zName);
  1049   1049     return;
  1050   1050   }
  1051   1051   
  1052         -/*
  1053         -** This macro is used to compare two strings in a case-insensitive manner.
  1054         -** It is slightly faster than calling sqlite3StrICmp() directly, but
  1055         -** produces larger code.
  1056         -**
  1057         -** WARNING: This macro is not compatible with the strcmp() family. It
  1058         -** returns true if the two strings are equal, otherwise false.
         1052  +/* Set properties of a table column based on the (magical)
         1053  +** name of the column.
  1059   1054   */
  1060         -#define STRICMP(x, y) (\
  1061         -sqlite3UpperToLower[*(unsigned char *)(x)]==   \
  1062         -sqlite3UpperToLower[*(unsigned char *)(y)]     \
  1063         -&& sqlite3StrICmp((x)+1,(y)+1)==0 )
         1055  +void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
         1056  +#if SQLITE_ENABLE_HIDDEN_COLUMNS
         1057  +  if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){
         1058  +    pCol->colFlags |= COLFLAG_HIDDEN;
         1059  +  }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){
         1060  +    pTab->tabFlags |= TF_OOOHidden;
         1061  +  }
         1062  +#endif
         1063  +}
         1064  +
  1064   1065   
  1065   1066   /*
  1066   1067   ** Add a new column to the table currently being constructed.
  1067   1068   **
  1068   1069   ** The parser calls this routine once for each column declaration
  1069   1070   ** in a CREATE TABLE statement.  sqlite3StartTable() gets called
  1070   1071   ** first to get things going.  Then this routine is called for each
................................................................................
  1082   1083       sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);
  1083   1084       return;
  1084   1085     }
  1085   1086   #endif
  1086   1087     z = sqlite3NameFromToken(db, pName);
  1087   1088     if( z==0 ) return;
  1088   1089     for(i=0; i<p->nCol; i++){
  1089         -    if( STRICMP(z, p->aCol[i].zName) ){
         1090  +    if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){
  1090   1091         sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
  1091   1092         sqlite3DbFree(db, z);
  1092   1093         return;
  1093   1094       }
  1094   1095     }
  1095   1096     if( (p->nCol & 0x7)==0 ){
  1096   1097       Column *aNew;
................................................................................
  1100   1101         return;
  1101   1102       }
  1102   1103       p->aCol = aNew;
  1103   1104     }
  1104   1105     pCol = &p->aCol[p->nCol];
  1105   1106     memset(pCol, 0, sizeof(p->aCol[0]));
  1106   1107     pCol->zName = z;
         1108  +  sqlite3ColumnPropertiesFromName(p, pCol);
  1107   1109    
  1108   1110     /* If there is no type specified, columns have the default affinity
  1109   1111     ** 'BLOB'. If there is a type specified, then sqlite3AddColumnType() will
  1110   1112     ** be called next to set pCol->affinity correctly.
  1111   1113     */
  1112   1114     pCol->affinity = SQLITE_AFF_BLOB;
  1113   1115     pCol->szEst = 1;

Changes to src/delete.c.

   102    102     if( pFrom ){
   103    103       assert( pFrom->nSrc==1 );
   104    104       pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);
   105    105       pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
   106    106       assert( pFrom->a[0].pOn==0 );
   107    107       assert( pFrom->a[0].pUsing==0 );
   108    108     }
   109         -  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
          109  +  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 
          110  +                          SF_IncludeHidden, 0, 0);
   110    111     sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
   111    112     sqlite3Select(pParse, pSel, &dest);
   112    113     sqlite3SelectDelete(db, pSel);
   113    114   }
   114    115   #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */
   115    116   
   116    117   #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)

Changes to src/insert.c.

   732    732     if( pColumn==0 && nColumn>0 ){
   733    733       ipkColumn = pTab->iPKey;
   734    734     }
   735    735   
   736    736     /* Make sure the number of columns in the source data matches the number
   737    737     ** of columns to be inserted into the table.
   738    738     */
   739         -  if( IsVirtual(pTab) ){
   740         -    for(i=0; i<pTab->nCol; i++){
   741         -      nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);
   742         -    }
          739  +  for(i=0; i<pTab->nCol; i++){
          740  +    nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);
   743    741     }
   744    742     if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
   745    743       sqlite3ErrorMsg(pParse, 
   746    744          "table %S has %d columns but %d values were supplied",
   747    745          pTabList, 0, pTab->nCol-nHidden, nColumn);
   748    746       goto insert_cleanup;
   749    747     }
................................................................................
   831    829       /* Cannot have triggers on a virtual table. If it were possible,
   832    830       ** this block would have to account for hidden column.
   833    831       */
   834    832       assert( !IsVirtual(pTab) );
   835    833   
   836    834       /* Create the new column data
   837    835       */
   838         -    for(i=0; i<pTab->nCol; i++){
   839         -      if( pColumn==0 ){
   840         -        j = i;
   841         -      }else{
          836  +    for(i=j=0; i<pTab->nCol; i++){
          837  +      if( pColumn ){
   842    838           for(j=0; j<pColumn->nId; j++){
   843    839             if( pColumn->a[j].idx==i ) break;
   844    840           }
   845    841         }
   846         -      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId) ){
          842  +      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId)
          843  +            || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){
   847    844           sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);
   848    845         }else if( useTempTable ){
   849    846           sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); 
   850    847         }else{
   851    848           assert( pSelect==0 ); /* Otherwise useTempTable is true */
   852    849           sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);
   853    850         }
          851  +      if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++;
   854    852       }
   855    853   
   856    854       /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
   857    855       ** do not attempt any conversions before assembling the record.
   858    856       ** If this is a real table, attempt conversions as required by the
   859    857       ** table column affinities.
   860    858       */
................................................................................
   930    928           ** taking up data space with information that will never be used.
   931    929           ** As there may be shallow copies of this value, make it a soft-NULL */
   932    930           sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
   933    931           continue;
   934    932         }
   935    933         if( pColumn==0 ){
   936    934           if( IsHiddenColumn(&pTab->aCol[i]) ){
   937         -          assert( IsVirtual(pTab) );
   938    935             j = -1;
   939    936             nHidden++;
   940    937           }else{
   941    938             j = i - nHidden;
   942    939           }
   943    940         }else{
   944    941           for(j=0; j<pColumn->nId; j++){
................................................................................
  1872   1869     }
  1873   1870     pEList = pSelect->pEList;
  1874   1871     assert( pEList!=0 );
  1875   1872     if( pEList->nExpr!=1 ){
  1876   1873       return 0;   /* The result set must have exactly one column */
  1877   1874     }
  1878   1875     assert( pEList->a[0].pExpr );
  1879         -  if( pEList->a[0].pExpr->op!=TK_ALL ){
         1876  +  if( pEList->a[0].pExpr->op!=TK_ASTERISK ){
  1880   1877       return 0;   /* The result set must be the special operator "*" */
  1881   1878     }
  1882   1879   
  1883   1880     /* At this point we have established that the statement is of the
  1884   1881     ** correct syntactic form to participate in this optimization.  Now
  1885   1882     ** we have to check the semantics.
  1886   1883     */
................................................................................
  1908   1905     }
  1909   1906     if( pDest->iPKey!=pSrc->iPKey ){
  1910   1907       return 0;   /* Both tables must have the same INTEGER PRIMARY KEY */
  1911   1908     }
  1912   1909     for(i=0; i<pDest->nCol; i++){
  1913   1910       Column *pDestCol = &pDest->aCol[i];
  1914   1911       Column *pSrcCol = &pSrc->aCol[i];
         1912  +#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
         1913  +    if( (db->flags & SQLITE_Vacuum)==0 
         1914  +     && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN 
         1915  +    ){
         1916  +      return 0;    /* Neither table may have __hidden__ columns */
         1917  +    }
         1918  +#endif
  1915   1919       if( pDestCol->affinity!=pSrcCol->affinity ){
  1916   1920         return 0;    /* Affinity must be the same on all columns */
  1917   1921       }
  1918   1922       if( !xferCompatibleCollation(pDestCol->zColl, pSrcCol->zColl) ){
  1919   1923         return 0;    /* Collating sequence must be the same on all columns */
  1920   1924       }
  1921   1925       if( pDestCol->notNull && !pSrcCol->notNull ){

Changes to src/os_unix.c.

  3724   3724         if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){
  3725   3725           pFile->transCntrChng = 1;  /* The transaction counter has changed */
  3726   3726         }
  3727   3727       }
  3728   3728     }
  3729   3729   #endif
  3730   3730   
  3731         -#if SQLITE_MAX_MMAP_SIZE>0
         3731  +#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0
  3732   3732     /* Deal with as much of this write request as possible by transfering
  3733   3733     ** data from the memory mapping using memcpy().  */
  3734   3734     if( offset<pFile->mmapSize ){
  3735   3735       if( offset+amt <= pFile->mmapSize ){
  3736   3736         memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
  3737   3737         return SQLITE_OK;
  3738   3738       }else{
................................................................................
  5938   5938     assert( pFd->nFetchOut==0 );
  5939   5939     assert( nNew>pFd->mmapSize );
  5940   5940     assert( nNew<=pFd->mmapSizeMax );
  5941   5941     assert( nNew>0 );
  5942   5942     assert( pFd->mmapSizeActual>=pFd->mmapSize );
  5943   5943     assert( MAP_FAILED!=0 );
  5944   5944   
         5945  +#ifdef SQLITE_MMAP_READWRITE
  5945   5946     if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;
         5947  +#endif
  5946   5948   
  5947   5949     if( pOrig ){
  5948   5950   #if HAVE_MREMAP
  5949   5951       i64 nReuse = pFd->mmapSize;
  5950   5952   #else
  5951   5953       const int szSyspage = osGetpagesize();
  5952   5954       i64 nReuse = (pFd->mmapSize & ~(szSyspage-1));

Changes to src/os_win.c.

  2598   2598     SimulateIOError(return SQLITE_IOERR_WRITE);
  2599   2599     SimulateDiskfullError(return SQLITE_FULL);
  2600   2600   
  2601   2601     OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
  2602   2602              "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
  2603   2603              pFile->h, pBuf, amt, offset, pFile->locktype));
  2604   2604   
  2605         -#if SQLITE_MAX_MMAP_SIZE>0
         2605  +#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0
  2606   2606     /* Deal with as much of this write request as possible by transfering
  2607   2607     ** data from the memory mapping using memcpy().  */
  2608   2608     if( offset<pFile->mmapSize ){
  2609   2609       if( offset+amt <= pFile->mmapSize ){
  2610   2610         memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
  2611   2611         OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
  2612   2612                  osGetCurrentProcessId(), pFile, pFile->h));
................................................................................
  4101   4101     }
  4102   4102     if( nMap!=pFd->mmapSize ){
  4103   4103       void *pNew = 0;
  4104   4104       DWORD protect = PAGE_READONLY;
  4105   4105       DWORD flags = FILE_MAP_READ;
  4106   4106   
  4107   4107       winUnmapfile(pFd);
         4108  +#ifdef SQLITE_MMAP_READWRITE
  4108   4109       if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){
  4109   4110         protect = PAGE_READWRITE;
  4110   4111         flags |= FILE_MAP_WRITE;
  4111   4112       }
         4113  +#endif
  4112   4114   #if SQLITE_OS_WINRT
  4113   4115       pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);
  4114   4116   #elif defined(SQLITE_WIN32_HAS_WIDE)
  4115   4117       pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,
  4116   4118                                   (DWORD)((nMap>>32) & 0xffffffff),
  4117   4119                                   (DWORD)(nMap & 0xffffffff), NULL);
  4118   4120   #elif defined(SQLITE_WIN32_HAS_ANSI)

Changes to src/parse.y.

   542    542   distinct(A) ::= DISTINCT.   {A = SF_Distinct;}
   543    543   distinct(A) ::= ALL.        {A = SF_All;}
   544    544   distinct(A) ::= .           {A = 0;}
   545    545   
   546    546   // selcollist is a list of expressions that are to become the return
   547    547   // values of the SELECT statement.  The "*" in statements like
   548    548   // "SELECT * FROM ..." is encoded as a special expression with an
   549         -// opcode of TK_ALL.
          549  +// opcode of TK_ASTERISK.
   550    550   //
   551    551   %type selcollist {ExprList*}
   552    552   %destructor selcollist {sqlite3ExprListDelete(pParse->db, $$);}
   553    553   %type sclp {ExprList*}
   554    554   %destructor sclp {sqlite3ExprListDelete(pParse->db, $$);}
   555    555   sclp(A) ::= selcollist(X) COMMA.             {A = X;}
   556    556   sclp(A) ::= .                                {A = 0;}
   557    557   selcollist(A) ::= sclp(P) expr(X) as(Y).     {
   558    558      A = sqlite3ExprListAppend(pParse, P, X.pExpr);
   559    559      if( Y.n>0 ) sqlite3ExprListSetName(pParse, A, &Y, 1);
   560    560      sqlite3ExprListSetSpan(pParse,A,&X);
   561    561   }
   562    562   selcollist(A) ::= sclp(P) STAR. {
   563         -  Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
          563  +  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
   564    564     A = sqlite3ExprListAppend(pParse, P, p);
   565    565   }
   566    566   selcollist(A) ::= sclp(P) nm(X) DOT STAR(Y). {
   567         -  Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &Y);
          567  +  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &Y);
   568    568     Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &X);
   569    569     Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
   570    570     A = sqlite3ExprListAppend(pParse,P, pDot);
   571    571   }
   572    572   
   573    573   // An option "AS <id>" phrase that can follow one of the expressions that
   574    574   // define the result set, or one of the tables in the FROM clause.

Changes to src/printf.c.

   722    722       */
   723    723       width -= length;
   724    724       if( width>0 && !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
   725    725       sqlite3StrAccumAppend(pAccum, bufpt, length);
   726    726       if( width>0 && flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
   727    727   
   728    728       if( zExtra ){
   729         -      sqlite3_free(zExtra);
          729  +      sqlite3DbFree(pAccum->db, zExtra);
   730    730         zExtra = 0;
   731    731       }
   732    732     }/* End for loop over the format string */
   733    733   } /* End of function */
   734    734   
   735    735   /*
   736    736   ** Enlarge the memory allocation on a StrAccum object so that it is

Changes to src/select.c.

   114    114     pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
   115    115     if( pNew==0 ){
   116    116       assert( db->mallocFailed );
   117    117       pNew = &standin;
   118    118       memset(pNew, 0, sizeof(*pNew));
   119    119     }
   120    120     if( pEList==0 ){
   121         -    pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ALL,0));
          121  +    pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ASTERISK,0));
   122    122     }
   123    123     pNew->pEList = pEList;
   124    124     if( pSrc==0 ) pSrc = sqlite3DbMallocZero(db, sizeof(*pSrc));
   125    125     pNew->pSrc = pSrc;
   126    126     pNew->pWhere = pWhere;
   127    127     pNew->pGroupBy = pGroupBy;
   128    128     pNew->pHaving = pHaving;
................................................................................
  1592   1592     Parse *pParse,          /* Parsing context */
  1593   1593     ExprList *pEList,       /* Expr list from which to derive column names */
  1594   1594     i16 *pnCol,             /* Write the number of columns here */
  1595   1595     Column **paCol          /* Write the new column list here */
  1596   1596   ){
  1597   1597     sqlite3 *db = pParse->db;   /* Database connection */
  1598   1598     int i, j;                   /* Loop counters */
  1599         -  int cnt;                    /* Index added to make the name unique */
         1599  +  u32 cnt;                    /* Index added to make the name unique */
  1600   1600     Column *aCol, *pCol;        /* For looping over result columns */
  1601   1601     int nCol;                   /* Number of columns in the result set */
  1602   1602     Expr *p;                    /* Expression for a single result column */
  1603   1603     char *zName;                /* Column name */
  1604   1604     int nName;                  /* Size of name in zName[] */
         1605  +  Hash ht;                    /* Hash table of column names */
  1605   1606   
         1607  +  sqlite3HashInit(&ht);
  1606   1608     if( pEList ){
  1607   1609       nCol = pEList->nExpr;
  1608   1610       aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
  1609   1611       testcase( aCol==0 );
  1610   1612     }else{
  1611   1613       nCol = 0;
  1612   1614       aCol = 0;
  1613   1615     }
  1614   1616     *pnCol = nCol;
  1615   1617     *paCol = aCol;
  1616   1618   
  1617         -  for(i=0, pCol=aCol; i<nCol; i++, pCol++){
         1619  +  for(i=0, pCol=aCol; i<nCol && !db->mallocFailed; i++, pCol++){
  1618   1620       /* Get an appropriate name for the column
  1619   1621       */
  1620   1622       p = sqlite3ExprSkipCollate(pEList->a[i].pExpr);
  1621   1623       if( (zName = pEList->a[i].zName)!=0 ){
  1622   1624         /* If the column contains an "AS <name>" phrase, use <name> as the name */
  1623         -      zName = sqlite3DbStrDup(db, zName);
  1624   1625       }else{
  1625   1626         Expr *pColExpr = p;  /* The expression that is the result column name */
  1626   1627         Table *pTab;         /* Table associated with this expression */
  1627   1628         while( pColExpr->op==TK_DOT ){
  1628   1629           pColExpr = pColExpr->pRight;
  1629   1630           assert( pColExpr!=0 );
  1630   1631         }
  1631   1632         if( pColExpr->op==TK_COLUMN && ALWAYS(pColExpr->pTab!=0) ){
  1632   1633           /* For columns use the column name name */
  1633   1634           int iCol = pColExpr->iColumn;
  1634   1635           pTab = pColExpr->pTab;
  1635   1636           if( iCol<0 ) iCol = pTab->iPKey;
  1636         -        zName = sqlite3MPrintf(db, "%s",
  1637         -                 iCol>=0 ? pTab->aCol[iCol].zName : "rowid");
         1637  +        zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
  1638   1638         }else if( pColExpr->op==TK_ID ){
  1639   1639           assert( !ExprHasProperty(pColExpr, EP_IntValue) );
  1640         -        zName = sqlite3MPrintf(db, "%s", pColExpr->u.zToken);
         1640  +        zName = pColExpr->u.zToken;
  1641   1641         }else{
  1642   1642           /* Use the original text of the column expression as its name */
  1643         -        zName = sqlite3MPrintf(db, "%s", pEList->a[i].zSpan);
         1643  +        zName = pEList->a[i].zSpan;
  1644   1644         }
  1645   1645       }
  1646         -    if( db->mallocFailed ){
  1647         -      sqlite3DbFree(db, zName);
  1648         -      break;
  1649         -    }
         1646  +    zName = sqlite3MPrintf(db, "%s", zName);
  1650   1647   
  1651   1648       /* Make sure the column name is unique.  If the name is not unique,
  1652   1649       ** append an integer to the name so that it becomes unique.
  1653   1650       */
  1654         -    nName = sqlite3Strlen30(zName);
  1655         -    for(j=cnt=0; j<i; j++){
  1656         -      if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
  1657         -        char *zNewName;
  1658         -        int k;
  1659         -        for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
  1660         -        if( k>=0 && zName[k]==':' ) nName = k;
  1661         -        zName[nName] = 0;
  1662         -        zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
  1663         -        sqlite3DbFree(db, zName);
  1664         -        zName = zNewName;
  1665         -        j = -1;
  1666         -        if( zName==0 ) break;
         1651  +    cnt = 0;
         1652  +    while( zName && sqlite3HashFind(&ht, zName)!=0 ){
         1653  +      nName = sqlite3Strlen30(zName);
         1654  +      if( nName>0 ){
         1655  +        for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}
         1656  +        if( zName[j]==':' ) nName = j;
  1667   1657         }
         1658  +      zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt);
         1659  +      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
  1668   1660       }
  1669   1661       pCol->zName = zName;
         1662  +    sqlite3ColumnPropertiesFromName(0, pCol);
         1663  +    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){
         1664  +      db->mallocFailed = 1;
         1665  +    }
  1670   1666     }
         1667  +  sqlite3HashClear(&ht);
  1671   1668     if( db->mallocFailed ){
  1672   1669       for(j=0; j<i; j++){
  1673   1670         sqlite3DbFree(db, aCol[j].zName);
  1674   1671       }
  1675   1672       sqlite3DbFree(db, aCol);
  1676   1673       *paCol = 0;
  1677   1674       *pnCol = 0;
................................................................................
  3937   3934     pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
  3938   3935     if( pNew==0 ) return WRC_Abort;
  3939   3936     memset(&dummy, 0, sizeof(dummy));
  3940   3937     pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0);
  3941   3938     if( pNewSrc==0 ) return WRC_Abort;
  3942   3939     *pNew = *p;
  3943   3940     p->pSrc = pNewSrc;
  3944         -  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ALL, 0));
         3941  +  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0));
  3945   3942     p->op = TK_SELECT;
  3946   3943     p->pWhere = 0;
  3947   3944     pNew->pGroupBy = 0;
  3948   3945     pNew->pHaving = 0;
  3949   3946     pNew->pOrderBy = 0;
  3950   3947     p->pPrior = 0;
  3951   3948     p->pNext = 0;
................................................................................
  4278   4275     if( db->mallocFailed || sqliteProcessJoin(pParse, p) ){
  4279   4276       return WRC_Abort;
  4280   4277     }
  4281   4278   
  4282   4279     /* For every "*" that occurs in the column list, insert the names of
  4283   4280     ** all columns in all tables.  And for every TABLE.* insert the names
  4284   4281     ** of all columns in TABLE.  The parser inserted a special expression
  4285         -  ** with the TK_ALL operator for each "*" that it found in the column list.
  4286         -  ** The following code just has to locate the TK_ALL expressions and expand
  4287         -  ** each one to the list of all columns in all tables.
         4282  +  ** with the TK_ASTERISK operator for each "*" that it found in the column
         4283  +  ** list.  The following code just has to locate the TK_ASTERISK
         4284  +  ** expressions and expand each one to the list of all columns in
         4285  +  ** all tables.
  4288   4286     **
  4289   4287     ** The first loop just checks to see if there are any "*" operators
  4290   4288     ** that need expanding.
  4291   4289     */
  4292   4290     for(k=0; k<pEList->nExpr; k++){
  4293   4291       pE = pEList->a[k].pExpr;
  4294         -    if( pE->op==TK_ALL ) break;
         4292  +    if( pE->op==TK_ASTERISK ) break;
  4295   4293       assert( pE->op!=TK_DOT || pE->pRight!=0 );
  4296   4294       assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );
  4297         -    if( pE->op==TK_DOT && pE->pRight->op==TK_ALL ) break;
         4295  +    if( pE->op==TK_DOT && pE->pRight->op==TK_ASTERISK ) break;
  4298   4296     }
  4299   4297     if( k<pEList->nExpr ){
  4300   4298       /*
  4301   4299       ** If we get here it means the result set contains one or more "*"
  4302   4300       ** operators that need to be expanded.  Loop through each expression
  4303   4301       ** in the result set and expand them one by one.
  4304   4302       */
................................................................................
  4308   4306       int longNames = (flags & SQLITE_FullColNames)!=0
  4309   4307                         && (flags & SQLITE_ShortColNames)==0;
  4310   4308   
  4311   4309       for(k=0; k<pEList->nExpr; k++){
  4312   4310         pE = a[k].pExpr;
  4313   4311         pRight = pE->pRight;
  4314   4312         assert( pE->op!=TK_DOT || pRight!=0 );
  4315         -      if( pE->op!=TK_ALL && (pE->op!=TK_DOT || pRight->op!=TK_ALL) ){
         4313  +      if( pE->op!=TK_ASTERISK
         4314  +       && (pE->op!=TK_DOT || pRight->op!=TK_ASTERISK)
         4315  +      ){
  4316   4316           /* This particular expression does not need to be expanded.
  4317   4317           */
  4318   4318           pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);
  4319   4319           if( pNew ){
  4320   4320             pNew->a[pNew->nExpr-1].zName = a[k].zName;
  4321   4321             pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan;
  4322   4322             a[k].zName = 0;
................................................................................
  4360   4360               assert( zName );
  4361   4361               if( zTName && pSub
  4362   4362                && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0
  4363   4363               ){
  4364   4364                 continue;
  4365   4365               }
  4366   4366   
  4367         -            /* If a column is marked as 'hidden' (currently only possible
  4368         -            ** for virtual tables), do not include it in the expanded
  4369         -            ** result-set list.
         4367  +            /* If a column is marked as 'hidden', omit it from the expanded
         4368  +            ** result-set list unless the SELECT has the SF_IncludeHidden
         4369  +            ** bit set.
  4370   4370               */
  4371         -            if( IsHiddenColumn(&pTab->aCol[j]) ){
  4372         -              assert(IsVirtual(pTab));
         4371  +            if( (p->selFlags & SF_IncludeHidden)==0
         4372  +             && IsHiddenColumn(&pTab->aCol[j]) 
         4373  +            ){
  4373   4374                 continue;
  4374   4375               }
  4375   4376               tableSeen = 1;
  4376   4377   
  4377   4378               if( i>0 && zTName==0 ){
  4378   4379                 if( (pFrom->fg.jointype & JT_NATURAL)!=0
  4379   4380                   && tableAndColumnIndex(pTabList, i, zName, 0, 0)

Changes to src/shell.c.

   161    161   static int enableTimer = 0;
   162    162   
   163    163   /* Return the current wall-clock time */
   164    164   static sqlite3_int64 timeOfDay(void){
   165    165     static sqlite3_vfs *clockVfs = 0;
   166    166     sqlite3_int64 t;
   167    167     if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
   168         -  if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
          168  +  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
   169    169       clockVfs->xCurrentTimeInt64(clockVfs, &t);
   170    170     }else{
   171    171       double r;
   172    172       clockVfs->xCurrentTime(clockVfs, &r);
   173    173       t = (sqlite3_int64)(r*86400000.0);
   174    174     }
   175    175     return t;
................................................................................
  2556   2556        { "number of triggers:",
  2557   2557          "SELECT count(*) FROM %s WHERE type='trigger'" },
  2558   2558        { "number of views:",
  2559   2559          "SELECT count(*) FROM %s WHERE type='view'" },
  2560   2560        { "schema size:",
  2561   2561          "SELECT total(length(sql)) FROM %s" },
  2562   2562     };
  2563         -  sqlite3_file *pFile;
         2563  +  sqlite3_file *pFile = 0;
  2564   2564     int i;
  2565   2565     char *zSchemaTab;
  2566   2566     char *zDb = nArg>=2 ? azArg[1] : "main";
  2567   2567     unsigned char aHdr[100];
  2568   2568     open_db(p, 0);
  2569   2569     if( p->db==0 ) return 1;
  2570   2570     sqlite3_file_control(p->db, zDb, SQLITE_FCNTL_FILE_POINTER, &pFile);

Changes to src/sqliteInt.h.

  1679   1679     Schema *pSchema;     /* Schema that contains this table */
  1680   1680     Table *pNextZombie;  /* Next on the Parse.pZombieTab list */
  1681   1681   };
  1682   1682   
  1683   1683   /*
  1684   1684   ** Allowed values for Table.tabFlags.
  1685   1685   **
  1686         -** TF_OOOHidden applies to virtual tables that have hidden columns that are
         1686  +** TF_OOOHidden applies to tables or view that have hidden columns that are
  1687   1687   ** followed by non-hidden columns.  Example:  "CREATE VIRTUAL TABLE x USING
  1688   1688   ** vtab1(a HIDDEN, b);".  Since "b" is a non-hidden column but "a" is hidden,
  1689   1689   ** the TF_OOOHidden attribute would apply in this case.  Such tables require
  1690   1690   ** special handling during INSERT processing.
  1691   1691   */
  1692   1692   #define TF_Readonly        0x01    /* Read-only system table */
  1693   1693   #define TF_Ephemeral       0x02    /* An ephemeral table */
................................................................................
  1702   1702   /*
  1703   1703   ** Test to see whether or not a table is a virtual table.  This is
  1704   1704   ** done as a macro so that it will be optimized out when virtual
  1705   1705   ** table support is omitted from the build.
  1706   1706   */
  1707   1707   #ifndef SQLITE_OMIT_VIRTUALTABLE
  1708   1708   #  define IsVirtual(X)      (((X)->tabFlags & TF_Virtual)!=0)
  1709         -#  define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  1710   1709   #else
  1711   1710   #  define IsVirtual(X)      0
  1712         -#  define IsHiddenColumn(X) 0
  1713   1711   #endif
         1712  +
         1713  +/*
         1714  +** Macros to determine if a column is hidden.  IsOrdinaryHiddenColumn()
         1715  +** only works for non-virtual tables (ordinary tables and views) and is
         1716  +** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined.  The
         1717  +** IsHiddenColumn() macro is general purpose.
         1718  +*/
         1719  +#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)
         1720  +#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)
         1721  +#  define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
         1722  +#elif !defined(SQLITE_OMIT_VIRTUALTABLE)
         1723  +#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)
         1724  +#  define IsOrdinaryHiddenColumn(X) 0
         1725  +#else
         1726  +#  define IsHiddenColumn(X)         0
         1727  +#  define IsOrdinaryHiddenColumn(X) 0
         1728  +#endif
         1729  +
  1714   1730   
  1715   1731   /* Does the table have a rowid */
  1716   1732   #define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)
  1717   1733   #define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)
  1718   1734   
  1719   1735   /*
  1720   1736   ** Each foreign key constraint is an instance of the following structure.
................................................................................
  2501   2517   #define SF_Values          0x0100  /* Synthesized from VALUES clause */
  2502   2518   #define SF_MultiValue      0x0200  /* Single VALUES term with multiple rows */
  2503   2519   #define SF_NestedFrom      0x0400  /* Part of a parenthesized FROM clause */
  2504   2520   #define SF_MaybeConvert    0x0800  /* Need convertCompoundSelectToSubquery() */
  2505   2521   #define SF_MinMaxAgg       0x1000  /* Aggregate containing min() or max() */
  2506   2522   #define SF_Recursive       0x2000  /* The recursive part of a recursive CTE */
  2507   2523   #define SF_Converted       0x4000  /* By convertCompoundSelectToSubquery() */
         2524  +#define SF_IncludeHidden   0x8000  /* Include hidden columns in output */
  2508   2525   
  2509   2526   
  2510   2527   /*
  2511   2528   ** The results of a SELECT can be distributed in several ways, as defined
  2512   2529   ** by one of the following macros.  The "SRT" prefix means "SELECT Result
  2513   2530   ** Type".
  2514   2531   **
................................................................................
  3320   3337   void sqlite3DeleteColumnNames(sqlite3*,Table*);
  3321   3338   int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
  3322   3339   Table *sqlite3ResultSetOfSelect(Parse*,Select*);
  3323   3340   void sqlite3OpenMasterTable(Parse *, int);
  3324   3341   Index *sqlite3PrimaryKeyIndex(Table*);
  3325   3342   i16 sqlite3ColumnOfIndex(Index*, i16);
  3326   3343   void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
         3344  +void sqlite3ColumnPropertiesFromName(Table*, Column*);
  3327   3345   void sqlite3AddColumn(Parse*,Token*);
  3328   3346   void sqlite3AddNotNull(Parse*, int);
  3329   3347   void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
  3330   3348   void sqlite3AddCheckConstraint(Parse*, Expr*);
  3331   3349   void sqlite3AddColumnType(Parse*,Token*);
  3332   3350   void sqlite3AddDefaultValue(Parse*,ExprSpan*);
  3333   3351   void sqlite3AddCollateType(Parse*, Token*);

Changes to src/test1.c.

  2234   2234   */
  2235   2235   static int test_config_sqllog(
  2236   2236     void * clientData,
  2237   2237     Tcl_Interp *interp,
  2238   2238     int objc,
  2239   2239     Tcl_Obj *CONST objv[]
  2240   2240   ){
  2241         -  sqlite3_stmt *pStmt;            /* First argument */
  2242   2241     if( objc!=1 ){
  2243   2242       Tcl_WrongNumArgs(interp, 1, objv, "");
  2244   2243       return TCL_ERROR;
  2245   2244     }
  2246   2245     sqlite3_config(SQLITE_CONFIG_SQLLOG, 0, 0);
  2247   2246     return TCL_OK;
  2248   2247   }
  2249   2248   #endif
         2249  +
         2250  +/*
         2251  +** Usage: vfs_current_time_int64
         2252  +**
         2253  +** Return the value returned by the default VFS's xCurrentTimeInt64 method.
         2254  +*/
         2255  +static int vfsCurrentTimeInt64(
         2256  +  void * clientData,
         2257  +  Tcl_Interp *interp,
         2258  +  int objc,
         2259  +  Tcl_Obj *CONST objv[]
         2260  +){
         2261  +  i64 t;
         2262  +  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
         2263  +  if( objc!=1 ){
         2264  +    Tcl_WrongNumArgs(interp, 1, objv, "");
         2265  +    return TCL_ERROR;
         2266  +  }
         2267  +  pVfs->xCurrentTimeInt64(pVfs, &t);
         2268  +  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(t));
         2269  +  return TCL_OK;
         2270  +}
  2250   2271   
  2251   2272   /*
  2252   2273   ** Usage:  sqlite3_next_stmt  DB  STMT
  2253   2274   **
  2254   2275   ** Return the next statment in sequence after STMT.
  2255   2276   */
  2256   2277   static int test_next_stmt(
................................................................................
  7256   7277   #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
  7257   7278        { "sqlite3_stmt_scanstatus",       test_stmt_scanstatus,   0 },
  7258   7279        { "sqlite3_stmt_scanstatus_reset", test_stmt_scanstatus_reset,   0 },
  7259   7280   #endif
  7260   7281   #ifdef SQLITE_ENABLE_SQLLOG
  7261   7282        { "sqlite3_config_sqllog",         test_config_sqllog,   0 },
  7262   7283   #endif
  7263         -
         7284  +     { "vfs_current_time_int64",           vfsCurrentTimeInt64,   0 },
  7264   7285     };
  7265   7286     static int bitmask_size = sizeof(Bitmask)*8;
  7266   7287     static int longdouble_size = sizeof(LONGDOUBLE_TYPE);
  7267   7288     int i;
  7268   7289     extern int sqlite3_sync_count, sqlite3_fullsync_count;
  7269   7290     extern int sqlite3_opentemp_count;
  7270   7291     extern int sqlite3_like_count;

Changes to src/test_config.c.

   120    120   #endif
   121    121   
   122    122   #ifdef SQLITE_ENABLE_CURSOR_HINTS
   123    123     Tcl_SetVar2(interp, "sqlite_options", "cursorhints", "1", TCL_GLOBAL_ONLY);
   124    124   #else
   125    125     Tcl_SetVar2(interp, "sqlite_options", "cursorhints", "0", TCL_GLOBAL_ONLY);
   126    126   #endif
          127  +
          128  +#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
          129  +  Tcl_SetVar2(interp, "sqlite_options", "hiddencolumns", "1", TCL_GLOBAL_ONLY);
          130  +#else
          131  +  Tcl_SetVar2(interp, "sqlite_options", "hiddencolumns", "0", TCL_GLOBAL_ONLY);
          132  +#endif
   127    133   
   128    134   #ifdef SQLITE_ENABLE_MEMSYS3
   129    135     Tcl_SetVar2(interp, "sqlite_options", "mem3", "1", TCL_GLOBAL_ONLY);
   130    136   #else
   131    137     Tcl_SetVar2(interp, "sqlite_options", "mem3", "0", TCL_GLOBAL_ONLY);
   132    138   #endif
   133    139   

Changes to test/fuzzcheck.c.

   834    834     const char *zFailCode = 0;   /* Value of the TEST_FAILURE environment variable */
   835    835     int cellSzCkFlag = 0;        /* --cell-size-check */
   836    836     int sqlFuzz = 0;             /* True for SQL fuzz testing. False for DB fuzz */
   837    837     int iTimeout = 120;          /* Default 120-second timeout */
   838    838     int nMem = 0;                /* Memory limit */
   839    839     char *zExpDb = 0;            /* Write Databases to files in this directory */
   840    840     char *zExpSql = 0;           /* Write SQL to files in this directory */
          841  +  void *pHeap = 0;             /* Heap for use by SQLite */
   841    842   
   842    843     iBegin = timeOfDay();
   843    844   #ifdef __unix__
   844    845     signal(SIGALRM, timeoutHandler);
   845    846   #endif
   846    847     g.zArgv0 = argv[0];
   847    848     zFailCode = getenv("TEST_FAILURE");
................................................................................
  1081   1082       sqlite3_close(db);
  1082   1083       if( sqlite3_memory_used()>0 ){
  1083   1084         fatalError("SQLite has memory in use before the start of testing");
  1084   1085       }
  1085   1086   
  1086   1087       /* Limit available memory, if requested */
  1087   1088       if( nMem>0 ){
  1088         -      void *pHeap;
  1089   1089         sqlite3_shutdown();
  1090   1090         pHeap = malloc(nMem);
  1091   1091         if( pHeap==0 ){
  1092   1092           fatalError("failed to allocate %d bytes of heap memory", nMem);
  1093   1093         }
  1094   1094         sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nMem, 128);
  1095   1095       }
................................................................................
  1180   1180       sqlite3_int64 iElapse = timeOfDay() - iBegin;
  1181   1181       printf("fuzzcheck: 0 errors out of %d tests in %d.%03d seconds\n"
  1182   1182              "SQLite %s %s\n",
  1183   1183              nTest, (int)(iElapse/1000), (int)(iElapse%1000),
  1184   1184              sqlite3_libversion(), sqlite3_sourceid());
  1185   1185     }
  1186   1186     free(azSrcDb);
         1187  +  free(pHeap);
  1187   1188     return 0;
  1188   1189   }

Added test/hidden.test.

            1  +# 2015 November 18
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# Test the __hidden__ hack.
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +set testprefix hidden
           18  +
           19  +ifcapable !hiddencolumns {
           20  +  finish_test
           21  +  return
           22  +}
           23  +
           24  +do_execsql_test 1.1 {
           25  +  CREATE TABLE t1(__hidden__a, b);
           26  +  INSERT INTO t1 VALUES('1');
           27  +  INSERT INTO t1(__hidden__a, b) VALUES('x', 'y');
           28  +} {}
           29  +
           30  +do_execsql_test 1.2 {
           31  +  SELECT * FROM t1;
           32  +} {1 y}
           33  +
           34  +do_execsql_test 1.3 {
           35  +  SELECT __hidden__a, * FROM t1;
           36  +} {{} 1 x y}
           37  +
           38  +foreach {tn view} {
           39  +  1 { CREATE VIEW v1(a, b, __hidden__c) AS SELECT a, b, c FROM x1 }
           40  +  2 { CREATE VIEW v1 AS SELECT a, b, c AS __hidden__c FROM x1 }
           41  +} {
           42  +  do_execsql_test 2.$tn.1 {
           43  +    DROP TABLE IF EXISTS x1;
           44  +    CREATE TABLE x1(a, b, c);
           45  +    INSERT INTO x1 VALUES(1, 2, 3);
           46  +  }
           47  +
           48  +  catchsql { DROP VIEW v1 }
           49  +  execsql $view
           50  +
           51  +  do_execsql_test 2.$tn.2 {
           52  +    SELECT a, b, __hidden__c FROM v1;
           53  +  } {1 2 3}
           54  +  
           55  +  do_execsql_test 2.$tn.3 {
           56  +    SELECT * FROM v1;
           57  +  } {1 2}
           58  +  
           59  +  do_execsql_test 2.$tn.4 {
           60  +    CREATE TRIGGER tr1 INSTEAD OF INSERT ON v1 BEGIN
           61  +      INSERT INTO x1 VALUES(new.a, new.b, new.__hidden__c);
           62  +    END;
           63  +  
           64  +    INSERT INTO v1 VALUES(4, 5);
           65  +    SELECT * FROM x1;
           66  +  } {1 2 3 4 5 {}}
           67  +  
           68  +  do_execsql_test 2.$tn.5 {
           69  +    INSERT INTO v1(a, b, __hidden__c) VALUES(7, 8, 9);
           70  +    SELECT * FROM x1;
           71  +  } {1 2 3 4 5 {} 7 8 9}
           72  +}
           73  +
           74  +#-------------------------------------------------------------------------
           75  +# Test INSERT INTO ... SELECT ... statements that write to tables with
           76  +# hidden columns.
           77  +#
           78  +do_execsql_test 3.1 {
           79  +  CREATE TABLE t4(a, __hidden__b, c);
           80  +  INSERT INTO t4 SELECT 1, 2;
           81  +  SELECT a, __hidden__b, c FROM t4;
           82  +} {1 {} 2}
           83  +
           84  +do_execsql_test 3.2.1 {
           85  +  CREATE TABLE t5(__hidden__a, b, c);
           86  +  CREATE TABLE t6(__hidden__a, b, c);
           87  +  INSERT INTO t6(__hidden__a, b, c) VALUES(1, 2, 3);
           88  +  INSERT INTO t6(__hidden__a, b, c) VALUES(4, 5, 6);
           89  +  INSERT INTO t6(__hidden__a, b, c) VALUES(7, 8, 9);
           90  +}
           91  +
           92  +do_execsql_test 3.2.2 {
           93  +  INSERT INTO t5 SELECT * FROM t6;
           94  +  SELECT * FROM t5;
           95  +} {2 3   5 6   8 9}
           96  +
           97  +do_execsql_test 3.2.3 {
           98  +  SELECT __hidden__a FROM t5;
           99  +} {{} {} {}}
          100  +
          101  +
          102  +do_execsql_test 3.3.1 {
          103  +  CREATE TABLE t5a(a, b, __hidden__c);
          104  +  CREATE TABLE t6a(a, b, __hidden__c);
          105  +  INSERT INTO t6a(a, b, __hidden__c) VALUES(1, 2, 3);
          106  +  INSERT INTO t6a(a, b, __hidden__c) VALUES(4, 5, 6);
          107  +  INSERT INTO t6a(a, b, __hidden__c) VALUES(7, 8, 9);
          108  +}
          109  +
          110  +do_execsql_test 3.3.2 {
          111  +  INSERT INTO t5a SELECT * FROM t6a;
          112  +  SELECT * FROM t5a;
          113  +} {1 2   4 5   7 8}
          114  +
          115  +do_execsql_test 3.3.3 {
          116  +  SELECT __hidden__c FROM t5a;
          117  +} {{} {} {}}
          118  +
          119  +do_execsql_test 3.4.1 {
          120  +  CREATE TABLE t5b(a, __hidden__b, c);
          121  +  CREATE TABLE t6b(a, b, __hidden__c);
          122  +  INSERT INTO t6b(a, b, __hidden__c) VALUES(1, 2, 3);
          123  +  INSERT INTO t6b(a, b, __hidden__c) VALUES(4, 5, 6);
          124  +  INSERT INTO t6b(a, b, __hidden__c) VALUES(7, 8, 9);
          125  +}
          126  +
          127  +do_execsql_test 3.4.2 {
          128  +  INSERT INTO t5b SELECT * FROM t6b;
          129  +  SELECT * FROM t5b;
          130  +} {1 2   4 5   7 8}
          131  +
          132  +do_execsql_test 3.4.3 {
          133  +  SELECT __hidden__b FROM t5b;
          134  +} {{} {} {}}
          135  +
          136  +#-------------------------------------------------------------------------
          137  +# Test VACUUM
          138  +#
          139  +reset_db
          140  +do_execsql_test 4.1 {
          141  +  CREATE TABLE t1(a, __hidden__b, c UNIQUE);
          142  +  INSERT INTO t1(a, __hidden__b, c) VALUES(1, 2, 3);
          143  +  INSERT INTO t1(a, __hidden__b, c) VALUES(4, 5, 6);
          144  +  INSERT INTO t1(a, __hidden__b, c) VALUES(7, 8, 9);
          145  +  DELETE FROM t1 WHERE __hidden__b = 5;
          146  +  SELECT rowid, a, __hidden__b, c FROM t1;
          147  +} {1 1 2 3   3 7 8 9}
          148  +do_execsql_test 4.2 {
          149  +  VACUUM;
          150  +  SELECT rowid, a, __hidden__b, c FROM t1;
          151  +} {1 1 2 3   3 7 8 9}
          152  +
          153  +finish_test

Changes to test/misc1.test.

   696    696   
   697    697   # At one point, running this would read one byte passed the end of a 
   698    698   # buffer, upsetting valgrind.
   699    699   #
   700    700   do_test misc1-24.0 {
   701    701     list [catch { sqlite3_prepare_v2 db ! -1 dummy } msg] $msg
   702    702   } {1 {(1) unrecognized token: "!}}
          703  +
          704  +# The following query (provided by Kostya Serebryany) used to take 25
          705  +# minutes to prepare.  This has been speeded up to about 250 milliseconds.
          706  +#
          707  +do_catchsql_test misc1-25.0 {
          708  +SELECT-1 UNION  SELECT 5 UNION SELECT 0 UNION SElECT*from(SELECT-5) UNION SELECT*from(SELECT-0) UNION  SELECT:SELECT-0 UNION SELECT-1 UNION SELECT 1 UNION SELECT 1 ORDER BY S  in(WITH K AS(WITH K AS(select'CREINDERcharREADEVIRTUL5TABLECONFLICT !1 USIN'' MFtOR(b38q,eWITH K AS(selectCREATe TABLE t0(a,b,c,d,e, PRIMARY KEY(a,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,b,c,d,c,a,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d'CEIl,k'',ab, g, a,b,o11b, i'nEX/charREDE IVT LR!VABLt5SG',N  ,N in rement,l_vacuum,M&U,'te3(''5l' a,bB,b,l*e)SELECT:SELECT, *,*,*from(( SELECT
          709  +$group,:conc ap0,1)fro,(select"",:PBAG,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d, foreign_keysc,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,a,b,d,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,bb,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,a,b,d,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,MAato_aecSELEC,+?b," "O,"i","a",""b  ,5 ))KEY)SELECT*FROM((k()reaC,k,K) eA,k '' )t ,K  M);
          710  +} {1 {too many columns in result set}}
          711  +
   703    712   
   704    713   finish_test

Changes to test/pragma2.test.

   196    196       PRAGMA cache_spill=100000;
   197    197       PRAGMA cache_spill;
   198    198       BEGIN;
   199    199       UPDATE t1 SET c=c+1;
   200    200       PRAGMA lock_status;
   201    201     }
   202    202   } {100000 main reserved temp unknown}   ;# Big spill threshold -> no excl lock
   203         -do_test pragma2-4.5.3 {
   204         -  db eval {
   205         -    ROLLBACK;
   206         -    PRAGMA cache_spill=25;
   207         -    PRAGMA main.cache_spill;
   208         -    BEGIN;
   209         -    UPDATE t1 SET c=c+1;
   210         -    PRAGMA lock_status;
   211         -  }
   212         -} {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock
   213         -do_test pragma2-4.5.4 {
   214         -  db eval {
   215         -    ROLLBACK;
   216         -    PRAGMA cache_spill(-25);
   217         -    PRAGMA main.cache_spill;
   218         -    BEGIN;
   219         -    UPDATE t1 SET c=c+1;
   220         -    PRAGMA lock_status;
   221         -  }
   222         -} {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock
          203  +ifcapable !memorymanage {
          204  +  do_test pragma2-4.5.3 {
          205  +    db eval {
          206  +      ROLLBACK;
          207  +      PRAGMA cache_spill=25;
          208  +      PRAGMA main.cache_spill;
          209  +      BEGIN;
          210  +      UPDATE t1 SET c=c+1;
          211  +      PRAGMA lock_status;
          212  +    }
          213  +  } {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock
          214  +  do_test pragma2-4.5.4 {
          215  +    db eval {
          216  +      ROLLBACK;
          217  +      PRAGMA cache_spill(-25);
          218  +      PRAGMA main.cache_spill;
          219  +      BEGIN;
          220  +      UPDATE t1 SET c=c+1;
          221  +      PRAGMA lock_status;
          222  +    }
          223  +  } {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock
          224  +}
   223    225   
   224    226   
   225    227   # Verify that newly attached databases inherit the cache_spill=OFF
   226    228   # setting.
   227    229   #
   228    230   do_execsql_test pragma2-4.6 {
   229    231     ROLLBACK;

Changes to test/releasetest.tcl.

   115    115       -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
   116    116       -DSQLITE_ENABLE_FTS3=1
   117    117       -DSQLITE_ENABLE_RTREE=1
   118    118       -DSQLITE_ENABLE_MEMSYS5=1
   119    119       -DSQLITE_ENABLE_MEMSYS3=1
   120    120       -DSQLITE_ENABLE_COLUMN_METADATA=1
   121    121       -DSQLITE_ENABLE_STAT4
          122  +    -DSQLITE_ENABLE_HIDDEN_COLUMNS
   122    123       -DSQLITE_MAX_ATTACHED=125
   123    124     }
   124    125     "Fast-One" {
   125    126       -O6
   126    127       -DSQLITE_ENABLE_FTS4=1
   127    128       -DSQLITE_ENABLE_RTREE=1
   128    129       -DSQLITE_ENABLE_STAT4
................................................................................
   141    142       -DSQLITE_ENABLE_ATOMIC_WRITE=1
   142    143       -DSQLITE_ENABLE_IOTRACE=1
   143    144       -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
   144    145       -DSQLITE_MAX_PAGE_SIZE=4096
   145    146       -DSQLITE_OMIT_LOAD_EXTENSION=1
   146    147       -DSQLITE_OMIT_PROGRESS_CALLBACK=1
   147    148       -DSQLITE_OMIT_VIRTUALTABLE=1
          149  +    -DSQLITE_ENABLE_HIDDEN_COLUMNS
   148    150       -DSQLITE_TEMP_STORE=3
   149    151       --enable-json1
   150    152     }
   151    153     "Device-Two" {
   152    154       -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
   153    155       -DSQLITE_DEFAULT_AUTOVACUUM=1
   154    156       -DSQLITE_DEFAULT_CACHE_SIZE=1000
................................................................................
   209    211       -DSQLITE_OMIT_LOOKASIDE=1
   210    212       -DHAVE_USLEEP=1
   211    213     }
   212    214     "Valgrind" {
   213    215       -DSQLITE_ENABLE_STAT4
   214    216       -DSQLITE_ENABLE_FTS4
   215    217       -DSQLITE_ENABLE_RTREE
          218  +    -DSQLITE_ENABLE_HIDDEN_COLUMNS
   216    219       --enable-json1
   217    220     }
   218    221   
   219    222     # The next group of configurations are used only by the
   220    223     # Failure-Detection platform.  They are all the same, but we need
   221    224     # different names for them all so that they results appear in separate
   222    225     # subdirectories.
................................................................................
   302    305       if {0==[info exists ::Configs($v)]} {
   303    306         puts stderr "No such configuration: \"$v\""
   304    307         exit -1
   305    308       }
   306    309     }
   307    310   }
   308    311   
   309         -# Output log
   310         -#
   311         -set LOG [open releasetest-out.txt w]
   312         -proc PUTS {args} {
   313         -  if {[llength $args]==2} {
   314         -    puts [lindex $args 0] [lindex $args 1]
   315         -    puts $::LOG [lindex $args 1]
   316         -  } else {
   317         -    puts [lindex $args 0]
   318         -    puts $::LOG [lindex $args 0]
   319         -  }
   320         -  flush $::LOG
   321         -}
   322         -puts $LOG "$argv0 $argv"
   323         -set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
   324         -puts $LOG "start-time: $tm0 UTC"
          312  +# Output log.   Disabled for slave interpreters.
          313  +#
          314  +if {[lindex $argv end]!="--slave"} {
          315  +  set LOG [open releasetest-out.txt w]
          316  +  proc PUTS {txt} {
          317  +    puts $txt
          318  +    puts $::LOG $txt
          319  +    flush $::LOG
          320  +  }
          321  +  proc PUTSNNL {txt} {
          322  +    puts -nonewline $txt
          323  +    puts -nonewline $::LOG $txt
          324  +    flush $::LOG
          325  +  }
          326  +  proc PUTSERR {txt} {
          327  +    puts stderr $txt
          328  +    puts $::LOG $txt
          329  +    flush $::LOG
          330  +  }
          331  +  puts $LOG "$argv0 $argv"
          332  +  set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
          333  +  puts $LOG "start-time: $tm0 UTC"
          334  +} else {
          335  +  proc PUTS {txt} {
          336  +    puts $txt
          337  +  }
          338  +  proc PUTSNNL {txt} {
          339  +    puts -nonewline $txt
          340  +  }
          341  +  proc PUTSERR {txt} {
          342  +    puts stderr $txt
          343  +  }
          344  +}
   325    345   
   326    346   # Open the file $logfile and look for a report on the number of errors
   327    347   # and the number of test cases run.  Add these values to the global
   328    348   # $::NERRCASE and $::NTESTCASE variables.
   329    349   #
   330    350   # If any errors occur, then write into $errmsgVar the text of an appropriate
   331    351   # one-line error message to show on the output.
................................................................................
   418    438     foreach {::TRACE ::MSVC ::DRYRUN} $V {}
   419    439   
   420    440     # Read the test-suite configuration from stdin.
   421    441     set T [gets stdin]
   422    442     foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
   423    443   
   424    444     # Create and switch to the test directory.
          445  +  set ::env(SQLITE_TMPDIR) [file normalize $dir]
   425    446     trace_cmd file mkdir $dir
   426    447     trace_cmd cd $dir
   427    448     catch {file delete core}
   428    449     catch {file delete test.log}
   429    450   
   430    451     # Run the "./configure && make" commands.
   431    452     set rc 0
................................................................................
   805    826         -enable-* -
   806    827         -disable-* -
   807    828         *=* {
   808    829           lappend ::EXTRACONFIG [lindex $argv $i]
   809    830         }
   810    831   
   811    832         default {
   812         -        PUTS stderr ""
   813         -        PUTS stderr [string trim $::USAGE_MESSAGE]
          833  +        PUTSERR stderr ""
          834  +        PUTSERR stderr [string trim $::USAGE_MESSAGE]
   814    835           exit -1
   815    836         }
   816    837       }
   817    838     }
   818    839   
   819    840     if {0==[info exists ::Platforms($platform)]} {
   820    841       PUTS "Unknown platform: $platform"
   821         -    PUTS -nonewline "Set the -platform option to "
          842  +    PUTSNNL "Set the -platform option to "
   822    843       set print [list]
   823    844       foreach p [array names ::Platforms] {
   824    845         lappend print "\"$p\""
   825    846       }
   826    847       lset print end "or [lindex $print end]"
   827    848       PUTS "[join $print {, }]."
   828    849       exit
................................................................................
   840    861         }
   841    862       } else {
   842    863         set ::CONFIGLIST $::Platforms($platform)
   843    864       }
   844    865     }
   845    866     PUTS "Running the following test configurations for $platform:"
   846    867     PUTS "    [string trim $::CONFIGLIST]"
   847         -  PUTS -nonewline "Flags:"
   848         -  if {$::PROGRESS_MSGS} {PUTS -nonewline " --progress"}
   849         -  if {$::DRYRUN} {PUTS -nonewline " --dryrun"}
   850         -  if {$::BUILDONLY} {PUTS -nonewline " --buildonly"}
   851         -  if {$::MSVC} {PUTS -nonewline " --msvc"}
          868  +  PUTSNNL "Flags:"
          869  +  if {$::PROGRESS_MSGS} {PUTSNNL " --progress"}
          870  +  if {$::DRYRUN} {PUTSNNL " --dryrun"}
          871  +  if {$::BUILDONLY} {PUTSNNL " --buildonly"}
          872  +  if {$::MSVC} {PUTSNNL " --msvc"}
   852    873     switch -- $::QUICK {
   853         -     1 {PUTS -nonewline " --quick"}
   854         -     2 {PUTS -nonewline " --veryquick"}
          874  +     1 {PUTSNNL " --quick"}
          875  +     2 {PUTSNNL " --veryquick"}
   855    876     }
   856         -  if {$::JOBS>1} {PUTS -nonewline " --jobs $::JOBS"}
          877  +  if {$::JOBS>1} {PUTSNNL " --jobs $::JOBS"}
   857    878     PUTS ""
   858    879   }
   859    880   
   860    881   # Main routine.
   861    882   #
   862    883   proc main {argv} {
   863    884   

Changes to tool/addopcodes.tcl.

    33     33     FUNCTION
    34     34     COLUMN
    35     35     AGG_FUNCTION
    36     36     AGG_COLUMN
    37     37     UMINUS
    38     38     UPLUS
    39     39     REGISTER
           40  +  ASTERISK
    40     41     SPACE
    41     42     ILLEGAL
    42     43   }
    43     44   if {[lrange $extras end-1 end]!="SPACE ILLEGAL"} {
    44     45     error "SPACE and ILLEGAL must be the last two token codes and they\
    45     46            must be in that order"
    46     47   }

Changes to tool/mkkeywordhash.c.

   324    324   }
   325    325   
   326    326   /*
   327    327   ** This routine does the work.  The generated code is printed on standard
   328    328   ** output.
   329    329   */
   330    330   int main(int argc, char **argv){
   331         -  int i, j, k, h, m;
          331  +  int i, j, k, h;
   332    332     int bestSize, bestCount;
   333    333     int count;
   334    334     int nChar;
   335    335     int totalLen = 0;
   336    336     int aHash[1000];  /* 1000 is much bigger than nKeyword */
   337    337     char zText[2000];
   338    338   

Changes to tool/sqldiff.c.

  1737   1737   "  --changeset FILE      Write a CHANGESET into FILE\n"
  1738   1738   "  -L|--lib LIBRARY      Load an SQLite extension library\n"
  1739   1739   "  --primarykey          Use schema-defined PRIMARY KEYs\n"
  1740   1740   "  --rbu                 Output SQL to create/populate RBU table(s)\n"
  1741   1741   "  --schema              Show only differences in the schema\n"
  1742   1742   "  --summary             Show only a summary of the differences\n"
  1743   1743   "  --table TAB           Show only differences in table TAB\n"
         1744  +"  --transaction         Show SQL output inside a transaction\n"
  1744   1745     );
  1745   1746   }
  1746   1747   
  1747   1748   int main(int argc, char **argv){
  1748   1749     const char *zDb1 = 0;
  1749   1750     const char *zDb2 = 0;
  1750   1751     int i;
................................................................................
  1753   1754     char *zSql;
  1754   1755     sqlite3_stmt *pStmt;
  1755   1756     char *zTab = 0;
  1756   1757     FILE *out = stdout;
  1757   1758     void (*xDiff)(const char*,FILE*) = diff_one_table;
  1758   1759     int nExt = 0;
  1759   1760     char **azExt = 0;
         1761  +  int useTransaction = 0;
         1762  +  int neverUseTransaction = 0;
  1760   1763   
  1761   1764     g.zArgv0 = argv[0];
  1762   1765     sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
  1763   1766     for(i=1; i<argc; i++){
  1764   1767       const char *z = argv[i];
  1765   1768       if( z[0]=='-' ){
  1766   1769         z++;
  1767   1770         if( z[0]=='-' ) z++;
  1768   1771         if( strcmp(z,"changeset")==0 ){
  1769   1772           if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
  1770   1773           out = fopen(argv[++i], "wb");
  1771   1774           if( out==0 ) cmdlineError("cannot open: %s", argv[i]);
  1772   1775           xDiff = changeset_one_table;
         1776  +        neverUseTransaction = 1;
  1773   1777         }else
  1774   1778         if( strcmp(z,"debug")==0 ){
  1775   1779           if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
  1776   1780           g.fDebug = strtol(argv[++i], 0, 0);
  1777   1781         }else
  1778   1782         if( strcmp(z,"help")==0 ){
  1779   1783           showHelp();
................................................................................
  1798   1802         }else
  1799   1803         if( strcmp(z,"summary")==0 ){
  1800   1804           xDiff = summarize_one_table;
  1801   1805         }else
  1802   1806         if( strcmp(z,"table")==0 ){
  1803   1807           if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
  1804   1808           zTab = argv[++i];
         1809  +      }else
         1810  +      if( strcmp(z,"transaction")==0 ){
         1811  +        useTransaction = 1;
  1805   1812         }else
  1806   1813         {
  1807   1814           cmdlineError("unknown option: %s", argv[i]);
  1808   1815         }
  1809   1816       }else if( zDb1==0 ){
  1810   1817         zDb1 = argv[i];
  1811   1818       }else if( zDb2==0 ){
................................................................................
  1841   1848       cmdlineError("cannot attach database \"%s\"", zDb2);
  1842   1849     }
  1843   1850     rc = sqlite3_exec(g.db, "SELECT * FROM aux.sqlite_master", 0, 0, &zErrMsg);
  1844   1851     if( rc || zErrMsg ){
  1845   1852       cmdlineError("\"%s\" does not appear to be a valid SQLite database", zDb2);
  1846   1853     }
  1847   1854   
         1855  +  if( neverUseTransaction ) useTransaction = 0;
         1856  +  if( useTransaction ) printf("BEGIN TRANSACTION;\n");
  1848   1857     if( zTab ){
  1849   1858       xDiff(zTab, out);
  1850   1859     }else{
  1851   1860       /* Handle tables one by one */
  1852   1861       pStmt = db_prepare(
  1853   1862         "SELECT name FROM main.sqlite_master\n"
  1854   1863         " WHERE type='table' AND sql NOT LIKE 'CREATE VIRTUAL%%'\n"
................................................................................
  1858   1867         " ORDER BY name"
  1859   1868       );
  1860   1869       while( SQLITE_ROW==sqlite3_step(pStmt) ){
  1861   1870         xDiff((const char*)sqlite3_column_text(pStmt,0), out);
  1862   1871       }
  1863   1872       sqlite3_finalize(pStmt);
  1864   1873     }
         1874  +  if( useTransaction ) printf("COMMIT;\n");
  1865   1875   
  1866   1876     /* TBD: Handle trigger differences */
  1867   1877     /* TBD: Handle view differences */
  1868   1878     sqlite3_close(g.db);
  1869   1879     return 0;
  1870   1880   }