/ Check-in [cc780842]
Login

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

Overview
Comment:Merge the testing enhancements and the unlimited VALUES enhancement from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: cc7808427f8e9df8e2810a6681b2ddd93e578c67
User & Date: drh 2015-01-08 19:55:13
Context
2015-01-16
12:24
Merge the 3.8.8 release changes from trunk. check-in: 518621f8 user: drh tags: apple-osx
2015-01-08
19:55
Merge the testing enhancements and the unlimited VALUES enhancement from trunk. check-in: cc780842 user: drh tags: apple-osx
16:47
Try to fix up the "valgrindtest" target in Makefile.in so that it avoids misuse testing that can trigger false errors. check-in: 50b5a8af user: drh tags: trunk
2015-01-02
19:17
Merge the latest changes from trunk into the apple-osx branch. check-in: df3cdf9f user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

    26     26   # will run on the target platform.  (BCC and TCC are usually the
    27     27   # same unless your are cross-compiling.)  Separate CC and CFLAGS macros
    28     28   # are provide so that these aspects of the build process can be changed
    29     29   # on the "make" command-line.  Ex:  "make CC=clang CFLAGS=-fsanitize=undefined"
    30     30   #
    31     31   CC = @CC@
    32     32   CFLAGS = @CPPFLAGS@ @CFLAGS@
    33         -TCC = $(CC) $(CFLAGS) -I. -I${TOP}/src -I${TOP}/ext/rtree
           33  +TCC = $(CC) $(CFLAGS) -I. -I${TOP}/src -I${TOP}/ext/rtree -I${TOP}/ext/fts3
    34     34   
    35     35   # Define this for the autoconf-based build, so that the code knows it can
    36     36   # include the generated config.h
    37     37   # 
    38     38   TCC += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
    39     39   
    40     40   # Define -DNDEBUG to compile without debugging (i.e., for production usage)
................................................................................
   939    939   TESTFIXTURE_SRC = $(TESTSRC) $(TOP)/src/tclsqlite.c
   940    940   TESTFIXTURE_SRC += $(TESTFIXTURE_SRC$(USE_AMALGAMATION))
   941    941   
   942    942   testfixture$(TEXE):	$(TESTFIXTURE_SRC)
   943    943   	$(LTLINK) -DSQLITE_NO_SYNC=1 $(TEMP_STORE) $(TESTFIXTURE_FLAGS) \
   944    944   		-o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS)
   945    945   
   946         -
          946  +# A very detailed test running most or all test cases
   947    947   fulltest:	testfixture$(TEXE) sqlite3$(TEXE)
   948    948   	./testfixture$(TEXE) $(TOP)/test/all.test
   949    949   
          950  +# Really really long testing
   950    951   soaktest:	testfixture$(TEXE) sqlite3$(TEXE)
   951    952   	./testfixture$(TEXE) $(TOP)/test/all.test -soak=1
   952    953   
          954  +# Do extra testing but not aeverything.
   953    955   fulltestonly:	testfixture$(TEXE) sqlite3$(TEXE)
   954    956   	./testfixture$(TEXE) $(TOP)/test/full.test
   955    957   
          958  +# This is the common case.  Run many tests but not those that take
          959  +# a really long time.
          960  +#
   956    961   test:	testfixture$(TEXE) sqlite3$(TEXE)
   957    962   	./testfixture$(TEXE) $(TOP)/test/veryquick.test
          963  +
          964  +# Run a test using valgrind.  This can take a really long time
          965  +# because valgrind is so much slower than a native machine.
          966  +#
          967  +valgrindtest:	testfixture$(TEXE) sqlite3$(TEXE)
          968  +	OMIT_MISUSE=1 valgrind -v ./testfixture$(TEXE) $(TOP)/test/permutations.test valgrind
          969  +
          970  +# A very fast test that checks basic sanity.  The name comes from
          971  +# the 60s-era electronics testing:  "Turn it on and see if smoke
          972  +# comes out."
          973  +#
          974  +smoketest:	testfixture$(TEXE)
          975  +	./testfixture$(TEXE) $(TOP)/test/main.test
   958    976   
   959    977   sqlite3_analyzer.c: sqlite3.c $(TOP)/src/test_stat.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl
   960    978   	echo "#define TCLSH 2" > $@
   961    979   	cat sqlite3.c $(TOP)/src/test_stat.c $(TOP)/src/tclsqlite.c >> $@
   962    980   	echo "static const char *tclsh_main_loop(void){" >> $@
   963    981   	echo "static const char *zMainloop = " >> $@
   964    982   	$(NAWK) -f $(TOP)/tool/tostr.awk $(TOP)/tool/spaceanal.tcl >> $@

Changes to src/os_unix.c.

  1667   1667     }
  1668   1668     if( buf.st_nlink>1 ){
  1669   1669       sqlite3_log(SQLITE_WARNING, "multiple links to file: %s", pFile->zPath);
  1670   1670       pFile->ctrlFlags |= UNIXFILE_WARNED;
  1671   1671       return;
  1672   1672     }
  1673   1673     if( fileHasMoved(pFile) ){
  1674         -    sqlite3_log(SQLITE_WARNING, "file renamed while open: %s", pFile->zPath);
         1674  +    sqlite3_log(SQLITE_WARNING, "file renamed while open: [%s]", pFile->zPath);
  1675   1675       pFile->ctrlFlags |= UNIXFILE_WARNED;
  1676   1676       return;
  1677   1677     }
  1678   1678   }
  1679   1679   
  1680   1680   
  1681   1681   /*
................................................................................
  4126   4126         ** single byte to the last byte in each block that falls entirely
  4127   4127         ** within the extended region. Then, if required, a single byte
  4128   4128         ** at offset (nSize-1), to set the size of the file correctly.
  4129   4129         ** This is a similar technique to that used by glibc on systems
  4130   4130         ** that do not have a real fallocate() call.
  4131   4131         */
  4132   4132         int nBlk = buf.st_blksize;  /* File-system block size */
         4133  +      int nWrite = 0;             /* Number of bytes written by seekAndWrite */
  4133   4134         i64 iWrite;                 /* Next offset to write to */
  4134   4135   
  4135   4136         if( robust_ftruncate(pFile->h, nSize) ){
  4136   4137           storeLastErrno(pFile, errno);
  4137   4138           return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
  4138   4139         }
  4139   4140         iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
  4140   4141         assert( iWrite>=buf.st_size );
  4141   4142         assert( (iWrite/nBlk)==((buf.st_size+nBlk-1)/nBlk) );
  4142   4143         assert( ((iWrite+1)%nBlk)==0 );
  4143   4144         for(/*no-op*/; iWrite<nSize; iWrite+=nBlk ){
  4144         -        int nWrite = seekAndWrite(pFile, iWrite, "", 1);
         4145  +        nWrite = seekAndWrite(pFile, iWrite, "", 1);
  4145   4146           if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
  4146   4147         }
  4147         -      if( nSize%nBlk ){
  4148         -        int nWrite = seekAndWrite(pFile, nSize-1, "", 1);
         4148  +      if( nWrite==0 || (nSize%nBlk) ){
         4149  +        nWrite = seekAndWrite(pFile, nSize-1, "", 1);
  4149   4150           if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
  4150   4151         }
  4151   4152   #endif
  4152   4153       }
  4153   4154     }
  4154   4155   
  4155   4156   #if SQLITE_MAX_MMAP_SIZE>0

Changes to src/parse.y.

   411    411   
   412    412   select(A) ::= with(W) selectnowith(X). {
   413    413     Select *p = X, *pNext, *pLoop;
   414    414     if( p ){
   415    415       int cnt = 0, mxSelect;
   416    416       p->pWith = W;
   417    417       if( p->pPrior ){
          418  +      u16 allValues = SF_Values;
   418    419         pNext = 0;
   419    420         for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
   420    421           pLoop->pNext = pNext;
   421    422           pLoop->selFlags |= SF_Compound;
          423  +        allValues &= pLoop->selFlags;
   422    424         }
   423         -      mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT];
   424         -      if( mxSelect && cnt>mxSelect ){
          425  +      if( allValues ){
          426  +        p->selFlags |= SF_AllValues;
          427  +      }else if(
          428  +        (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
          429  +        && cnt>mxSelect
          430  +      ){
   425    431           sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
   426    432         }
   427    433       }
   428    434     }else{
   429    435       sqlite3WithDelete(pParse->db, W);
   430    436     }
   431    437     A = p;

Changes to src/select.c.

    54     54     int labelBkOut;       /* Start label for the block-output subroutine */
    55     55     int addrSortIndex;    /* Address of the OP_SorterOpen or OP_OpenEphemeral */
    56     56     u8 sortFlags;         /* Zero or more SORTFLAG_* bits */
    57     57   };
    58     58   #define SORTFLAG_UseSorter  0x01   /* Use SorterOpen instead of OpenEphemeral */
    59     59   
    60     60   /*
    61         -** Delete all the content of a Select structure but do not deallocate
    62         -** the select structure itself.
           61  +** Delete all the content of a Select structure.  Deallocate the structure
           62  +** itself only if bFree is true.
    63     63   */
    64         -static void clearSelect(sqlite3 *db, Select *p){
    65         -  sqlite3ExprListDelete(db, p->pEList);
    66         -  sqlite3SrcListDelete(db, p->pSrc);
    67         -  sqlite3ExprDelete(db, p->pWhere);
    68         -  sqlite3ExprListDelete(db, p->pGroupBy);
    69         -  sqlite3ExprDelete(db, p->pHaving);
    70         -  sqlite3ExprListDelete(db, p->pOrderBy);
    71         -  sqlite3SelectDelete(db, p->pPrior);
    72         -  sqlite3ExprDelete(db, p->pLimit);
    73         -  sqlite3ExprDelete(db, p->pOffset);
    74         -  sqlite3WithDelete(db, p->pWith);
           64  +static void clearSelect(sqlite3 *db, Select *p, int bFree){
           65  +  while( p ){
           66  +    Select *pPrior = p->pPrior;
           67  +    sqlite3ExprListDelete(db, p->pEList);
           68  +    sqlite3SrcListDelete(db, p->pSrc);
           69  +    sqlite3ExprDelete(db, p->pWhere);
           70  +    sqlite3ExprListDelete(db, p->pGroupBy);
           71  +    sqlite3ExprDelete(db, p->pHaving);
           72  +    sqlite3ExprListDelete(db, p->pOrderBy);
           73  +    sqlite3ExprDelete(db, p->pLimit);
           74  +    sqlite3ExprDelete(db, p->pOffset);
           75  +    sqlite3WithDelete(db, p->pWith);
           76  +    if( bFree ) sqlite3DbFree(db, p);
           77  +    p = pPrior;
           78  +    bFree = 1;
           79  +  }
    75     80   }
    76     81   
    77     82   /*
    78     83   ** Initialize a SelectDest structure.
    79     84   */
    80     85   void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
    81     86     pDest->eDest = (u8)eDest;
................................................................................
   126    131     pNew->op = TK_SELECT;
   127    132     pNew->pLimit = pLimit;
   128    133     pNew->pOffset = pOffset;
   129    134     assert( pOffset==0 || pLimit!=0 );
   130    135     pNew->addrOpenEphm[0] = -1;
   131    136     pNew->addrOpenEphm[1] = -1;
   132    137     if( db->mallocFailed ) {
   133         -    clearSelect(db, pNew);
   134         -    if( pNew!=&standin ) sqlite3DbFree(db, pNew);
          138  +    clearSelect(db, pNew, pNew!=&standin);
   135    139       pNew = 0;
   136    140     }else{
   137    141       assert( pNew->pSrc!=0 || pParse->nErr>0 );
   138    142     }
   139    143     assert( pNew!=&standin );
   140    144     return pNew;
   141    145   }
................................................................................
   152    156   #endif
   153    157   
   154    158   
   155    159   /*
   156    160   ** Delete the given Select structure and all of its substructures.
   157    161   */
   158    162   void sqlite3SelectDelete(sqlite3 *db, Select *p){
   159         -  if( p ){
   160         -    clearSelect(db, p);
   161         -    sqlite3DbFree(db, p);
   162         -  }
          163  +  clearSelect(db, p, 1);
   163    164   }
   164    165   
   165    166   /*
   166    167   ** Return a pointer to the right-most SELECT statement in a compound.
   167    168   */
   168    169   static Select *findRightmost(Select *p){
   169    170     while( p->pNext ) p = p->pNext;
................................................................................
  2071   2072   /* Forward references */
  2072   2073   static int multiSelectOrderBy(
  2073   2074     Parse *pParse,        /* Parsing context */
  2074   2075     Select *p,            /* The right-most of SELECTs to be coded */
  2075   2076     SelectDest *pDest     /* What to do with query results */
  2076   2077   );
  2077   2078   
         2079  +/*
         2080  +** Error message for when two or more terms of a compound select have different
         2081  +** size result sets.
         2082  +*/
         2083  +static void selectWrongNumTermsError(Parse *pParse, Select *p){
         2084  +  if( p->selFlags & SF_Values ){
         2085  +    sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
         2086  +  }else{
         2087  +    sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
         2088  +      " do not have the same number of result columns", selectOpName(p->op));
         2089  +  }
         2090  +}
         2091  +
         2092  +/*
         2093  +** Handle the special case of a compound-select that originates from a
         2094  +** VALUES clause.  By handling this as a special case, we avoid deep
         2095  +** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT
         2096  +** on a VALUES clause.
         2097  +**
         2098  +** Because the Select object originates from a VALUES clause:
         2099  +**   (1) It has no LIMIT or OFFSET
         2100  +**   (2) All terms are UNION ALL
         2101  +**   (3) There is no ORDER BY clause
         2102  +*/
         2103  +static int multiSelectValues(
         2104  +  Parse *pParse,        /* Parsing context */
         2105  +  Select *p,            /* The right-most of SELECTs to be coded */
         2106  +  SelectDest *pDest     /* What to do with query results */
         2107  +){
         2108  +  Select *pPrior;
         2109  +  int nExpr = p->pEList->nExpr;
         2110  +  int nRow = 1;
         2111  +  int rc = 0;
         2112  +  assert( p->pNext==0 );
         2113  +  assert( p->selFlags & SF_AllValues );
         2114  +  do{
         2115  +    assert( p->selFlags & SF_Values );
         2116  +    assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
         2117  +    assert( p->pLimit==0 );
         2118  +    assert( p->pOffset==0 );
         2119  +    if( p->pEList->nExpr!=nExpr ){
         2120  +      selectWrongNumTermsError(pParse, p);
         2121  +      return 1;
         2122  +    }
         2123  +    if( p->pPrior==0 ) break;
         2124  +    assert( p->pPrior->pNext==p );
         2125  +    p = p->pPrior;
         2126  +    nRow++;
         2127  +  }while(1);
         2128  +  while( p ){
         2129  +    pPrior = p->pPrior;
         2130  +    p->pPrior = 0;
         2131  +    rc = sqlite3Select(pParse, p, pDest);
         2132  +    p->pPrior = pPrior;
         2133  +    if( rc ) break;
         2134  +    p->nSelectRow = nRow;
         2135  +    p = p->pNext;
         2136  +  }
         2137  +  return rc;
         2138  +}
  2078   2139   
  2079   2140   /*
  2080   2141   ** This routine is called to process a compound query form from
  2081   2142   ** two or more separate queries using UNION, UNION ALL, EXCEPT, or
  2082   2143   ** INTERSECT
  2083   2144   **
  2084   2145   ** "p" points to the right-most of the two queries.  the query on the
................................................................................
  2151   2212     */
  2152   2213     if( dest.eDest==SRT_EphemTab ){
  2153   2214       assert( p->pEList );
  2154   2215       sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr);
  2155   2216       sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
  2156   2217       dest.eDest = SRT_Table;
  2157   2218     }
         2219  +
         2220  +  /* Special handling for a compound-select that originates as a VALUES clause.
         2221  +  */
         2222  +  if( p->selFlags & SF_AllValues ){
         2223  +    rc = multiSelectValues(pParse, p, &dest);
         2224  +    goto multi_select_end;
         2225  +  }
  2158   2226   
  2159   2227     /* Make sure all SELECTs in the statement have the same number of elements
  2160   2228     ** in their result sets.
  2161   2229     */
  2162   2230     assert( p->pEList && pPrior->pEList );
  2163   2231     if( p->pEList->nExpr!=pPrior->pEList->nExpr ){
  2164         -    if( p->selFlags & SF_Values ){
  2165         -      sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
  2166         -    }else{
  2167         -      sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
  2168         -        " do not have the same number of result columns", selectOpName(p->op));
  2169         -    }
         2232  +    selectWrongNumTermsError(pParse, p);
  2170   2233       rc = 1;
  2171   2234       goto multi_select_end;
  2172   2235     }
  2173   2236   
  2174   2237   #ifndef SQLITE_OMIT_CTE
  2175   2238     if( p->selFlags & SF_Recursive ){
  2176   2239       generateWithRecursiveQuery(pParse, p, &dest);
................................................................................
  4048   4111       return WRC_Abort;
  4049   4112     }
  4050   4113     if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){
  4051   4114       return WRC_Prune;
  4052   4115     }
  4053   4116     pTabList = p->pSrc;
  4054   4117     pEList = p->pEList;
  4055         -  sqlite3WithPush(pParse, findRightmost(p)->pWith, 0);
         4118  +  if( pWalker->xSelectCallback2==selectPopWith ){
         4119  +    sqlite3WithPush(pParse, findRightmost(p)->pWith, 0);
         4120  +  }
  4056   4121   
  4057   4122     /* Make sure cursor numbers have been assigned to all entries in
  4058   4123     ** the FROM clause of the SELECT statement.
  4059   4124     */
  4060   4125     sqlite3SrcListAssignCursors(pParse, pTabList);
  4061   4126   
  4062   4127     /* Look up every table named in the FROM clause of the select.  If
................................................................................
  4339   4404     w.xExprCallback = exprWalkNoop;
  4340   4405     w.pParse = pParse;
  4341   4406     if( pParse->hasCompound ){
  4342   4407       w.xSelectCallback = convertCompoundSelectToSubquery;
  4343   4408       sqlite3WalkSelect(&w, pSelect);
  4344   4409     }
  4345   4410     w.xSelectCallback = selectExpander;
  4346         -  w.xSelectCallback2 = selectPopWith;
         4411  +  if( (pSelect->selFlags & SF_AllValues)==0 ){
         4412  +    w.xSelectCallback2 = selectPopWith;
         4413  +  }
  4347   4414     sqlite3WalkSelect(&w, pSelect);
  4348   4415   }
  4349   4416   
  4350   4417   
  4351   4418   #ifndef SQLITE_OMIT_SUBQUERY
  4352   4419   /*
  4353   4420   ** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()

Changes to src/sqliteInt.h.

  2355   2355   #define SF_Resolved        0x0002  /* Identifiers have been resolved */
  2356   2356   #define SF_Aggregate       0x0004  /* Contains aggregate functions */
  2357   2357   #define SF_UsesEphemeral   0x0008  /* Uses the OpenEphemeral opcode */
  2358   2358   #define SF_Expanded        0x0010  /* sqlite3SelectExpand() called on this */
  2359   2359   #define SF_HasTypeInfo     0x0020  /* FROM subqueries have Table metadata */
  2360   2360   #define SF_Compound        0x0040  /* Part of a compound query */
  2361   2361   #define SF_Values          0x0080  /* Synthesized from VALUES clause */
  2362         -                    /*     0x0100  NOT USED */
         2362  +#define SF_AllValues       0x0100  /* All terms of compound are VALUES */
  2363   2363   #define SF_NestedFrom      0x0200  /* Part of a parenthesized FROM clause */
  2364   2364   #define SF_MaybeConvert    0x0400  /* Need convertCompoundSelectToSubquery() */
  2365   2365   #define SF_Recursive       0x0800  /* The recursive part of a recursive CTE */
  2366   2366   #define SF_MinMaxAgg       0x1000  /* Aggregate containing min() or max() */
  2367   2367   
  2368   2368   
  2369   2369   /*

Changes to src/test1.c.

   257    257   }
   258    258   
   259    259   /*
   260    260   ** Usage:  clang_sanitize_address 
   261    261   **
   262    262   ** Returns true if the program was compiled using clang with the 
   263    263   ** -fsanitize=address switch on the command line. False otherwise.
          264  +**
          265  +** Also return true if the OMIT_MISUSE environment variable exists.
   264    266   */
   265    267   static int clang_sanitize_address(
   266    268     void *NotUsed,
   267    269     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   268    270     int argc,              /* Number of arguments */
   269    271     char **argv            /* Text of each argument */
   270    272   ){
   271    273     int res = 0;
   272    274   #if defined(__has_feature)
   273    275   # if __has_feature(address_sanitizer)
   274    276     res = 1;
   275    277   # endif
   276    278   #endif
          279  +  if( res==0 && getenv("OMIT_MISUSE")!=0 ) res = 1;
   277    280     Tcl_SetObjResult(interp, Tcl_NewIntObj(res));
   278    281     return TCL_OK;
   279    282   }
   280    283     
   281    284   /*
   282    285   ** Usage:  sqlite3_exec_printf  DB  FORMAT  STRING
   283    286   **
................................................................................
  6792   6795     zUser = Tcl_GetString(objv[2]);
  6793   6796     rc = sqlite3_user_delete(db, zUser);
  6794   6797     Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
  6795   6798     return TCL_OK;
  6796   6799   }
  6797   6800   #endif /* SQLITE_USER_AUTHENTICATION */
  6798   6801   
         6802  +/*
         6803  +** tclcmd: bad_behavior TYPE
         6804  +**
         6805  +** Do some things that should trigger a valgrind or -fsanitize=undefined
         6806  +** warning.  This is used to verify that errors and warnings output by those
         6807  +** tools are detected by the test scripts.
         6808  +**
         6809  +**       TYPE       BEHAVIOR
         6810  +**       1          Overflow a signed integer
         6811  +**       2          Jump based on an uninitialized variable
         6812  +**       3          Read after free
         6813  +*/
         6814  +static int test_bad_behavior(
         6815  +  ClientData clientData, /* Pointer to an integer containing zero */
         6816  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
         6817  +  int objc,              /* Number of arguments */
         6818  +  Tcl_Obj *CONST objv[]  /* Command arguments */
         6819  +){
         6820  +  int iType;
         6821  +  int xyz;
         6822  +  int i = *(int*)clientData;
         6823  +  int j;
         6824  +  int w[10];
         6825  +  int *a;
         6826  +  if( objc!=2 ){
         6827  +    Tcl_WrongNumArgs(interp, 1, objv, "TYPE");
         6828  +    return TCL_ERROR;
         6829  +  }
         6830  +  if( Tcl_GetIntFromObj(interp, objv[1], &iType) ) return TCL_ERROR;
         6831  +  switch( iType ){
         6832  +    case 1: {
         6833  +      xyz = 0x7fffff00 - i;
         6834  +      xyz += 0x100;
         6835  +      Tcl_SetObjResult(interp, Tcl_NewIntObj(xyz));
         6836  +      break;
         6837  +    }
         6838  +    case 2: {
         6839  +      w[1] = 5;
         6840  +      if( w[i]>0 ) w[1]++;
         6841  +      Tcl_SetObjResult(interp, Tcl_NewIntObj(w[1]));
         6842  +      break;
         6843  +    }
         6844  +    case 3: {
         6845  +      a = malloc( sizeof(int)*10 );
         6846  +      for(j=0; j<10; j++) a[j] = j;
         6847  +      free(a);
         6848  +      Tcl_SetObjResult(interp, Tcl_NewIntObj(a[i]));
         6849  +      break;
         6850  +    }
         6851  +  }
         6852  +  return TCL_OK;
         6853  +}  
         6854  +  
         6855  +
  6799   6856   /*
  6800   6857   ** Register commands with the TCL interpreter.
  6801   6858   */
  6802   6859   int Sqlitetest1_Init(Tcl_Interp *interp){
  6803   6860     extern int sqlite3_search_count;
  6804   6861     extern int sqlite3_found_count;
  6805   6862     extern int sqlite3_interrupt_count;
................................................................................
  6808   6865     extern int sqlite3_current_time;
  6809   6866   #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
  6810   6867     extern int sqlite3_hostid_num;
  6811   6868   #endif
  6812   6869     extern int sqlite3_max_blobsize;
  6813   6870     extern int sqlite3BtreeSharedCacheReport(void*,
  6814   6871                                             Tcl_Interp*,int,Tcl_Obj*CONST*);
         6872  +  static int iZero = 0;
  6815   6873     static struct {
  6816   6874        char *zName;
  6817   6875        Tcl_CmdProc *xProc;
  6818   6876     } aCmd[] = {
  6819   6877        { "db_enter",                      (Tcl_CmdProc*)db_enter               },
  6820   6878        { "db_leave",                      (Tcl_CmdProc*)db_leave               },
  6821   6879        { "sqlite3_mprintf_int",           (Tcl_CmdProc*)sqlite3_mprintf_int    },
................................................................................
  6860   6918        { "clang_sanitize_address",        (Tcl_CmdProc*)clang_sanitize_address },
  6861   6919     };
  6862   6920     static struct {
  6863   6921        char *zName;
  6864   6922        Tcl_ObjCmdProc *xProc;
  6865   6923        void *clientData;
  6866   6924     } aObjCmd[] = {
         6925  +     { "bad_behavior",                  test_bad_behavior,  (void*)&iZero },
  6867   6926        { "sqlite3_connection_pointer",    get_sqlite_pointer, 0 },
  6868   6927        { "sqlite3_bind_int",              test_bind_int,      0 },
  6869   6928        { "sqlite3_bind_zeroblob",         test_bind_zeroblob, 0 },
  6870   6929        { "sqlite3_bind_int64",            test_bind_int64,    0 },
  6871   6930        { "sqlite3_bind_double",           test_bind_double,   0 },
  6872   6931        { "sqlite3_bind_null",             test_bind_null     ,0 },
  6873   6932        { "sqlite3_bind_text",             test_bind_text     ,0 },

Changes to src/threads.c.

    22     22   ** or sqlite3ThreadJoin() call.  This is, in fact, what happens in
    23     23   ** single threaded systems.  Nothing in SQLite requires multiple threads.
    24     24   ** This interface exists so that applications that want to take advantage
    25     25   ** of multiple cores can do so, while also allowing applications to stay
    26     26   ** single-threaded if desired.
    27     27   */
    28     28   #include "sqliteInt.h"
           29  +#if SQLITE_OS_WIN
           30  +#  include "os_win.h"
           31  +#endif
    29     32   
    30     33   #if SQLITE_MAX_WORKER_THREADS>0
    31     34   
    32     35   /********************************* Unix Pthreads ****************************/
    33     36   #if SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0
    34     37   
    35     38   #define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */

Changes to src/vdbesort.c.

   845    845         pTask->pSorter = pSorter;
   846    846       }
   847    847   
   848    848       if( !sqlite3TempInMemory(db) ){
   849    849         u32 szPma = sqlite3GlobalConfig.szPma;
   850    850         pSorter->mnPmaSize = szPma * pgsz;
   851    851         mxCache = db->aDb[0].pSchema->cache_size;
   852         -      if( mxCache<szPma ) mxCache = szPma;
          852  +      if( mxCache<(int)szPma ) mxCache = (int)szPma;
   853    853         pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_PMASZ);
   854    854   
   855    855         /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
   856    856         ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
   857    857         ** large heap allocations.
   858    858         */
   859    859         if( sqlite3GlobalConfig.pScratch==0 ){

Changes to test/main.test.

   510    510       } {1 {no such vfs: crash}}
   511    511       do_test main-4.3 {
   512    512         set rc [catch {sqlite3 db test.db -vfs async} msg]
   513    513         list $rc $msg
   514    514       } {1 {no such vfs: async}}
   515    515     }
   516    516   }
          517  +
          518  +# Print the version number so that it can be picked up by releasetest.tcl.
          519  +#
          520  +puts [db one {SELECT 'VERSION: ' ||
          521  +                  sqlite_version() || ' ' ||
          522  +                  sqlite_source_id();}]
          523  +
          524  +# Do deliberate failures if the TEST_FAILURE environment variable is set.
          525  +# This is done to verify that failure notifications are detected by the
          526  +# releasetest.tcl script, or possibly by other scripts involved in automatic
          527  +# testing.
          528  +#
          529  +if {[info exists ::env(TEST_FAILURE)]} {
          530  +  set res 123
          531  +  if {$::env(TEST_FAILURE)==0} {set res 234}
          532  +  do_test main-99.1 {
          533  +     bad_behavior $::env(TEST_FAILURE)
          534  +     set x 123
          535  +  } $res
          536  +}
   517    537       
   518    538   finish_test

Changes to test/oserror.test.

    47     47   # Test a failure in open() due to too many files. 
    48     48   #
    49     49   # The xOpen() method of the unix VFS calls getcwd() as well as open().
    50     50   # Although this does not appear to be documented in the man page, on OSX
    51     51   # a call to getcwd() may fail if there are no free file descriptors. So
    52     52   # an error may be reported for either open() or getcwd() here.
    53     53   #
    54         -puts "Possible valgrind error about invalid file descriptor follows:"
    55         -do_test 1.1.1 {
    56         -  set ::log [list]
    57         -  list [catch {
    58         -    for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
    59         -  } msg] $msg
    60         -} {1 {unable to open database file}}
    61         -do_test 1.1.2 {
    62         -  catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
    63         -} {1}
    64         -do_re_test 1.1.3 { 
    65         -  lindex $::log 0 
    66         -} {^os_unix.c:\d+: \(\d+\) (open|getcwd)\(.*test.db\) - }
           54  +if {![clang_sanitize_address]} {
           55  +  do_test 1.1.1 {
           56  +    set ::log [list]
           57  +    list [catch {
           58  +      for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
           59  +    } msg] $msg
           60  +  } {1 {unable to open database file}}
           61  +  do_test 1.1.2 {
           62  +    catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
           63  +  } {1}
           64  +  do_re_test 1.1.3 { 
           65  +    lindex $::log 0 
           66  +  } {^os_unix.c:\d+: \(\d+\) (open|getcwd)\(.*test.db\) - }
           67  +}
    67     68   
    68     69   
    69     70   # Test a failure in open() due to the path being a directory.
    70     71   #
    71     72   do_test 1.2.1 {
    72     73     file mkdir dir.db
    73     74     set ::log [list]

Changes to test/permutations.test.

   119    119     set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
   120    120   }
   121    121   if {[info exists ::env(QUICKTEST_OMIT)]} {
   122    122     foreach x [split $::env(QUICKTEST_OMIT) ,] {
   123    123       regsub -all \\y$x\\y $allquicktests {} allquicktests
   124    124     }
   125    125   }
          126  +
          127  +# If the TEST_FAILURE environment variable is set, it means that we what to
          128  +# deliberately provoke test failures in order to test the test infrastructure.
          129  +# Only the main.test module is needed for this.
          130  +#
          131  +if {[info exists ::env(TEST_FAILURE)]} {
          132  +  set allquicktests main.test
          133  +}
   126    134   
   127    135   #############################################################################
   128    136   # Start of tests
   129    137   #
   130    138   
   131    139   #-------------------------------------------------------------------------
   132    140   # Define the generic test suites:

Changes to test/releasetest.tcl.

     9      9   before releasing a new version. Supported command line options (all
    10     10   optional) are:
    11     11   
    12     12       --srcdir   TOP-OF-SQLITE-TREE      (see below)
    13     13       --platform PLATFORM                (see below)
    14     14       --config   CONFIGNAME              (Run only CONFIGNAME)
    15     15       --quick                            (Run "veryquick.test" only)
           16  +    --veryquick                        (Run "make smoketest" only)
    16     17       --buildonly                        (Just build testfixture - do not run)
    17     18       --dryrun                           (Print what would have happened)
    18     19       --info                             (Show diagnostic info)
    19     20   
    20     21   The default value for --srcdir is the parent of the directory holding
    21     22   this script.
    22     23   
................................................................................
    27     28   Every test begins with a fresh run of the configure script at the top
    28     29   of the SQLite source tree.
    29     30   }
    30     31   
    31     32   array set ::Configs {
    32     33     "Default" {
    33     34       -O2
    34         -  }
    35         -  "Ftrapv" {
    36         -    -O2 -ftrapv
    37         -    -DSQLITE_MAX_ATTACHED=125
    38         -    -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
           35  +    --disable-amalgamation --disable-shared
    39     36     }
    40     37     "Sanitize" {
    41     38       CC=clang -fsanitize=undefined
    42     39       -DSQLITE_ENABLE_STAT4
    43     40     }
    44     41     "Unlock-Notify" {
    45     42       -O2
................................................................................
    70     67       -DSQLITE_SOUNDEX=1
    71     68       -DSQLITE_ENABLE_ATOMIC_WRITE=1
    72     69       -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
    73     70       -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
    74     71       -DSQLITE_ENABLE_STAT4
    75     72     }
    76     73     "Debug-One" {
           74  +    --disable-shared
    77     75       -O2
    78     76       -DSQLITE_DEBUG=1
    79     77       -DSQLITE_MEMDEBUG=1
    80     78       -DSQLITE_MUTEX_NOOP=1
    81     79       -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
    82     80       -DSQLITE_ENABLE_FTS3=1
    83     81       -DSQLITE_ENABLE_RTREE=1
    84     82       -DSQLITE_ENABLE_MEMSYS5=1
    85     83       -DSQLITE_ENABLE_MEMSYS3=1
    86     84       -DSQLITE_ENABLE_COLUMN_METADATA=1
    87     85       -DSQLITE_ENABLE_STAT4
           86  +    -DSQLITE_MAX_ATTACHED=125
    88     87     }
    89     88     "Device-One" {
    90     89       -O2
    91     90       -DSQLITE_DEBUG=1
    92     91       -DSQLITE_DEFAULT_AUTOVACUUM=1
    93     92       -DSQLITE_DEFAULT_CACHE_SIZE=64
    94     93       -DSQLITE_DEFAULT_PAGE_SIZE=1024
................................................................................
   151    150       -DSQLITE_MAX_ATTACHED=30
   152    151       -DSQLITE_ENABLE_COLUMN_METADATA
   153    152       -DSQLITE_ENABLE_FTS4
   154    153       -DSQLITE_ENABLE_FTS4_PARENTHESIS
   155    154       -DSQLITE_DISABLE_FTS4_DEFERRED
   156    155       -DSQLITE_ENABLE_RTREE
   157    156     }
   158         -
   159    157     "No-lookaside" {
   160    158       -DSQLITE_TEST_REALLOC_STRESS=1
   161    159       -DSQLITE_OMIT_LOOKASIDE=1
   162    160       -DHAVE_USLEEP=1
   163    161     }
          162  +  "Valgrind" {
          163  +    -DSQLITE_ENABLE_STAT4
          164  +    -DSQLITE_ENABLE_FTS4
          165  +    -DSQLITE_ENABLE_RTREE
          166  +  }
          167  +  Fail0 {-O0}
          168  +  Fail2 {-O0}
          169  +  Fail3 {-O0}
   164    170   }
   165    171   
   166    172   array set ::Platforms {
   167    173     Linux-x86_64 {
   168    174       "Check-Symbols"           checksymbols
   169    175       "Debug-One"               "mptest test"
   170    176       "Secure-Delete"           test
   171    177       "Unlock-Notify"           "QUICKTEST_INCLUDE=notify2.test test"
   172    178       "Update-Delete-Limit"     test
   173    179       "Extra-Robustness"        test
   174    180       "Device-Two"              test
   175         -    "Ftrapv"                  test
   176         -    "Sanitize"                {QUICKTEST_OMIT=func4.test,nan.test test}
   177    181       "No-lookaside"            test
   178    182       "Devkit"                  test
          183  +    "Sanitize"                {QUICKTEST_OMIT=func4.test,nan.test test}
          184  +    "Valgrind"                valgrindtest
   179    185       "Default"                 "threadtest fulltest"
   180    186       "Device-One"              fulltest
   181    187     }
   182    188     Linux-i686 {
   183    189       "Devkit"                  test
   184    190       "Unlock-Notify"           "QUICKTEST_INCLUDE=notify2.test test"
   185    191       "Device-One"              test
................................................................................
   193    199     Darwin-x86_64 {
   194    200       "Locking-Style"           "mptest test"
   195    201       "OS-X"                    "threadtest fulltest"
   196    202     }
   197    203     "Windows NT-intel" {
   198    204       "Default"                 "mptest fulltestonly"
   199    205     }
          206  +  Failure-Detection {
          207  +    Fail0     "TEST_FAILURE=0 test"
          208  +    Sanitize  "TEST_FAILURE=1 test"
          209  +    Fail2     "TEST_FAILURE=2 valgrindtest"
          210  +    Fail3     "TEST_FAILURE=3 valgrindtest"
          211  +  }
   200    212   }
   201    213   
   202    214   
   203    215   # End of configuration section.
   204    216   #########################################################################
   205    217   #########################################################################
   206    218   
................................................................................
   239    251       if {[regexp {runtime error: +(.*)} $line all msg]} {
   240    252         incr ::NERRCASE
   241    253         if {$rc==0} {
   242    254           set rc 1
   243    255           set errmsg $msg
   244    256         }
   245    257       }
          258  +    if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} {
          259  +      incr ::NERRCASE
          260  +      if {$rc==0} {
          261  +        set rc 1
          262  +        set errmsg $all
          263  +      }
          264  +    }
          265  +    if {[regexp {^VERSION: 3\.\d+.\d+} $line]} {
          266  +      set v [string range $line 9 end]
          267  +      if {$::SQLITE_VERSION eq ""} {
          268  +        set ::SQLITE_VERSION $v
          269  +      } elseif {$::SQLITE_VERSION ne $v} {
          270  +        set rc 1
          271  +        set errmsg "version conflict: {$::SQLITE_VERSION} vs. {$v}"
          272  +      }
          273  +    }
   246    274     }
   247    275     close $fd
   248    276     if {!$seen} {
   249    277       set rc 1
   250    278       set errmsg "Test did not complete"
   251    279     }
   252    280   }
................................................................................
   255    283     # Tcl variable $opts is used to build up the value used to set the
   256    284     # OPTS Makefile variable. Variable $cflags holds the value for
   257    285     # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
   258    286     # CFLAGS is only passed to gcc.
   259    287     #
   260    288     set cflags "-g"
   261    289     set opts ""
          290  +  set title ${name}($testtarget)
          291  +  set configOpts ""
          292  +
   262    293     regsub -all {#[^\n]*\n} $config \n config
   263    294     foreach arg $config {
   264    295       if {[string match -D* $arg]} {
   265    296         lappend opts $arg
   266    297       } elseif {[string match CC=* $arg]} {
   267    298         lappend testtarget $arg
          299  +    } elseif {[regexp {^--(enable|disable)-} $arg]} {
          300  +      lappend configOpts $arg
   268    301       } else {
   269    302         lappend cflags $arg
   270    303       }
   271    304     }
   272    305   
   273    306     set cflags [join $cflags " "]
   274    307     set opts   [join $opts " "]
................................................................................
   280    313   
   281    314     if {$::tcl_platform(platform)=="windows"} {
   282    315       append opts " -DSQLITE_OS_WIN=1"
   283    316     } else {
   284    317       append opts " -DSQLITE_OS_UNIX=1"
   285    318     }
   286    319   
   287         -  dryrun file mkdir $dir
   288         -  if {!$::DRYRUN} {
   289         -    set title ${name}($testtarget)
          320  +  if {!$::TRACE} {
   290    321       set n [string length $title]
   291    322       puts -nonewline "${title}[string repeat . [expr {63-$n}]]"
   292    323       flush stdout
   293    324     }
   294    325   
          326  +  set rc 0
   295    327     set tm1 [clock seconds]
   296    328     set origdir [pwd]
   297         -  dryrun cd $dir
          329  +  trace_cmd file mkdir $dir
          330  +  trace_cmd cd $dir
   298    331     set errmsg {}
   299         -  set rc [catch [configureCommand]]
          332  +  set rc [catch [configureCommand $configOpts]]
   300    333     if {!$rc} {
   301    334       set rc [catch [makeCommand $testtarget $cflags $opts]]
   302    335       count_tests_and_errors test.log rc errmsg
   303    336     }
          337  +  trace_cmd cd $origdir
   304    338     set tm2 [clock seconds]
   305         -  dryrun cd $origdir
   306    339   
   307         -  if {!$::DRYRUN} {
          340  +  if {!$::TRACE} {
   308    341       set hours [expr {($tm2-$tm1)/3600}]
   309    342       set minutes [expr {(($tm2-$tm1)/60)%60}]
   310    343       set seconds [expr {($tm2-$tm1)%60}]
   311    344       set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
   312    345       if {$rc} {
   313    346         puts " FAIL $tm"
   314    347         incr ::NERR
................................................................................
   318    351       }
   319    352     }
   320    353   }
   321    354   
   322    355   # The following procedure returns the "configure" command to be exectued for
   323    356   # the current platform, which may be Windows (via MinGW, etc).
   324    357   #
   325         -proc configureCommand {} {
   326         -  set result [list dryrun exec]
          358  +proc configureCommand {opts} {
          359  +  set result [list trace_cmd exec]
   327    360     if {$::tcl_platform(platform)=="windows"} {
   328    361       lappend result sh
   329    362     }
   330         -  lappend result $::SRCDIR/configure -enable-load-extension >& test.log
          363  +  lappend result $::SRCDIR/configure --enable-load-extension
          364  +  foreach x $opts {lappend result $x}
          365  +  lappend result >& test.log
   331    366   }
   332    367   
   333    368   # The following procedure returns the "make" command to be executed for the
   334    369   # specified targets, compiler flags, and options.
   335    370   #
   336    371   proc makeCommand { targets cflags opts } {
   337         -  set result [list dryrun exec make clean]
          372  +  set result [list trace_cmd exec make clean]
   338    373     foreach target $targets {
   339    374       lappend result $target
   340    375     }
   341    376     lappend result CFLAGS=$cflags OPTS=$opts >>& test.log
   342    377   }
   343    378   
   344         -# The following procedure either prints its arguments (if ::DRYRUN is true)
   345         -# or executes the command of its arguments in the calling context
   346         -# (if ::DRYRUN is false).
          379  +# The following procedure prints its arguments if ::TRACE is true.
          380  +# And it executes the command of its arguments in the calling context
          381  +# if ::DRYRUN is false.
   347    382   #
   348         -proc dryrun {args} {
   349         -  if {$::DRYRUN} {
          383  +proc trace_cmd {args} {
          384  +  if {$::TRACE} {
   350    385       puts $args
   351         -  } else {
          386  +  }
          387  +  if {!$::DRYRUN} {
   352    388       uplevel 1 $args
   353    389     }
   354    390   }
   355    391   
   356    392   
   357    393   # This proc processes the command line options passed to this script.
   358    394   # Currently the only option supported is "-makefile", default
................................................................................
   361    397   #
   362    398   proc process_options {argv} {
   363    399     set ::SRCDIR    [file normalize [file dirname [file dirname $::argv0]]]
   364    400     set ::QUICK     0
   365    401     set ::BUILDONLY 0
   366    402     set ::DRYRUN    0
   367    403     set ::EXEC      exec
          404  +  set ::TRACE     0
   368    405     set config {}
   369    406     set platform $::tcl_platform(os)-$::tcl_platform(machine)
   370    407   
   371    408     for {set i 0} {$i < [llength $argv]} {incr i} {
   372    409       set x [lindex $argv $i]
   373    410       if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
   374         -    switch -- $x {
          411  +    switch -glob -- $x {
   375    412         -srcdir {
   376    413           incr i
   377    414           set ::SRCDIR [file normalize [lindex $argv $i]]
   378    415         }
   379    416   
   380    417         -platform {
   381    418           incr i
   382    419           set platform [lindex $argv $i]
   383    420         }
   384    421   
   385    422         -quick {
   386    423           set ::QUICK 1
   387    424         }
          425  +      -veryquick {
          426  +        set ::QUICK 2
          427  +      }
   388    428   
   389    429         -config {
   390    430           incr i
   391    431           set config [lindex $argv $i]
   392    432         }
   393    433   
   394    434         -buildonly {
   395    435           set ::BUILDONLY 1
   396    436         }
   397    437   
   398    438         -dryrun {
   399    439           set ::DRYRUN 1
   400    440         }
          441  +
          442  +      -trace {
          443  +        set ::TRACE 1
          444  +      }
   401    445   
   402    446         -info {
   403    447           puts "Command-line Options:"
   404    448           puts "   --srcdir $::SRCDIR"
   405    449           puts "   --platform [list $platform]"
   406    450           puts "   --config [list $config]"
   407    451           if {$::QUICK}     {puts "   --quick"}
   408    452           if {$::BUILDONLY} {puts "   --buildonly"}
   409    453           if {$::DRYRUN}    {puts "   --dryrun"}
          454  +        if {$::TRACE}     {puts "   --trace"}
   410    455           puts "\nAvailable --platform options:"
   411    456           foreach y [lsort [array names ::Platforms]] {
   412    457             puts "   [list $y]"
   413    458           }
   414    459           puts "\nAvailable --config options:"
   415    460           foreach y [lsort [array names ::Configs]] {
   416    461             puts "   [list $y]"
   417    462           }
   418    463           exit
   419    464         }
          465  +      -g -
          466  +      -D* -
          467  +      -O* -
          468  +      -enable-* -
          469  +      -disable-* -
          470  +      *=* {
          471  +        lappend ::EXTRACONFIG [lindex $argv $i]
          472  +      }
   420    473   
   421    474         default {
   422    475           puts stderr ""
   423    476           puts stderr [string trim $::USAGE_MESSAGE]
   424    477           exit -1
   425    478         }
   426    479       }
................................................................................
   445    498       set ::CONFIGLIST $::Platforms($platform)
   446    499     }
   447    500     puts "Running the following test configurations for $platform:"
   448    501     puts "    [string trim $::CONFIGLIST]"
   449    502     puts -nonewline "Flags:"
   450    503     if {$::DRYRUN} {puts -nonewline " --dryrun"}
   451    504     if {$::BUILDONLY} {puts -nonewline " --buildonly"}
   452         -  if {$::QUICK} {puts -nonewline " --quick"}
          505  +  switch -- $::QUICK {
          506  +     1 {puts -nonewline " --quick"}
          507  +     2 {puts -nonewline " --veryquick"}
          508  +  }
   453    509     puts ""
   454    510   }
   455    511   
   456    512   # Main routine.
   457    513   #
   458    514   proc main {argv} {
   459    515   
   460    516     # Process any command line options.
          517  +  set ::EXTRACONFIG {}
   461    518     process_options $argv
   462    519     puts [string repeat * 79]
   463    520   
   464    521     set ::NERR 0
   465    522     set ::NTEST 0
   466    523     set ::NTESTCASE 0
   467    524     set ::NERRCASE 0
          525  +  set ::SQLITE_VERSION {}
   468    526     set STARTTIME [clock seconds]
   469    527     foreach {zConfig target} $::CONFIGLIST {
   470         -    if {$::QUICK} {set target test}
   471         -    if {$::BUILDONLY} {set target testfixture}
   472         -    set config_options $::Configs($zConfig)
          528  +    if {$target ne "checksymbols"} {
          529  +      switch -- $::QUICK {
          530  +         1 {set target test}
          531  +         2 {set target smoketest}
          532  +      }
          533  +      if {$::BUILDONLY} {set target testfixture}
          534  +    }
          535  +    set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
   473    536   
   474    537       incr NTEST
   475    538       run_test_suite $zConfig $target $config_options
   476    539   
   477    540       # If the configuration included the SQLITE_DEBUG option, then remove
   478    541       # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
   479    542       # add it and run veryquick.test.
   480         -    if {$target!="checksymbols" && !$::BUILDONLY} {
          543  +    if {$target!="checksymbols" && $target!="valgrindtest"
          544  +           && !$::BUILDONLY && $::QUICK<2} {
   481    545         set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
   482    546         set xtarget $target
   483    547         regsub -all {fulltest[a-z]*} $xtarget test xtarget
   484    548         if {$debug_idx < 0} {
   485    549           incr NTEST
   486    550           append config_options " -DSQLITE_DEBUG=1"
   487    551           run_test_suite "${zConfig}_debug" $xtarget $config_options
................................................................................
   496    560   
   497    561     set elapsetime [expr {[clock seconds]-$STARTTIME}]
   498    562     set hr [expr {$elapsetime/3600}]
   499    563     set min [expr {($elapsetime/60)%60}]
   500    564     set sec [expr {$elapsetime%60}]
   501    565     set etime [format (%02d:%02d:%02d) $hr $min $sec]
   502    566     puts [string repeat * 79]
   503         -  puts "$::NERRCASE failures of $::NTESTCASE tests run in $etime"
          567  +  puts "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
          568  +  if {$::SQLITE_VERSION ne ""} {
          569  +    puts "SQLite $::SQLITE_VERSION"
          570  +  }
   504    571   }
   505    572   
   506    573   main $argv

Added test/selectG.test.

            1  +# 2015-01-05
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file verifies that INSERT operations with a very large number of
           13  +# VALUE terms works and does not hit the SQLITE_LIMIT_COMPOUND_SELECT limit.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +set testprefix selectG
           19  +
           20  +# Do an INSERT with a VALUES clause that contains 100,000 entries.  Verify
           21  +# that this insert happens quickly (in less than 10 seconds).  Actually, the
           22  +# insert will normally happen in less than 0.5 seconds on a workstation, but
           23  +# we allow plenty of overhead for slower machines.  The speed test checks
           24  +# for an O(N*N) inefficiency that was once in the code and that would make
           25  +# the insert run for over a minute.
           26  +#
           27  +do_test 100 {
           28  +  set sql "CREATE TABLE t1(x);\nINSERT INTO t1(x) VALUES"
           29  +  for {set i 1} {$i<100000} {incr i} {
           30  +    append sql "($i),"
           31  +  }
           32  +  append sql "($i);"
           33  +  set microsec [lindex [time {db eval $sql}] 0]
           34  +  db eval {
           35  +    SELECT count(x), sum(x), avg(x), $microsec<10000000 FROM t1;
           36  +  }
           37  +} {100000 5000050000 50000.5 1}
           38  +  
           39  +finish_test