diff options
40 files changed, 1878 insertions, 167 deletions
diff --git a/Makefile.in b/Makefile.in index fb4bc5e71..77a7af9dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -404,6 +404,7 @@ TESTSRC += \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ + $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/wholenumber.c # Source code to the library files needed by the test fixture @@ -509,11 +510,11 @@ sqlite3.pc: $(TOP)/sqlite3.pc.in ./config.status libsqlite3.la: $(LIBOBJ) - $(LTLINK) -o $@ $(LIBOBJ) $(TLIBS) \ + $(LTLINK) -no-undefined -o $@ $(LIBOBJ) $(TLIBS) \ ${ALLOWRELEASE} -rpath "$(libdir)" -version-info "8:6:8" libtclsqlite3.la: tclsqlite.lo libsqlite3.la - $(LTLINK) -o $@ tclsqlite.lo \ + $(LTLINK) -no-undefined -o $@ tclsqlite.lo \ libsqlite3.la @TCL_STUB_LIB_SPEC@ $(TLIBS) \ -rpath "$(TCLLIBDIR)" \ -version-info "8:6:8" \ diff --git a/Makefile.msc b/Makefile.msc index 88f9fc95e..4a43cd410 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -13,6 +13,13 @@ TOP = . USE_AMALGAMATION = 1 !ENDIF +# Set this non-0 to split the SQLite amalgamation file into chunks to +# be used for debugging with Visual Studio. +# +!IFNDEF SPLIT_AMALGAMATION +SPLIT_AMALGAMATION = 0 +!ENDIF + # Set this non-0 to use the International Components for Unicode (ICU). # !IFNDEF USE_ICU @@ -25,6 +32,13 @@ USE_ICU = 0 USE_CRT_DLL = 0 !ENDIF +# Set this non-0 to generate assembly code listings for the source code +# files. +# +!IFNDEF USE_LISTINGS +USE_LISTINGS = 0 +!ENDIF + # Set this non-0 to attempt setting the native compiler automatically # for cross-compiling the command line tools needed during the compilation # process. @@ -181,6 +195,13 @@ NSDKLIBPATH = $(NSDKLIBPATH:\\=\) # BCC = $(NCC) -W3 +# Check if assembly code listings should be generated for the source +# code files to be compiled. +# +!IF $(USE_LISTINGS)!=0 +BCC = $(BCC) -FAcs +!ENDIF + # Check if the native library paths should be used when compiling # the command line tools used during the compilation process. If # so, set the necessary macro now. @@ -196,6 +217,13 @@ NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)" TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src +# Check if assembly code listings should be generated for the source +# code files to be compiled. +# +!IF $(USE_LISTINGS)!=0 +TCC = $(TCC) -FAcs +!ENDIF + # When compiling the library for use in the WinRT environment, # the following compile-time options must be used as well to # disable use of Win32 APIs that are not available and to enable @@ -763,6 +791,7 @@ TESTEXT = \ $(TOP)\ext\misc\percentile.c \ $(TOP)\ext\misc\regexp.c \ $(TOP)\ext\misc\spellfix.c \ + $(TOP)\ext\misc\totype.c \ $(TOP)\ext\misc\wholenumber.c @@ -912,10 +941,19 @@ sqlite3.c: .target_source $(TOP)\tool\mksqlite3c.tcl sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl +# Set the source code file to be used by executables and libraries when +# they need the amalgamation. +# +!IF $(SPLIT_AMALGAMATION)!=0 +SQLITE3C = sqlite3-all.c +!ELSE +SQLITE3C = sqlite3.c +!ENDIF + # Rule to build the amalgamation # -sqlite3.lo: sqlite3.c - $(LTCOMPILE) -c sqlite3.c +sqlite3.lo: $(SQLITE3C) + $(LTCOMPILE) -c $(SQLITE3C) # Rules to build the LEMON compiler generator # @@ -1278,7 +1316,7 @@ TESTFIXTURE_FLAGS = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) libsqlite3.lib -TESTFIXTURE_SRC1 = $(TESTEXT) $(TESTSRC3) sqlite3.c +TESTFIXTURE_SRC1 = $(TESTEXT) $(TESTSRC3) $(SQLITE3C) !IF $(USE_AMALGAMATION)==0 TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0) !ELSE @@ -1306,8 +1344,8 @@ queryplantest: testfixture.exe sqlite3.exe test: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\veryquick.test -sqlite3_analyzer.c: sqlite3.c $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl - copy sqlite3.c + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@ +sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl + copy $(SQLITE3C) + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@ echo static const char *tclsh_main_loop(void){ >> $@ echo static const char *zMainloop = >> $@ $(NAWK) -f $(TOP)\tool\tostr.awk $(TOP)\tool\spaceanal.tcl >> $@ @@ -1319,7 +1357,7 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) clean: del /Q *.lo *.ilk *.lib *.obj *.pdb sqlite3.exe libsqlite3.lib - del /Q *.da *.bb *.bbg gmon.out + del /Q *.cod *.da *.bb *.bbg gmon.out del /Q sqlite3.h opcodes.c opcodes.h del /Q lemon.exe lempar.c parse.* del /Q mkkeywordhash.exe keywordhash.h @@ -1333,7 +1371,7 @@ clean: del /Q tclsqlite3.exe tclsqlite3.exp del /Q testfixture.exe testfixture.exp test.db del /Q sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def - del /Q sqlite3.c + del /Q sqlite3.c sqlite3-*.c del /Q sqlite3rc.h del /Q shell.c sqlite3ext.h del /Q sqlite3_analyzer.exe sqlite3_analyzer.exp sqlite3_analyzer.c diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 192e32965..dd6d38a59 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4327,11 +4327,11 @@ static int fts3EvalIncrPhraseNext( while( bEof==0 ){ int bMaxSet = 0; - sqlite3_int64 iMax; /* Largest docid for all iterators */ + sqlite3_int64 iMax = 0; /* Largest docid for all iterators */ int i; /* Used to iterate through tokens */ /* Advance the iterator for each token in the phrase once. */ - for(i=0; rc==SQLITE_OK && i<p->nToken; i++){ + for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){ rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof); if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){ iMax = a[i].iDocid; @@ -4370,7 +4370,7 @@ static int fts3EvalIncrPhraseNext( int nDist = p->nToken-1-i; int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR); if( res==0 ) break; - nList = (pOut - aDoclist); + nList = (int)(pOut - aDoclist); } } if( i==(p->nToken-1) ){ diff --git a/ext/misc/totype.c b/ext/misc/totype.c new file mode 100644 index 000000000..5dc99f3d7 --- /dev/null +++ b/ext/misc/totype.c @@ -0,0 +1,512 @@ +/* +** 2013-10-14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This SQLite extension implements functions tointeger(X) and toreal(X). +** +** If X is an integer, real, or string value that can be +** losslessly represented as an integer, then tointeger(X) +** returns the corresponding integer value. +** If X is an 8-byte BLOB then that blob is interpreted as +** a signed two-compliment little-endian encoding of an integer +** and tointeger(X) returns the corresponding integer value. +** Otherwise tointeger(X) return NULL. +** +** If X is an integer, real, or string value that can be +** convert into a real number, preserving at least 15 digits +** of precision, then toreal(X) returns the corresponding real value. +** If X is an 8-byte BLOB then that blob is interpreted as +** a 64-bit IEEE754 big-endian floating point value +** and toreal(X) returns the corresponding real value. +** Otherwise toreal(X) return NULL. +** +** Note that tointeger(X) of an 8-byte BLOB assumes a little-endian +** encoding whereas toreal(X) of an 8-byte BLOB assumes a big-endian +** encoding. +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include <assert.h> +#include <string.h> + +/* +** Determine if this is running on a big-endian or little-endian +** processor +*/ +#if defined(i386) || defined(__i386__) || defined(_M_IX86)\ + || defined(__x86_64) || defined(__x86_64__) +# define TOTYPE_BIGENDIAN 0 +# define TOTYPE_LITTLEENDIAN 1 +#else + const int totype_one = 1; +# define TOTYPE_BIGENDIAN (*(char *)(&totype_one)==0) +# define TOTYPE_LITTLEENDIAN (*(char *)(&totype_one)==1) +#endif + +/* +** Constants for the largest and smallest possible 64-bit signed integers. +** These macros are designed to work correctly on both 32-bit and 64-bit +** compilers. +*/ +#ifndef LARGEST_INT64 +# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) +#endif + +#ifndef SMALLEST_INT64 +# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) +#endif + +/* +** Return TRUE if character c is a whitespace character +*/ +static int totypeIsspace(unsigned char c){ + return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f' || c=='\r'; +} + +/* +** Return TRUE if character c is a digit +*/ +static int totypeIsdigit(unsigned char c){ + return c>='0' && c<='9'; +} + +/* +** Compare the 19-character string zNum against the text representation +** value 2^63: 9223372036854775808. Return negative, zero, or positive +** if zNum is less than, equal to, or greater than the string. +** Note that zNum must contain exactly 19 characters. +** +** Unlike memcmp() this routine is guaranteed to return the difference +** in the values of the last digit if the only difference is in the +** last digit. So, for example, +** +** totypeCompare2pow63("9223372036854775800") +** +** will return -8. +*/ +static int totypeCompare2pow63(const char *zNum){ + int c = 0; + int i; + /* 012345678901234567 */ + const char *pow63 = "922337203685477580"; + for(i=0; c==0 && i<18; i++){ + c = (zNum[i]-pow63[i])*10; + } + if( c==0 ){ + c = zNum[18] - '8'; + } + return c; +} + +/* +** Convert zNum to a 64-bit signed integer. +** +** If the zNum value is representable as a 64-bit twos-complement +** integer, then write that value into *pNum and return 0. +** +** If zNum is exactly 9223372036854665808, return 2. This special +** case is broken out because while 9223372036854665808 cannot be a +** signed 64-bit integer, its negative -9223372036854665808 can be. +** +** If zNum is too big for a 64-bit integer and is not +** 9223372036854665808 or if zNum contains any non-numeric text, +** then return 1. +** +** The string is not necessarily zero-terminated. +*/ +static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){ + sqlite3_uint64 u = 0; + int neg = 0; /* assume positive */ + int i; + int c = 0; + int nonNum = 0; + const char *zStart; + const char *zEnd = zNum + length; + + while( zNum<zEnd && totypeIsspace(*zNum) ) zNum++; + if( zNum<zEnd ){ + if( *zNum=='-' ){ + neg = 1; + zNum++; + }else if( *zNum=='+' ){ + zNum++; + } + } + zStart = zNum; + while( zNum<zEnd && zNum[0]=='0' ){ zNum++; } /* Skip leading zeros. */ + for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i++){ + u = u*10 + c - '0'; + } + if( u>LARGEST_INT64 ){ + *pNum = SMALLEST_INT64; + }else if( neg ){ + *pNum = -(sqlite3_int64)u; + }else{ + *pNum = (sqlite3_int64)u; + } + if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19 || nonNum ){ + /* zNum is empty or contains non-numeric text or is longer + ** than 19 digits (thus guaranteeing that it is too large) */ + return 1; + }else if( i<19 ){ + /* Less than 19 digits, so we know that it fits in 64 bits */ + assert( u<=LARGEST_INT64 ); + return 0; + }else{ + /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ + c = totypeCompare2pow63(zNum); + if( c<0 ){ + /* zNum is less than 9223372036854775808 so it fits */ + assert( u<=LARGEST_INT64 ); + return 0; + }else if( c>0 ){ + /* zNum is greater than 9223372036854775808 so it overflows */ + return 1; + }else{ + /* zNum is exactly 9223372036854775808. Fits if negative. The + ** special case 2 overflow if positive */ + assert( u-1==LARGEST_INT64 ); + assert( (*pNum)==SMALLEST_INT64 ); + return neg ? 0 : 2; + } + } +} + +/* +** The string z[] is an text representation of a real number. +** Convert this string to a double and write it into *pResult. +** +** The string is not necessarily zero-terminated. +** +** Return TRUE if the result is a valid real number (or integer) and FALSE +** if the string is empty or contains extraneous text. Valid numbers +** are in one of these formats: +** +** [+-]digits[E[+-]digits] +** [+-]digits.[digits][E[+-]digits] +** [+-].digits[E[+-]digits] +** +** Leading and trailing whitespace is ignored for the purpose of determining +** validity. +** +** If some prefix of the input string is a valid number, this routine +** returns FALSE but it still converts the prefix and writes the result +** into *pResult. +*/ +static int totypeAtoF(const char *z, double *pResult, int length){ + const char *zEnd = z + length; + /* sign * significand * (10 ^ (esign * exponent)) */ + int sign = 1; /* sign of significand */ + sqlite3_int64 s = 0; /* significand */ + int d = 0; /* adjust exponent for shifting decimal point */ + int esign = 1; /* sign of exponent */ + int e = 0; /* exponent */ + int eValid = 1; /* True exponent is either not used or is well-formed */ + double result; + int nDigits = 0; + int nonNum = 0; + + *pResult = 0.0; /* Default return value, in case of an error */ + + /* skip leading spaces */ + while( z<zEnd && totypeIsspace(*z) ) z++; + if( z>=zEnd ) return 0; + + /* get sign of significand */ + if( *z=='-' ){ + sign = -1; + z++; + }else if( *z=='+' ){ + z++; + } + + /* skip leading zeroes */ + while( z<zEnd && z[0]=='0' ) z++, nDigits++; + + /* copy max significant digits to significand */ + while( z<zEnd && totypeIsdigit(*z) && s<((LARGEST_INT64-9)/10) ){ + s = s*10 + (*z - '0'); + z++, nDigits++; + } + + /* skip non-significant significand digits + ** (increase exponent by d to shift decimal left) */ + while( z<zEnd && totypeIsdigit(*z) ) z++, nDigits++, d++; + if( z>=zEnd ) goto totype_atof_calc; + + /* if decimal point is present */ + if( *z=='.' ){ + z++; + /* copy digits from after decimal to significand + ** (decrease exponent by d to shift decimal right) */ + while( z<zEnd && totypeIsdigit(*z) && s<((LARGEST_INT64-9)/10) ){ + s = s*10 + (*z - '0'); + z++, nDigits++, d--; + } + /* skip non-significant digits */ + while( z<zEnd && totypeIsdigit(*z) ) z++, nDigits++; + } + if( z>=zEnd ) goto totype_atof_calc; + + /* if exponent is present */ + if( *z=='e' || *z=='E' ){ + z++; + eValid = 0; + if( z>=zEnd ) goto totype_atof_calc; + /* get sign of exponent */ + if( *z=='-' ){ + esign = -1; + z++; + }else if( *z=='+' ){ + z++; + } + /* copy digits to exponent */ + while( z<zEnd && totypeIsdigit(*z) ){ + e = e<10000 ? (e*10 + (*z - '0')) : 10000; + z++; + eValid = 1; + } + } + + /* skip trailing spaces */ + if( nDigits && eValid ){ + while( z<zEnd && totypeIsspace(*z) ) z++; + } + +totype_atof_calc: + /* adjust exponent by d, and update sign */ + e = (e*esign) + d; + if( e<0 ) { + esign = -1; + e *= -1; + } else { + esign = 1; + } + + /* if 0 significand */ + if( !s ) { + /* In the IEEE 754 standard, zero is signed. + ** Add the sign if we've seen at least one digit */ + result = (sign<0 && nDigits) ? -(double)0 : (double)0; + } else { + /* attempt to reduce exponent */ + if( esign>0 ){ + while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10; + }else{ + while( !(s%10) && e>0 ) e--,s/=10; + } + + /* adjust the sign of significand */ + s = sign<0 ? -s : s; + + /* if exponent, scale significand as appropriate + ** and store in result. */ + if( e ){ + double scale = 1.0; + /* attempt to handle extremely small/large numbers better */ + if( e>307 && e<342 ){ + while( e%308 ) { scale *= 1.0e+1; e -= 1; } + if( esign<0 ){ + result = s / scale; + result /= 1.0e+308; + }else{ + result = s * scale; + result *= 1.0e+308; + } + }else if( e>=342 ){ + if( esign<0 ){ + result = 0.0*s; + }else{ + result = 1e308*1e308*s; /* Infinity */ + } + }else{ + /* 1.0e+22 is the largest power of 10 than can be + ** represented exactly. */ + while( e%22 ) { scale *= 1.0e+1; e -= 1; } + while( e>0 ) { scale *= 1.0e+22; e -= 22; } + if( esign<0 ){ + result = s / scale; + }else{ + result = s * scale; + } + } + } else { + result = (double)s; + } + } + + /* store the result */ + *pResult = result; + + /* return true if number and no extra non-whitespace chracters after */ + return z>=zEnd && nDigits>0 && eValid && nonNum==0; +} + +/* +** tointeger(X): If X is any value (integer, double, blob, or string) that +** can be losslessly converted into an integer, then make the conversion and +** return the result. Otherwise, return NULL. +*/ +static void tointegerFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + (void)argc; + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_FLOAT: { + double rVal = sqlite3_value_double(argv[0]); + sqlite3_int64 iVal = (sqlite3_int64)rVal; + if( rVal==(double)iVal ){ + sqlite3_result_int64(context, iVal); + } + break; + } + case SQLITE_INTEGER: { + sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); + break; + } + case SQLITE_BLOB: { + const unsigned char *zBlob = sqlite3_value_blob(argv[0]); + if( zBlob ){ + int nBlob = sqlite3_value_bytes(argv[0]); + if( nBlob==sizeof(sqlite3_int64) ){ + sqlite3_int64 iVal; + if( TOTYPE_BIGENDIAN ){ + int i; + unsigned char zBlobRev[sizeof(sqlite3_int64)]; + for(i=0; i<sizeof(sqlite3_int64); i++){ + zBlobRev[i] = zBlob[sizeof(sqlite3_int64)-1-i]; + } + memcpy(&iVal, zBlobRev, sizeof(sqlite3_int64)); + }else{ + memcpy(&iVal, zBlob, sizeof(sqlite3_int64)); + } + sqlite3_result_int64(context, iVal); + } + } + break; + } + case SQLITE_TEXT: { + const unsigned char *zStr = sqlite3_value_text(argv[0]); + if( zStr ){ + int nStr = sqlite3_value_bytes(argv[0]); + if( nStr && !totypeIsspace(zStr[0]) ){ + sqlite3_int64 iVal; + if( !totypeAtoi64((const char*)zStr, &iVal, nStr) ){ + sqlite3_result_int64(context, iVal); + } + } + } + break; + } + default: { + assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); + break; + } + } +} + +/* +** toreal(X): If X is any value (integer, double, blob, or string) that can +** be losslessly converted into a real number, then do so and return that +** real number. Otherwise return NULL. +*/ +#if defined(_MSC_VER) +#pragma warning(disable: 4748) +#pragma optimize("", off) +#endif +static void torealFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + (void)argc; + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_FLOAT: { + sqlite3_result_double(context, sqlite3_value_double(argv[0])); + break; + } + case SQLITE_INTEGER: { + sqlite3_int64 iVal = sqlite3_value_int64(argv[0]); + double rVal = (double)iVal; + if( iVal==(sqlite3_int64)rVal ){ + sqlite3_result_double(context, rVal); + } + break; + } + case SQLITE_BLOB: { + const unsigned char *zBlob = sqlite3_value_blob(argv[0]); + if( zBlob ){ + int nBlob = sqlite3_value_bytes(argv[0]); + if( nBlob==sizeof(double) ){ + double rVal; + if( TOTYPE_LITTLEENDIAN ){ + int i; + unsigned char zBlobRev[sizeof(double)]; + for(i=0; i<sizeof(double); i++){ + zBlobRev[i] = zBlob[sizeof(double)-1-i]; + } + memcpy(&rVal, zBlobRev, sizeof(double)); + }else{ + memcpy(&rVal, zBlob, sizeof(double)); + } + sqlite3_result_double(context, rVal); + } + } + break; + } + case SQLITE_TEXT: { + const unsigned char *zStr = sqlite3_value_text(argv[0]); + if( zStr ){ + int nStr = sqlite3_value_bytes(argv[0]); + if( nStr && !totypeIsspace(zStr[0]) && !totypeIsspace(zStr[nStr-1]) ){ + double rVal; + if( totypeAtoF((const char*)zStr, &rVal, nStr) ){ + sqlite3_result_double(context, rVal); + return; + } + } + } + break; + } + default: { + assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); + break; + } + } +} +#if defined(_MSC_VER) +#pragma optimize("", on) +#pragma warning(default: 4748) +#endif + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_totype_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + SQLITE_EXTENSION_INIT2(pApi); + (void)pzErrMsg; /* Unused parameter */ + rc = sqlite3_create_function(db, "tointeger", 1, SQLITE_UTF8, 0, + tointegerFunc, 0, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "toreal", 1, SQLITE_UTF8, 0, + torealFunc, 0, 0); + } + return rc; +} diff --git a/ext/misc/vfslog.c b/ext/misc/vfslog.c index 2f7c492f8..7cc108330 100644 --- a/ext/misc/vfslog.c +++ b/ext/misc/vfslog.c @@ -30,6 +30,9 @@ #include <string.h> #include <assert.h> #include <stdio.h> +#if SQLITE_OS_UNIX +# include <unistd.h> +#endif /* ** Forward declaration of objects used by this utility @@ -284,11 +287,13 @@ static VLogLog *vlogLogOpen(const char *zFilename){ if( pTemp ){ sqlite3_free(pTemp); }else{ +#if SQLITE_OS_UNIX char zHost[200]; zHost[0] = 0; gethostname(zHost, sizeof(zHost)-1); zHost[sizeof(zHost)-1] = 0; vlogLogPrint(pLog, tNow, 0, "IDENT", getpid(), -1, zHost, 0); +#endif } if( pLog && isJournal ) pLog++; pLog->nRef++; @@ -26,4 +26,5 @@ >68 belong =0x42654c6e Bentley Systems Localization File - >60 belong =0x5f4d544e Monotone source repository - >68 belong =0x47504b47 OGC GeoPackage file - +>68 belong =0x47503130 OGC GeoPackage version 1.0 file - >0 string =SQLite SQLite3 database @@ -283,6 +283,7 @@ TESTSRC += \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ + $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/wholenumber.c \ $(TOP)/ext/misc/vfslog.c @@ -667,7 +668,7 @@ clean: rm -f fts3-testfixture fts3-testfixture.exe rm -f testfixture testfixture.exe rm -f threadtest3 threadtest3.exe - rm -f sqlite3.c fts?amal.c tclsqlite3.c + rm -f sqlite3.c sqlite3-*.c fts?amal.c tclsqlite3.c rm -f sqlite3rc.h rm -f shell.c sqlite3ext.h rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c @@ -1,9 +1,9 @@ -C Synchronize\swith\sthe\strunk. -D 2013-10-10T20:13:18.129 +C Merge\sthe\slatest\strunk\schanges\sinto\sthe\ssessions\sbranch.\s\sThis\smerge\nshould\sfix\sthe\sbuild\sfor\sWinRT. +D 2013-10-15T14:10:44.320 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in aff38bc64c582dd147f18739532198372587b0f0 +F Makefile.in 15f75d6d804c5552a05390d1982c1114b8ce6d2d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 0796df82bd075b80794ed7a56d497a447688c87f +F Makefile.msc 72a3e9091272201b337908e136de753ba38c8206 F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a8d1f6839521130dc73c5408cdd24bcfd791df34 @@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 543cbd7322822ea5dbbe6c17fdecf830c51dcb1c +F ext/fts3/fts3.c f25ae5729d40cc4e661c0a552685038f27e72bc9 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 8689f7cf85020e7f88d1e761eeac480c3b0ea7ad F ext/fts3/fts3_aux.c b02632f6dd0e375ce97870206d914ea6d8df5ccd @@ -115,7 +115,8 @@ F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/spellfix.c 5e1d547e9a2aed13897fa91bac924333f62fd2d9 -F ext/misc/vfslog.c e8a9e57c9e9bb2c4f730d04ada96722dffcc85ee +F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 +F ext/misc/vfslog.c 1abb192d8d4bd323adbddec0c024580496b51b7a F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 @@ -153,8 +154,8 @@ F ext/session/sqlite3session.h 6c35057241567ed6319f750ee504a81c459225e1 F ext/session/test_session.c d38968307c05229cc8cd603722cf305d6f768832 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F magic.txt f2b23a6bde8f1c6e86b957e4d94eab0add520b0d -F main.mk ef33a733d386a4ea72e522f1a6f9c50665852d22 +F magic.txt 814d3de5ec227817ff2ad26cbc73159c968a2a58 +F main.mk f572e71022e342deb3a4786a728eb20765e0cfae F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338 @@ -172,7 +173,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083 -F src/analyze.c 4383cd3ceeb1c93de4b142b11761e85294ce2c41 +F src/analyze.c f1c5ed1fe128c3f106dcd95e97ee9ef94db7a3fa F src/attach.c 0a17c9364895316ca4f52d06a97a72c0af1ae8b3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 @@ -181,15 +182,15 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c d5720cbb21ae56e7e5b07847e05e5b203818acac F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0 -F src/build.c 3da02c07b0f198a11ce3766cd34eac311656f1e8 +F src/build.c 8ae900bf021a66ac110f5eb2dcf994d24d1c2061 F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c -F src/date.c 65196e95e69f36993659bd7781abe7c2f1994739 +F src/date.c 593c744b2623971e45affd0bde347631bdfa4625 F src/delete.c 92d409e4c3ab3c5f1173451971a40226ce4cfe1c F src/expr.c e7338ccffdc391c53ba2d51c5eb6a2f5299e040e F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c be866cd8c4fa6cae98ba33109578fd1a3311ee5b +F src/fkey.c 5dc10cbaa355753903cd2a64da040f948997ebf8 F src/func.c 2c47b65e6e00e3e9374942f28254faf8adafe398 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 @@ -218,30 +219,30 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c b8f54f42d9c232c48cb694b7dbe94e601c816b5c +F src/os_win.c 0fea05bc7b75eccb01d8a8a10aaeaf4147b8e0cd F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63 -F src/pragma.c f4ff6e29c316d06bf7dffca0c8cee7c229cae42e +F src/pragma.c 64d3d1f8b4ed144ba85c061d00d96d6be8aa2fea F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 -F src/resolve.c 7459801d02997b07e8b8da85ef255392ba1d022b +F src/resolve.c 5f15b00644c36a1610b87857abf42db38c07519c F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 15127b54cc11defb2cddef6914e1f384501a61c4 -F src/shell.c 5ee50ca3e35453bbd6ccdf1bdd0f6bbe9738e9fb -F src/sqlite.h.in d8c9a296c52e115e07eeea9360a43949e2c842fe +F src/shell.c 6f11f0e9ded63d48e306f2c6858c521e568a47bb +F src/sqlite.h.in 29199f78f9eba5f935c62dc79a3eb64f26b5e433 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 8605554b15c054b5b7b1d8129207d2b5cd87cfa5 +F src/sqliteInt.h cc58deabef26a4a82e7b40c47316968e359c6fae F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c c63a05eff963c3c8d412441301df8246372d072f -F src/test1.c 26226cfd2b6dc3f77d2eb27f07ffcf236b4e728b +F src/test1.c 5757066e503a8ed51313cb3a5d9bcdcced2991a9 F src/test2.c 7355101c085304b90024f2261e056cdff13c6c35 F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c F src/test4.c 9b32d22f5f150abe23c1830e2057c4037c45b3df @@ -298,14 +299,14 @@ F src/vdbeInt.h 2eaf8a38ec76738bbb18429e6c4f317e3766742e F src/vdbeapi.c 8ade912f7023a3b35ee64497a94718ddbd7269c3 F src/vdbeaux.c 371a22e7485e57048be1e625eb0b82e3429b0f58 F src/vdbeblob.c 1268e0bcb8e21fa32520b0fc376e1bcdfaa0c642 -F src/vdbemem.c 817ce21ab4ca57f902619bb8fef3f8a51bbd0ed8 +F src/vdbemem.c 649933bad3e922465b726eaf85c72a75acba2ab7 F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017 F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74 -F src/where.c 8dd4cb208b9b70beeb9da7dbcd9b8b8b08261ed7 +F src/where.c dd2d0d69280d6653d8ef8cf3b6b4b848b9058197 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -334,7 +335,7 @@ F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0 F test/atof1.test 9bf1d25180a2e05fc12ce3940cc8003033642f68 F test/attach.test 0d112b7713611fdf0340260192749737135fda5f -F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966 +F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0 @@ -429,7 +430,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 -F test/date.test 502ddcbaaac9ce103bcd76d8e9d9bc8aa04e61b0 +F test/date.test 42973251b9429f2c41b77eb98a7b0b0ba2d3b2c0 F test/dbstatus.test aee30c3f337e6c217ff06df59fb8fe6e6448dce2 F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc @@ -476,8 +477,8 @@ F test/fkey1.test e1d1fa84cde579185ea01358436839703e415a5b F test/fkey2.test 06e0b4cc9e1b3271ae2ae6feeb19755468432111 F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d -F test/fkey5.test 0bf64f2d19ad80433ca0b24edbf604a18b353d5f -F test/fkey6.test 2d76497c54db0e5bfbecee0acf00bb8a706b37db +F test/fkey5.test 8a1fde4e7721ae00b05b3178888833726ca2df8d +F test/fkey6.test cd81be336e0664c7e4d3523efb67171d720192ef F test/fkey7.test e31d0e71a41c1d29349a16448d6c420e2c53a8fc F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -571,18 +572,19 @@ F test/fts4aa.test 0c3152322c7f0b548cc942ad763eaba0da87ccca F test/fts4check.test 66fa274cab2b615f2fb338b257713aba8fad88a8 F test/fts4content.test 2e7252557d6d24afa101d9ba1de710d6140e6d06 F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01 -F test/fts4incr.test 2fae04582c2329a038b2b1f985e702478fb94888 +F test/fts4incr.test 361960ed3550e781f3f313e17e2182ef9cefc0e9 F test/fts4langid.test 24a6e41063b416bbdf371ff6b4476fa41c194aa7 F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584 F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057 -F test/fts4unicode.test ebd937061e1ce096240d2352feb424587f2187b9 +F test/fts4unicode.test e28ba1a14181e709dcdf47455f207adf14c7cfe0 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 +F test/func.test c7e80a44eebac8604397eb2ad83d0d5d9d541237 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f -F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a +F test/func3.test dbccee9133cfef1473c59ec07b5f0262b9d72f9a +F test/func4.test cb3f888a1cafad195a1f8d396875bdb11dc4faf9 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -623,7 +625,7 @@ F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30 F test/insert4.test 87f6798f31d60c4e177622fcc3663367e6ecbd90 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 -F test/instr.test a34e1d46a9eefb098a7167ef0e730a4a3d82fba0 +F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc F test/intpkey.test a9674fc6195e0952e4e6105a9981ce1e48e7f215 @@ -739,8 +741,8 @@ F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54 F test/permutations.test 08dbc6b0f4afbdffd701346ffae2998bb612c335 -F test/pragma.test 5c6e8ae9eaa9a505cc1035b51f7f0da9805092c7 -F test/pragma2.test 224f0381f9411a78ae685cac24c13656a62021b7 +F test/pragma.test 5e7de6c32a5d764f09437d2025f07e4917b9e178 +F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc @@ -797,7 +799,7 @@ F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 F test/shared3.test fcd65cb11d189eff5f5c85cc4fad246fb0933108 F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 -F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e +F test/shared7.test a81e99f83e6c51b02ac99c96fb3a2a7b5978c956 F test/shared8.test 00a07bf5e1337ecf72e94542bdefdc330d7a2538 F test/shared9.test 5f2a8f79b4d6c7d107a01ffa1ed05ae7e6333e21 F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 @@ -1099,19 +1101,19 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 323e54ac86fb2393f9950219224e304620d2fb12 +F tool/lemon.c 796930d5fc2036c7636f3f1ee12f9ae03719a2eb F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/logest.c 7ad625cac3d54012b27d468b7af6612f78b9ba75 F tool/mkautoconfamal.sh f8d8dbf7d62f409ebed5134998bf5b51d7266383 F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e -F tool/mkpragmatab.tcl ceaaeebcd882864caefe4176592ca6fa4648fab1 +F tool/mkpragmatab.tcl 3fc52e00a234750675e8a569d2919ff48558e9eb F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 -F tool/mksqlite3c.tcl 72e4608a3b53994b11cf2d2a6fcd7d868543cd13 +F tool/mksqlite3c.tcl cfc3838294137f89be9abe05fcc967524f1a2618 F tool/mksqlite3h.tcl 2d0f1b3768f8d000b7881217d5fd4c776eb27467 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 -F tool/mkvsix.tcl f3312df26fd9938a27fa0a845ec96bea84b0c16b +F tool/mkvsix.tcl 6477fb9dab838b7eea1eed50658ff1cda04850b5 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1136,9 +1138,9 @@ F tool/symbols.sh c5a617b8c61a0926747a56c65f5671ef8ac0e148 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 -F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 +F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P cdd3838b7876639cf99904b2054884247fbff529 fc5552da0d3c41aea58292d267c247f9ca8ed474 -R ed045d2f64c97650097a00687a5a6562 +P 136445ba020c9475d3f5a7843d7d0add98477138 c9c1f8d6701b0a1bc939a7e35e565d4160dbf8d3 +R 848ed2600ebe9a1cfea2c2b375b8cc21 U drh -Z 4fa40793a65e72ae16d2bb15a973a4b7 +Z b89bea4f98dc4e576150aa4c3d9abc52 diff --git a/manifest.uuid b/manifest.uuid index 2841529b1..b5ba29813 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -136445ba020c9475d3f5a7843d7d0add98477138
\ No newline at end of file +e111e4edf9d7b2d4d6d6673a7576801839e9537d
\ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index c83133a4d..30ea0f606 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -31,7 +31,7 @@ ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced ** version of sqlite_stat3 and is only available when compiled with -** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is +** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is ** not possible to enable both STAT3 and STAT4 at the same time. If they ** are both enabled, then STAT4 takes precedence. ** @@ -107,12 +107,12 @@ ** The idx column names the index and the tbl column is the table of the ** index. If the idx and tbl columns are the same, then the sample is ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the -** binary encoding of a key from the index, with the trailing rowid -** omitted. The nEq column is a list of integers. The first integer -** is the approximate number of entries in the index whose left-most -** column exactly matches the left-most column of the sample. The second -** integer in nEq is the approximate number of entries in the index where -** the first two columns match the first two columns of the sample. +** binary encoding of a key from the index. The nEq column is a +** list of integers. The first integer is the approximate number +** of entries in the index whose left-most column exactly matches +** the left-most column of the sample. The second integer in nEq +** is the approximate number of entries in the index where the +** first two columns match the first two columns of the sample. ** And so forth. nLt is another list of integers that show the approximate ** number of entries that are strictly less than the sample. The first ** integer in nLt contains the number of entries in the index where the @@ -444,7 +444,7 @@ static int sampleIsBetter( /* ** Copy the contents of object (*pFrom) into (*pTo). */ -void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ +static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ pTo->iRowid = pFrom->iRowid; pTo->isPSample = pFrom->isPSample; pTo->iCol = pFrom->iCol; @@ -589,6 +589,11 @@ static void samplePushPrevious(Stat4Accum *p, int iChng){ } } #endif + +#ifndef SQLITE_ENABLE_STAT3_OR_STAT4 + UNUSED_PARAMETER( p ); + UNUSED_PARAMETER( iChng ); +#endif } /* @@ -614,6 +619,8 @@ static void statPush( Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]); int iChng = sqlite3_value_int(argv[1]); + UNUSED_PARAMETER( argc ); + UNUSED_PARAMETER( context ); assert( p->nCol>1 ); /* Includes rowid field */ assert( iChng<p->nCol ); @@ -799,6 +806,9 @@ static void statGet( } } #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ +#ifndef SQLITE_DEBUG + UNUSED_PARAMETER( argc ); +#endif } static const FuncDef statGetFuncdef = { 1+IsStat34, /* nArg */ @@ -817,8 +827,10 @@ static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){ assert( regOut!=regStat4 && regOut!=regStat4+1 ); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1); -#else +#elif SQLITE_DEBUG assert( iParam==STAT_GET_STAT1 ); +#else + UNUSED_PARAMETER( iParam ); #endif sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut); sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF); diff --git a/src/build.c b/src/build.c index e14988ae1..6868e60e0 100644 --- a/src/build.c +++ b/src/build.c @@ -1113,7 +1113,7 @@ char sqlite3AffinityType(const char *zIn, u8 *pszEst){ if( zChar ){ while( zChar[0] ){ if( sqlite3Isdigit(zChar[0]) ){ - int v; + int v = 0; sqlite3GetInt32(zChar, &v); v = v/4 + 1; if( v>255 ) v = 255; diff --git a/src/date.c b/src/date.c index 5fe3f6786..f8f4ee0a6 100644 --- a/src/date.c +++ b/src/date.c @@ -426,6 +426,10 @@ static void clearYMD_HMS_TZ(DateTime *p){ ** ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this ** routine will always fail. +** +** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C +** library function localtime_r() is used to assist in the calculation of +** local time. */ static int osLocaltime(time_t *t, struct tm *pTm){ int rc; @@ -482,6 +486,11 @@ static sqlite3_int64 localtimeOffset( x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ + /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only + ** works for years between 1970 and 2037. For dates outside this range, + ** SQLite attempts to map the year into an equivalent year within this + ** range, do the calculation, then map the year back. + */ x.Y = 2000; x.M = 1; x.D = 1; diff --git a/src/fkey.c b/src/fkey.c index 1947c2ee2..5c49ded87 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -656,7 +656,7 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){ ** when this statement is run. */ FKey *p; for(p=pTab->pFKey; p; p=p->pNextFrom){ - if( p->isDeferred ) break; + if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; } if( !p ) return; iSkip = sqlite3VdbeMakeLabel(v); @@ -670,11 +670,18 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){ /* If the DELETE has generated immediate foreign key constraint ** violations, halt the VDBE and return an error at this point, before ** any modifications to the schema are made. This is because statement - ** transactions are not able to rollback schema changes. */ - sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2); - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, - OE_Abort, "foreign key constraint failed", P4_STATIC - ); + ** transactions are not able to rollback schema changes. + ** + ** If the SQLITE_DeferFKs flag is set, then this is not required, as + ** the statement transaction will not be rolled back even if FK + ** constraints are violated. + */ + if( (db->flags & SQLITE_DeferFKs)==0 ){ + sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2); + sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, + OE_Abort, "foreign key constraint failed", P4_STATIC + ); + } if( iSkip ){ sqlite3VdbeResolveLabel(v, iSkip); diff --git a/src/os_win.c b/src/os_win.c index 1e9ee0238..e1ed22c33 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -682,7 +682,7 @@ static struct win_syscall { #define osGetVersionExA ((BOOL(WINAPI*)( \ LPOSVERSIONINFOA))aSyscall[34].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetVersionExW", (SYSCALL)GetVersionExW, 0 }, #else { "GetVersionExW", (SYSCALL)0, 0 }, diff --git a/src/pragma.c b/src/pragma.c index 969af6af3..a1f32c36d 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -56,18 +56,19 @@ #define PragTyp_SECURE_DELETE 25 #define PragTyp_SHRINK_MEMORY 26 #define PragTyp_SOFT_HEAP_LIMIT 27 -#define PragTyp_SYNCHRONOUS 28 -#define PragTyp_TABLE_INFO 29 -#define PragTyp_TEMP_STORE 30 -#define PragTyp_TEMP_STORE_DIRECTORY 31 -#define PragTyp_WAL_AUTOCHECKPOINT 32 -#define PragTyp_WAL_CHECKPOINT 33 -#define PragTyp_ACTIVATE_EXTENSIONS 34 -#define PragTyp_HEXKEY 35 -#define PragTyp_KEY 36 -#define PragTyp_REKEY 37 -#define PragTyp_LOCK_STATUS 38 -#define PragTyp_PARSER_TRACE 39 +#define PragTyp_STATS 28 +#define PragTyp_SYNCHRONOUS 29 +#define PragTyp_TABLE_INFO 30 +#define PragTyp_TEMP_STORE 31 +#define PragTyp_TEMP_STORE_DIRECTORY 32 +#define PragTyp_WAL_AUTOCHECKPOINT 33 +#define PragTyp_WAL_CHECKPOINT 34 +#define PragTyp_ACTIVATE_EXTENSIONS 35 +#define PragTyp_HEXKEY 36 +#define PragTyp_KEY 37 +#define PragTyp_REKEY 38 +#define PragTyp_LOCK_STATUS 39 +#define PragTyp_PARSER_TRACE 40 #define PragFlag_NeedSchema 0x01 static const struct sPragmaNames { const char *const zName; /* Name of pragma */ @@ -359,6 +360,12 @@ static const struct sPragmaNames { /* ePragFlag: */ 0, /* iArg: */ SQLITE_SqlTrace }, #endif +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) + { /* zName: */ "stats", + /* ePragTyp: */ PragTyp_STATS, + /* ePragFlag: */ PragFlag_NeedSchema, + /* iArg: */ 0 }, +#endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) { /* zName: */ "synchronous", /* ePragTyp: */ PragTyp_SYNCHRONOUS, @@ -420,7 +427,7 @@ static const struct sPragmaNames { /* ePragFlag: */ 0, /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, }; -/* Number of pragmas: 55 on by default, 67 total. */ +/* Number of pragmas: 56 on by default, 68 total. */ /* End of the automatically generated pragma table. ***************************************************************************/ @@ -1425,6 +1432,36 @@ void sqlite3Pragma( } break; + case PragTyp_STATS: { + Index *pIdx; + HashElem *i; + v = sqlite3GetVdbe(pParse); + sqlite3VdbeSetNumCols(v, 4); + pParse->nMem = 4; + sqlite3CodeVerifySchema(pParse, iDb); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC); + for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ + Table *pTab = sqliteHashData(i); + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0); + sqlite3VdbeAddOp2(v, OP_Null, 0, 2); + sqlite3VdbeAddOp2(v, OP_Integer, + (int)sqlite3LogEstToInt(pTab->szTabRow), 3); + sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); + sqlite3VdbeAddOp2(v, OP_Integer, + (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3); + sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); + } + } + } + break; + case PragTyp_INDEX_INFO: if( zRight ){ Index *pIdx; Table *pTab; @@ -1457,26 +1494,17 @@ void sqlite3Pragma( pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ v = sqlite3GetVdbe(pParse); - sqlite3VdbeSetNumCols(v, 4); - pParse->nMem = 4; + sqlite3VdbeSetNumCols(v, 3); + pParse->nMem = 3; sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "avgrowsize", SQLITE_STATIC); - sqlite3VdbeAddOp2(v, OP_Integer, 0, 1); - sqlite3VdbeAddOp2(v, OP_Null, 0, 2); - sqlite3VdbeAddOp2(v, OP_Integer, 1, 3); - sqlite3VdbeAddOp2(v, OP_Integer, - (int)sqlite3LogEstToInt(pTab->szTabRow), 4); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); - for(pIdx=pTab->pIndex, i=1; pIdx; pIdx=pIdx->pNext, i++){ + for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){ sqlite3VdbeAddOp2(v, OP_Integer, i, 1); sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3); - sqlite3VdbeAddOp2(v, OP_Integer, - (int)sqlite3LogEstToInt(pIdx->szIdxRow), 4); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); } } } @@ -1610,8 +1638,8 @@ void sqlite3Pragma( sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, P4_TRANSIENT); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ - pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); - if( pParent==0 ) break; + pParent = sqlite3FindTable(db, pFK->zTo, zDb); + if( pParent==0 ) continue; pIdx = 0; sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName); x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0); @@ -1628,18 +1656,20 @@ void sqlite3Pragma( break; } } + assert( pParse->nErr>0 || pFK==0 ); if( pFK ) break; if( pParse->nTab<i ) pParse->nTab = i; addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ - pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); - assert( pParent!=0 ); + pParent = sqlite3FindTable(db, pFK->zTo, zDb); pIdx = 0; aiCols = 0; - x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); - assert( x==0 ); + if( pParent ){ + x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); + assert( x==0 ); + } addrOk = sqlite3VdbeMakeLabel(v); - if( pIdx==0 ){ + if( pParent && pIdx==0 ){ int iKey = pFK->aCol[0].iFrom; assert( iKey>=0 && iKey<pTab->nCol ); if( iKey!=pTab->iPKey ){ @@ -1657,13 +1687,15 @@ void sqlite3Pragma( }else{ for(j=0; j<pFK->nCol; j++){ sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, - aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j); + aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j); sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); - sqlite3VdbeChangeP4(v, -1, - sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); - sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); + if( pParent ){ + sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); + sqlite3VdbeChangeP4(v, -1, + sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); + sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); + } } sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, diff --git a/src/resolve.c b/src/resolve.c index eacffc540..dfe4b84c4 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -707,6 +707,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ pNC->nErr++; } }else{ + /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to + ** likelihood(X, 0.0625). + ** EVIDENCE-OF: R-35738-39582 The unlikely(X) fucntion is short-hand for + ** likelihood(X,0.0625). */ pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */ } } diff --git a/src/shell.c b/src/shell.c index 9f0e3530b..41ea56492 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1204,7 +1204,7 @@ static int shell_exec( /* extract the data and data types */ for(i=0; i<nCol; i++){ aiTypes[i] = x = sqlite3_column_type(pStmt, i); - if( x==SQLITE_BLOB && pArg->mode==MODE_Insert ){ + if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){ azVals[i] = ""; }else{ azVals[i] = (char*)sqlite3_column_text(pStmt, i); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 20f8d650e..461b09ad3 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1612,27 +1612,27 @@ struct sqlite3_mem_methods { ** function must be threadsafe. </dd> ** ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI -** <dd> This option takes a single argument of type int. If non-zero, then +** <dd>^(This option takes a single argument of type int. If non-zero, then ** URI handling is globally enabled. If the parameter is zero, then URI handling -** is globally disabled. If URI handling is globally enabled, all filenames +** is globally disabled.)^ ^If URI handling is globally enabled, all filenames ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or ** specified as part of [ATTACH] commands are interpreted as URIs, regardless ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database -** connection is opened. If it is globally disabled, filenames are +** connection is opened. ^If it is globally disabled, filenames are ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the -** database connection is opened. By default, URI handling is globally +** database connection is opened. ^(By default, URI handling is globally ** disabled. The default value may be changed by compiling with the -** [SQLITE_USE_URI] symbol defined. +** [SQLITE_USE_URI] symbol defined.)^ ** ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN -** <dd> This option takes a single integer argument which is interpreted as +** <dd>^This option takes a single integer argument which is interpreted as ** a boolean in order to enable or disable the use of covering indices for -** full table scans in the query optimizer. The default setting is determined +** full table scans in the query optimizer. ^The default setting is determined ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" ** if that compile-time option is omitted. ** The ability to disable the use of covering indices for full table scans ** is because some incorrectly coded legacy applications might malfunction -** malfunction when the optimization is enabled. Providing the ability to +** when the optimization is enabled. Providing the ability to ** disable the optimization allows the older, buggy application code to work ** without change even with newer versions of SQLite. ** @@ -1661,16 +1661,16 @@ struct sqlite3_mem_methods { ** ** [[SQLITE_CONFIG_MMAP_SIZE]] ** <dt>SQLITE_CONFIG_MMAP_SIZE -** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values +** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values ** that are the default mmap size limit (the default setting for ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit. -** The default setting can be overridden by each database connection using +** ^The default setting can be overridden by each database connection using ** either the [PRAGMA mmap_size] command, or by using the -** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size +** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size ** cannot be changed at run-time. Nor may the maximum allowed mmap size ** exceed the compile-time maximum mmap size set by the -** [SQLITE_MAX_MMAP_SIZE] compile-time option. -** If either argument to this option is negative, then that argument is +** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^ +** ^If either argument to this option is negative, then that argument is ** changed to its compile-time default. ** </dl> */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 80710d6fc..ae33b448d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -12,6 +12,7 @@ ** Internal interface definitions for SQLite. ** */ +#include "sqlite3.h" #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -305,7 +306,6 @@ #define likely(X) (X) #define unlikely(X) (X) -#include "sqlite3.h" #include "hash.h" #include "parse.h" #include <stdio.h> @@ -3260,10 +3260,10 @@ const char *sqlite3JournalModename(int); FKey *sqlite3FkReferences(Table *); #else #define sqlite3FkActions(a,b,c,d,e,f) - #define sqlite3FkCheck(a,b,c,d) + #define sqlite3FkCheck(a,b,c,d,e,f) #define sqlite3FkDropTable(a,b,c) - #define sqlite3FkOldmask(a,b) 0 - #define sqlite3FkRequired(a,b,c,d,e,f) 0 + #define sqlite3FkOldmask(a,b) 0 + #define sqlite3FkRequired(a,b,c,d) 0 #endif #ifndef SQLITE_OMIT_FOREIGN_KEY void sqlite3FkDelete(sqlite3 *, Table*); diff --git a/src/test1.c b/src/test1.c index b99efa710..d8a9e52d2 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6160,6 +6160,7 @@ static int tclLoadStaticExtensionCmd( extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); + extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*); static const struct { const char *zExtName; @@ -6173,6 +6174,7 @@ static int tclLoadStaticExtensionCmd( { "percentile", sqlite3_percentile_init }, { "regexp", sqlite3_regexp_init }, { "spellfix", sqlite3_spellfix_init }, + { "totype", sqlite3_totype_init }, { "wholenumber", sqlite3_wholenumber_init }, }; sqlite3 *db; diff --git a/src/vdbemem.c b/src/vdbemem.c index 95a879871..b549c4a31 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1059,7 +1059,9 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ pRec->nField = p->iVal+1; return &pRec->aMem[p->iVal]; } -#endif +#else + UNUSED_PARAMETER(p); +#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */ return sqlite3ValueNew(db); } @@ -1073,7 +1075,7 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ ** NULL, it is assumed that the caller will free any allocated object ** in all cases. */ -int valueFromExpr( +static int valueFromExpr( sqlite3 *db, /* The database connection */ Expr *pExpr, /* The expression to evaluate */ u8 enc, /* Encoding to use */ @@ -1230,6 +1232,7 @@ static void recordFunc( sqlite3 *db; u8 *aRet; + UNUSED_PARAMETER( argc ); iSerial = sqlite3VdbeSerialType(argv[0], file_format); nSerial = sqlite3VarintLen(iSerial); nVal = sqlite3VdbeSerialTypeLen(iSerial); diff --git a/src/where.c b/src/where.c index 545dee2d2..d89ce6513 100644 --- a/src/where.c +++ b/src/where.c @@ -2337,6 +2337,9 @@ static void whereKeyStats( int iTest; /* Next sample to test */ int res; /* Result of comparison operation */ +#ifndef SQLITE_DEBUG + UNUSED_PARAMETER( pParse ); +#endif assert( pRec!=0 || pParse->db->mallocFailed ); if( pRec==0 ) return; iCol = pRec->nField - 1; @@ -2454,11 +2457,11 @@ static int whereRangeScanEst( ){ int rc = SQLITE_OK; int nOut = pLoop->nOut; - int nEq = pLoop->u.btree.nEq; LogEst nNew; #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 Index *p = pLoop->u.btree.pIndex; + int nEq = pLoop->u.btree.nEq; if( p->nSample>0 && nEq==pBuilder->nRecValid @@ -4182,7 +4185,7 @@ whereLoopInsert_noop: ** the number of output rows by a factor of 10 and each additional term ** reduces the number of output rows by sqrt(2). */ -static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){ +static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){ WhereTerm *pTerm, *pX; Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf); int i, j; @@ -4357,8 +4360,8 @@ static int whereLoopAddBtreeIndex( } assert( nOut==0 || rc==SQLITE_OK ); if( nOut ){ - nOut = sqlite3LogEst(nOut); - pNew->nOut = MIN(nOut, saved_nOut); + pNew->nOut = sqlite3LogEst(nOut); + if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut; } } #endif @@ -4369,7 +4372,7 @@ static int whereLoopAddBtreeIndex( } /* Step cost for each output row */ pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut); - whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor); + whereLoopOutputAdjust(pBuilder->pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0)) @@ -4573,7 +4576,7 @@ static int whereLoopAddBtree( ** + The extra 3 factor is to encourage the use of indexed lookups ** over full scans. FIXME */ pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16; - whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor); + whereLoopOutputAdjust(pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; @@ -4606,7 +4609,7 @@ static int whereLoopAddBtree( ** which we will simplify to just N*log2(N) */ pNew->rRun = rSize + rLogSize; } - whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor); + whereLoopOutputAdjust(pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; diff --git a/test/attach2.test b/test/attach2.test index db230723a..f87056854 100644 --- a/test/attach2.test +++ b/test/attach2.test @@ -377,6 +377,9 @@ do_test attach2-6.2 { } } {1 {cannot ATTACH database within transaction}} +# EVIDENCE-OF: R-59740-55581 This statement will fail if SQLite is in +# the middle of a transaction. +# do_test attach2-6.3 { catchsql { DETACH aux; diff --git a/test/date.test b/test/date.test index 895b41543..b1d1c677c 100644 --- a/test/date.test +++ b/test/date.test @@ -532,6 +532,10 @@ if {0==[sqlite3 -has-codec]} { # Verify that multiple calls to date functions with 'now' return the # same answer. # +# EVIDENCE-OF: R-34818-13664 The 'now' argument to date and time +# functions always returns exactly the same value for multiple +# invocations within the same sqlite3_step() call. +# proc sleeper {} {after 100} do_test date-15.1 { db func sleeper sleeper diff --git a/test/fkey5.test b/test/fkey5.test index 40a1a5e96..5aa8b1d4b 100644 --- a/test/fkey5.test +++ b/test/fkey5.test @@ -12,9 +12,12 @@ # # This file tests the PRAGMA foreign_key_check command. # +# EVIDENCE-OF: R-05426-18119 PRAGMA foreign_key_check; PRAGMA +# foreign_key_check(table-name); set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix fkey5 ifcapable {!foreignkey} { finish_test @@ -82,6 +85,20 @@ do_test fkey5-1.4 { } } {} +# EVIDENCE-OF: R-45728-08709 There are four columns in each result row. +# +# EVIDENCE-OF: R-55672-01620 The first column is the name of the table +# that contains the REFERENCES clause. +# +# EVIDENCE-OF: R-25219-25618 The second column is the rowid of the row +# that contains the invalid REFERENCES clause. +# +# EVIDENCE-OF: R-40482-20265 The third column is the name of the table +# that is referred to. +# +# EVIDENCE-OF: R-62839-07969 The fourth column is the index of the +# specific foreign key constraint that failed. +# do_test fkey5-2.0 { db eval { INSERT INTO c5 SELECT x FROM c1; @@ -99,6 +116,9 @@ do_test fkey5-2.2 { PRAGMA foreign_key_check(c1); } } {} +do_execsql_test fkey5-2.3 { + PRAGMA foreign_key_list(c5); +} {0 0 p1 x {} {NO ACTION} {NO ACTION} NONE} do_test fkey5-3.0 { db eval { @@ -306,5 +326,38 @@ do_test fkey5-8.7 { } {} +#------------------------------------------------------------------------- +# Tests 9.* verify that missing parent tables are handled correctly. +# +do_execsql_test 9.1.1 { + CREATE TABLE k1(x REFERENCES s1); + PRAGMA foreign_key_check(k1); +} {} +do_execsql_test 9.1.2 { + INSERT INTO k1 VALUES(NULL); + PRAGMA foreign_key_check(k1); +} {} +do_execsql_test 9.1.3 { + INSERT INTO k1 VALUES(1); + PRAGMA foreign_key_check(k1); +} {k1 2 s1 0} + +do_execsql_test 9.2.1 { + CREATE TABLE k2(x, y, FOREIGN KEY(x, y) REFERENCES s1(a, b)); + PRAGMA foreign_key_check(k2); +} {} +do_execsql_test 9.2 { + INSERT INTO k2 VALUES(NULL, 'five'); + PRAGMA foreign_key_check(k2); +} {} +do_execsql_test 9.3 { + INSERT INTO k2 VALUES('one', NULL); + PRAGMA foreign_key_check(k2); +} {} +do_execsql_test 9.4 { + INSERT INTO k2 VALUES('six', 'seven'); + PRAGMA foreign_key_check(k2); +} {k2 3 s1 0} + finish_test diff --git a/test/fkey6.test b/test/fkey6.test index 66286b43e..f14e15d2d 100644 --- a/test/fkey6.test +++ b/test/fkey6.test @@ -13,6 +13,13 @@ # This file tests the PRAGMA defer_foreign_keys and # SQLITE_DBSTATUS_DEFERRED_FKS # +# EVIDENCE-OF: R-18981-16292 When the defer_foreign_keys PRAGMA is on, +# enforcement of all foreign key constraints is delayed until the +# outermost transaction is committed. +# +# EVIDENCE-OF: R-28911-57501 The defer_foreign_keys pragma defaults to +# OFF so that foreign key constraints are only deferred if they are +# created as "DEFERRABLE INITIALLY DEFERRED". set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -22,6 +29,10 @@ ifcapable {!foreignkey} { return } +do_execsql_test fkey6-1.0 { + PRAGMA defer_foreign_keys; +} {0} + do_execsql_test fkey6-1.1 { PRAGMA foreign_keys=ON; CREATE TABLE t1(x INTEGER PRIMARY KEY); @@ -70,12 +81,23 @@ do_test fkey6-1.8 { do_test fkey6-1.9 { sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0 } {0 1 0} -do_test fkey6-1.10 { - execsql { - ROLLBACK; - PRAGMA defer_foreign_keys=OFF; - BEGIN; - } + +# EVIDENCE-OF: R-21752-26913 The defer_foreign_keys pragma is +# automatically switched off at each COMMIT or ROLLBACK. Hence, the +# defer_foreign_keys pragma must be separately enabled for each +# transaction. +do_execsql_test fkey6-1.10.1 { + PRAGMA defer_foreign_keys; + ROLLBACK; + PRAGMA defer_foreign_keys; + BEGIN; + PRAGMA defer_foreign_keys=ON; + PRAGMA defer_foreign_keys; + COMMIT; + PRAGMA defer_foreign_keys; + BEGIN; +} {1 0 1 0} +do_test fkey6-1.10.2 { catchsql {DELETE FROM t1 WHERE x=3} } {1 {foreign key constraint failed}} db eval {ROLLBACK} @@ -99,5 +121,56 @@ do_test fkey6-1.22 { } } {} +do_execsql_test fkey6-2.1 { + CREATE TABLE p1(a PRIMARY KEY); + INSERT INTO p1 VALUES('one'), ('two'); + CREATE TABLE c1(x REFERENCES p1); + INSERT INTO c1 VALUES('two'), ('one'); +} + +do_execsql_test fkey6-2.2 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + DELETE FROM p1; + ROLLBACK; + PRAGMA defer_foreign_keys; +} {0} + +do_execsql_test fkey6-2.3 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + DROP TABLE p1; + PRAGMA vdbe_trace = 0; + ROLLBACK; + PRAGMA defer_foreign_keys; +} {0} + +do_execsql_test fkey6-2.4 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + DELETE FROM p1; + DROP TABLE c1; + COMMIT; + PRAGMA defer_foreign_keys; +} {0} + +do_execsql_test fkey6-2.5 { + DROP TABLE p1; + CREATE TABLE p1(a PRIMARY KEY); + INSERT INTO p1 VALUES('one'), ('two'); + CREATE TABLE c1(x REFERENCES p1); + INSERT INTO c1 VALUES('two'), ('one'); +} + +do_execsql_test fkey6-2.6 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + INSERT INTO c1 VALUES('three'); + DROP TABLE c1; + COMMIT; + PRAGMA defer_foreign_keys; +} {0} + finish_test + diff --git a/test/fts4incr.test b/test/fts4incr.test index a9799b351..17212efce 100644 --- a/test/fts4incr.test +++ b/test/fts4incr.test @@ -50,4 +50,26 @@ foreach {tn q res} { puts "with optimization: $t(0) without: $t(1)" } +do_test 2.1 { + execsql { + CREATE VIRTUAL TABLE t2 USING fts4(order=DESC); + } + set num [list one two three four five six seven eight nine ten] + execsql BEGIN + for {set i 0} {$i < 10000} {incr i} { + set x "[lindex $num [expr $i%10]] zero" + execsql { INSERT INTO t2(docid, content) VALUES($i, $x) } + } + execsql COMMIT + execsql { INSERT INTO t2(t2) VALUES('optimize') } +} {} + +do_execsql_test 2.2 { + SELECT count(*) FROM t2 WHERE t2 MATCH '"never zero"' +} {0} + +do_execsql_test 2.3 { + SELECT count(*) FROM t2 WHERE t2 MATCH '"two zero"' +} {1000} + finish_test diff --git a/test/fts4unicode.test b/test/fts4unicode.test index f49a9fd2a..8edc2877d 100644 --- a/test/fts4unicode.test +++ b/test/fts4unicode.test @@ -44,31 +44,36 @@ proc do_unicode_token_test3 {tn args} { } do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D} -do_unicode_token_test 1.1 {Ä Ö Ü} {0 ä Ä 1 ö Ö 2 ü Ü} -do_unicode_token_test 1.2 {xÄx xÖx xÜx} {0 xäx xÄx 1 xöx xÖx 2 xüx xÜx} + +do_unicode_token_test 1.1 "\uC4 \uD6 \uDC" \ + "0 \uE4 \uC4 1 \uF6 \uD6 2 \uFC \uDC" + +do_unicode_token_test 1.2 "x\uC4x x\uD6x x\uDCx" \ + "0 x\uE4x x\uC4x 1 x\uF6x x\uD6x 2 x\uFCx x\uDCx" # 0x00DF is a small "sharp s". 0x1E9E is a capital sharp s. do_unicode_token_test 1.3 "\uDF" "0 \uDF \uDF" -do_unicode_token_test 1.4 "\u1E9E" "0 ß \u1E9E" -do_unicode_token_test 1.5 "\u1E9E" "0 \uDF \u1E9E" +do_unicode_token_test 1.4 "\u1E9E" "0 \uDF \u1E9E" -do_unicode_token_test 1.6 "The quick brown fox" { +do_unicode_token_test 1.5 "The quick brown fox" { 0 the The 1 quick quick 2 brown brown 3 fox fox } -do_unicode_token_test 1.7 "The\u00bfquick\u224ebrown\u2263fox" { +do_unicode_token_test 1.6 "The\u00bfquick\u224ebrown\u2263fox" { 0 the The 1 quick quick 2 brown brown 3 fox fox } -do_unicode_token_test2 1.8 {a B c D} {0 a a 1 b B 2 c c 3 d D} -do_unicode_token_test2 1.9 {Ä Ö Ü} {0 a Ä 1 o Ö 2 u Ü} -do_unicode_token_test2 1.10 {xÄx xÖx xÜx} {0 xax xÄx 1 xox xÖx 2 xux xÜx} +do_unicode_token_test2 1.7 {a B c D} {0 a a 1 b B 2 c c 3 d D} +do_unicode_token_test2 1.8 "\uC4 \uD6 \uDC" "0 a \uC4 1 o \uD6 2 u \uDC" + +do_unicode_token_test2 1.9 "x\uC4x x\uD6x x\uDCx" \ + "0 xax x\uC4x 1 xox x\uD6x 2 xux x\uDCx" # Check that diacritics are removed if remove_diacritics=1 is specified. # And that they do not break tokens. -do_unicode_token_test2 1.11 "xx\u0301xx" "0 xxxx xx\u301xx" +do_unicode_token_test2 1.10 "xx\u0301xx" "0 xxxx xx\u301xx" # Title-case mappings work -do_unicode_token_test 1.12 "\u01c5" "0 \u01c6 \u01c5" +do_unicode_token_test 1.11 "\u01c5" "0 \u01c6 \u01c5" #------------------------------------------------------------------------- # @@ -378,10 +383,10 @@ foreach T $tokenizers { do_isspace_test 6.$T.18 $T 12288 do_isspace_test 6.$T.19 $T {32 160 5760 6158} - do_isspace_test 6.$T.19 $T {8192 8193 8194 8195} - do_isspace_test 6.$T.19 $T {8196 8197 8198 8199} - do_isspace_test 6.$T.19 $T {8200 8201 8202 8239} - do_isspace_test 6.$T.19 $T {8287 12288} + do_isspace_test 6.$T.20 $T {8192 8193 8194 8195} + do_isspace_test 6.$T.21 $T {8196 8197 8198 8199} + do_isspace_test 6.$T.22 $T {8200 8201 8202 8239} + do_isspace_test 6.$T.23 $T {8287 12288} } #------------------------------------------------------------------------- diff --git a/test/func.test b/test/func.test index d8303f8bf..7c7d55e1b 100644 --- a/test/func.test +++ b/test/func.test @@ -1319,6 +1319,14 @@ do_test func-29.6 { set x } {1} +# EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric +# unicode code point corresponding to the first character of the string +# X. +# +# EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a +# string composed of characters having the unicode code point values of +# integers X1 through XN, respectively. +# do_execsql_test func-30.1 {SELECT unicode('$');} 36 do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162 do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364 diff --git a/test/func3.test b/test/func3.test index d5a462fe3..2a2b7be4f 100644 --- a/test/func3.test +++ b/test/func3.test @@ -70,4 +70,87 @@ do_test func3-4.1 { } {1 SQLITE_MISUSE} do_test func3-4.2 { set destroyed } 1 +# EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns +# argument X unchanged. +# +do_execsql_test func3-5.1 { + SELECT likelihood(9223372036854775807, 0.5); +} {9223372036854775807} +do_execsql_test func3-5.2 { + SELECT likelihood(-9223372036854775808, 0.5); +} {-9223372036854775808} +do_execsql_test func3-5.3 { + SELECT likelihood(14.125, 0.5); +} {14.125} +do_execsql_test func3-5.4 { + SELECT likelihood(NULL, 0.5); +} {{}} +do_execsql_test func3-5.5 { + SELECT likelihood('test-string', 0.5); +} {test-string} +do_execsql_test func3-5.6 { + SELECT quote(likelihood(x'010203000405', 0.5)); +} {X'010203000405'} + +# EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a +# floating point constant between 0.0 and 1.0, inclusive. +# +do_execsql_test func3-5.7 { + SELECT likelihood(123, 1.0), likelihood(456, 0.0); +} {123 456} +do_test func3-5.8 { + catchsql { + SELECT likelihood(123, 1.000001); + } +} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} +do_test func3-5.9 { + catchsql { + SELECT likelihood(123, -0.000001); + } +} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} +do_test func3-5.10 { + catchsql { + SELECT likelihood(123, 0.5+0.3); + } +} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} + +# EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that +# the code generator optimizes away so that it consumes no CPU cycles +# during run-time (that is, during calls to sqlite3_step()). +# +do_test func3-5.20 { + db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)} +} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] + + +# EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the +# argument X unchanged. +# +do_execsql_test func3-5.30 { + SELECT unlikely(9223372036854775807); +} {9223372036854775807} +do_execsql_test func3-5.31 { + SELECT unlikely(-9223372036854775808); +} {-9223372036854775808} +do_execsql_test func3-5.32 { + SELECT unlikely(14.125); +} {14.125} +do_execsql_test func3-5.33 { + SELECT unlikely(NULL); +} {{}} +do_execsql_test func3-5.34 { + SELECT unlikely('test-string'); +} {test-string} +do_execsql_test func3-5.35 { + SELECT quote(unlikely(x'010203000405')); +} {X'010203000405'} + +# EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that +# the code generator optimizes away so that it consumes no CPU cycles at +# run-time (that is, during calls to sqlite3_step()). +# +do_test func3-5.40 { + db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))} +} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] + finish_test diff --git a/test/func4.test b/test/func4.test new file mode 100644 index 000000000..34a8be884 --- /dev/null +++ b/test/func4.test @@ -0,0 +1,758 @@ +# 2013 March 10 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The focus of +# this file is testing the tointeger() and toreal() functions. +# +# Several of the toreal() tests are disabled on platforms where floating +# point precision is not high enough to represent their constant integer +# expression arguments as double precision floating point values. +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set saved_tcl_precision $tcl_precision +set tcl_precision 0 +load_static_extension db totype + +set highPrecision(1) [expr \ + {[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}] + +do_execsql_test func4-1.1 { + SELECT tointeger(NULL); +} {{}} +do_execsql_test func4-1.2 { + SELECT tointeger(''); +} {{}} +do_execsql_test func4-1.3 { + SELECT tointeger(' '); +} {{}} +do_execsql_test func4-1.4 { + SELECT tointeger('1234'); +} {1234} +do_execsql_test func4-1.5 { + SELECT tointeger(' 1234'); +} {{}} +do_execsql_test func4-1.6 { + SELECT tointeger('bad'); +} {{}} +do_execsql_test func4-1.7 { + SELECT tointeger('0xBAD'); +} {{}} +do_execsql_test func4-1.8 { + SELECT tointeger('123BAD'); +} {{}} +do_execsql_test func4-1.9 { + SELECT tointeger('0x123BAD'); +} {{}} +do_execsql_test func4-1.10 { + SELECT tointeger('123NO'); +} {{}} +do_execsql_test func4-1.11 { + SELECT tointeger('0x123NO'); +} {{}} +do_execsql_test func4-1.12 { + SELECT tointeger('-0x1'); +} {{}} +do_execsql_test func4-1.13 { + SELECT tointeger('-0x0'); +} {{}} +do_execsql_test func4-1.14 { + SELECT tointeger('0x0'); +} {{}} +do_execsql_test func4-1.15 { + SELECT tointeger('0x1'); +} {{}} +do_execsql_test func4-1.16 { + SELECT tointeger(-1); +} {-1} +do_execsql_test func4-1.17 { + SELECT tointeger(-0); +} {0} +do_execsql_test func4-1.18 { + SELECT tointeger(0); +} {0} +do_execsql_test func4-1.19 { + SELECT tointeger(1); +} {1} +do_execsql_test func4-1.20 { + SELECT tointeger(-1.79769313486232e308 - 1); +} {{}} +do_execsql_test func4-1.21 { + SELECT tointeger(-1.79769313486232e308); +} {{}} +do_execsql_test func4-1.22 { + SELECT tointeger(-1.79769313486232e308 + 1); +} {{}} +do_execsql_test func4-1.23 { + SELECT tointeger(-9223372036854775808 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.24 { + SELECT tointeger(-9223372036854775808); +} {-9223372036854775808} +do_execsql_test func4-1.25 { + SELECT tointeger(-9223372036854775808 + 1); +} {-9223372036854775807} +do_execsql_test func4-1.26 { + SELECT tointeger(-9223372036854775807 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.27 { + SELECT tointeger(-9223372036854775807); +} {-9223372036854775807} +do_execsql_test func4-1.28 { + SELECT tointeger(-9223372036854775807 + 1); +} {-9223372036854775806} +do_execsql_test func4-1.29 { + SELECT tointeger(-2147483648 - 1); +} {-2147483649} +do_execsql_test func4-1.30 { + SELECT tointeger(-2147483648); +} {-2147483648} +do_execsql_test func4-1.31 { + SELECT tointeger(-2147483648 + 1); +} {-2147483647} +do_execsql_test func4-1.32 { + SELECT tointeger(2147483647 - 1); +} {2147483646} +do_execsql_test func4-1.33 { + SELECT tointeger(2147483647); +} {2147483647} +do_execsql_test func4-1.34 { + SELECT tointeger(2147483647 + 1); +} {2147483648} +do_execsql_test func4-1.35 { + SELECT tointeger(9223372036854775807 - 1); +} {9223372036854775806} +do_execsql_test func4-1.36 { + SELECT tointeger(9223372036854775807); +} {9223372036854775807} +if {$highPrecision(1)} { + do_execsql_test func4-1.37 { + SELECT tointeger(9223372036854775807 + 1); + } {{}} +} +do_execsql_test func4-1.38 { + SELECT tointeger(1.79769313486232e308 - 1); +} {{}} +do_execsql_test func4-1.39 { + SELECT tointeger(1.79769313486232e308); +} {{}} +do_execsql_test func4-1.40 { + SELECT tointeger(1.79769313486232e308 + 1); +} {{}} +do_execsql_test func4-1.41 { + SELECT tointeger(4503599627370496 - 1); +} {4503599627370495} +do_execsql_test func4-1.42 { + SELECT tointeger(4503599627370496); +} {4503599627370496} +do_execsql_test func4-1.43 { + SELECT tointeger(4503599627370496 + 1); +} {4503599627370497} +do_execsql_test func4-1.44 { + SELECT tointeger(9007199254740992 - 1); +} {9007199254740991} +do_execsql_test func4-1.45 { + SELECT tointeger(9007199254740992); +} {9007199254740992} +do_execsql_test func4-1.46 { + SELECT tointeger(9007199254740992 + 1); +} {9007199254740993} +do_execsql_test func4-1.47 { + SELECT tointeger(9223372036854775807 - 1); +} {9223372036854775806} +do_execsql_test func4-1.48 { + SELECT tointeger(9223372036854775807); +} {9223372036854775807} +if {$highPrecision(1)} { + do_execsql_test func4-1.49 { + SELECT tointeger(9223372036854775807 + 1); + } {{}} + do_execsql_test func4-1.50 { + SELECT tointeger(9223372036854775808 - 1); + } {{}} + do_execsql_test func4-1.51 { + SELECT tointeger(9223372036854775808); + } {{}} + do_execsql_test func4-1.52 { + SELECT tointeger(9223372036854775808 + 1); + } {{}} +} +do_execsql_test func4-1.53 { + SELECT tointeger(18446744073709551616 - 1); +} {{}} +do_execsql_test func4-1.54 { + SELECT tointeger(18446744073709551616); +} {{}} +do_execsql_test func4-1.55 { + SELECT tointeger(18446744073709551616 + 1); +} {{}} + +ifcapable floatingpoint { + set highPrecision(2) [expr \ + {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] + + do_execsql_test func4-2.1 { + SELECT toreal(NULL); + } {{}} + do_execsql_test func4-2.2 { + SELECT toreal(''); + } {{}} + do_execsql_test func4-2.3 { + SELECT toreal(' '); + } {{}} + do_execsql_test func4-2.4 { + SELECT toreal('1234'); + } {1234.0} + do_execsql_test func4-2.5 { + SELECT toreal(' 1234'); + } {{}} + do_execsql_test func4-2.6 { + SELECT toreal('bad'); + } {{}} + do_execsql_test func4-2.7 { + SELECT toreal('0xBAD'); + } {{}} + do_execsql_test func4-2.8 { + SELECT toreal('123BAD'); + } {{}} + do_execsql_test func4-2.9 { + SELECT toreal('0x123BAD'); + } {{}} + do_execsql_test func4-2.10 { + SELECT toreal('123NO'); + } {{}} + do_execsql_test func4-2.11 { + SELECT toreal('0x123NO'); + } {{}} + do_execsql_test func4-2.12 { + SELECT toreal('-0x1'); + } {{}} + do_execsql_test func4-2.13 { + SELECT toreal('-0x0'); + } {{}} + do_execsql_test func4-2.14 { + SELECT toreal('0x0'); + } {{}} + do_execsql_test func4-2.15 { + SELECT toreal('0x1'); + } {{}} + do_execsql_test func4-2.16 { + SELECT toreal(-1); + } {-1.0} + do_execsql_test func4-2.17 { + SELECT toreal(-0); + } {0.0} + do_execsql_test func4-2.18 { + SELECT toreal(0); + } {0.0} + do_execsql_test func4-2.19 { + SELECT toreal(1); + } {1.0} + do_execsql_test func4-2.20 { + SELECT toreal(-1.79769313486232e308 - 1); + } {-Inf} + do_execsql_test func4-2.21 { + SELECT toreal(-1.79769313486232e308); + } {-Inf} + do_execsql_test func4-2.22 { + SELECT toreal(-1.79769313486232e308 + 1); + } {-Inf} + do_execsql_test func4-2.23 { + SELECT toreal(-9223372036854775808 - 1); + } {-9.223372036854776e+18} + do_execsql_test func4-2.24 { + SELECT toreal(-9223372036854775808); + } {-9.223372036854776e+18} + if {$highPrecision(2)} { + do_execsql_test func4-2.25 { + SELECT toreal(-9223372036854775808 + 1); + } {{}} + } + do_execsql_test func4-2.26 { + SELECT toreal(-9223372036854775807 - 1); + } {-9.223372036854776e+18} + if {$highPrecision(2)} { + do_execsql_test func4-2.27 { + SELECT toreal(-9223372036854775807); + } {{}} + do_execsql_test func4-2.28 { + SELECT toreal(-9223372036854775807 + 1); + } {{}} + } + do_execsql_test func4-2.29 { + SELECT toreal(-2147483648 - 1); + } {-2147483649.0} + do_execsql_test func4-2.30 { + SELECT toreal(-2147483648); + } {-2147483648.0} + do_execsql_test func4-2.31 { + SELECT toreal(-2147483648 + 1); + } {-2147483647.0} + do_execsql_test func4-2.32 { + SELECT toreal(2147483647 - 1); + } {2147483646.0} + do_execsql_test func4-2.33 { + SELECT toreal(2147483647); + } {2147483647.0} + do_execsql_test func4-2.34 { + SELECT toreal(2147483647 + 1); + } {2147483648.0} + if {$highPrecision(2)} { + do_execsql_test func4-2.35 { + SELECT toreal(9223372036854775807 - 1); + } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-2.36 { + SELECT toreal(9223372036854775807); + } {{}} + } + } + do_execsql_test func4-2.37 { + SELECT toreal(9223372036854775807 + 1); + } {9.223372036854776e+18} + do_execsql_test func4-2.38 { + SELECT toreal(1.79769313486232e308 - 1); + } {Inf} + do_execsql_test func4-2.39 { + SELECT toreal(1.79769313486232e308); + } {Inf} + do_execsql_test func4-2.40 { + SELECT toreal(1.79769313486232e308 + 1); + } {Inf} + do_execsql_test func4-2.41 { + SELECT toreal(4503599627370496 - 1); + } {4503599627370495.0} + do_execsql_test func4-2.42 { + SELECT toreal(4503599627370496); + } {4503599627370496.0} + do_execsql_test func4-2.43 { + SELECT toreal(4503599627370496 + 1); + } {4503599627370497.0} + do_execsql_test func4-2.44 { + SELECT toreal(9007199254740992 - 1); + } {9007199254740991.0} + do_execsql_test func4-2.45 { + SELECT toreal(9007199254740992); + } {9007199254740992.0} + if {$highPrecision(2)} { + do_execsql_test func4-2.46 { + SELECT toreal(9007199254740992 + 1); + } {{}} + } + do_execsql_test func4-2.47 { + SELECT toreal(9007199254740992 + 2); + } {9007199254740994.0} + do_execsql_test func4-2.48 { + SELECT toreal(tointeger(9223372036854775808) - 1); + } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-2.49 { + SELECT toreal(tointeger(9223372036854775808)); + } {{}} + do_execsql_test func4-2.50 { + SELECT toreal(tointeger(9223372036854775808) + 1); + } {{}} + } + do_execsql_test func4-2.51 { + SELECT toreal(tointeger(18446744073709551616) - 1); + } {{}} + do_execsql_test func4-2.52 { + SELECT toreal(tointeger(18446744073709551616)); + } {{}} + do_execsql_test func4-2.53 { + SELECT toreal(tointeger(18446744073709551616) + 1); + } {{}} +} + +ifcapable check { + do_execsql_test func4-3.1 { + CREATE TABLE t1( + x INTEGER CHECK(tointeger(x) IS NOT NULL) + ); + } {} + do_test func4-3.2 { + catchsql { + INSERT INTO t1 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-3.3 { + catchsql { + INSERT INTO t1 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-3.4 { + catchsql { + INSERT INTO t1 (x) VALUES (''); + } + } {1 {constraint failed}} + do_test func4-3.5 { + catchsql { + INSERT INTO t1 (x) VALUES ('bad'); + } + } {1 {constraint failed}} + do_test func4-3.6 { + catchsql { + INSERT INTO t1 (x) VALUES ('1234bad'); + } + } {1 {constraint failed}} + do_test func4-3.7 { + catchsql { + INSERT INTO t1 (x) VALUES ('1234.56bad'); + } + } {1 {constraint failed}} + do_test func4-3.8 { + catchsql { + INSERT INTO t1 (x) VALUES (1234); + } + } {0 {}} + do_test func4-3.9 { + catchsql { + INSERT INTO t1 (x) VALUES (1234.56); + } + } {1 {constraint failed}} + do_test func4-3.10 { + catchsql { + INSERT INTO t1 (x) VALUES ('1234'); + } + } {0 {}} + do_test func4-3.11 { + catchsql { + INSERT INTO t1 (x) VALUES ('1234.56'); + } + } {1 {constraint failed}} + do_test func4-3.12 { + catchsql { + INSERT INTO t1 (x) VALUES (ZEROBLOB(4)); + } + } {1 {constraint failed}} + do_test func4-3.13 { + catchsql { + INSERT INTO t1 (x) VALUES (X''); + } + } {1 {constraint failed}} + do_test func4-3.14 { + catchsql { + INSERT INTO t1 (x) VALUES (X'1234'); + } + } {1 {constraint failed}} + do_test func4-3.15 { + catchsql { + INSERT INTO t1 (x) VALUES (X'12345678'); + } + } {1 {constraint failed}} + do_test func4-3.16 { + catchsql { + INSERT INTO t1 (x) VALUES ('1234.00'); + } + } {1 {constraint failed}} + do_test func4-3.17 { + catchsql { + INSERT INTO t1 (x) VALUES (1234.00); + } + } {0 {}} + do_test func4-3.18 { + catchsql { + INSERT INTO t1 (x) VALUES ('-9223372036854775809'); + } + } {1 {constraint failed}} + if {$highPrecision(1)} { + do_test func4-3.19 { + catchsql { + INSERT INTO t1 (x) VALUES (9223372036854775808); + } + } {1 {constraint failed}} + } + do_execsql_test func4-3.20 { + SELECT x FROM t1 ORDER BY x; + } {1234 1234 1234} + + ifcapable floatingpoint { + do_execsql_test func4-4.1 { + CREATE TABLE t2( + x REAL CHECK(toreal(x) IS NOT NULL) + ); + } {} + do_test func4-4.2 { + catchsql { + INSERT INTO t2 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-4.3 { + catchsql { + INSERT INTO t2 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-4.4 { + catchsql { + INSERT INTO t2 (x) VALUES (''); + } + } {1 {constraint failed}} + do_test func4-4.5 { + catchsql { + INSERT INTO t2 (x) VALUES ('bad'); + } + } {1 {constraint failed}} + do_test func4-4.6 { + catchsql { + INSERT INTO t2 (x) VALUES ('1234bad'); + } + } {1 {constraint failed}} + do_test func4-4.7 { + catchsql { + INSERT INTO t2 (x) VALUES ('1234.56bad'); + } + } {1 {constraint failed}} + do_test func4-4.8 { + catchsql { + INSERT INTO t2 (x) VALUES (1234); + } + } {0 {}} + do_test func4-4.9 { + catchsql { + INSERT INTO t2 (x) VALUES (1234.56); + } + } {0 {}} + do_test func4-4.10 { + catchsql { + INSERT INTO t2 (x) VALUES ('1234'); + } + } {0 {}} + do_test func4-4.11 { + catchsql { + INSERT INTO t2 (x) VALUES ('1234.56'); + } + } {0 {}} + do_test func4-4.12 { + catchsql { + INSERT INTO t2 (x) VALUES (ZEROBLOB(4)); + } + } {1 {constraint failed}} + do_test func4-4.13 { + catchsql { + INSERT INTO t2 (x) VALUES (X''); + } + } {1 {constraint failed}} + do_test func4-4.14 { + catchsql { + INSERT INTO t2 (x) VALUES (X'1234'); + } + } {1 {constraint failed}} + do_test func4-4.15 { + catchsql { + INSERT INTO t2 (x) VALUES (X'12345678'); + } + } {1 {constraint failed}} + do_execsql_test func4-4.16 { + SELECT x FROM t2 ORDER BY x; + } {1234.0 1234.0 1234.56 1234.56} + } +} + +ifcapable floatingpoint { + do_execsql_test func4-5.1 { + SELECT tointeger(toreal('1234')); + } {1234} + do_execsql_test func4-5.2 { + SELECT tointeger(toreal(-1)); + } {-1} + do_execsql_test func4-5.3 { + SELECT tointeger(toreal(-0)); + } {0} + do_execsql_test func4-5.4 { + SELECT tointeger(toreal(0)); + } {0} + do_execsql_test func4-5.5 { + SELECT tointeger(toreal(1)); + } {1} + do_execsql_test func4-5.6 { + SELECT tointeger(toreal(-9223372036854775808 - 1)); + } {-9223372036854775808} + do_execsql_test func4-5.7 { + SELECT tointeger(toreal(-9223372036854775808)); + } {-9223372036854775808} + if {$highPrecision(2)} { + do_execsql_test func4-5.8 { + SELECT tointeger(toreal(-9223372036854775808 + 1)); + } {{}} + } + do_execsql_test func4-5.9 { + SELECT tointeger(toreal(-2147483648 - 1)); + } {-2147483649} + do_execsql_test func4-5.10 { + SELECT tointeger(toreal(-2147483648)); + } {-2147483648} + do_execsql_test func4-5.11 { + SELECT tointeger(toreal(-2147483648 + 1)); + } {-2147483647} + do_execsql_test func4-5.12 { + SELECT tointeger(toreal(2147483647 - 1)); + } {2147483646} + do_execsql_test func4-5.13 { + SELECT tointeger(toreal(2147483647)); + } {2147483647} + do_execsql_test func4-5.14 { + SELECT tointeger(toreal(2147483647 + 1)); + } {2147483648} + do_execsql_test func4-5.15 { + SELECT tointeger(toreal(9223372036854775807 - 1)); + } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-5.16 { + SELECT tointeger(toreal(9223372036854775807)); + } {{}} + do_execsql_test func4-5.17 { + SELECT tointeger(toreal(9223372036854775807 + 1)); + } {{}} + } + do_execsql_test func4-5.18 { + SELECT tointeger(toreal(4503599627370496 - 1)); + } {4503599627370495} + do_execsql_test func4-5.19 { + SELECT tointeger(toreal(4503599627370496)); + } {4503599627370496} + do_execsql_test func4-5.20 { + SELECT tointeger(toreal(4503599627370496 + 1)); + } {4503599627370497} + do_execsql_test func4-5.21 { + SELECT tointeger(toreal(9007199254740992 - 1)); + } {9007199254740991} + do_execsql_test func4-5.22 { + SELECT tointeger(toreal(9007199254740992)); + } {9007199254740992} + if {$highPrecision(2)} { + do_execsql_test func4-5.23 { + SELECT tointeger(toreal(9007199254740992 + 1)); + } {{}} + } + do_execsql_test func4-5.24 { + SELECT tointeger(toreal(9007199254740992 + 2)); + } {9007199254740994} + if {$highPrecision(1)} { + do_execsql_test func4-5.25 { + SELECT tointeger(toreal(9223372036854775808 - 1)); + } {{}} + do_execsql_test func4-5.26 { + SELECT tointeger(toreal(9223372036854775808)); + } {{}} + do_execsql_test func4-5.27 { + SELECT tointeger(toreal(9223372036854775808 + 1)); + } {{}} + } + do_execsql_test func4-5.28 { + SELECT tointeger(toreal(18446744073709551616 - 1)); + } {{}} + do_execsql_test func4-5.29 { + SELECT tointeger(toreal(18446744073709551616)); + } {{}} + do_execsql_test func4-5.30 { + SELECT tointeger(toreal(18446744073709551616 + 1)); + } {{}} +} + +for {set i 0} {$i < 10} {incr i} { + if {$i == 8} continue + do_execsql_test func4-6.1.$i.1 [subst { + SELECT tointeger(x'[string repeat 01 $i]'); + }] {{}} + ifcapable floatingpoint { + do_execsql_test func4-6.1.$i.2 [subst { + SELECT toreal(x'[string repeat 01 $i]'); + }] {{}} + } +} + +do_execsql_test func4-6.2.1 { + SELECT tointeger(x'0102030405060708'); +} {578437695752307201} +do_execsql_test func4-6.2.2 { + SELECT tointeger(x'0807060504030201'); +} {72623859790382856} + +ifcapable floatingpoint { + do_execsql_test func4-6.3.1 { + SELECT toreal(x'ffefffffffffffff'); + } {-1.7976931348623157e+308} + do_execsql_test func4-6.3.2 { + SELECT toreal(x'8010000000000000'); + } {-2.2250738585072014e-308} + do_execsql_test func4-6.3.3 { + SELECT toreal(x'c000000000000000'); + } {-2.0} + do_execsql_test func4-6.3.4 { + SELECT toreal(x'bff0000000000000'); + } {-1.0} + do_execsql_test func4-6.3.5 { + SELECT toreal(x'8000000000000000'); + } {-0.0} + do_execsql_test func4-6.3.6 { + SELECT toreal(x'0000000000000000'); + } {0.0} + do_execsql_test func4-6.3.7 { + SELECT toreal(x'3ff0000000000000'); + } {1.0} + do_execsql_test func4-6.3.8 { + SELECT toreal(x'4000000000000000'); + } {2.0} + do_execsql_test func4-6.3.9 { + SELECT toreal(x'0010000000000000'); + } {2.2250738585072014e-308} + do_execsql_test func4-6.3.10 { + SELECT toreal(x'7fefffffffffffff'); + } {1.7976931348623157e+308} + do_execsql_test func4-6.3.11 { + SELECT toreal(x'8000000000000001'); + } {-5e-324} + do_execsql_test func4-6.3.12 { + SELECT toreal(x'800fffffffffffff'); + } {-2.225073858507201e-308} + do_execsql_test func4-6.3.13 { + SELECT toreal(x'0000000000000001'); + } {5e-324} + do_execsql_test func4-6.3.14 { + SELECT toreal(x'000fffffffffffff'); + } {2.225073858507201e-308} + do_execsql_test func4-6.3.15 { + SELECT toreal(x'fff0000000000000'); + } {-Inf} + do_execsql_test func4-6.3.16 { + SELECT toreal(x'7ff0000000000000'); + } {Inf} + do_execsql_test func4-6.3.17 { + SELECT toreal(x'fff8000000000000'); + } {{}} + do_execsql_test func4-6.3.18 { + SELECT toreal(x'fff0000000000001'); + } {{}} + do_execsql_test func4-6.3.19 { + SELECT toreal(x'fff7ffffffffffff'); + } {{}} + do_execsql_test func4-6.3.20 { + SELECT toreal(x'7ff0000000000001'); + } {{}} + do_execsql_test func4-6.3.21 { + SELECT toreal(x'7ff7ffffffffffff'); + } {{}} + do_execsql_test func4-6.3.22 { + SELECT toreal(x'fff8000000000001'); + } {{}} + do_execsql_test func4-6.3.23 { + SELECT toreal(x'ffffffffffffffff'); + } {{}} + do_execsql_test func4-6.3.24 { + SELECT toreal(x'7ff8000000000000'); + } {{}} + do_execsql_test func4-6.3.25 { + SELECT toreal(x'7fffffffffffffff'); + } {{}} +} + +set tcl_precision $saved_tcl_precision +unset saved_tcl_precision +finish_test diff --git a/test/instr.test b/test/instr.test index b328cd1d2..c8be4862b 100644 --- a/test/instr.test +++ b/test/instr.test @@ -11,6 +11,11 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the built-in INSTR() functions. # +# EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first +# occurrence of string Y within string X and returns the number of prior +# characters plus 1, or 0 if Y is nowhere found within X. +# + set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -199,12 +204,48 @@ do_test instr-1.54 { do_test instr-1.55 { db eval {SELECT instr(x'78c3a4e282ac79','y');} } {4} -do_test instr-1.56 { + +# EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then +# instr(X,Y) returns one more than the number bytes prior to the first +# occurrence of Y, or 0 if Y does not occur anywhere within X. +# +do_test instr-1.56.1 { db eval {SELECT instr(x'78c3a4e282ac79',x'79');} } {7} -do_test instr-1.57 { +do_test instr-1.56.2 { + db eval {SELECT instr(x'78c3a4e282ac79',x'7a');} +} {0} +do_test instr-1.56.3 { + db eval {SELECT instr(x'78c3a4e282ac79',x'78');} +} {1} +do_test instr-1.56.3 { + db eval {SELECT instr(x'78c3a4e282ac79',x'a4');} +} {3} + +# EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are +# non-NULL and are not BLOBs then both are interpreted as strings. +# +do_test instr-1.57.1 { db eval {SELECT instr('xä€y',x'79');} } {4} +do_test instr-1.57.2 { + db eval {SELECT instr('xä€y',x'a4');} +} {0} +do_test instr-1.57.3 { + db eval {SELECT instr(x'78c3a4e282ac79','y');} +} {4} +# EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y) +# then the result is NULL. +# +do_execsql_test instr-1.60 { + SELECT coalesce(instr(NULL,'abc'), 999); +} {999} +do_execsql_test instr-1.61 { + SELECT coalesce(instr('abc',NULL), 999); +} {999} +do_execsql_test instr-1.62 { + SELECT coalesce(instr(NULL,NULL), 999); +} {999} finish_test diff --git a/test/pragma.test b/test/pragma.test index 808aeb04d..a6d198eb6 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -574,7 +574,7 @@ ifcapable {foreignkey} { execsql { pragma index_list(t3); } - } {/0 {} 1 \d+ 1 sqlite_autoindex_t3_1 1 \d+/} + } {0 sqlite_autoindex_t3_1 1} } ifcapable {!foreignkey} { execsql {CREATE TABLE t3(a,b UNIQUE)} @@ -647,7 +647,7 @@ do_test pragma-7.1.1 { execsql { pragma index_list(t3); } -} {/0 {} 1 \d+ 1 t3i1 0 \d+ 2 sqlite_autoindex_t3_1 1 \d+/} +} {0 t3i1 0 1 sqlite_autoindex_t3_1 1} do_test pragma-7.1.2 { execsql { pragma index_list(t3_bogus); @@ -1661,7 +1661,7 @@ do_test 23.3 { CREATE INDEX i3 ON t1(d,b,c); } db2 eval {PRAGMA index_list(t1)} -} {/0 {} 1 \d+ 1 i3 0 \d+ 2 i2 0 \d+ 3 i1 0 \d+/} +} {0 i3 0 1 i2 0 2 i1 0} do_test 23.4 { db eval { ALTER TABLE t1 ADD COLUMN e; diff --git a/test/pragma2.test b/test/pragma2.test index 85ea962e0..0dbc9777d 100644 --- a/test/pragma2.test +++ b/test/pragma2.test @@ -119,6 +119,11 @@ ifcapable attach { # Default setting of PRAGMA cache_spill is always ON # +# EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA +# cache_spill=boolean; +# +# EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default +# db close delete_file test.db test.db-journal delete_file test2.db test2.db-journal @@ -155,6 +160,11 @@ do_execsql_test pragma2-4.3 { PRAGMA cache_spill=ON; } {} sqlite3_release_memory +# +# EVIDENCE-OF: R-07634-40532 The cache_spill pragma enables or disables +# the ability of the pager to spill dirty cache pages to the database +# file in the middle of a transaction. +# do_test pragma2-4.4 { db eval { BEGIN; diff --git a/test/shared7.test b/test/shared7.test index 5c4a1da24..9f4880f56 100644 --- a/test/shared7.test +++ b/test/shared7.test @@ -23,6 +23,9 @@ do_test shared7-1.1 { sqlite3_enable_shared_cache } {1} +# EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach +# the same database file more than once results in an error. +# do_test shared7-1.2 { db close sqlite3 db test.db diff --git a/tool/lemon.c b/tool/lemon.c index ac0825022..58f13880f 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -3458,7 +3458,7 @@ void print_stack_union( break; } hash++; - if( hash>=arraysize ) hash = 0; + if( hash>=(unsigned)arraysize ) hash = 0; } if( types[hash]==0 ){ sp->dtnum = hash + 1; diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index a5d9f5ab6..1ba0bd6be 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -172,6 +172,10 @@ set pragma_def { FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) + NAME: stats + FLAG: NeedSchema + IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) + NAME: index_info FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index dd5748200..9e796e376 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -122,6 +122,7 @@ foreach hdr { } set available_hdr(sqliteInt.h) 0 set available_hdr(sqlite3session.h) 0 +set available_hdr(sqlite3.h) 0 # 78 stars used for comment formatting. set s78 \ @@ -229,6 +230,7 @@ proc copy_file {filename} { # inlining opportunities. # foreach file { + sqlite3.h sqliteInt.h global.c diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 77ec4b15c..65fa73124 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -279,8 +279,18 @@ if {[string equal -nocase $packageFlavor WinRT]} then { set minVsVersion 11.0 set extraSdkPath "\\..\\$targetPlatformIdentifier" set extraFileListAttributes "" +} elseif {[string equal -nocase $packageFlavor Win32]} then { + set shortName SQLite.Win32 + set displayName "SQLite for Windows" + set targetPlatformIdentifier Windows + set targetPlatformVersion v8.0 + set minVsVersion 11.0 + set extraSdkPath "" + set extraFileListAttributes [appendArgs \ + "\r\n " {AppliesTo="VisualC"} \ + "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}] } else { - fail "unsupported package flavor, must be \"WinRT\", \"WinRT81\", or \"WP80\"" + fail "unsupported package flavor, must be one of: WinRT WinRT81 WP80 Win32" } if {$argc >= 4} then { diff --git a/tool/warnings.sh b/tool/warnings.sh index 78cfb55d3..246bccbe2 100644 --- a/tool/warnings.sh +++ b/tool/warnings.sh @@ -9,9 +9,9 @@ echo '********** No optimizations. Includes FTS4 and RTREE *********' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c -echo '********** No optimizations. ENABLE_STAT3. THREADSAFE=0 *******' +echo '********** No optimizations. ENABLE_STAT4. THREADSAFE=0 *******' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ - -ansi -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ + -ansi -DSQLITE_ENABLE_STAT4 -DSQLITE_THREADSAFE=0 \ sqlite3.c echo '********** Optimized -O3. Includes FTS4 and RTREE ************' gcc -O3 -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ |