Fossil SCM
Update to the latest SQLite 3.7.3 beta.
Commit
12a79e5b933b9800c9c2492c418d959d973fbddc
Parent
d96c4a42f051c9d…
2 files changed
+223
-268
+1
-1
+223
-268
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -650,11 +650,11 @@ | ||
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.3" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007003 |
| 655 | -#define SQLITE_SOURCE_ID "2010-09-29 23:09:23 1ef0dc9328f47506cb2dcd142150e96cb4755216" | |
| 655 | +#define SQLITE_SOURCE_ID "2010-10-04 23:55:51 ece641eb8951c6314cedbdb3243f91cb199c3239" | |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| @@ -10570,11 +10570,10 @@ | ||
| 10570 | 10570 | |
| 10571 | 10571 | /* |
| 10572 | 10572 | ** Internal function prototypes |
| 10573 | 10573 | */ |
| 10574 | 10574 | SQLITE_PRIVATE int sqlite3StrICmp(const char *, const char *); |
| 10575 | -SQLITE_PRIVATE int sqlite3IsNumber(const char*, int*, u8); | |
| 10576 | 10575 | SQLITE_PRIVATE int sqlite3Strlen30(const char*); |
| 10577 | 10576 | #define sqlite3StrNICmp sqlite3_strnicmp |
| 10578 | 10577 | |
| 10579 | 10578 | SQLITE_PRIVATE int sqlite3MallocInit(void); |
| 10580 | 10579 | SQLITE_PRIVATE void sqlite3MallocEnd(void); |
| @@ -10890,13 +10889,12 @@ | ||
| 10890 | 10889 | SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*); |
| 10891 | 10890 | SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*); |
| 10892 | 10891 | SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*); |
| 10893 | 10892 | SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*); |
| 10894 | 10893 | SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); |
| 10895 | -SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*); | |
| 10894 | +SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8); | |
| 10896 | 10895 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 10897 | -SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int); | |
| 10898 | 10896 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 10899 | 10897 | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); |
| 10900 | 10898 | SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8**); |
| 10901 | 10899 | |
| 10902 | 10900 | /* |
| @@ -10938,11 +10936,11 @@ | ||
| 10938 | 10936 | SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *); |
| 10939 | 10937 | SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *, Table *); |
| 10940 | 10938 | SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2); |
| 10941 | 10939 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); |
| 10942 | 10940 | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr); |
| 10943 | -SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*); | |
| 10941 | +SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); | |
| 10944 | 10942 | SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...); |
| 10945 | 10943 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 10946 | 10944 | SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
| 10947 | 10945 | SQLITE_PRIVATE const char *sqlite3ErrStr(int); |
| 10948 | 10946 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse); |
| @@ -12637,16 +12635,10 @@ | ||
| 12637 | 12635 | end_getDigits: |
| 12638 | 12636 | va_end(ap); |
| 12639 | 12637 | return cnt; |
| 12640 | 12638 | } |
| 12641 | 12639 | |
| 12642 | -/* | |
| 12643 | -** Read text from z[] and convert into a floating point number. Return | |
| 12644 | -** the number of digits converted. | |
| 12645 | -*/ | |
| 12646 | -#define getValue sqlite3AtoF | |
| 12647 | - | |
| 12648 | 12640 | /* |
| 12649 | 12641 | ** Parse a timezone extension on the end of a date-time. |
| 12650 | 12642 | ** The extension is of the form: |
| 12651 | 12643 | ** |
| 12652 | 12644 | ** (+/-)HH:MM |
| @@ -12844,21 +12836,19 @@ | ||
| 12844 | 12836 | static int parseDateOrTime( |
| 12845 | 12837 | sqlite3_context *context, |
| 12846 | 12838 | const char *zDate, |
| 12847 | 12839 | DateTime *p |
| 12848 | 12840 | ){ |
| 12849 | - int isRealNum; /* Return from sqlite3IsNumber(). Not used */ | |
| 12841 | + double r; | |
| 12850 | 12842 | if( parseYyyyMmDd(zDate,p)==0 ){ |
| 12851 | 12843 | return 0; |
| 12852 | 12844 | }else if( parseHhMmSs(zDate, p)==0 ){ |
| 12853 | 12845 | return 0; |
| 12854 | 12846 | }else if( sqlite3StrICmp(zDate,"now")==0){ |
| 12855 | 12847 | setDateTimeToCurrent(context, p); |
| 12856 | 12848 | return 0; |
| 12857 | - }else if( sqlite3IsNumber(zDate, &isRealNum, SQLITE_UTF8) ){ | |
| 12858 | - double r; | |
| 12859 | - getValue(zDate, &r); | |
| 12849 | + }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){ | |
| 12860 | 12850 | p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5); |
| 12861 | 12851 | p->validJD = 1; |
| 12862 | 12852 | return 0; |
| 12863 | 12853 | } |
| 12864 | 12854 | return 1; |
| @@ -13075,12 +13065,13 @@ | ||
| 13075 | 13065 | ** |
| 13076 | 13066 | ** Move the date to the same time on the next occurrence of |
| 13077 | 13067 | ** weekday N where 0==Sunday, 1==Monday, and so forth. If the |
| 13078 | 13068 | ** date is already on the appropriate weekday, this is a no-op. |
| 13079 | 13069 | */ |
| 13080 | - if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0 | |
| 13081 | - && (n=(int)r)==r && n>=0 && r<7 ){ | |
| 13070 | + if( strncmp(z, "weekday ", 8)==0 | |
| 13071 | + && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8) | |
| 13072 | + && (n=(int)r)==r && n>=0 && r<7 ){ | |
| 13082 | 13073 | sqlite3_int64 Z; |
| 13083 | 13074 | computeYMD_HMS(p); |
| 13084 | 13075 | p->validTZ = 0; |
| 13085 | 13076 | p->validJD = 0; |
| 13086 | 13077 | computeJD(p); |
| @@ -13131,12 +13122,15 @@ | ||
| 13131 | 13122 | case '6': |
| 13132 | 13123 | case '7': |
| 13133 | 13124 | case '8': |
| 13134 | 13125 | case '9': { |
| 13135 | 13126 | double rRounder; |
| 13136 | - n = getValue(z, &r); | |
| 13137 | - assert( n>=1 ); | |
| 13127 | + for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){} | |
| 13128 | + if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){ | |
| 13129 | + rc = 1; | |
| 13130 | + break; | |
| 13131 | + } | |
| 13138 | 13132 | if( z[n]==':' ){ |
| 13139 | 13133 | /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the |
| 13140 | 13134 | ** specified number of hours, minutes, seconds, and fractional seconds |
| 13141 | 13135 | ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be |
| 13142 | 13136 | ** omitted. |
| @@ -17502,11 +17496,11 @@ | ||
| 17502 | 17496 | sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n); |
| 17503 | 17497 | }else{ |
| 17504 | 17498 | sqlite3MemoryAlarm(0, 0, 0); |
| 17505 | 17499 | } |
| 17506 | 17500 | excess = sqlite3_memory_used() - n; |
| 17507 | - if( excess>0 ) sqlite3_release_memory(excess & 0x7fffffff); | |
| 17501 | + if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff)); | |
| 17508 | 17502 | return priorLimit; |
| 17509 | 17503 | } |
| 17510 | 17504 | SQLITE_API void sqlite3_soft_heap_limit(int n){ |
| 17511 | 17505 | if( n<0 ) n = 0; |
| 17512 | 17506 | sqlite3_soft_heap_limit64(n); |
| @@ -20096,125 +20090,115 @@ | ||
| 20096 | 20090 | while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } |
| 20097 | 20091 | return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b]; |
| 20098 | 20092 | } |
| 20099 | 20093 | |
| 20100 | 20094 | /* |
| 20101 | -** Return TRUE if z is a pure numeric string. Return FALSE and leave | |
| 20102 | -** *realnum unchanged if the string contains any character which is not | |
| 20103 | -** part of a number. | |
| 20104 | -** | |
| 20105 | -** If the string is pure numeric, set *realnum to TRUE if the string | |
| 20106 | -** contains the '.' character or an "E+000" style exponentiation suffix. | |
| 20107 | -** Otherwise set *realnum to FALSE. Note that just becaue *realnum is | |
| 20108 | -** false does not mean that the number can be successfully converted into | |
| 20109 | -** an integer - it might be too big. | |
| 20110 | -** | |
| 20111 | -** An empty string is considered non-numeric. | |
| 20112 | -*/ | |
| 20113 | -SQLITE_PRIVATE int sqlite3IsNumber(const char *z, int *realnum, u8 enc){ | |
| 20095 | +** The string z[] is an text representation of a real number. | |
| 20096 | +** Convert this string to a double and write it into *pResult. | |
| 20097 | +** | |
| 20098 | +** The string z[] is length bytes in length (bytes, not characters) and | |
| 20099 | +** uses the encoding enc. The string is not necessarily zero-terminated. | |
| 20100 | +** | |
| 20101 | +** Return TRUE if the result is a valid real number (or integer) and FALSE | |
| 20102 | +** if the string is empty or contains extraneous text. Valid numbers | |
| 20103 | +** are in one of these formats: | |
| 20104 | +** | |
| 20105 | +** [+-]digits[E[+-]digits] | |
| 20106 | +** [+-]digits.[digits][E[+-]digits] | |
| 20107 | +** [+-].digits[E[+-]digits] | |
| 20108 | +** | |
| 20109 | +** Leading and trailing whitespace is ignored for the purpose of determining | |
| 20110 | +** validity. | |
| 20111 | +** | |
| 20112 | +** If some prefix of the input string is a valid number, this routine | |
| 20113 | +** returns FALSE but it still converts the prefix and writes the result | |
| 20114 | +** into *pResult. | |
| 20115 | +*/ | |
| 20116 | +SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ | |
| 20117 | +#ifndef SQLITE_OMIT_FLOATING_POINT | |
| 20114 | 20118 | int incr = (enc==SQLITE_UTF8?1:2); |
| 20115 | - if( enc==SQLITE_UTF16BE ) z++; | |
| 20116 | - if( *z=='-' || *z=='+' ) z += incr; | |
| 20117 | - if( !sqlite3Isdigit(*z) ){ | |
| 20118 | - return 0; | |
| 20119 | - } | |
| 20120 | - z += incr; | |
| 20121 | - *realnum = 0; | |
| 20122 | - while( sqlite3Isdigit(*z) ){ z += incr; } | |
| 20123 | -#ifndef SQLITE_OMIT_FLOATING_POINT | |
| 20124 | - if( *z=='.' ){ | |
| 20125 | - z += incr; | |
| 20126 | - if( !sqlite3Isdigit(*z) ) return 0; | |
| 20127 | - while( sqlite3Isdigit(*z) ){ z += incr; } | |
| 20128 | - *realnum = 1; | |
| 20129 | - } | |
| 20130 | - if( *z=='e' || *z=='E' ){ | |
| 20131 | - z += incr; | |
| 20132 | - if( *z=='+' || *z=='-' ) z += incr; | |
| 20133 | - if( !sqlite3Isdigit(*z) ) return 0; | |
| 20134 | - while( sqlite3Isdigit(*z) ){ z += incr; } | |
| 20135 | - *realnum = 1; | |
| 20136 | - } | |
| 20137 | -#endif | |
| 20138 | - return *z==0; | |
| 20139 | -} | |
| 20140 | - | |
| 20141 | -/* | |
| 20142 | -** The string z[] is an ASCII representation of a real number. | |
| 20143 | -** Convert this string to a double. | |
| 20144 | -** | |
| 20145 | -** This routine assumes that z[] really is a valid number. If it | |
| 20146 | -** is not, the result is undefined. | |
| 20147 | -** | |
| 20148 | -** This routine is used instead of the library atof() function because | |
| 20149 | -** the library atof() might want to use "," as the decimal point instead | |
| 20150 | -** of "." depending on how locale is set. But that would cause problems | |
| 20151 | -** for SQL. So this routine always uses "." regardless of locale. | |
| 20152 | -*/ | |
| 20153 | -SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){ | |
| 20154 | -#ifndef SQLITE_OMIT_FLOATING_POINT | |
| 20155 | - const char *zBegin = z; | |
| 20119 | + const char *zEnd = z + length; | |
| 20156 | 20120 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 20157 | - int sign = 1; /* sign of significand */ | |
| 20158 | - i64 s = 0; /* significand */ | |
| 20159 | - int d = 0; /* adjust exponent for shifting decimal point */ | |
| 20160 | - int esign = 1; /* sign of exponent */ | |
| 20161 | - int e = 0; /* exponent */ | |
| 20121 | + int sign = 1; /* sign of significand */ | |
| 20122 | + i64 s = 0; /* significand */ | |
| 20123 | + int d = 0; /* adjust exponent for shifting decimal point */ | |
| 20124 | + int esign = 1; /* sign of exponent */ | |
| 20125 | + int e = 0; /* exponent */ | |
| 20126 | + int eValid = 1; /* True exponent is either not used or is well-formed */ | |
| 20162 | 20127 | double result; |
| 20163 | 20128 | int nDigits = 0; |
| 20164 | 20129 | |
| 20130 | + *pResult = 0.0; /* Default return value, in case of an error */ | |
| 20131 | + | |
| 20132 | + if( enc==SQLITE_UTF16BE ) z++; | |
| 20133 | + | |
| 20165 | 20134 | /* skip leading spaces */ |
| 20166 | - while( sqlite3Isspace(*z) ) z++; | |
| 20135 | + while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; | |
| 20136 | + if( z>=zEnd ) return 0; | |
| 20137 | + | |
| 20167 | 20138 | /* get sign of significand */ |
| 20168 | 20139 | if( *z=='-' ){ |
| 20169 | 20140 | sign = -1; |
| 20170 | - z++; | |
| 20141 | + z+=incr; | |
| 20171 | 20142 | }else if( *z=='+' ){ |
| 20172 | - z++; | |
| 20143 | + z+=incr; | |
| 20173 | 20144 | } |
| 20145 | + | |
| 20174 | 20146 | /* skip leading zeroes */ |
| 20175 | - while( z[0]=='0' ) z++, nDigits++; | |
| 20147 | + while( z<zEnd && z[0]=='0' ) z+=incr, nDigits++; | |
| 20176 | 20148 | |
| 20177 | 20149 | /* copy max significant digits to significand */ |
| 20178 | - while( sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ | |
| 20150 | + while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ | |
| 20179 | 20151 | s = s*10 + (*z - '0'); |
| 20180 | - z++, nDigits++; | |
| 20152 | + z+=incr, nDigits++; | |
| 20181 | 20153 | } |
| 20154 | + | |
| 20182 | 20155 | /* skip non-significant significand digits |
| 20183 | 20156 | ** (increase exponent by d to shift decimal left) */ |
| 20184 | - while( sqlite3Isdigit(*z) ) z++, nDigits++, d++; | |
| 20157 | + while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++; | |
| 20158 | + if( z>=zEnd ) goto do_atof_calc; | |
| 20185 | 20159 | |
| 20186 | 20160 | /* if decimal point is present */ |
| 20187 | 20161 | if( *z=='.' ){ |
| 20188 | - z++; | |
| 20162 | + z+=incr; | |
| 20189 | 20163 | /* copy digits from after decimal to significand |
| 20190 | 20164 | ** (decrease exponent by d to shift decimal right) */ |
| 20191 | - while( sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ | |
| 20165 | + while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ | |
| 20192 | 20166 | s = s*10 + (*z - '0'); |
| 20193 | - z++, nDigits++, d--; | |
| 20167 | + z+=incr, nDigits++, d--; | |
| 20194 | 20168 | } |
| 20195 | 20169 | /* skip non-significant digits */ |
| 20196 | - while( sqlite3Isdigit(*z) ) z++, nDigits++; | |
| 20170 | + while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++; | |
| 20197 | 20171 | } |
| 20172 | + if( z>=zEnd ) goto do_atof_calc; | |
| 20198 | 20173 | |
| 20199 | 20174 | /* if exponent is present */ |
| 20200 | 20175 | if( *z=='e' || *z=='E' ){ |
| 20201 | - z++; | |
| 20176 | + z+=incr; | |
| 20177 | + eValid = 0; | |
| 20178 | + if( z>=zEnd ) goto do_atof_calc; | |
| 20202 | 20179 | /* get sign of exponent */ |
| 20203 | 20180 | if( *z=='-' ){ |
| 20204 | 20181 | esign = -1; |
| 20205 | - z++; | |
| 20182 | + z+=incr; | |
| 20206 | 20183 | }else if( *z=='+' ){ |
| 20207 | - z++; | |
| 20184 | + z+=incr; | |
| 20208 | 20185 | } |
| 20209 | 20186 | /* copy digits to exponent */ |
| 20210 | - while( sqlite3Isdigit(*z) ){ | |
| 20187 | + while( z<zEnd && sqlite3Isdigit(*z) ){ | |
| 20211 | 20188 | e = e*10 + (*z - '0'); |
| 20212 | - z++; | |
| 20189 | + z+=incr; | |
| 20190 | + eValid = 1; | |
| 20213 | 20191 | } |
| 20214 | 20192 | } |
| 20215 | 20193 | |
| 20194 | + /* skip trailing spaces */ | |
| 20195 | + if( nDigits && eValid ){ | |
| 20196 | + while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; | |
| 20197 | + } | |
| 20198 | + | |
| 20199 | +do_atof_calc: | |
| 20216 | 20200 | /* adjust exponent by d, and update sign */ |
| 20217 | 20201 | e = (e*esign) + d; |
| 20218 | 20202 | if( e<0 ) { |
| 20219 | 20203 | esign = -1; |
| 20220 | 20204 | e *= -1; |
| @@ -20269,132 +20253,104 @@ | ||
| 20269 | 20253 | } |
| 20270 | 20254 | |
| 20271 | 20255 | /* store the result */ |
| 20272 | 20256 | *pResult = result; |
| 20273 | 20257 | |
| 20274 | - /* return number of characters used */ | |
| 20275 | - return (int)(z - zBegin); | |
| 20258 | + /* return true if number and no extra non-whitespace chracters after */ | |
| 20259 | + return z>=zEnd && nDigits>0 && eValid; | |
| 20276 | 20260 | #else |
| 20277 | - return sqlite3Atoi64(z, pResult); | |
| 20261 | + return !sqlite3Atoi64(z, pResult, length, enc); | |
| 20278 | 20262 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 20279 | 20263 | } |
| 20280 | 20264 | |
| 20281 | 20265 | /* |
| 20282 | 20266 | ** Compare the 19-character string zNum against the text representation |
| 20283 | 20267 | ** value 2^63: 9223372036854775808. Return negative, zero, or positive |
| 20284 | 20268 | ** if zNum is less than, equal to, or greater than the string. |
| 20269 | +** Note that zNum must contain exactly 19 characters. | |
| 20285 | 20270 | ** |
| 20286 | 20271 | ** Unlike memcmp() this routine is guaranteed to return the difference |
| 20287 | 20272 | ** in the values of the last digit if the only difference is in the |
| 20288 | 20273 | ** last digit. So, for example, |
| 20289 | 20274 | ** |
| 20290 | -** compare2pow63("9223372036854775800") | |
| 20275 | +** compare2pow63("9223372036854775800", 1) | |
| 20291 | 20276 | ** |
| 20292 | 20277 | ** will return -8. |
| 20293 | 20278 | */ |
| 20294 | -static int compare2pow63(const char *zNum){ | |
| 20295 | - int c; | |
| 20296 | - c = memcmp(zNum,"922337203685477580",18)*10; | |
| 20279 | +static int compare2pow63(const char *zNum, int incr){ | |
| 20280 | + int c = 0; | |
| 20281 | + int i; | |
| 20282 | + /* 012345678901234567 */ | |
| 20283 | + const char *pow63 = "922337203685477580"; | |
| 20284 | + for(i=0; c==0 && i<18; i++){ | |
| 20285 | + c = (zNum[i*incr]-pow63[i])*10; | |
| 20286 | + } | |
| 20297 | 20287 | if( c==0 ){ |
| 20298 | - c = zNum[18] - '8'; | |
| 20288 | + c = zNum[18*incr] - '8'; | |
| 20299 | 20289 | testcase( c==(-1) ); |
| 20300 | 20290 | testcase( c==0 ); |
| 20301 | 20291 | testcase( c==(+1) ); |
| 20302 | 20292 | } |
| 20303 | 20293 | return c; |
| 20304 | 20294 | } |
| 20305 | 20295 | |
| 20306 | 20296 | |
| 20307 | 20297 | /* |
| 20308 | -** Return TRUE if zNum is a 64-bit signed integer and write | |
| 20309 | -** the value of the integer into *pNum. If zNum is not an integer | |
| 20310 | -** or is an integer that is too large to be expressed with 64 bits, | |
| 20311 | -** then return false. | |
| 20298 | +** Convert zNum to a 64-bit signed integer and write | |
| 20299 | +** the value of the integer into *pNum. | |
| 20300 | +** If zNum is exactly 9223372036854665808, return 2. | |
| 20301 | +** This is a special case as the context will determine | |
| 20302 | +** if it is too big (used as a negative). | |
| 20303 | +** If zNum is not an integer or is an integer that | |
| 20304 | +** is too large to be expressed with 64 bits, | |
| 20305 | +** then return 1. Otherwise return 0. | |
| 20312 | 20306 | ** |
| 20313 | -** When this routine was originally written it dealt with only | |
| 20314 | -** 32-bit numbers. At that time, it was much faster than the | |
| 20315 | -** atoi() library routine in RedHat 7.2. | |
| 20307 | +** length is the number of bytes in the string (bytes, not characters). | |
| 20308 | +** The string is not necessarily zero-terminated. The encoding is | |
| 20309 | +** given by enc. | |
| 20316 | 20310 | */ |
| 20317 | -SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum){ | |
| 20311 | +SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ | |
| 20312 | + int incr = (enc==SQLITE_UTF8?1:2); | |
| 20318 | 20313 | i64 v = 0; |
| 20319 | - int neg; | |
| 20320 | - int i, c; | |
| 20314 | + int neg = 0; /* assume positive */ | |
| 20315 | + int i; | |
| 20316 | + int c = 0; | |
| 20321 | 20317 | const char *zStart; |
| 20322 | - while( sqlite3Isspace(*zNum) ) zNum++; | |
| 20318 | + const char *zEnd = zNum + length; | |
| 20319 | + if( enc==SQLITE_UTF16BE ) zNum++; | |
| 20320 | + while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr; | |
| 20321 | + if( zNum>=zEnd ) goto do_atoi_calc; | |
| 20323 | 20322 | if( *zNum=='-' ){ |
| 20324 | 20323 | neg = 1; |
| 20325 | - zNum++; | |
| 20324 | + zNum+=incr; | |
| 20326 | 20325 | }else if( *zNum=='+' ){ |
| 20327 | - neg = 0; | |
| 20328 | - zNum++; | |
| 20329 | - }else{ | |
| 20330 | - neg = 0; | |
| 20326 | + zNum+=incr; | |
| 20331 | 20327 | } |
| 20328 | +do_atoi_calc: | |
| 20332 | 20329 | zStart = zNum; |
| 20333 | - while( zNum[0]=='0' ){ zNum++; } /* Skip over leading zeros. Ticket #2454 */ | |
| 20334 | - for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ | |
| 20330 | + while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */ | |
| 20331 | + for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){ | |
| 20335 | 20332 | v = v*10 + c - '0'; |
| 20336 | 20333 | } |
| 20337 | 20334 | *pNum = neg ? -v : v; |
| 20338 | 20335 | testcase( i==18 ); |
| 20339 | 20336 | testcase( i==19 ); |
| 20340 | 20337 | testcase( i==20 ); |
| 20341 | - if( c!=0 || (i==0 && zStart==zNum) || i>19 ){ | |
| 20338 | + if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){ | |
| 20342 | 20339 | /* zNum is empty or contains non-numeric text or is longer |
| 20343 | - ** than 19 digits (thus guaranting that it is too large) */ | |
| 20344 | - return 0; | |
| 20345 | - }else if( i<19 ){ | |
| 20340 | + ** than 19 digits (thus guaranteeing that it is too large) */ | |
| 20341 | + return 1; | |
| 20342 | + }else if( i<19*incr ){ | |
| 20346 | 20343 | /* Less than 19 digits, so we know that it fits in 64 bits */ |
| 20347 | - return 1; | |
| 20344 | + return 0; | |
| 20348 | 20345 | }else{ |
| 20349 | 20346 | /* 19-digit numbers must be no larger than 9223372036854775807 if positive |
| 20350 | 20347 | ** or 9223372036854775808 if negative. Note that 9223372036854665808 |
| 20351 | - ** is 2^63. */ | |
| 20352 | - return compare2pow63(zNum)<neg; | |
| 20353 | - } | |
| 20354 | -} | |
| 20355 | - | |
| 20356 | -/* | |
| 20357 | -** The string zNum represents an unsigned integer. The zNum string | |
| 20358 | -** consists of one or more digit characters and is terminated by | |
| 20359 | -** a zero character. Any stray characters in zNum result in undefined | |
| 20360 | -** behavior. | |
| 20361 | -** | |
| 20362 | -** If the unsigned integer that zNum represents will fit in a | |
| 20363 | -** 64-bit signed integer, return TRUE. Otherwise return FALSE. | |
| 20364 | -** | |
| 20365 | -** If the negFlag parameter is true, that means that zNum really represents | |
| 20366 | -** a negative number. (The leading "-" is omitted from zNum.) This | |
| 20367 | -** parameter is needed to determine a boundary case. A string | |
| 20368 | -** of "9223373036854775808" returns false if negFlag is false or true | |
| 20369 | -** if negFlag is true. | |
| 20370 | -** | |
| 20371 | -** Leading zeros are ignored. | |
| 20372 | -*/ | |
| 20373 | -SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *zNum, int negFlag){ | |
| 20374 | - int i; | |
| 20375 | - int neg = 0; | |
| 20376 | - | |
| 20377 | - assert( zNum[0]>='0' && zNum[0]<='9' ); /* zNum is an unsigned number */ | |
| 20378 | - | |
| 20379 | - if( negFlag ) neg = 1-neg; | |
| 20380 | - while( *zNum=='0' ){ | |
| 20381 | - zNum++; /* Skip leading zeros. Ticket #2454 */ | |
| 20382 | - } | |
| 20383 | - for(i=0; zNum[i]; i++){ assert( zNum[i]>='0' && zNum[i]<='9' ); } | |
| 20384 | - testcase( i==18 ); | |
| 20385 | - testcase( i==19 ); | |
| 20386 | - testcase( i==20 ); | |
| 20387 | - if( i<19 ){ | |
| 20388 | - /* Guaranteed to fit if less than 19 digits */ | |
| 20389 | - return 1; | |
| 20390 | - }else if( i>19 ){ | |
| 20391 | - /* Guaranteed to be too big if greater than 19 digits */ | |
| 20392 | - return 0; | |
| 20393 | - }else{ | |
| 20394 | - /* Compare against 2^63. */ | |
| 20395 | - return compare2pow63(zNum)<neg; | |
| 20348 | + ** is 2^63. Return 1 if to large */ | |
| 20349 | + c=compare2pow63(zNum, incr); | |
| 20350 | + if( c==0 && neg==0 ) return 2; /* too big, exactly 9223372036854665808 */ | |
| 20351 | + return c<neg ? 0 : 1; | |
| 20396 | 20352 | } |
| 20397 | 20353 | } |
| 20398 | 20354 | |
| 20399 | 20355 | /* |
| 20400 | 20356 | ** If zNum represents an integer that will fit in 32-bits, then set |
| @@ -54149,17 +54105,13 @@ | ||
| 54149 | 54105 | return pMem->u.i; |
| 54150 | 54106 | }else if( flags & MEM_Real ){ |
| 54151 | 54107 | return doubleToInt64(pMem->r); |
| 54152 | 54108 | }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 54153 | 54109 | i64 value; |
| 54154 | - pMem->flags |= MEM_Str; | |
| 54155 | - if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) | |
| 54156 | - || sqlite3VdbeMemNulTerminate(pMem) ){ | |
| 54157 | - return 0; | |
| 54158 | - } | |
| 54159 | - assert( pMem->z ); | |
| 54160 | - sqlite3Atoi64(pMem->z, &value); | |
| 54110 | + assert( pMem->z || pMem->n==0 ); | |
| 54111 | + testcase( pMem->z==0 ); | |
| 54112 | + sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc); | |
| 54161 | 54113 | return value; |
| 54162 | 54114 | }else{ |
| 54163 | 54115 | return 0; |
| 54164 | 54116 | } |
| 54165 | 54117 | } |
| @@ -54185,11 +54137,11 @@ | ||
| 54185 | 54137 | || sqlite3VdbeMemNulTerminate(pMem) ){ |
| 54186 | 54138 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54187 | 54139 | return (double)0; |
| 54188 | 54140 | } |
| 54189 | 54141 | assert( pMem->z ); |
| 54190 | - sqlite3AtoF(pMem->z, &val); | |
| 54142 | + sqlite3AtoF(pMem->z, &val, pMem->n, SQLITE_UTF8); | |
| 54191 | 54143 | return val; |
| 54192 | 54144 | }else{ |
| 54193 | 54145 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54194 | 54146 | return (double)0; |
| 54195 | 54147 | } |
| @@ -54258,25 +54210,23 @@ | ||
| 54258 | 54210 | ** Every effort is made to force the conversion, even if the input |
| 54259 | 54211 | ** is a string that does not look completely like a number. Convert |
| 54260 | 54212 | ** as much of the string as we can and ignore the rest. |
| 54261 | 54213 | */ |
| 54262 | 54214 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){ |
| 54263 | - int rc; | |
| 54264 | - assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ); | |
| 54265 | - assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); | |
| 54266 | - assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | |
| 54267 | - rc = sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8); | |
| 54268 | - if( rc ) return rc; | |
| 54269 | - rc = sqlite3VdbeMemNulTerminate(pMem); | |
| 54270 | - if( rc ) return rc; | |
| 54271 | - if( sqlite3Atoi64(pMem->z, &pMem->u.i) ){ | |
| 54272 | - MemSetTypeFlag(pMem, MEM_Int); | |
| 54273 | - }else{ | |
| 54274 | - pMem->r = sqlite3VdbeRealValue(pMem); | |
| 54275 | - MemSetTypeFlag(pMem, MEM_Real); | |
| 54276 | - sqlite3VdbeIntegerAffinity(pMem); | |
| 54277 | - } | |
| 54215 | + if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){ | |
| 54216 | + assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); | |
| 54217 | + assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | |
| 54218 | + if( 0==sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc) ){ | |
| 54219 | + MemSetTypeFlag(pMem, MEM_Int); | |
| 54220 | + }else{ | |
| 54221 | + pMem->r = sqlite3VdbeRealValue(pMem); | |
| 54222 | + MemSetTypeFlag(pMem, MEM_Real); | |
| 54223 | + sqlite3VdbeIntegerAffinity(pMem); | |
| 54224 | + } | |
| 54225 | + } | |
| 54226 | + assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 ); | |
| 54227 | + pMem->flags &= ~(MEM_Str|MEM_Blob); | |
| 54278 | 54228 | return SQLITE_OK; |
| 54279 | 54229 | } |
| 54280 | 54230 | |
| 54281 | 54231 | /* |
| 54282 | 54232 | ** Delete any previous value and set the value stored in *pMem to NULL. |
| @@ -54815,10 +54765,12 @@ | ||
| 54815 | 54765 | sqlite3_value **ppVal /* Write the new value here */ |
| 54816 | 54766 | ){ |
| 54817 | 54767 | int op; |
| 54818 | 54768 | char *zVal = 0; |
| 54819 | 54769 | sqlite3_value *pVal = 0; |
| 54770 | + int negInt = 1; | |
| 54771 | + const char *zNeg = ""; | |
| 54820 | 54772 | |
| 54821 | 54773 | if( !pExpr ){ |
| 54822 | 54774 | *ppVal = 0; |
| 54823 | 54775 | return SQLITE_OK; |
| 54824 | 54776 | } |
| @@ -54831,35 +54783,50 @@ | ||
| 54831 | 54783 | #ifdef SQLITE_ENABLE_STAT2 |
| 54832 | 54784 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 54833 | 54785 | #else |
| 54834 | 54786 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 54835 | 54787 | #endif |
| 54788 | + | |
| 54789 | + /* Handle negative integers in a single step. This is needed in the | |
| 54790 | + ** case when the value is -9223372036854775808. | |
| 54791 | + */ | |
| 54792 | + if( op==TK_UMINUS | |
| 54793 | + && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){ | |
| 54794 | + pExpr = pExpr->pLeft; | |
| 54795 | + op = pExpr->op; | |
| 54796 | + negInt = -1; | |
| 54797 | + zNeg = "-"; | |
| 54798 | + } | |
| 54836 | 54799 | |
| 54837 | 54800 | if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){ |
| 54838 | 54801 | pVal = sqlite3ValueNew(db); |
| 54839 | 54802 | if( pVal==0 ) goto no_mem; |
| 54840 | 54803 | if( ExprHasProperty(pExpr, EP_IntValue) ){ |
| 54841 | - sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue); | |
| 54804 | + sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt); | |
| 54842 | 54805 | }else{ |
| 54843 | - zVal = sqlite3DbStrDup(db, pExpr->u.zToken); | |
| 54806 | + zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken); | |
| 54844 | 54807 | if( zVal==0 ) goto no_mem; |
| 54845 | 54808 | sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); |
| 54846 | 54809 | if( op==TK_FLOAT ) pVal->type = SQLITE_FLOAT; |
| 54847 | 54810 | } |
| 54848 | 54811 | if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){ |
| 54849 | 54812 | sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); |
| 54850 | 54813 | }else{ |
| 54851 | 54814 | sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); |
| 54852 | 54815 | } |
| 54816 | + if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str; | |
| 54853 | 54817 | if( enc!=SQLITE_UTF8 ){ |
| 54854 | 54818 | sqlite3VdbeChangeEncoding(pVal, enc); |
| 54855 | 54819 | } |
| 54856 | 54820 | }else if( op==TK_UMINUS ) { |
| 54821 | + /* This branch happens for multiple negative signs. Ex: -(-5) */ | |
| 54857 | 54822 | if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){ |
| 54823 | + sqlite3VdbeMemNumerify(pVal); | |
| 54858 | 54824 | pVal->u.i = -1 * pVal->u.i; |
| 54859 | 54825 | /* (double)-1 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54860 | 54826 | pVal->r = (double)-1 * pVal->r; |
| 54827 | + sqlite3ValueApplyAffinity(pVal, affinity, enc); | |
| 54861 | 54828 | } |
| 54862 | 54829 | } |
| 54863 | 54830 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 54864 | 54831 | else if( op==TK_BLOB ){ |
| 54865 | 54832 | int nVal; |
| @@ -59770,35 +59737,21 @@ | ||
| 59770 | 59737 | ** looks like a number, convert it into a number. If it does not |
| 59771 | 59738 | ** look like a number, leave it alone. |
| 59772 | 59739 | */ |
| 59773 | 59740 | static void applyNumericAffinity(Mem *pRec){ |
| 59774 | 59741 | if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){ |
| 59775 | - int realnum; | |
| 59742 | + double rValue; | |
| 59743 | + i64 iValue; | |
| 59776 | 59744 | u8 enc = pRec->enc; |
| 59777 | - sqlite3VdbeMemNulTerminate(pRec); | |
| 59778 | - if( (pRec->flags&MEM_Str) && sqlite3IsNumber(pRec->z, &realnum, enc) ){ | |
| 59779 | - i64 value; | |
| 59780 | - char *zUtf8 = pRec->z; | |
| 59781 | -#ifndef SQLITE_OMIT_UTF16 | |
| 59782 | - if( enc!=SQLITE_UTF8 ){ | |
| 59783 | - assert( pRec->db ); | |
| 59784 | - zUtf8 = sqlite3Utf16to8(pRec->db, pRec->z, pRec->n, enc); | |
| 59785 | - if( !zUtf8 ) return; | |
| 59786 | - } | |
| 59787 | -#endif | |
| 59788 | - if( !realnum && sqlite3Atoi64(zUtf8, &value) ){ | |
| 59789 | - pRec->u.i = value; | |
| 59790 | - MemSetTypeFlag(pRec, MEM_Int); | |
| 59791 | - }else{ | |
| 59792 | - sqlite3AtoF(zUtf8, &pRec->r); | |
| 59793 | - MemSetTypeFlag(pRec, MEM_Real); | |
| 59794 | - } | |
| 59795 | -#ifndef SQLITE_OMIT_UTF16 | |
| 59796 | - if( enc!=SQLITE_UTF8 ){ | |
| 59797 | - sqlite3DbFree(pRec->db, zUtf8); | |
| 59798 | - } | |
| 59799 | -#endif | |
| 59745 | + if( (pRec->flags&MEM_Str)==0 ) return; | |
| 59746 | + if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return; | |
| 59747 | + if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){ | |
| 59748 | + pRec->u.i = iValue; | |
| 59749 | + pRec->flags |= MEM_Int; | |
| 59750 | + }else{ | |
| 59751 | + pRec->r = rValue; | |
| 59752 | + pRec->flags |= MEM_Real; | |
| 59800 | 59753 | } |
| 59801 | 59754 | } |
| 59802 | 59755 | } |
| 59803 | 59756 | |
| 59804 | 59757 | /* |
| @@ -61580,11 +61533,10 @@ | ||
| 61580 | 61533 | ** integers, for space efficiency, but after extraction we want them |
| 61581 | 61534 | ** to have only a real value. |
| 61582 | 61535 | */ |
| 61583 | 61536 | case OP_RealAffinity: { /* in1 */ |
| 61584 | 61537 | pIn1 = &aMem[pOp->p1]; |
| 61585 | - memAboutToChange(p, pIn1); | |
| 61586 | 61538 | if( pIn1->flags & MEM_Int ){ |
| 61587 | 61539 | sqlite3VdbeMemRealify(pIn1); |
| 61588 | 61540 | } |
| 61589 | 61541 | break; |
| 61590 | 61542 | } |
| @@ -61623,11 +61575,10 @@ | ||
| 61623 | 61575 | ** |
| 61624 | 61576 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61625 | 61577 | */ |
| 61626 | 61578 | case OP_ToBlob: { /* same as TK_TO_BLOB, in1 */ |
| 61627 | 61579 | pIn1 = &aMem[pOp->p1]; |
| 61628 | - memAboutToChange(p, pIn1); | |
| 61629 | 61580 | if( pIn1->flags & MEM_Null ) break; |
| 61630 | 61581 | if( (pIn1->flags & MEM_Blob)==0 ){ |
| 61631 | 61582 | applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); |
| 61632 | 61583 | assert( pIn1->flags & MEM_Str || db->mallocFailed ); |
| 61633 | 61584 | MemSetTypeFlag(pIn1, MEM_Blob); |
| @@ -61648,14 +61599,11 @@ | ||
| 61648 | 61599 | ** |
| 61649 | 61600 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61650 | 61601 | */ |
| 61651 | 61602 | case OP_ToNumeric: { /* same as TK_TO_NUMERIC, in1 */ |
| 61652 | 61603 | pIn1 = &aMem[pOp->p1]; |
| 61653 | - memAboutToChange(p, pIn1); | |
| 61654 | - if( (pIn1->flags & (MEM_Null|MEM_Int|MEM_Real))==0 ){ | |
| 61655 | - sqlite3VdbeMemNumerify(pIn1); | |
| 61656 | - } | |
| 61604 | + sqlite3VdbeMemNumerify(pIn1); | |
| 61657 | 61605 | break; |
| 61658 | 61606 | } |
| 61659 | 61607 | #endif /* SQLITE_OMIT_CAST */ |
| 61660 | 61608 | |
| 61661 | 61609 | /* Opcode: ToInt P1 * * * * |
| @@ -61667,11 +61615,10 @@ | ||
| 61667 | 61615 | ** |
| 61668 | 61616 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61669 | 61617 | */ |
| 61670 | 61618 | case OP_ToInt: { /* same as TK_TO_INT, in1 */ |
| 61671 | 61619 | pIn1 = &aMem[pOp->p1]; |
| 61672 | - memAboutToChange(p, pIn1); | |
| 61673 | 61620 | if( (pIn1->flags & MEM_Null)==0 ){ |
| 61674 | 61621 | sqlite3VdbeMemIntegerify(pIn1); |
| 61675 | 61622 | } |
| 61676 | 61623 | break; |
| 61677 | 61624 | } |
| @@ -61781,12 +61728,10 @@ | ||
| 61781 | 61728 | u16 flags3; /* Copy of initial value of pIn3->flags */ |
| 61782 | 61729 | #endif /* local variables moved into u.ai */ |
| 61783 | 61730 | |
| 61784 | 61731 | pIn1 = &aMem[pOp->p1]; |
| 61785 | 61732 | pIn3 = &aMem[pOp->p3]; |
| 61786 | - memAboutToChange(p, pIn1); | |
| 61787 | - memAboutToChange(p, pIn3); | |
| 61788 | 61733 | u.ai.flags1 = pIn1->flags; |
| 61789 | 61734 | u.ai.flags3 = pIn3->flags; |
| 61790 | 61735 | if( (pIn1->flags | pIn3->flags)&MEM_Null ){ |
| 61791 | 61736 | /* One or both operands are NULL */ |
| 61792 | 61737 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| @@ -62415,11 +62360,10 @@ | ||
| 62415 | 62360 | assert( u.an.zAffinity[pOp->p2]==0 ); |
| 62416 | 62361 | pIn1 = &aMem[pOp->p1]; |
| 62417 | 62362 | while( (u.an.cAff = *(u.an.zAffinity++))!=0 ){ |
| 62418 | 62363 | assert( pIn1 <= &p->aMem[p->nMem] ); |
| 62419 | 62364 | assert( memIsValid(pIn1) ); |
| 62420 | - memAboutToChange(p, pIn1); | |
| 62421 | 62365 | ExpandBlob(pIn1); |
| 62422 | 62366 | applyAffinity(pIn1, u.an.cAff, encoding); |
| 62423 | 62367 | pIn1++; |
| 62424 | 62368 | } |
| 62425 | 62369 | break; |
| @@ -62495,11 +62439,10 @@ | ||
| 62495 | 62439 | ** out how much space is required for the new record. |
| 62496 | 62440 | */ |
| 62497 | 62441 | for(u.ao.pRec=u.ao.pData0; u.ao.pRec<=u.ao.pLast; u.ao.pRec++){ |
| 62498 | 62442 | assert( memIsValid(u.ao.pRec) ); |
| 62499 | 62443 | if( u.ao.zAffinity ){ |
| 62500 | - memAboutToChange(p, u.ao.pRec); | |
| 62501 | 62444 | applyAffinity(u.ao.pRec, u.ao.zAffinity[u.ao.pRec-u.ao.pData0], encoding); |
| 62502 | 62445 | } |
| 62503 | 62446 | if( u.ao.pRec->flags&MEM_Zero && u.ao.pRec->n>0 ){ |
| 62504 | 62447 | sqlite3VdbeMemExpandBlob(u.ao.pRec); |
| 62505 | 62448 | } |
| @@ -68880,11 +68823,11 @@ | ||
| 68880 | 68823 | pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 68881 | 68824 | }else if( z[0]=='?' ){ |
| 68882 | 68825 | /* Wildcard of the form "?nnn". Convert "nnn" to an integer and |
| 68883 | 68826 | ** use it as the variable number */ |
| 68884 | 68827 | i64 i; |
| 68885 | - int bOk = sqlite3Atoi64(&z[1], &i); | |
| 68828 | + int bOk = 0==sqlite3Atoi64(&z[1], &i, sqlite3Strlen30(&z[1]), SQLITE_UTF8); | |
| 68886 | 68829 | pExpr->iColumn = (ynVar)i; |
| 68887 | 68830 | testcase( i==0 ); |
| 68888 | 68831 | testcase( i==1 ); |
| 68889 | 68832 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); |
| 68890 | 68833 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); |
| @@ -70243,11 +70186,11 @@ | ||
| 70243 | 70186 | */ |
| 70244 | 70187 | static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){ |
| 70245 | 70188 | if( ALWAYS(z!=0) ){ |
| 70246 | 70189 | double value; |
| 70247 | 70190 | char *zV; |
| 70248 | - sqlite3AtoF(z, &value); | |
| 70191 | + sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); | |
| 70249 | 70192 | assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */ |
| 70250 | 70193 | if( negateFlag ) value = -value; |
| 70251 | 70194 | zV = dup8bytes(v, (char*)&value); |
| 70252 | 70195 | sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL); |
| 70253 | 70196 | } |
| @@ -70257,28 +70200,27 @@ | ||
| 70257 | 70200 | |
| 70258 | 70201 | /* |
| 70259 | 70202 | ** Generate an instruction that will put the integer describe by |
| 70260 | 70203 | ** text z[0..n-1] into register iMem. |
| 70261 | 70204 | ** |
| 70262 | -** The z[] string will probably not be zero-terminated. But the | |
| 70263 | -** z[n] character is guaranteed to be something that does not look | |
| 70264 | -** like the continuation of the number. | |
| 70205 | +** Expr.u.zToken is always UTF8 and zero-terminated. | |
| 70265 | 70206 | */ |
| 70266 | 70207 | static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){ |
| 70267 | 70208 | Vdbe *v = pParse->pVdbe; |
| 70268 | 70209 | if( pExpr->flags & EP_IntValue ){ |
| 70269 | 70210 | int i = pExpr->u.iValue; |
| 70270 | 70211 | if( negFlag ) i = -i; |
| 70271 | 70212 | sqlite3VdbeAddOp2(v, OP_Integer, i, iMem); |
| 70272 | 70213 | }else{ |
| 70214 | + int c; | |
| 70215 | + i64 value; | |
| 70273 | 70216 | const char *z = pExpr->u.zToken; |
| 70274 | 70217 | assert( z!=0 ); |
| 70275 | - if( sqlite3FitsIn64Bits(z, negFlag) ){ | |
| 70276 | - i64 value; | |
| 70218 | + c = sqlite3Atoi64(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); | |
| 70219 | + if( c==0 || (c==2 && negFlag) ){ | |
| 70277 | 70220 | char *zV; |
| 70278 | - sqlite3Atoi64(z, &value); | |
| 70279 | - if( negFlag ) value = -value; | |
| 70221 | + if( negFlag ){ value = -value; } | |
| 70280 | 70222 | zV = dup8bytes(v, (char*)&value); |
| 70281 | 70223 | sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64); |
| 70282 | 70224 | }else{ |
| 70283 | 70225 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 70284 | 70226 | sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z); |
| @@ -79414,11 +79356,11 @@ | ||
| 79414 | 79356 | zBuf = sqlite3_mprintf("%.*f",n,r); |
| 79415 | 79357 | if( zBuf==0 ){ |
| 79416 | 79358 | sqlite3_result_error_nomem(context); |
| 79417 | 79359 | return; |
| 79418 | 79360 | } |
| 79419 | - sqlite3AtoF(zBuf, &r); | |
| 79361 | + sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8); | |
| 79420 | 79362 | sqlite3_free(zBuf); |
| 79421 | 79363 | } |
| 79422 | 79364 | sqlite3_result_double(context, r); |
| 79423 | 79365 | } |
| 79424 | 79366 | #endif |
| @@ -85472,11 +85414,11 @@ | ||
| 85472 | 85414 | */ |
| 85473 | 85415 | if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){ |
| 85474 | 85416 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 85475 | 85417 | i64 iLimit = -2; |
| 85476 | 85418 | if( zRight ){ |
| 85477 | - sqlite3Atoi64(zRight, &iLimit); | |
| 85419 | + sqlite3Atoi64(zRight, &iLimit, 1000000, SQLITE_UTF8); | |
| 85478 | 85420 | if( iLimit<-1 ) iLimit = -1; |
| 85479 | 85421 | } |
| 85480 | 85422 | iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); |
| 85481 | 85423 | returnSingleInt(pParse, "journal_size_limit", iLimit); |
| 85482 | 85424 | }else |
| @@ -96380,11 +96322,12 @@ | ||
| 96380 | 96322 | |
| 96381 | 96323 | /* |
| 96382 | 96324 | ** Required because bestIndex() is called by bestOrClauseIndex() |
| 96383 | 96325 | */ |
| 96384 | 96326 | static void bestIndex( |
| 96385 | - Parse*, WhereClause*, struct SrcList_item*, Bitmask, ExprList*, WhereCost*); | |
| 96327 | + Parse*, WhereClause*, struct SrcList_item*, | |
| 96328 | + Bitmask, Bitmask, ExprList*, WhereCost*); | |
| 96386 | 96329 | |
| 96387 | 96330 | /* |
| 96388 | 96331 | ** This routine attempts to find an scanning strategy that can be used |
| 96389 | 96332 | ** to optimize an 'OR' expression that is part of a WHERE clause. |
| 96390 | 96333 | ** |
| @@ -96393,11 +96336,12 @@ | ||
| 96393 | 96336 | */ |
| 96394 | 96337 | static void bestOrClauseIndex( |
| 96395 | 96338 | Parse *pParse, /* The parsing context */ |
| 96396 | 96339 | WhereClause *pWC, /* The WHERE clause */ |
| 96397 | 96340 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 96398 | - Bitmask notReady, /* Mask of cursors that are not available */ | |
| 96341 | + Bitmask notReady, /* Mask of cursors not available for indexing */ | |
| 96342 | + Bitmask notValid, /* Cursors not available for any purpose */ | |
| 96399 | 96343 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 96400 | 96344 | WhereCost *pCost /* Lowest cost query plan */ |
| 96401 | 96345 | ){ |
| 96402 | 96346 | #ifndef SQLITE_OMIT_OR_OPTIMIZATION |
| 96403 | 96347 | const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| @@ -96429,19 +96373,19 @@ | ||
| 96429 | 96373 | WHERETRACE(("... Multi-index OR testing for term %d of %d....\n", |
| 96430 | 96374 | (pOrTerm - pOrWC->a), (pTerm - pWC->a) |
| 96431 | 96375 | )); |
| 96432 | 96376 | if( pOrTerm->eOperator==WO_AND ){ |
| 96433 | 96377 | WhereClause *pAndWC = &pOrTerm->u.pAndInfo->wc; |
| 96434 | - bestIndex(pParse, pAndWC, pSrc, notReady, 0, &sTermCost); | |
| 96378 | + bestIndex(pParse, pAndWC, pSrc, notReady, notValid, 0, &sTermCost); | |
| 96435 | 96379 | }else if( pOrTerm->leftCursor==iCur ){ |
| 96436 | 96380 | WhereClause tempWC; |
| 96437 | 96381 | tempWC.pParse = pWC->pParse; |
| 96438 | 96382 | tempWC.pMaskSet = pWC->pMaskSet; |
| 96439 | 96383 | tempWC.op = TK_AND; |
| 96440 | 96384 | tempWC.a = pOrTerm; |
| 96441 | 96385 | tempWC.nTerm = 1; |
| 96442 | - bestIndex(pParse, &tempWC, pSrc, notReady, 0, &sTermCost); | |
| 96386 | + bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost); | |
| 96443 | 96387 | }else{ |
| 96444 | 96388 | continue; |
| 96445 | 96389 | } |
| 96446 | 96390 | rTotal += sTermCost.rCost; |
| 96447 | 96391 | nRow += sTermCost.nRow; |
| @@ -96884,11 +96828,12 @@ | ||
| 96884 | 96828 | */ |
| 96885 | 96829 | static void bestVirtualIndex( |
| 96886 | 96830 | Parse *pParse, /* The parsing context */ |
| 96887 | 96831 | WhereClause *pWC, /* The WHERE clause */ |
| 96888 | 96832 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 96889 | - Bitmask notReady, /* Mask of cursors that are not available */ | |
| 96833 | + Bitmask notReady, /* Mask of cursors not available for index */ | |
| 96834 | + Bitmask notValid, /* Cursors not valid for any purpose */ | |
| 96890 | 96835 | ExprList *pOrderBy, /* The order by clause */ |
| 96891 | 96836 | WhereCost *pCost, /* Lowest cost query plan */ |
| 96892 | 96837 | sqlite3_index_info **ppIdxInfo /* Index information passed to xBestIndex */ |
| 96893 | 96838 | ){ |
| 96894 | 96839 | Table *pTab = pSrc->pTab; |
| @@ -97014,11 +96959,11 @@ | ||
| 97014 | 96959 | pIdxInfo->nOrderBy = nOrderBy; |
| 97015 | 96960 | |
| 97016 | 96961 | /* Try to find a more efficient access pattern by using multiple indexes |
| 97017 | 96962 | ** to optimize an OR expression within the WHERE clause. |
| 97018 | 96963 | */ |
| 97019 | - bestOrClauseIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost); | |
| 96964 | + bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); | |
| 97020 | 96965 | } |
| 97021 | 96966 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 97022 | 96967 | |
| 97023 | 96968 | /* |
| 97024 | 96969 | ** Argument pIdx is a pointer to an index structure that has an array of |
| @@ -97295,11 +97240,12 @@ | ||
| 97295 | 97240 | */ |
| 97296 | 97241 | static void bestBtreeIndex( |
| 97297 | 97242 | Parse *pParse, /* The parsing context */ |
| 97298 | 97243 | WhereClause *pWC, /* The WHERE clause */ |
| 97299 | 97244 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 97300 | - Bitmask notReady, /* Mask of cursors that are not available */ | |
| 97245 | + Bitmask notReady, /* Mask of cursors not available for indexing */ | |
| 97246 | + Bitmask notValid, /* Cursors not available for any purpose */ | |
| 97301 | 97247 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 97302 | 97248 | WhereCost *pCost /* Lowest cost query plan */ |
| 97303 | 97249 | ){ |
| 97304 | 97250 | int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| 97305 | 97251 | Index *pProbe; /* An index we are evaluating */ |
| @@ -97557,29 +97503,29 @@ | ||
| 97557 | 97503 | ** of output rows, adjust the nRow value accordingly. This only |
| 97558 | 97504 | ** matters if the current index is the least costly, so do not bother |
| 97559 | 97505 | ** with this step if we already know this index will not be chosen. |
| 97560 | 97506 | ** Also, never reduce the output row count below 2 using this step. |
| 97561 | 97507 | ** |
| 97562 | - ** Do not reduce the output row count if pSrc is the only table that | |
| 97563 | - ** is notReady; if notReady is a power of two. This will be the case | |
| 97564 | - ** when the main sqlite3WhereBegin() loop is scanning for a table with | |
| 97565 | - ** and "optimal" index, and on such a scan the output row count | |
| 97566 | - ** reduction is not valid because it does not update the "pCost->used" | |
| 97567 | - ** bitmap. The notReady bitmap will also be a power of two when we | |
| 97568 | - ** are scanning for the last table in a 64-way join. We are willing | |
| 97569 | - ** to bypass this optimization in that corner case. | |
| 97508 | + ** It is critical that the notValid mask be used here instead of | |
| 97509 | + ** the notReady mask. When computing an "optimal" index, the notReady | |
| 97510 | + ** mask will only have one bit set - the bit for the current table. | |
| 97511 | + ** The notValid mask, on the other hand, always has all bits set for | |
| 97512 | + ** tables that are not in outer loops. If notReady is used here instead | |
| 97513 | + ** of notValid, then a optimal index that depends on inner joins loops | |
| 97514 | + ** might be selected even when there exists an optimal index that has | |
| 97515 | + ** no such dependency. | |
| 97570 | 97516 | */ |
| 97571 | - if( nRow>2 && cost<=pCost->rCost && (notReady & (notReady-1))!=0 ){ | |
| 97517 | + if( nRow>2 && cost<=pCost->rCost ){ | |
| 97572 | 97518 | int k; /* Loop counter */ |
| 97573 | 97519 | int nSkipEq = nEq; /* Number of == constraints to skip */ |
| 97574 | 97520 | int nSkipRange = nBound; /* Number of < constraints to skip */ |
| 97575 | 97521 | Bitmask thisTab; /* Bitmap for pSrc */ |
| 97576 | 97522 | |
| 97577 | 97523 | thisTab = getMask(pWC->pMaskSet, iCur); |
| 97578 | 97524 | for(pTerm=pWC->a, k=pWC->nTerm; nRow>2 && k; k--, pTerm++){ |
| 97579 | 97525 | if( pTerm->wtFlags & TERM_VIRTUAL ) continue; |
| 97580 | - if( (pTerm->prereqAll & notReady)!=thisTab ) continue; | |
| 97526 | + if( (pTerm->prereqAll & notValid)!=thisTab ) continue; | |
| 97581 | 97527 | if( pTerm->eOperator & (WO_EQ|WO_IN|WO_ISNULL) ){ |
| 97582 | 97528 | if( nSkipEq ){ |
| 97583 | 97529 | /* Ignore the first nEq equality matches since the index |
| 97584 | 97530 | ** has already accounted for these */ |
| 97585 | 97531 | nSkipEq--; |
| @@ -97657,11 +97603,11 @@ | ||
| 97657 | 97603 | WHERETRACE(("best index is: %s\n", |
| 97658 | 97604 | ((pCost->plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ? "none" : |
| 97659 | 97605 | pCost->plan.u.pIdx ? pCost->plan.u.pIdx->zName : "ipk") |
| 97660 | 97606 | )); |
| 97661 | 97607 | |
| 97662 | - bestOrClauseIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost); | |
| 97608 | + bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); | |
| 97663 | 97609 | bestAutomaticIndex(pParse, pWC, pSrc, notReady, pCost); |
| 97664 | 97610 | pCost->plan.wsFlags |= eqTermMask; |
| 97665 | 97611 | } |
| 97666 | 97612 | |
| 97667 | 97613 | /* |
| @@ -97672,26 +97618,27 @@ | ||
| 97672 | 97618 | */ |
| 97673 | 97619 | static void bestIndex( |
| 97674 | 97620 | Parse *pParse, /* The parsing context */ |
| 97675 | 97621 | WhereClause *pWC, /* The WHERE clause */ |
| 97676 | 97622 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 97677 | - Bitmask notReady, /* Mask of cursors that are not available */ | |
| 97623 | + Bitmask notReady, /* Mask of cursors not available for indexing */ | |
| 97624 | + Bitmask notValid, /* Cursors not available for any purpose */ | |
| 97678 | 97625 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 97679 | 97626 | WhereCost *pCost /* Lowest cost query plan */ |
| 97680 | 97627 | ){ |
| 97681 | 97628 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 97682 | 97629 | if( IsVirtual(pSrc->pTab) ){ |
| 97683 | 97630 | sqlite3_index_info *p = 0; |
| 97684 | - bestVirtualIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost, &p); | |
| 97631 | + bestVirtualIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost,&p); | |
| 97685 | 97632 | if( p->needToFreeIdxStr ){ |
| 97686 | 97633 | sqlite3_free(p->idxStr); |
| 97687 | 97634 | } |
| 97688 | 97635 | sqlite3DbFree(pParse->db, p); |
| 97689 | 97636 | }else |
| 97690 | 97637 | #endif |
| 97691 | 97638 | { |
| 97692 | - bestBtreeIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost); | |
| 97639 | + bestBtreeIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); | |
| 97693 | 97640 | } |
| 97694 | 97641 | } |
| 97695 | 97642 | |
| 97696 | 97643 | /* |
| 97697 | 97644 | ** Disable a term in the WHERE clause. Except, do not disable the term |
| @@ -98902,14 +98849,20 @@ | ||
| 98902 | 98849 | ** by waiting for other tables to run first. This "optimal" test works |
| 98903 | 98850 | ** by first assuming that the FROM clause is on the inner loop and finding |
| 98904 | 98851 | ** its query plan, then checking to see if that query plan uses any |
| 98905 | 98852 | ** other FROM clause terms that are notReady. If no notReady terms are |
| 98906 | 98853 | ** used then the "optimal" query plan works. |
| 98854 | + ** | |
| 98855 | + ** Note that the WhereCost.nRow parameter for an optimal scan might | |
| 98856 | + ** not be as small as it would be if the table really were the innermost | |
| 98857 | + ** join. The nRow value can be reduced by WHERE clause constraints | |
| 98858 | + ** that do not use indices. But this nRow reduction only happens if the | |
| 98859 | + ** table really is the innermost join. | |
| 98907 | 98860 | ** |
| 98908 | 98861 | ** The second loop iteration is only performed if no optimal scan |
| 98909 | - ** strategies were found by the first loop. This 2nd iteration is used to | |
| 98910 | - ** search for the lowest cost scan overall. | |
| 98862 | + ** strategies were found by the first iteration. This second iteration | |
| 98863 | + ** is used to search for the lowest cost scan overall. | |
| 98911 | 98864 | ** |
| 98912 | 98865 | ** Previous versions of SQLite performed only the second iteration - |
| 98913 | 98866 | ** the next outermost loop was always that with the lowest overall |
| 98914 | 98867 | ** cost. However, this meant that SQLite could select the wrong plan |
| 98915 | 98868 | ** for scripts such as the following: |
| @@ -98925,11 +98878,11 @@ | ||
| 98925 | 98878 | ** algorithm may choose to use t2 for the outer loop, which is a much |
| 98926 | 98879 | ** costlier approach. |
| 98927 | 98880 | */ |
| 98928 | 98881 | nUnconstrained = 0; |
| 98929 | 98882 | notIndexed = 0; |
| 98930 | - for(isOptimal=(iFrom<nTabList-1); isOptimal>=0; isOptimal--){ | |
| 98883 | + for(isOptimal=(iFrom<nTabList-1); isOptimal>=0 && bestJ<0; isOptimal--){ | |
| 98931 | 98884 | Bitmask mask; /* Mask of tables not yet ready */ |
| 98932 | 98885 | for(j=iFrom, pTabItem=&pTabList->a[j]; j<nTabList; j++, pTabItem++){ |
| 98933 | 98886 | int doNotReorder; /* True if this table should not be reordered */ |
| 98934 | 98887 | WhereCost sCost; /* Cost information from best[Virtual]Index() */ |
| 98935 | 98888 | ExprList *pOrderBy; /* ORDER BY clause for index to optimize */ |
| @@ -98947,15 +98900,17 @@ | ||
| 98947 | 98900 | |
| 98948 | 98901 | assert( pTabItem->pTab ); |
| 98949 | 98902 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 98950 | 98903 | if( IsVirtual(pTabItem->pTab) ){ |
| 98951 | 98904 | sqlite3_index_info **pp = &pWInfo->a[j].pIdxInfo; |
| 98952 | - bestVirtualIndex(pParse, pWC, pTabItem, mask, pOrderBy, &sCost, pp); | |
| 98905 | + bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, | |
| 98906 | + &sCost, pp); | |
| 98953 | 98907 | }else |
| 98954 | 98908 | #endif |
| 98955 | 98909 | { |
| 98956 | - bestBtreeIndex(pParse, pWC, pTabItem, mask, pOrderBy, &sCost); | |
| 98910 | + bestBtreeIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, | |
| 98911 | + &sCost); | |
| 98957 | 98912 | } |
| 98958 | 98913 | assert( isOptimal || (sCost.used¬Ready)==0 ); |
| 98959 | 98914 | |
| 98960 | 98915 | /* If an INDEXED BY clause is present, then the plan must use that |
| 98961 | 98916 | ** index if it uses any index at all */ |
| 98962 | 98917 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.3" |
| 654 | #define SQLITE_VERSION_NUMBER 3007003 |
| 655 | #define SQLITE_SOURCE_ID "2010-09-29 23:09:23 1ef0dc9328f47506cb2dcd142150e96cb4755216" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -10570,11 +10570,10 @@ | |
| 10570 | |
| 10571 | /* |
| 10572 | ** Internal function prototypes |
| 10573 | */ |
| 10574 | SQLITE_PRIVATE int sqlite3StrICmp(const char *, const char *); |
| 10575 | SQLITE_PRIVATE int sqlite3IsNumber(const char*, int*, u8); |
| 10576 | SQLITE_PRIVATE int sqlite3Strlen30(const char*); |
| 10577 | #define sqlite3StrNICmp sqlite3_strnicmp |
| 10578 | |
| 10579 | SQLITE_PRIVATE int sqlite3MallocInit(void); |
| 10580 | SQLITE_PRIVATE void sqlite3MallocEnd(void); |
| @@ -10890,13 +10889,12 @@ | |
| 10890 | SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*); |
| 10891 | SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*); |
| 10892 | SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*); |
| 10893 | SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*); |
| 10894 | SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); |
| 10895 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*); |
| 10896 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 10897 | SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int); |
| 10898 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 10899 | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); |
| 10900 | SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8**); |
| 10901 | |
| 10902 | /* |
| @@ -10938,11 +10936,11 @@ | |
| 10938 | SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *); |
| 10939 | SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *, Table *); |
| 10940 | SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2); |
| 10941 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); |
| 10942 | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr); |
| 10943 | SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*); |
| 10944 | SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...); |
| 10945 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 10946 | SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
| 10947 | SQLITE_PRIVATE const char *sqlite3ErrStr(int); |
| 10948 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse); |
| @@ -12637,16 +12635,10 @@ | |
| 12637 | end_getDigits: |
| 12638 | va_end(ap); |
| 12639 | return cnt; |
| 12640 | } |
| 12641 | |
| 12642 | /* |
| 12643 | ** Read text from z[] and convert into a floating point number. Return |
| 12644 | ** the number of digits converted. |
| 12645 | */ |
| 12646 | #define getValue sqlite3AtoF |
| 12647 | |
| 12648 | /* |
| 12649 | ** Parse a timezone extension on the end of a date-time. |
| 12650 | ** The extension is of the form: |
| 12651 | ** |
| 12652 | ** (+/-)HH:MM |
| @@ -12844,21 +12836,19 @@ | |
| 12844 | static int parseDateOrTime( |
| 12845 | sqlite3_context *context, |
| 12846 | const char *zDate, |
| 12847 | DateTime *p |
| 12848 | ){ |
| 12849 | int isRealNum; /* Return from sqlite3IsNumber(). Not used */ |
| 12850 | if( parseYyyyMmDd(zDate,p)==0 ){ |
| 12851 | return 0; |
| 12852 | }else if( parseHhMmSs(zDate, p)==0 ){ |
| 12853 | return 0; |
| 12854 | }else if( sqlite3StrICmp(zDate,"now")==0){ |
| 12855 | setDateTimeToCurrent(context, p); |
| 12856 | return 0; |
| 12857 | }else if( sqlite3IsNumber(zDate, &isRealNum, SQLITE_UTF8) ){ |
| 12858 | double r; |
| 12859 | getValue(zDate, &r); |
| 12860 | p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5); |
| 12861 | p->validJD = 1; |
| 12862 | return 0; |
| 12863 | } |
| 12864 | return 1; |
| @@ -13075,12 +13065,13 @@ | |
| 13075 | ** |
| 13076 | ** Move the date to the same time on the next occurrence of |
| 13077 | ** weekday N where 0==Sunday, 1==Monday, and so forth. If the |
| 13078 | ** date is already on the appropriate weekday, this is a no-op. |
| 13079 | */ |
| 13080 | if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0 |
| 13081 | && (n=(int)r)==r && n>=0 && r<7 ){ |
| 13082 | sqlite3_int64 Z; |
| 13083 | computeYMD_HMS(p); |
| 13084 | p->validTZ = 0; |
| 13085 | p->validJD = 0; |
| 13086 | computeJD(p); |
| @@ -13131,12 +13122,15 @@ | |
| 13131 | case '6': |
| 13132 | case '7': |
| 13133 | case '8': |
| 13134 | case '9': { |
| 13135 | double rRounder; |
| 13136 | n = getValue(z, &r); |
| 13137 | assert( n>=1 ); |
| 13138 | if( z[n]==':' ){ |
| 13139 | /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the |
| 13140 | ** specified number of hours, minutes, seconds, and fractional seconds |
| 13141 | ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be |
| 13142 | ** omitted. |
| @@ -17502,11 +17496,11 @@ | |
| 17502 | sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n); |
| 17503 | }else{ |
| 17504 | sqlite3MemoryAlarm(0, 0, 0); |
| 17505 | } |
| 17506 | excess = sqlite3_memory_used() - n; |
| 17507 | if( excess>0 ) sqlite3_release_memory(excess & 0x7fffffff); |
| 17508 | return priorLimit; |
| 17509 | } |
| 17510 | SQLITE_API void sqlite3_soft_heap_limit(int n){ |
| 17511 | if( n<0 ) n = 0; |
| 17512 | sqlite3_soft_heap_limit64(n); |
| @@ -20096,125 +20090,115 @@ | |
| 20096 | while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } |
| 20097 | return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b]; |
| 20098 | } |
| 20099 | |
| 20100 | /* |
| 20101 | ** Return TRUE if z is a pure numeric string. Return FALSE and leave |
| 20102 | ** *realnum unchanged if the string contains any character which is not |
| 20103 | ** part of a number. |
| 20104 | ** |
| 20105 | ** If the string is pure numeric, set *realnum to TRUE if the string |
| 20106 | ** contains the '.' character or an "E+000" style exponentiation suffix. |
| 20107 | ** Otherwise set *realnum to FALSE. Note that just becaue *realnum is |
| 20108 | ** false does not mean that the number can be successfully converted into |
| 20109 | ** an integer - it might be too big. |
| 20110 | ** |
| 20111 | ** An empty string is considered non-numeric. |
| 20112 | */ |
| 20113 | SQLITE_PRIVATE int sqlite3IsNumber(const char *z, int *realnum, u8 enc){ |
| 20114 | int incr = (enc==SQLITE_UTF8?1:2); |
| 20115 | if( enc==SQLITE_UTF16BE ) z++; |
| 20116 | if( *z=='-' || *z=='+' ) z += incr; |
| 20117 | if( !sqlite3Isdigit(*z) ){ |
| 20118 | return 0; |
| 20119 | } |
| 20120 | z += incr; |
| 20121 | *realnum = 0; |
| 20122 | while( sqlite3Isdigit(*z) ){ z += incr; } |
| 20123 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 20124 | if( *z=='.' ){ |
| 20125 | z += incr; |
| 20126 | if( !sqlite3Isdigit(*z) ) return 0; |
| 20127 | while( sqlite3Isdigit(*z) ){ z += incr; } |
| 20128 | *realnum = 1; |
| 20129 | } |
| 20130 | if( *z=='e' || *z=='E' ){ |
| 20131 | z += incr; |
| 20132 | if( *z=='+' || *z=='-' ) z += incr; |
| 20133 | if( !sqlite3Isdigit(*z) ) return 0; |
| 20134 | while( sqlite3Isdigit(*z) ){ z += incr; } |
| 20135 | *realnum = 1; |
| 20136 | } |
| 20137 | #endif |
| 20138 | return *z==0; |
| 20139 | } |
| 20140 | |
| 20141 | /* |
| 20142 | ** The string z[] is an ASCII representation of a real number. |
| 20143 | ** Convert this string to a double. |
| 20144 | ** |
| 20145 | ** This routine assumes that z[] really is a valid number. If it |
| 20146 | ** is not, the result is undefined. |
| 20147 | ** |
| 20148 | ** This routine is used instead of the library atof() function because |
| 20149 | ** the library atof() might want to use "," as the decimal point instead |
| 20150 | ** of "." depending on how locale is set. But that would cause problems |
| 20151 | ** for SQL. So this routine always uses "." regardless of locale. |
| 20152 | */ |
| 20153 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){ |
| 20154 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 20155 | const char *zBegin = z; |
| 20156 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 20157 | int sign = 1; /* sign of significand */ |
| 20158 | i64 s = 0; /* significand */ |
| 20159 | int d = 0; /* adjust exponent for shifting decimal point */ |
| 20160 | int esign = 1; /* sign of exponent */ |
| 20161 | int e = 0; /* exponent */ |
| 20162 | double result; |
| 20163 | int nDigits = 0; |
| 20164 | |
| 20165 | /* skip leading spaces */ |
| 20166 | while( sqlite3Isspace(*z) ) z++; |
| 20167 | /* get sign of significand */ |
| 20168 | if( *z=='-' ){ |
| 20169 | sign = -1; |
| 20170 | z++; |
| 20171 | }else if( *z=='+' ){ |
| 20172 | z++; |
| 20173 | } |
| 20174 | /* skip leading zeroes */ |
| 20175 | while( z[0]=='0' ) z++, nDigits++; |
| 20176 | |
| 20177 | /* copy max significant digits to significand */ |
| 20178 | while( sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ |
| 20179 | s = s*10 + (*z - '0'); |
| 20180 | z++, nDigits++; |
| 20181 | } |
| 20182 | /* skip non-significant significand digits |
| 20183 | ** (increase exponent by d to shift decimal left) */ |
| 20184 | while( sqlite3Isdigit(*z) ) z++, nDigits++, d++; |
| 20185 | |
| 20186 | /* if decimal point is present */ |
| 20187 | if( *z=='.' ){ |
| 20188 | z++; |
| 20189 | /* copy digits from after decimal to significand |
| 20190 | ** (decrease exponent by d to shift decimal right) */ |
| 20191 | while( sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ |
| 20192 | s = s*10 + (*z - '0'); |
| 20193 | z++, nDigits++, d--; |
| 20194 | } |
| 20195 | /* skip non-significant digits */ |
| 20196 | while( sqlite3Isdigit(*z) ) z++, nDigits++; |
| 20197 | } |
| 20198 | |
| 20199 | /* if exponent is present */ |
| 20200 | if( *z=='e' || *z=='E' ){ |
| 20201 | z++; |
| 20202 | /* get sign of exponent */ |
| 20203 | if( *z=='-' ){ |
| 20204 | esign = -1; |
| 20205 | z++; |
| 20206 | }else if( *z=='+' ){ |
| 20207 | z++; |
| 20208 | } |
| 20209 | /* copy digits to exponent */ |
| 20210 | while( sqlite3Isdigit(*z) ){ |
| 20211 | e = e*10 + (*z - '0'); |
| 20212 | z++; |
| 20213 | } |
| 20214 | } |
| 20215 | |
| 20216 | /* adjust exponent by d, and update sign */ |
| 20217 | e = (e*esign) + d; |
| 20218 | if( e<0 ) { |
| 20219 | esign = -1; |
| 20220 | e *= -1; |
| @@ -20269,132 +20253,104 @@ | |
| 20269 | } |
| 20270 | |
| 20271 | /* store the result */ |
| 20272 | *pResult = result; |
| 20273 | |
| 20274 | /* return number of characters used */ |
| 20275 | return (int)(z - zBegin); |
| 20276 | #else |
| 20277 | return sqlite3Atoi64(z, pResult); |
| 20278 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 20279 | } |
| 20280 | |
| 20281 | /* |
| 20282 | ** Compare the 19-character string zNum against the text representation |
| 20283 | ** value 2^63: 9223372036854775808. Return negative, zero, or positive |
| 20284 | ** if zNum is less than, equal to, or greater than the string. |
| 20285 | ** |
| 20286 | ** Unlike memcmp() this routine is guaranteed to return the difference |
| 20287 | ** in the values of the last digit if the only difference is in the |
| 20288 | ** last digit. So, for example, |
| 20289 | ** |
| 20290 | ** compare2pow63("9223372036854775800") |
| 20291 | ** |
| 20292 | ** will return -8. |
| 20293 | */ |
| 20294 | static int compare2pow63(const char *zNum){ |
| 20295 | int c; |
| 20296 | c = memcmp(zNum,"922337203685477580",18)*10; |
| 20297 | if( c==0 ){ |
| 20298 | c = zNum[18] - '8'; |
| 20299 | testcase( c==(-1) ); |
| 20300 | testcase( c==0 ); |
| 20301 | testcase( c==(+1) ); |
| 20302 | } |
| 20303 | return c; |
| 20304 | } |
| 20305 | |
| 20306 | |
| 20307 | /* |
| 20308 | ** Return TRUE if zNum is a 64-bit signed integer and write |
| 20309 | ** the value of the integer into *pNum. If zNum is not an integer |
| 20310 | ** or is an integer that is too large to be expressed with 64 bits, |
| 20311 | ** then return false. |
| 20312 | ** |
| 20313 | ** When this routine was originally written it dealt with only |
| 20314 | ** 32-bit numbers. At that time, it was much faster than the |
| 20315 | ** atoi() library routine in RedHat 7.2. |
| 20316 | */ |
| 20317 | SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum){ |
| 20318 | i64 v = 0; |
| 20319 | int neg; |
| 20320 | int i, c; |
| 20321 | const char *zStart; |
| 20322 | while( sqlite3Isspace(*zNum) ) zNum++; |
| 20323 | if( *zNum=='-' ){ |
| 20324 | neg = 1; |
| 20325 | zNum++; |
| 20326 | }else if( *zNum=='+' ){ |
| 20327 | neg = 0; |
| 20328 | zNum++; |
| 20329 | }else{ |
| 20330 | neg = 0; |
| 20331 | } |
| 20332 | zStart = zNum; |
| 20333 | while( zNum[0]=='0' ){ zNum++; } /* Skip over leading zeros. Ticket #2454 */ |
| 20334 | for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ |
| 20335 | v = v*10 + c - '0'; |
| 20336 | } |
| 20337 | *pNum = neg ? -v : v; |
| 20338 | testcase( i==18 ); |
| 20339 | testcase( i==19 ); |
| 20340 | testcase( i==20 ); |
| 20341 | if( c!=0 || (i==0 && zStart==zNum) || i>19 ){ |
| 20342 | /* zNum is empty or contains non-numeric text or is longer |
| 20343 | ** than 19 digits (thus guaranting that it is too large) */ |
| 20344 | return 0; |
| 20345 | }else if( i<19 ){ |
| 20346 | /* Less than 19 digits, so we know that it fits in 64 bits */ |
| 20347 | return 1; |
| 20348 | }else{ |
| 20349 | /* 19-digit numbers must be no larger than 9223372036854775807 if positive |
| 20350 | ** or 9223372036854775808 if negative. Note that 9223372036854665808 |
| 20351 | ** is 2^63. */ |
| 20352 | return compare2pow63(zNum)<neg; |
| 20353 | } |
| 20354 | } |
| 20355 | |
| 20356 | /* |
| 20357 | ** The string zNum represents an unsigned integer. The zNum string |
| 20358 | ** consists of one or more digit characters and is terminated by |
| 20359 | ** a zero character. Any stray characters in zNum result in undefined |
| 20360 | ** behavior. |
| 20361 | ** |
| 20362 | ** If the unsigned integer that zNum represents will fit in a |
| 20363 | ** 64-bit signed integer, return TRUE. Otherwise return FALSE. |
| 20364 | ** |
| 20365 | ** If the negFlag parameter is true, that means that zNum really represents |
| 20366 | ** a negative number. (The leading "-" is omitted from zNum.) This |
| 20367 | ** parameter is needed to determine a boundary case. A string |
| 20368 | ** of "9223373036854775808" returns false if negFlag is false or true |
| 20369 | ** if negFlag is true. |
| 20370 | ** |
| 20371 | ** Leading zeros are ignored. |
| 20372 | */ |
| 20373 | SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *zNum, int negFlag){ |
| 20374 | int i; |
| 20375 | int neg = 0; |
| 20376 | |
| 20377 | assert( zNum[0]>='0' && zNum[0]<='9' ); /* zNum is an unsigned number */ |
| 20378 | |
| 20379 | if( negFlag ) neg = 1-neg; |
| 20380 | while( *zNum=='0' ){ |
| 20381 | zNum++; /* Skip leading zeros. Ticket #2454 */ |
| 20382 | } |
| 20383 | for(i=0; zNum[i]; i++){ assert( zNum[i]>='0' && zNum[i]<='9' ); } |
| 20384 | testcase( i==18 ); |
| 20385 | testcase( i==19 ); |
| 20386 | testcase( i==20 ); |
| 20387 | if( i<19 ){ |
| 20388 | /* Guaranteed to fit if less than 19 digits */ |
| 20389 | return 1; |
| 20390 | }else if( i>19 ){ |
| 20391 | /* Guaranteed to be too big if greater than 19 digits */ |
| 20392 | return 0; |
| 20393 | }else{ |
| 20394 | /* Compare against 2^63. */ |
| 20395 | return compare2pow63(zNum)<neg; |
| 20396 | } |
| 20397 | } |
| 20398 | |
| 20399 | /* |
| 20400 | ** If zNum represents an integer that will fit in 32-bits, then set |
| @@ -54149,17 +54105,13 @@ | |
| 54149 | return pMem->u.i; |
| 54150 | }else if( flags & MEM_Real ){ |
| 54151 | return doubleToInt64(pMem->r); |
| 54152 | }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 54153 | i64 value; |
| 54154 | pMem->flags |= MEM_Str; |
| 54155 | if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) |
| 54156 | || sqlite3VdbeMemNulTerminate(pMem) ){ |
| 54157 | return 0; |
| 54158 | } |
| 54159 | assert( pMem->z ); |
| 54160 | sqlite3Atoi64(pMem->z, &value); |
| 54161 | return value; |
| 54162 | }else{ |
| 54163 | return 0; |
| 54164 | } |
| 54165 | } |
| @@ -54185,11 +54137,11 @@ | |
| 54185 | || sqlite3VdbeMemNulTerminate(pMem) ){ |
| 54186 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54187 | return (double)0; |
| 54188 | } |
| 54189 | assert( pMem->z ); |
| 54190 | sqlite3AtoF(pMem->z, &val); |
| 54191 | return val; |
| 54192 | }else{ |
| 54193 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54194 | return (double)0; |
| 54195 | } |
| @@ -54258,25 +54210,23 @@ | |
| 54258 | ** Every effort is made to force the conversion, even if the input |
| 54259 | ** is a string that does not look completely like a number. Convert |
| 54260 | ** as much of the string as we can and ignore the rest. |
| 54261 | */ |
| 54262 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){ |
| 54263 | int rc; |
| 54264 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ); |
| 54265 | assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); |
| 54266 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 54267 | rc = sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8); |
| 54268 | if( rc ) return rc; |
| 54269 | rc = sqlite3VdbeMemNulTerminate(pMem); |
| 54270 | if( rc ) return rc; |
| 54271 | if( sqlite3Atoi64(pMem->z, &pMem->u.i) ){ |
| 54272 | MemSetTypeFlag(pMem, MEM_Int); |
| 54273 | }else{ |
| 54274 | pMem->r = sqlite3VdbeRealValue(pMem); |
| 54275 | MemSetTypeFlag(pMem, MEM_Real); |
| 54276 | sqlite3VdbeIntegerAffinity(pMem); |
| 54277 | } |
| 54278 | return SQLITE_OK; |
| 54279 | } |
| 54280 | |
| 54281 | /* |
| 54282 | ** Delete any previous value and set the value stored in *pMem to NULL. |
| @@ -54815,10 +54765,12 @@ | |
| 54815 | sqlite3_value **ppVal /* Write the new value here */ |
| 54816 | ){ |
| 54817 | int op; |
| 54818 | char *zVal = 0; |
| 54819 | sqlite3_value *pVal = 0; |
| 54820 | |
| 54821 | if( !pExpr ){ |
| 54822 | *ppVal = 0; |
| 54823 | return SQLITE_OK; |
| 54824 | } |
| @@ -54831,35 +54783,50 @@ | |
| 54831 | #ifdef SQLITE_ENABLE_STAT2 |
| 54832 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 54833 | #else |
| 54834 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 54835 | #endif |
| 54836 | |
| 54837 | if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){ |
| 54838 | pVal = sqlite3ValueNew(db); |
| 54839 | if( pVal==0 ) goto no_mem; |
| 54840 | if( ExprHasProperty(pExpr, EP_IntValue) ){ |
| 54841 | sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue); |
| 54842 | }else{ |
| 54843 | zVal = sqlite3DbStrDup(db, pExpr->u.zToken); |
| 54844 | if( zVal==0 ) goto no_mem; |
| 54845 | sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); |
| 54846 | if( op==TK_FLOAT ) pVal->type = SQLITE_FLOAT; |
| 54847 | } |
| 54848 | if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){ |
| 54849 | sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); |
| 54850 | }else{ |
| 54851 | sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); |
| 54852 | } |
| 54853 | if( enc!=SQLITE_UTF8 ){ |
| 54854 | sqlite3VdbeChangeEncoding(pVal, enc); |
| 54855 | } |
| 54856 | }else if( op==TK_UMINUS ) { |
| 54857 | if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){ |
| 54858 | pVal->u.i = -1 * pVal->u.i; |
| 54859 | /* (double)-1 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54860 | pVal->r = (double)-1 * pVal->r; |
| 54861 | } |
| 54862 | } |
| 54863 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 54864 | else if( op==TK_BLOB ){ |
| 54865 | int nVal; |
| @@ -59770,35 +59737,21 @@ | |
| 59770 | ** looks like a number, convert it into a number. If it does not |
| 59771 | ** look like a number, leave it alone. |
| 59772 | */ |
| 59773 | static void applyNumericAffinity(Mem *pRec){ |
| 59774 | if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){ |
| 59775 | int realnum; |
| 59776 | u8 enc = pRec->enc; |
| 59777 | sqlite3VdbeMemNulTerminate(pRec); |
| 59778 | if( (pRec->flags&MEM_Str) && sqlite3IsNumber(pRec->z, &realnum, enc) ){ |
| 59779 | i64 value; |
| 59780 | char *zUtf8 = pRec->z; |
| 59781 | #ifndef SQLITE_OMIT_UTF16 |
| 59782 | if( enc!=SQLITE_UTF8 ){ |
| 59783 | assert( pRec->db ); |
| 59784 | zUtf8 = sqlite3Utf16to8(pRec->db, pRec->z, pRec->n, enc); |
| 59785 | if( !zUtf8 ) return; |
| 59786 | } |
| 59787 | #endif |
| 59788 | if( !realnum && sqlite3Atoi64(zUtf8, &value) ){ |
| 59789 | pRec->u.i = value; |
| 59790 | MemSetTypeFlag(pRec, MEM_Int); |
| 59791 | }else{ |
| 59792 | sqlite3AtoF(zUtf8, &pRec->r); |
| 59793 | MemSetTypeFlag(pRec, MEM_Real); |
| 59794 | } |
| 59795 | #ifndef SQLITE_OMIT_UTF16 |
| 59796 | if( enc!=SQLITE_UTF8 ){ |
| 59797 | sqlite3DbFree(pRec->db, zUtf8); |
| 59798 | } |
| 59799 | #endif |
| 59800 | } |
| 59801 | } |
| 59802 | } |
| 59803 | |
| 59804 | /* |
| @@ -61580,11 +61533,10 @@ | |
| 61580 | ** integers, for space efficiency, but after extraction we want them |
| 61581 | ** to have only a real value. |
| 61582 | */ |
| 61583 | case OP_RealAffinity: { /* in1 */ |
| 61584 | pIn1 = &aMem[pOp->p1]; |
| 61585 | memAboutToChange(p, pIn1); |
| 61586 | if( pIn1->flags & MEM_Int ){ |
| 61587 | sqlite3VdbeMemRealify(pIn1); |
| 61588 | } |
| 61589 | break; |
| 61590 | } |
| @@ -61623,11 +61575,10 @@ | |
| 61623 | ** |
| 61624 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61625 | */ |
| 61626 | case OP_ToBlob: { /* same as TK_TO_BLOB, in1 */ |
| 61627 | pIn1 = &aMem[pOp->p1]; |
| 61628 | memAboutToChange(p, pIn1); |
| 61629 | if( pIn1->flags & MEM_Null ) break; |
| 61630 | if( (pIn1->flags & MEM_Blob)==0 ){ |
| 61631 | applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); |
| 61632 | assert( pIn1->flags & MEM_Str || db->mallocFailed ); |
| 61633 | MemSetTypeFlag(pIn1, MEM_Blob); |
| @@ -61648,14 +61599,11 @@ | |
| 61648 | ** |
| 61649 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61650 | */ |
| 61651 | case OP_ToNumeric: { /* same as TK_TO_NUMERIC, in1 */ |
| 61652 | pIn1 = &aMem[pOp->p1]; |
| 61653 | memAboutToChange(p, pIn1); |
| 61654 | if( (pIn1->flags & (MEM_Null|MEM_Int|MEM_Real))==0 ){ |
| 61655 | sqlite3VdbeMemNumerify(pIn1); |
| 61656 | } |
| 61657 | break; |
| 61658 | } |
| 61659 | #endif /* SQLITE_OMIT_CAST */ |
| 61660 | |
| 61661 | /* Opcode: ToInt P1 * * * * |
| @@ -61667,11 +61615,10 @@ | |
| 61667 | ** |
| 61668 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61669 | */ |
| 61670 | case OP_ToInt: { /* same as TK_TO_INT, in1 */ |
| 61671 | pIn1 = &aMem[pOp->p1]; |
| 61672 | memAboutToChange(p, pIn1); |
| 61673 | if( (pIn1->flags & MEM_Null)==0 ){ |
| 61674 | sqlite3VdbeMemIntegerify(pIn1); |
| 61675 | } |
| 61676 | break; |
| 61677 | } |
| @@ -61781,12 +61728,10 @@ | |
| 61781 | u16 flags3; /* Copy of initial value of pIn3->flags */ |
| 61782 | #endif /* local variables moved into u.ai */ |
| 61783 | |
| 61784 | pIn1 = &aMem[pOp->p1]; |
| 61785 | pIn3 = &aMem[pOp->p3]; |
| 61786 | memAboutToChange(p, pIn1); |
| 61787 | memAboutToChange(p, pIn3); |
| 61788 | u.ai.flags1 = pIn1->flags; |
| 61789 | u.ai.flags3 = pIn3->flags; |
| 61790 | if( (pIn1->flags | pIn3->flags)&MEM_Null ){ |
| 61791 | /* One or both operands are NULL */ |
| 61792 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| @@ -62415,11 +62360,10 @@ | |
| 62415 | assert( u.an.zAffinity[pOp->p2]==0 ); |
| 62416 | pIn1 = &aMem[pOp->p1]; |
| 62417 | while( (u.an.cAff = *(u.an.zAffinity++))!=0 ){ |
| 62418 | assert( pIn1 <= &p->aMem[p->nMem] ); |
| 62419 | assert( memIsValid(pIn1) ); |
| 62420 | memAboutToChange(p, pIn1); |
| 62421 | ExpandBlob(pIn1); |
| 62422 | applyAffinity(pIn1, u.an.cAff, encoding); |
| 62423 | pIn1++; |
| 62424 | } |
| 62425 | break; |
| @@ -62495,11 +62439,10 @@ | |
| 62495 | ** out how much space is required for the new record. |
| 62496 | */ |
| 62497 | for(u.ao.pRec=u.ao.pData0; u.ao.pRec<=u.ao.pLast; u.ao.pRec++){ |
| 62498 | assert( memIsValid(u.ao.pRec) ); |
| 62499 | if( u.ao.zAffinity ){ |
| 62500 | memAboutToChange(p, u.ao.pRec); |
| 62501 | applyAffinity(u.ao.pRec, u.ao.zAffinity[u.ao.pRec-u.ao.pData0], encoding); |
| 62502 | } |
| 62503 | if( u.ao.pRec->flags&MEM_Zero && u.ao.pRec->n>0 ){ |
| 62504 | sqlite3VdbeMemExpandBlob(u.ao.pRec); |
| 62505 | } |
| @@ -68880,11 +68823,11 @@ | |
| 68880 | pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 68881 | }else if( z[0]=='?' ){ |
| 68882 | /* Wildcard of the form "?nnn". Convert "nnn" to an integer and |
| 68883 | ** use it as the variable number */ |
| 68884 | i64 i; |
| 68885 | int bOk = sqlite3Atoi64(&z[1], &i); |
| 68886 | pExpr->iColumn = (ynVar)i; |
| 68887 | testcase( i==0 ); |
| 68888 | testcase( i==1 ); |
| 68889 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); |
| 68890 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); |
| @@ -70243,11 +70186,11 @@ | |
| 70243 | */ |
| 70244 | static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){ |
| 70245 | if( ALWAYS(z!=0) ){ |
| 70246 | double value; |
| 70247 | char *zV; |
| 70248 | sqlite3AtoF(z, &value); |
| 70249 | assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */ |
| 70250 | if( negateFlag ) value = -value; |
| 70251 | zV = dup8bytes(v, (char*)&value); |
| 70252 | sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL); |
| 70253 | } |
| @@ -70257,28 +70200,27 @@ | |
| 70257 | |
| 70258 | /* |
| 70259 | ** Generate an instruction that will put the integer describe by |
| 70260 | ** text z[0..n-1] into register iMem. |
| 70261 | ** |
| 70262 | ** The z[] string will probably not be zero-terminated. But the |
| 70263 | ** z[n] character is guaranteed to be something that does not look |
| 70264 | ** like the continuation of the number. |
| 70265 | */ |
| 70266 | static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){ |
| 70267 | Vdbe *v = pParse->pVdbe; |
| 70268 | if( pExpr->flags & EP_IntValue ){ |
| 70269 | int i = pExpr->u.iValue; |
| 70270 | if( negFlag ) i = -i; |
| 70271 | sqlite3VdbeAddOp2(v, OP_Integer, i, iMem); |
| 70272 | }else{ |
| 70273 | const char *z = pExpr->u.zToken; |
| 70274 | assert( z!=0 ); |
| 70275 | if( sqlite3FitsIn64Bits(z, negFlag) ){ |
| 70276 | i64 value; |
| 70277 | char *zV; |
| 70278 | sqlite3Atoi64(z, &value); |
| 70279 | if( negFlag ) value = -value; |
| 70280 | zV = dup8bytes(v, (char*)&value); |
| 70281 | sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64); |
| 70282 | }else{ |
| 70283 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 70284 | sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z); |
| @@ -79414,11 +79356,11 @@ | |
| 79414 | zBuf = sqlite3_mprintf("%.*f",n,r); |
| 79415 | if( zBuf==0 ){ |
| 79416 | sqlite3_result_error_nomem(context); |
| 79417 | return; |
| 79418 | } |
| 79419 | sqlite3AtoF(zBuf, &r); |
| 79420 | sqlite3_free(zBuf); |
| 79421 | } |
| 79422 | sqlite3_result_double(context, r); |
| 79423 | } |
| 79424 | #endif |
| @@ -85472,11 +85414,11 @@ | |
| 85472 | */ |
| 85473 | if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){ |
| 85474 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 85475 | i64 iLimit = -2; |
| 85476 | if( zRight ){ |
| 85477 | sqlite3Atoi64(zRight, &iLimit); |
| 85478 | if( iLimit<-1 ) iLimit = -1; |
| 85479 | } |
| 85480 | iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); |
| 85481 | returnSingleInt(pParse, "journal_size_limit", iLimit); |
| 85482 | }else |
| @@ -96380,11 +96322,12 @@ | |
| 96380 | |
| 96381 | /* |
| 96382 | ** Required because bestIndex() is called by bestOrClauseIndex() |
| 96383 | */ |
| 96384 | static void bestIndex( |
| 96385 | Parse*, WhereClause*, struct SrcList_item*, Bitmask, ExprList*, WhereCost*); |
| 96386 | |
| 96387 | /* |
| 96388 | ** This routine attempts to find an scanning strategy that can be used |
| 96389 | ** to optimize an 'OR' expression that is part of a WHERE clause. |
| 96390 | ** |
| @@ -96393,11 +96336,12 @@ | |
| 96393 | */ |
| 96394 | static void bestOrClauseIndex( |
| 96395 | Parse *pParse, /* The parsing context */ |
| 96396 | WhereClause *pWC, /* The WHERE clause */ |
| 96397 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 96398 | Bitmask notReady, /* Mask of cursors that are not available */ |
| 96399 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 96400 | WhereCost *pCost /* Lowest cost query plan */ |
| 96401 | ){ |
| 96402 | #ifndef SQLITE_OMIT_OR_OPTIMIZATION |
| 96403 | const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| @@ -96429,19 +96373,19 @@ | |
| 96429 | WHERETRACE(("... Multi-index OR testing for term %d of %d....\n", |
| 96430 | (pOrTerm - pOrWC->a), (pTerm - pWC->a) |
| 96431 | )); |
| 96432 | if( pOrTerm->eOperator==WO_AND ){ |
| 96433 | WhereClause *pAndWC = &pOrTerm->u.pAndInfo->wc; |
| 96434 | bestIndex(pParse, pAndWC, pSrc, notReady, 0, &sTermCost); |
| 96435 | }else if( pOrTerm->leftCursor==iCur ){ |
| 96436 | WhereClause tempWC; |
| 96437 | tempWC.pParse = pWC->pParse; |
| 96438 | tempWC.pMaskSet = pWC->pMaskSet; |
| 96439 | tempWC.op = TK_AND; |
| 96440 | tempWC.a = pOrTerm; |
| 96441 | tempWC.nTerm = 1; |
| 96442 | bestIndex(pParse, &tempWC, pSrc, notReady, 0, &sTermCost); |
| 96443 | }else{ |
| 96444 | continue; |
| 96445 | } |
| 96446 | rTotal += sTermCost.rCost; |
| 96447 | nRow += sTermCost.nRow; |
| @@ -96884,11 +96828,12 @@ | |
| 96884 | */ |
| 96885 | static void bestVirtualIndex( |
| 96886 | Parse *pParse, /* The parsing context */ |
| 96887 | WhereClause *pWC, /* The WHERE clause */ |
| 96888 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 96889 | Bitmask notReady, /* Mask of cursors that are not available */ |
| 96890 | ExprList *pOrderBy, /* The order by clause */ |
| 96891 | WhereCost *pCost, /* Lowest cost query plan */ |
| 96892 | sqlite3_index_info **ppIdxInfo /* Index information passed to xBestIndex */ |
| 96893 | ){ |
| 96894 | Table *pTab = pSrc->pTab; |
| @@ -97014,11 +96959,11 @@ | |
| 97014 | pIdxInfo->nOrderBy = nOrderBy; |
| 97015 | |
| 97016 | /* Try to find a more efficient access pattern by using multiple indexes |
| 97017 | ** to optimize an OR expression within the WHERE clause. |
| 97018 | */ |
| 97019 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost); |
| 97020 | } |
| 97021 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 97022 | |
| 97023 | /* |
| 97024 | ** Argument pIdx is a pointer to an index structure that has an array of |
| @@ -97295,11 +97240,12 @@ | |
| 97295 | */ |
| 97296 | static void bestBtreeIndex( |
| 97297 | Parse *pParse, /* The parsing context */ |
| 97298 | WhereClause *pWC, /* The WHERE clause */ |
| 97299 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 97300 | Bitmask notReady, /* Mask of cursors that are not available */ |
| 97301 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 97302 | WhereCost *pCost /* Lowest cost query plan */ |
| 97303 | ){ |
| 97304 | int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| 97305 | Index *pProbe; /* An index we are evaluating */ |
| @@ -97557,29 +97503,29 @@ | |
| 97557 | ** of output rows, adjust the nRow value accordingly. This only |
| 97558 | ** matters if the current index is the least costly, so do not bother |
| 97559 | ** with this step if we already know this index will not be chosen. |
| 97560 | ** Also, never reduce the output row count below 2 using this step. |
| 97561 | ** |
| 97562 | ** Do not reduce the output row count if pSrc is the only table that |
| 97563 | ** is notReady; if notReady is a power of two. This will be the case |
| 97564 | ** when the main sqlite3WhereBegin() loop is scanning for a table with |
| 97565 | ** and "optimal" index, and on such a scan the output row count |
| 97566 | ** reduction is not valid because it does not update the "pCost->used" |
| 97567 | ** bitmap. The notReady bitmap will also be a power of two when we |
| 97568 | ** are scanning for the last table in a 64-way join. We are willing |
| 97569 | ** to bypass this optimization in that corner case. |
| 97570 | */ |
| 97571 | if( nRow>2 && cost<=pCost->rCost && (notReady & (notReady-1))!=0 ){ |
| 97572 | int k; /* Loop counter */ |
| 97573 | int nSkipEq = nEq; /* Number of == constraints to skip */ |
| 97574 | int nSkipRange = nBound; /* Number of < constraints to skip */ |
| 97575 | Bitmask thisTab; /* Bitmap for pSrc */ |
| 97576 | |
| 97577 | thisTab = getMask(pWC->pMaskSet, iCur); |
| 97578 | for(pTerm=pWC->a, k=pWC->nTerm; nRow>2 && k; k--, pTerm++){ |
| 97579 | if( pTerm->wtFlags & TERM_VIRTUAL ) continue; |
| 97580 | if( (pTerm->prereqAll & notReady)!=thisTab ) continue; |
| 97581 | if( pTerm->eOperator & (WO_EQ|WO_IN|WO_ISNULL) ){ |
| 97582 | if( nSkipEq ){ |
| 97583 | /* Ignore the first nEq equality matches since the index |
| 97584 | ** has already accounted for these */ |
| 97585 | nSkipEq--; |
| @@ -97657,11 +97603,11 @@ | |
| 97657 | WHERETRACE(("best index is: %s\n", |
| 97658 | ((pCost->plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ? "none" : |
| 97659 | pCost->plan.u.pIdx ? pCost->plan.u.pIdx->zName : "ipk") |
| 97660 | )); |
| 97661 | |
| 97662 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost); |
| 97663 | bestAutomaticIndex(pParse, pWC, pSrc, notReady, pCost); |
| 97664 | pCost->plan.wsFlags |= eqTermMask; |
| 97665 | } |
| 97666 | |
| 97667 | /* |
| @@ -97672,26 +97618,27 @@ | |
| 97672 | */ |
| 97673 | static void bestIndex( |
| 97674 | Parse *pParse, /* The parsing context */ |
| 97675 | WhereClause *pWC, /* The WHERE clause */ |
| 97676 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 97677 | Bitmask notReady, /* Mask of cursors that are not available */ |
| 97678 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 97679 | WhereCost *pCost /* Lowest cost query plan */ |
| 97680 | ){ |
| 97681 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 97682 | if( IsVirtual(pSrc->pTab) ){ |
| 97683 | sqlite3_index_info *p = 0; |
| 97684 | bestVirtualIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost, &p); |
| 97685 | if( p->needToFreeIdxStr ){ |
| 97686 | sqlite3_free(p->idxStr); |
| 97687 | } |
| 97688 | sqlite3DbFree(pParse->db, p); |
| 97689 | }else |
| 97690 | #endif |
| 97691 | { |
| 97692 | bestBtreeIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost); |
| 97693 | } |
| 97694 | } |
| 97695 | |
| 97696 | /* |
| 97697 | ** Disable a term in the WHERE clause. Except, do not disable the term |
| @@ -98902,14 +98849,20 @@ | |
| 98902 | ** by waiting for other tables to run first. This "optimal" test works |
| 98903 | ** by first assuming that the FROM clause is on the inner loop and finding |
| 98904 | ** its query plan, then checking to see if that query plan uses any |
| 98905 | ** other FROM clause terms that are notReady. If no notReady terms are |
| 98906 | ** used then the "optimal" query plan works. |
| 98907 | ** |
| 98908 | ** The second loop iteration is only performed if no optimal scan |
| 98909 | ** strategies were found by the first loop. This 2nd iteration is used to |
| 98910 | ** search for the lowest cost scan overall. |
| 98911 | ** |
| 98912 | ** Previous versions of SQLite performed only the second iteration - |
| 98913 | ** the next outermost loop was always that with the lowest overall |
| 98914 | ** cost. However, this meant that SQLite could select the wrong plan |
| 98915 | ** for scripts such as the following: |
| @@ -98925,11 +98878,11 @@ | |
| 98925 | ** algorithm may choose to use t2 for the outer loop, which is a much |
| 98926 | ** costlier approach. |
| 98927 | */ |
| 98928 | nUnconstrained = 0; |
| 98929 | notIndexed = 0; |
| 98930 | for(isOptimal=(iFrom<nTabList-1); isOptimal>=0; isOptimal--){ |
| 98931 | Bitmask mask; /* Mask of tables not yet ready */ |
| 98932 | for(j=iFrom, pTabItem=&pTabList->a[j]; j<nTabList; j++, pTabItem++){ |
| 98933 | int doNotReorder; /* True if this table should not be reordered */ |
| 98934 | WhereCost sCost; /* Cost information from best[Virtual]Index() */ |
| 98935 | ExprList *pOrderBy; /* ORDER BY clause for index to optimize */ |
| @@ -98947,15 +98900,17 @@ | |
| 98947 | |
| 98948 | assert( pTabItem->pTab ); |
| 98949 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 98950 | if( IsVirtual(pTabItem->pTab) ){ |
| 98951 | sqlite3_index_info **pp = &pWInfo->a[j].pIdxInfo; |
| 98952 | bestVirtualIndex(pParse, pWC, pTabItem, mask, pOrderBy, &sCost, pp); |
| 98953 | }else |
| 98954 | #endif |
| 98955 | { |
| 98956 | bestBtreeIndex(pParse, pWC, pTabItem, mask, pOrderBy, &sCost); |
| 98957 | } |
| 98958 | assert( isOptimal || (sCost.used¬Ready)==0 ); |
| 98959 | |
| 98960 | /* If an INDEXED BY clause is present, then the plan must use that |
| 98961 | ** index if it uses any index at all */ |
| 98962 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.3" |
| 654 | #define SQLITE_VERSION_NUMBER 3007003 |
| 655 | #define SQLITE_SOURCE_ID "2010-10-04 23:55:51 ece641eb8951c6314cedbdb3243f91cb199c3239" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -10570,11 +10570,10 @@ | |
| 10570 | |
| 10571 | /* |
| 10572 | ** Internal function prototypes |
| 10573 | */ |
| 10574 | SQLITE_PRIVATE int sqlite3StrICmp(const char *, const char *); |
| 10575 | SQLITE_PRIVATE int sqlite3Strlen30(const char*); |
| 10576 | #define sqlite3StrNICmp sqlite3_strnicmp |
| 10577 | |
| 10578 | SQLITE_PRIVATE int sqlite3MallocInit(void); |
| 10579 | SQLITE_PRIVATE void sqlite3MallocEnd(void); |
| @@ -10890,13 +10889,12 @@ | |
| 10889 | SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*); |
| 10890 | SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*); |
| 10891 | SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*); |
| 10892 | SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*); |
| 10893 | SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); |
| 10894 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8); |
| 10895 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 10896 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 10897 | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); |
| 10898 | SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8**); |
| 10899 | |
| 10900 | /* |
| @@ -10938,11 +10936,11 @@ | |
| 10936 | SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *); |
| 10937 | SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *, Table *); |
| 10938 | SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2); |
| 10939 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); |
| 10940 | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr); |
| 10941 | SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); |
| 10942 | SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...); |
| 10943 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 10944 | SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
| 10945 | SQLITE_PRIVATE const char *sqlite3ErrStr(int); |
| 10946 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse); |
| @@ -12637,16 +12635,10 @@ | |
| 12635 | end_getDigits: |
| 12636 | va_end(ap); |
| 12637 | return cnt; |
| 12638 | } |
| 12639 | |
| 12640 | /* |
| 12641 | ** Parse a timezone extension on the end of a date-time. |
| 12642 | ** The extension is of the form: |
| 12643 | ** |
| 12644 | ** (+/-)HH:MM |
| @@ -12844,21 +12836,19 @@ | |
| 12836 | static int parseDateOrTime( |
| 12837 | sqlite3_context *context, |
| 12838 | const char *zDate, |
| 12839 | DateTime *p |
| 12840 | ){ |
| 12841 | double r; |
| 12842 | if( parseYyyyMmDd(zDate,p)==0 ){ |
| 12843 | return 0; |
| 12844 | }else if( parseHhMmSs(zDate, p)==0 ){ |
| 12845 | return 0; |
| 12846 | }else if( sqlite3StrICmp(zDate,"now")==0){ |
| 12847 | setDateTimeToCurrent(context, p); |
| 12848 | return 0; |
| 12849 | }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){ |
| 12850 | p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5); |
| 12851 | p->validJD = 1; |
| 12852 | return 0; |
| 12853 | } |
| 12854 | return 1; |
| @@ -13075,12 +13065,13 @@ | |
| 13065 | ** |
| 13066 | ** Move the date to the same time on the next occurrence of |
| 13067 | ** weekday N where 0==Sunday, 1==Monday, and so forth. If the |
| 13068 | ** date is already on the appropriate weekday, this is a no-op. |
| 13069 | */ |
| 13070 | if( strncmp(z, "weekday ", 8)==0 |
| 13071 | && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8) |
| 13072 | && (n=(int)r)==r && n>=0 && r<7 ){ |
| 13073 | sqlite3_int64 Z; |
| 13074 | computeYMD_HMS(p); |
| 13075 | p->validTZ = 0; |
| 13076 | p->validJD = 0; |
| 13077 | computeJD(p); |
| @@ -13131,12 +13122,15 @@ | |
| 13122 | case '6': |
| 13123 | case '7': |
| 13124 | case '8': |
| 13125 | case '9': { |
| 13126 | double rRounder; |
| 13127 | for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){} |
| 13128 | if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){ |
| 13129 | rc = 1; |
| 13130 | break; |
| 13131 | } |
| 13132 | if( z[n]==':' ){ |
| 13133 | /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the |
| 13134 | ** specified number of hours, minutes, seconds, and fractional seconds |
| 13135 | ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be |
| 13136 | ** omitted. |
| @@ -17502,11 +17496,11 @@ | |
| 17496 | sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n); |
| 17497 | }else{ |
| 17498 | sqlite3MemoryAlarm(0, 0, 0); |
| 17499 | } |
| 17500 | excess = sqlite3_memory_used() - n; |
| 17501 | if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff)); |
| 17502 | return priorLimit; |
| 17503 | } |
| 17504 | SQLITE_API void sqlite3_soft_heap_limit(int n){ |
| 17505 | if( n<0 ) n = 0; |
| 17506 | sqlite3_soft_heap_limit64(n); |
| @@ -20096,125 +20090,115 @@ | |
| 20090 | while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } |
| 20091 | return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b]; |
| 20092 | } |
| 20093 | |
| 20094 | /* |
| 20095 | ** The string z[] is an text representation of a real number. |
| 20096 | ** Convert this string to a double and write it into *pResult. |
| 20097 | ** |
| 20098 | ** The string z[] is length bytes in length (bytes, not characters) and |
| 20099 | ** uses the encoding enc. The string is not necessarily zero-terminated. |
| 20100 | ** |
| 20101 | ** Return TRUE if the result is a valid real number (or integer) and FALSE |
| 20102 | ** if the string is empty or contains extraneous text. Valid numbers |
| 20103 | ** are in one of these formats: |
| 20104 | ** |
| 20105 | ** [+-]digits[E[+-]digits] |
| 20106 | ** [+-]digits.[digits][E[+-]digits] |
| 20107 | ** [+-].digits[E[+-]digits] |
| 20108 | ** |
| 20109 | ** Leading and trailing whitespace is ignored for the purpose of determining |
| 20110 | ** validity. |
| 20111 | ** |
| 20112 | ** If some prefix of the input string is a valid number, this routine |
| 20113 | ** returns FALSE but it still converts the prefix and writes the result |
| 20114 | ** into *pResult. |
| 20115 | */ |
| 20116 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ |
| 20117 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 20118 | int incr = (enc==SQLITE_UTF8?1:2); |
| 20119 | const char *zEnd = z + length; |
| 20120 | /* sign * significand * (10 ^ (esign * exponent)) */ |
| 20121 | int sign = 1; /* sign of significand */ |
| 20122 | i64 s = 0; /* significand */ |
| 20123 | int d = 0; /* adjust exponent for shifting decimal point */ |
| 20124 | int esign = 1; /* sign of exponent */ |
| 20125 | int e = 0; /* exponent */ |
| 20126 | int eValid = 1; /* True exponent is either not used or is well-formed */ |
| 20127 | double result; |
| 20128 | int nDigits = 0; |
| 20129 | |
| 20130 | *pResult = 0.0; /* Default return value, in case of an error */ |
| 20131 | |
| 20132 | if( enc==SQLITE_UTF16BE ) z++; |
| 20133 | |
| 20134 | /* skip leading spaces */ |
| 20135 | while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; |
| 20136 | if( z>=zEnd ) return 0; |
| 20137 | |
| 20138 | /* get sign of significand */ |
| 20139 | if( *z=='-' ){ |
| 20140 | sign = -1; |
| 20141 | z+=incr; |
| 20142 | }else if( *z=='+' ){ |
| 20143 | z+=incr; |
| 20144 | } |
| 20145 | |
| 20146 | /* skip leading zeroes */ |
| 20147 | while( z<zEnd && z[0]=='0' ) z+=incr, nDigits++; |
| 20148 | |
| 20149 | /* copy max significant digits to significand */ |
| 20150 | while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ |
| 20151 | s = s*10 + (*z - '0'); |
| 20152 | z+=incr, nDigits++; |
| 20153 | } |
| 20154 | |
| 20155 | /* skip non-significant significand digits |
| 20156 | ** (increase exponent by d to shift decimal left) */ |
| 20157 | while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++; |
| 20158 | if( z>=zEnd ) goto do_atof_calc; |
| 20159 | |
| 20160 | /* if decimal point is present */ |
| 20161 | if( *z=='.' ){ |
| 20162 | z+=incr; |
| 20163 | /* copy digits from after decimal to significand |
| 20164 | ** (decrease exponent by d to shift decimal right) */ |
| 20165 | while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){ |
| 20166 | s = s*10 + (*z - '0'); |
| 20167 | z+=incr, nDigits++, d--; |
| 20168 | } |
| 20169 | /* skip non-significant digits */ |
| 20170 | while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++; |
| 20171 | } |
| 20172 | if( z>=zEnd ) goto do_atof_calc; |
| 20173 | |
| 20174 | /* if exponent is present */ |
| 20175 | if( *z=='e' || *z=='E' ){ |
| 20176 | z+=incr; |
| 20177 | eValid = 0; |
| 20178 | if( z>=zEnd ) goto do_atof_calc; |
| 20179 | /* get sign of exponent */ |
| 20180 | if( *z=='-' ){ |
| 20181 | esign = -1; |
| 20182 | z+=incr; |
| 20183 | }else if( *z=='+' ){ |
| 20184 | z+=incr; |
| 20185 | } |
| 20186 | /* copy digits to exponent */ |
| 20187 | while( z<zEnd && sqlite3Isdigit(*z) ){ |
| 20188 | e = e*10 + (*z - '0'); |
| 20189 | z+=incr; |
| 20190 | eValid = 1; |
| 20191 | } |
| 20192 | } |
| 20193 | |
| 20194 | /* skip trailing spaces */ |
| 20195 | if( nDigits && eValid ){ |
| 20196 | while( z<zEnd && sqlite3Isspace(*z) ) z+=incr; |
| 20197 | } |
| 20198 | |
| 20199 | do_atof_calc: |
| 20200 | /* adjust exponent by d, and update sign */ |
| 20201 | e = (e*esign) + d; |
| 20202 | if( e<0 ) { |
| 20203 | esign = -1; |
| 20204 | e *= -1; |
| @@ -20269,132 +20253,104 @@ | |
| 20253 | } |
| 20254 | |
| 20255 | /* store the result */ |
| 20256 | *pResult = result; |
| 20257 | |
| 20258 | /* return true if number and no extra non-whitespace chracters after */ |
| 20259 | return z>=zEnd && nDigits>0 && eValid; |
| 20260 | #else |
| 20261 | return !sqlite3Atoi64(z, pResult, length, enc); |
| 20262 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 20263 | } |
| 20264 | |
| 20265 | /* |
| 20266 | ** Compare the 19-character string zNum against the text representation |
| 20267 | ** value 2^63: 9223372036854775808. Return negative, zero, or positive |
| 20268 | ** if zNum is less than, equal to, or greater than the string. |
| 20269 | ** Note that zNum must contain exactly 19 characters. |
| 20270 | ** |
| 20271 | ** Unlike memcmp() this routine is guaranteed to return the difference |
| 20272 | ** in the values of the last digit if the only difference is in the |
| 20273 | ** last digit. So, for example, |
| 20274 | ** |
| 20275 | ** compare2pow63("9223372036854775800", 1) |
| 20276 | ** |
| 20277 | ** will return -8. |
| 20278 | */ |
| 20279 | static int compare2pow63(const char *zNum, int incr){ |
| 20280 | int c = 0; |
| 20281 | int i; |
| 20282 | /* 012345678901234567 */ |
| 20283 | const char *pow63 = "922337203685477580"; |
| 20284 | for(i=0; c==0 && i<18; i++){ |
| 20285 | c = (zNum[i*incr]-pow63[i])*10; |
| 20286 | } |
| 20287 | if( c==0 ){ |
| 20288 | c = zNum[18*incr] - '8'; |
| 20289 | testcase( c==(-1) ); |
| 20290 | testcase( c==0 ); |
| 20291 | testcase( c==(+1) ); |
| 20292 | } |
| 20293 | return c; |
| 20294 | } |
| 20295 | |
| 20296 | |
| 20297 | /* |
| 20298 | ** Convert zNum to a 64-bit signed integer and write |
| 20299 | ** the value of the integer into *pNum. |
| 20300 | ** If zNum is exactly 9223372036854665808, return 2. |
| 20301 | ** This is a special case as the context will determine |
| 20302 | ** if it is too big (used as a negative). |
| 20303 | ** If zNum is not an integer or is an integer that |
| 20304 | ** is too large to be expressed with 64 bits, |
| 20305 | ** then return 1. Otherwise return 0. |
| 20306 | ** |
| 20307 | ** length is the number of bytes in the string (bytes, not characters). |
| 20308 | ** The string is not necessarily zero-terminated. The encoding is |
| 20309 | ** given by enc. |
| 20310 | */ |
| 20311 | SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ |
| 20312 | int incr = (enc==SQLITE_UTF8?1:2); |
| 20313 | i64 v = 0; |
| 20314 | int neg = 0; /* assume positive */ |
| 20315 | int i; |
| 20316 | int c = 0; |
| 20317 | const char *zStart; |
| 20318 | const char *zEnd = zNum + length; |
| 20319 | if( enc==SQLITE_UTF16BE ) zNum++; |
| 20320 | while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr; |
| 20321 | if( zNum>=zEnd ) goto do_atoi_calc; |
| 20322 | if( *zNum=='-' ){ |
| 20323 | neg = 1; |
| 20324 | zNum+=incr; |
| 20325 | }else if( *zNum=='+' ){ |
| 20326 | zNum+=incr; |
| 20327 | } |
| 20328 | do_atoi_calc: |
| 20329 | zStart = zNum; |
| 20330 | while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */ |
| 20331 | for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){ |
| 20332 | v = v*10 + c - '0'; |
| 20333 | } |
| 20334 | *pNum = neg ? -v : v; |
| 20335 | testcase( i==18 ); |
| 20336 | testcase( i==19 ); |
| 20337 | testcase( i==20 ); |
| 20338 | if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){ |
| 20339 | /* zNum is empty or contains non-numeric text or is longer |
| 20340 | ** than 19 digits (thus guaranteeing that it is too large) */ |
| 20341 | return 1; |
| 20342 | }else if( i<19*incr ){ |
| 20343 | /* Less than 19 digits, so we know that it fits in 64 bits */ |
| 20344 | return 0; |
| 20345 | }else{ |
| 20346 | /* 19-digit numbers must be no larger than 9223372036854775807 if positive |
| 20347 | ** or 9223372036854775808 if negative. Note that 9223372036854665808 |
| 20348 | ** is 2^63. Return 1 if to large */ |
| 20349 | c=compare2pow63(zNum, incr); |
| 20350 | if( c==0 && neg==0 ) return 2; /* too big, exactly 9223372036854665808 */ |
| 20351 | return c<neg ? 0 : 1; |
| 20352 | } |
| 20353 | } |
| 20354 | |
| 20355 | /* |
| 20356 | ** If zNum represents an integer that will fit in 32-bits, then set |
| @@ -54149,17 +54105,13 @@ | |
| 54105 | return pMem->u.i; |
| 54106 | }else if( flags & MEM_Real ){ |
| 54107 | return doubleToInt64(pMem->r); |
| 54108 | }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 54109 | i64 value; |
| 54110 | assert( pMem->z || pMem->n==0 ); |
| 54111 | testcase( pMem->z==0 ); |
| 54112 | sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc); |
| 54113 | return value; |
| 54114 | }else{ |
| 54115 | return 0; |
| 54116 | } |
| 54117 | } |
| @@ -54185,11 +54137,11 @@ | |
| 54137 | || sqlite3VdbeMemNulTerminate(pMem) ){ |
| 54138 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54139 | return (double)0; |
| 54140 | } |
| 54141 | assert( pMem->z ); |
| 54142 | sqlite3AtoF(pMem->z, &val, pMem->n, SQLITE_UTF8); |
| 54143 | return val; |
| 54144 | }else{ |
| 54145 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54146 | return (double)0; |
| 54147 | } |
| @@ -54258,25 +54210,23 @@ | |
| 54210 | ** Every effort is made to force the conversion, even if the input |
| 54211 | ** is a string that does not look completely like a number. Convert |
| 54212 | ** as much of the string as we can and ignore the rest. |
| 54213 | */ |
| 54214 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){ |
| 54215 | if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){ |
| 54216 | assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); |
| 54217 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 54218 | if( 0==sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc) ){ |
| 54219 | MemSetTypeFlag(pMem, MEM_Int); |
| 54220 | }else{ |
| 54221 | pMem->r = sqlite3VdbeRealValue(pMem); |
| 54222 | MemSetTypeFlag(pMem, MEM_Real); |
| 54223 | sqlite3VdbeIntegerAffinity(pMem); |
| 54224 | } |
| 54225 | } |
| 54226 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 ); |
| 54227 | pMem->flags &= ~(MEM_Str|MEM_Blob); |
| 54228 | return SQLITE_OK; |
| 54229 | } |
| 54230 | |
| 54231 | /* |
| 54232 | ** Delete any previous value and set the value stored in *pMem to NULL. |
| @@ -54815,10 +54765,12 @@ | |
| 54765 | sqlite3_value **ppVal /* Write the new value here */ |
| 54766 | ){ |
| 54767 | int op; |
| 54768 | char *zVal = 0; |
| 54769 | sqlite3_value *pVal = 0; |
| 54770 | int negInt = 1; |
| 54771 | const char *zNeg = ""; |
| 54772 | |
| 54773 | if( !pExpr ){ |
| 54774 | *ppVal = 0; |
| 54775 | return SQLITE_OK; |
| 54776 | } |
| @@ -54831,35 +54783,50 @@ | |
| 54783 | #ifdef SQLITE_ENABLE_STAT2 |
| 54784 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 54785 | #else |
| 54786 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 54787 | #endif |
| 54788 | |
| 54789 | /* Handle negative integers in a single step. This is needed in the |
| 54790 | ** case when the value is -9223372036854775808. |
| 54791 | */ |
| 54792 | if( op==TK_UMINUS |
| 54793 | && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){ |
| 54794 | pExpr = pExpr->pLeft; |
| 54795 | op = pExpr->op; |
| 54796 | negInt = -1; |
| 54797 | zNeg = "-"; |
| 54798 | } |
| 54799 | |
| 54800 | if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){ |
| 54801 | pVal = sqlite3ValueNew(db); |
| 54802 | if( pVal==0 ) goto no_mem; |
| 54803 | if( ExprHasProperty(pExpr, EP_IntValue) ){ |
| 54804 | sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt); |
| 54805 | }else{ |
| 54806 | zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken); |
| 54807 | if( zVal==0 ) goto no_mem; |
| 54808 | sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); |
| 54809 | if( op==TK_FLOAT ) pVal->type = SQLITE_FLOAT; |
| 54810 | } |
| 54811 | if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){ |
| 54812 | sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); |
| 54813 | }else{ |
| 54814 | sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8); |
| 54815 | } |
| 54816 | if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str; |
| 54817 | if( enc!=SQLITE_UTF8 ){ |
| 54818 | sqlite3VdbeChangeEncoding(pVal, enc); |
| 54819 | } |
| 54820 | }else if( op==TK_UMINUS ) { |
| 54821 | /* This branch happens for multiple negative signs. Ex: -(-5) */ |
| 54822 | if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){ |
| 54823 | sqlite3VdbeMemNumerify(pVal); |
| 54824 | pVal->u.i = -1 * pVal->u.i; |
| 54825 | /* (double)-1 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 54826 | pVal->r = (double)-1 * pVal->r; |
| 54827 | sqlite3ValueApplyAffinity(pVal, affinity, enc); |
| 54828 | } |
| 54829 | } |
| 54830 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 54831 | else if( op==TK_BLOB ){ |
| 54832 | int nVal; |
| @@ -59770,35 +59737,21 @@ | |
| 59737 | ** looks like a number, convert it into a number. If it does not |
| 59738 | ** look like a number, leave it alone. |
| 59739 | */ |
| 59740 | static void applyNumericAffinity(Mem *pRec){ |
| 59741 | if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){ |
| 59742 | double rValue; |
| 59743 | i64 iValue; |
| 59744 | u8 enc = pRec->enc; |
| 59745 | if( (pRec->flags&MEM_Str)==0 ) return; |
| 59746 | if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return; |
| 59747 | if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){ |
| 59748 | pRec->u.i = iValue; |
| 59749 | pRec->flags |= MEM_Int; |
| 59750 | }else{ |
| 59751 | pRec->r = rValue; |
| 59752 | pRec->flags |= MEM_Real; |
| 59753 | } |
| 59754 | } |
| 59755 | } |
| 59756 | |
| 59757 | /* |
| @@ -61580,11 +61533,10 @@ | |
| 61533 | ** integers, for space efficiency, but after extraction we want them |
| 61534 | ** to have only a real value. |
| 61535 | */ |
| 61536 | case OP_RealAffinity: { /* in1 */ |
| 61537 | pIn1 = &aMem[pOp->p1]; |
| 61538 | if( pIn1->flags & MEM_Int ){ |
| 61539 | sqlite3VdbeMemRealify(pIn1); |
| 61540 | } |
| 61541 | break; |
| 61542 | } |
| @@ -61623,11 +61575,10 @@ | |
| 61575 | ** |
| 61576 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61577 | */ |
| 61578 | case OP_ToBlob: { /* same as TK_TO_BLOB, in1 */ |
| 61579 | pIn1 = &aMem[pOp->p1]; |
| 61580 | if( pIn1->flags & MEM_Null ) break; |
| 61581 | if( (pIn1->flags & MEM_Blob)==0 ){ |
| 61582 | applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding); |
| 61583 | assert( pIn1->flags & MEM_Str || db->mallocFailed ); |
| 61584 | MemSetTypeFlag(pIn1, MEM_Blob); |
| @@ -61648,14 +61599,11 @@ | |
| 61599 | ** |
| 61600 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61601 | */ |
| 61602 | case OP_ToNumeric: { /* same as TK_TO_NUMERIC, in1 */ |
| 61603 | pIn1 = &aMem[pOp->p1]; |
| 61604 | sqlite3VdbeMemNumerify(pIn1); |
| 61605 | break; |
| 61606 | } |
| 61607 | #endif /* SQLITE_OMIT_CAST */ |
| 61608 | |
| 61609 | /* Opcode: ToInt P1 * * * * |
| @@ -61667,11 +61615,10 @@ | |
| 61615 | ** |
| 61616 | ** A NULL value is not changed by this routine. It remains NULL. |
| 61617 | */ |
| 61618 | case OP_ToInt: { /* same as TK_TO_INT, in1 */ |
| 61619 | pIn1 = &aMem[pOp->p1]; |
| 61620 | if( (pIn1->flags & MEM_Null)==0 ){ |
| 61621 | sqlite3VdbeMemIntegerify(pIn1); |
| 61622 | } |
| 61623 | break; |
| 61624 | } |
| @@ -61781,12 +61728,10 @@ | |
| 61728 | u16 flags3; /* Copy of initial value of pIn3->flags */ |
| 61729 | #endif /* local variables moved into u.ai */ |
| 61730 | |
| 61731 | pIn1 = &aMem[pOp->p1]; |
| 61732 | pIn3 = &aMem[pOp->p3]; |
| 61733 | u.ai.flags1 = pIn1->flags; |
| 61734 | u.ai.flags3 = pIn3->flags; |
| 61735 | if( (pIn1->flags | pIn3->flags)&MEM_Null ){ |
| 61736 | /* One or both operands are NULL */ |
| 61737 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| @@ -62415,11 +62360,10 @@ | |
| 62360 | assert( u.an.zAffinity[pOp->p2]==0 ); |
| 62361 | pIn1 = &aMem[pOp->p1]; |
| 62362 | while( (u.an.cAff = *(u.an.zAffinity++))!=0 ){ |
| 62363 | assert( pIn1 <= &p->aMem[p->nMem] ); |
| 62364 | assert( memIsValid(pIn1) ); |
| 62365 | ExpandBlob(pIn1); |
| 62366 | applyAffinity(pIn1, u.an.cAff, encoding); |
| 62367 | pIn1++; |
| 62368 | } |
| 62369 | break; |
| @@ -62495,11 +62439,10 @@ | |
| 62439 | ** out how much space is required for the new record. |
| 62440 | */ |
| 62441 | for(u.ao.pRec=u.ao.pData0; u.ao.pRec<=u.ao.pLast; u.ao.pRec++){ |
| 62442 | assert( memIsValid(u.ao.pRec) ); |
| 62443 | if( u.ao.zAffinity ){ |
| 62444 | applyAffinity(u.ao.pRec, u.ao.zAffinity[u.ao.pRec-u.ao.pData0], encoding); |
| 62445 | } |
| 62446 | if( u.ao.pRec->flags&MEM_Zero && u.ao.pRec->n>0 ){ |
| 62447 | sqlite3VdbeMemExpandBlob(u.ao.pRec); |
| 62448 | } |
| @@ -68880,11 +68823,11 @@ | |
| 68823 | pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 68824 | }else if( z[0]=='?' ){ |
| 68825 | /* Wildcard of the form "?nnn". Convert "nnn" to an integer and |
| 68826 | ** use it as the variable number */ |
| 68827 | i64 i; |
| 68828 | int bOk = 0==sqlite3Atoi64(&z[1], &i, sqlite3Strlen30(&z[1]), SQLITE_UTF8); |
| 68829 | pExpr->iColumn = (ynVar)i; |
| 68830 | testcase( i==0 ); |
| 68831 | testcase( i==1 ); |
| 68832 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); |
| 68833 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); |
| @@ -70243,11 +70186,11 @@ | |
| 70186 | */ |
| 70187 | static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){ |
| 70188 | if( ALWAYS(z!=0) ){ |
| 70189 | double value; |
| 70190 | char *zV; |
| 70191 | sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); |
| 70192 | assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */ |
| 70193 | if( negateFlag ) value = -value; |
| 70194 | zV = dup8bytes(v, (char*)&value); |
| 70195 | sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL); |
| 70196 | } |
| @@ -70257,28 +70200,27 @@ | |
| 70200 | |
| 70201 | /* |
| 70202 | ** Generate an instruction that will put the integer describe by |
| 70203 | ** text z[0..n-1] into register iMem. |
| 70204 | ** |
| 70205 | ** Expr.u.zToken is always UTF8 and zero-terminated. |
| 70206 | */ |
| 70207 | static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){ |
| 70208 | Vdbe *v = pParse->pVdbe; |
| 70209 | if( pExpr->flags & EP_IntValue ){ |
| 70210 | int i = pExpr->u.iValue; |
| 70211 | if( negFlag ) i = -i; |
| 70212 | sqlite3VdbeAddOp2(v, OP_Integer, i, iMem); |
| 70213 | }else{ |
| 70214 | int c; |
| 70215 | i64 value; |
| 70216 | const char *z = pExpr->u.zToken; |
| 70217 | assert( z!=0 ); |
| 70218 | c = sqlite3Atoi64(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); |
| 70219 | if( c==0 || (c==2 && negFlag) ){ |
| 70220 | char *zV; |
| 70221 | if( negFlag ){ value = -value; } |
| 70222 | zV = dup8bytes(v, (char*)&value); |
| 70223 | sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64); |
| 70224 | }else{ |
| 70225 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 70226 | sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z); |
| @@ -79414,11 +79356,11 @@ | |
| 79356 | zBuf = sqlite3_mprintf("%.*f",n,r); |
| 79357 | if( zBuf==0 ){ |
| 79358 | sqlite3_result_error_nomem(context); |
| 79359 | return; |
| 79360 | } |
| 79361 | sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8); |
| 79362 | sqlite3_free(zBuf); |
| 79363 | } |
| 79364 | sqlite3_result_double(context, r); |
| 79365 | } |
| 79366 | #endif |
| @@ -85472,11 +85414,11 @@ | |
| 85414 | */ |
| 85415 | if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){ |
| 85416 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 85417 | i64 iLimit = -2; |
| 85418 | if( zRight ){ |
| 85419 | sqlite3Atoi64(zRight, &iLimit, 1000000, SQLITE_UTF8); |
| 85420 | if( iLimit<-1 ) iLimit = -1; |
| 85421 | } |
| 85422 | iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); |
| 85423 | returnSingleInt(pParse, "journal_size_limit", iLimit); |
| 85424 | }else |
| @@ -96380,11 +96322,12 @@ | |
| 96322 | |
| 96323 | /* |
| 96324 | ** Required because bestIndex() is called by bestOrClauseIndex() |
| 96325 | */ |
| 96326 | static void bestIndex( |
| 96327 | Parse*, WhereClause*, struct SrcList_item*, |
| 96328 | Bitmask, Bitmask, ExprList*, WhereCost*); |
| 96329 | |
| 96330 | /* |
| 96331 | ** This routine attempts to find an scanning strategy that can be used |
| 96332 | ** to optimize an 'OR' expression that is part of a WHERE clause. |
| 96333 | ** |
| @@ -96393,11 +96336,12 @@ | |
| 96336 | */ |
| 96337 | static void bestOrClauseIndex( |
| 96338 | Parse *pParse, /* The parsing context */ |
| 96339 | WhereClause *pWC, /* The WHERE clause */ |
| 96340 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 96341 | Bitmask notReady, /* Mask of cursors not available for indexing */ |
| 96342 | Bitmask notValid, /* Cursors not available for any purpose */ |
| 96343 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 96344 | WhereCost *pCost /* Lowest cost query plan */ |
| 96345 | ){ |
| 96346 | #ifndef SQLITE_OMIT_OR_OPTIMIZATION |
| 96347 | const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| @@ -96429,19 +96373,19 @@ | |
| 96373 | WHERETRACE(("... Multi-index OR testing for term %d of %d....\n", |
| 96374 | (pOrTerm - pOrWC->a), (pTerm - pWC->a) |
| 96375 | )); |
| 96376 | if( pOrTerm->eOperator==WO_AND ){ |
| 96377 | WhereClause *pAndWC = &pOrTerm->u.pAndInfo->wc; |
| 96378 | bestIndex(pParse, pAndWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 96379 | }else if( pOrTerm->leftCursor==iCur ){ |
| 96380 | WhereClause tempWC; |
| 96381 | tempWC.pParse = pWC->pParse; |
| 96382 | tempWC.pMaskSet = pWC->pMaskSet; |
| 96383 | tempWC.op = TK_AND; |
| 96384 | tempWC.a = pOrTerm; |
| 96385 | tempWC.nTerm = 1; |
| 96386 | bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 96387 | }else{ |
| 96388 | continue; |
| 96389 | } |
| 96390 | rTotal += sTermCost.rCost; |
| 96391 | nRow += sTermCost.nRow; |
| @@ -96884,11 +96828,12 @@ | |
| 96828 | */ |
| 96829 | static void bestVirtualIndex( |
| 96830 | Parse *pParse, /* The parsing context */ |
| 96831 | WhereClause *pWC, /* The WHERE clause */ |
| 96832 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 96833 | Bitmask notReady, /* Mask of cursors not available for index */ |
| 96834 | Bitmask notValid, /* Cursors not valid for any purpose */ |
| 96835 | ExprList *pOrderBy, /* The order by clause */ |
| 96836 | WhereCost *pCost, /* Lowest cost query plan */ |
| 96837 | sqlite3_index_info **ppIdxInfo /* Index information passed to xBestIndex */ |
| 96838 | ){ |
| 96839 | Table *pTab = pSrc->pTab; |
| @@ -97014,11 +96959,11 @@ | |
| 96959 | pIdxInfo->nOrderBy = nOrderBy; |
| 96960 | |
| 96961 | /* Try to find a more efficient access pattern by using multiple indexes |
| 96962 | ** to optimize an OR expression within the WHERE clause. |
| 96963 | */ |
| 96964 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); |
| 96965 | } |
| 96966 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 96967 | |
| 96968 | /* |
| 96969 | ** Argument pIdx is a pointer to an index structure that has an array of |
| @@ -97295,11 +97240,12 @@ | |
| 97240 | */ |
| 97241 | static void bestBtreeIndex( |
| 97242 | Parse *pParse, /* The parsing context */ |
| 97243 | WhereClause *pWC, /* The WHERE clause */ |
| 97244 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 97245 | Bitmask notReady, /* Mask of cursors not available for indexing */ |
| 97246 | Bitmask notValid, /* Cursors not available for any purpose */ |
| 97247 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 97248 | WhereCost *pCost /* Lowest cost query plan */ |
| 97249 | ){ |
| 97250 | int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| 97251 | Index *pProbe; /* An index we are evaluating */ |
| @@ -97557,29 +97503,29 @@ | |
| 97503 | ** of output rows, adjust the nRow value accordingly. This only |
| 97504 | ** matters if the current index is the least costly, so do not bother |
| 97505 | ** with this step if we already know this index will not be chosen. |
| 97506 | ** Also, never reduce the output row count below 2 using this step. |
| 97507 | ** |
| 97508 | ** It is critical that the notValid mask be used here instead of |
| 97509 | ** the notReady mask. When computing an "optimal" index, the notReady |
| 97510 | ** mask will only have one bit set - the bit for the current table. |
| 97511 | ** The notValid mask, on the other hand, always has all bits set for |
| 97512 | ** tables that are not in outer loops. If notReady is used here instead |
| 97513 | ** of notValid, then a optimal index that depends on inner joins loops |
| 97514 | ** might be selected even when there exists an optimal index that has |
| 97515 | ** no such dependency. |
| 97516 | */ |
| 97517 | if( nRow>2 && cost<=pCost->rCost ){ |
| 97518 | int k; /* Loop counter */ |
| 97519 | int nSkipEq = nEq; /* Number of == constraints to skip */ |
| 97520 | int nSkipRange = nBound; /* Number of < constraints to skip */ |
| 97521 | Bitmask thisTab; /* Bitmap for pSrc */ |
| 97522 | |
| 97523 | thisTab = getMask(pWC->pMaskSet, iCur); |
| 97524 | for(pTerm=pWC->a, k=pWC->nTerm; nRow>2 && k; k--, pTerm++){ |
| 97525 | if( pTerm->wtFlags & TERM_VIRTUAL ) continue; |
| 97526 | if( (pTerm->prereqAll & notValid)!=thisTab ) continue; |
| 97527 | if( pTerm->eOperator & (WO_EQ|WO_IN|WO_ISNULL) ){ |
| 97528 | if( nSkipEq ){ |
| 97529 | /* Ignore the first nEq equality matches since the index |
| 97530 | ** has already accounted for these */ |
| 97531 | nSkipEq--; |
| @@ -97657,11 +97603,11 @@ | |
| 97603 | WHERETRACE(("best index is: %s\n", |
| 97604 | ((pCost->plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ? "none" : |
| 97605 | pCost->plan.u.pIdx ? pCost->plan.u.pIdx->zName : "ipk") |
| 97606 | )); |
| 97607 | |
| 97608 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); |
| 97609 | bestAutomaticIndex(pParse, pWC, pSrc, notReady, pCost); |
| 97610 | pCost->plan.wsFlags |= eqTermMask; |
| 97611 | } |
| 97612 | |
| 97613 | /* |
| @@ -97672,26 +97618,27 @@ | |
| 97618 | */ |
| 97619 | static void bestIndex( |
| 97620 | Parse *pParse, /* The parsing context */ |
| 97621 | WhereClause *pWC, /* The WHERE clause */ |
| 97622 | struct SrcList_item *pSrc, /* The FROM clause term to search */ |
| 97623 | Bitmask notReady, /* Mask of cursors not available for indexing */ |
| 97624 | Bitmask notValid, /* Cursors not available for any purpose */ |
| 97625 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 97626 | WhereCost *pCost /* Lowest cost query plan */ |
| 97627 | ){ |
| 97628 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 97629 | if( IsVirtual(pSrc->pTab) ){ |
| 97630 | sqlite3_index_info *p = 0; |
| 97631 | bestVirtualIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost,&p); |
| 97632 | if( p->needToFreeIdxStr ){ |
| 97633 | sqlite3_free(p->idxStr); |
| 97634 | } |
| 97635 | sqlite3DbFree(pParse->db, p); |
| 97636 | }else |
| 97637 | #endif |
| 97638 | { |
| 97639 | bestBtreeIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); |
| 97640 | } |
| 97641 | } |
| 97642 | |
| 97643 | /* |
| 97644 | ** Disable a term in the WHERE clause. Except, do not disable the term |
| @@ -98902,14 +98849,20 @@ | |
| 98849 | ** by waiting for other tables to run first. This "optimal" test works |
| 98850 | ** by first assuming that the FROM clause is on the inner loop and finding |
| 98851 | ** its query plan, then checking to see if that query plan uses any |
| 98852 | ** other FROM clause terms that are notReady. If no notReady terms are |
| 98853 | ** used then the "optimal" query plan works. |
| 98854 | ** |
| 98855 | ** Note that the WhereCost.nRow parameter for an optimal scan might |
| 98856 | ** not be as small as it would be if the table really were the innermost |
| 98857 | ** join. The nRow value can be reduced by WHERE clause constraints |
| 98858 | ** that do not use indices. But this nRow reduction only happens if the |
| 98859 | ** table really is the innermost join. |
| 98860 | ** |
| 98861 | ** The second loop iteration is only performed if no optimal scan |
| 98862 | ** strategies were found by the first iteration. This second iteration |
| 98863 | ** is used to search for the lowest cost scan overall. |
| 98864 | ** |
| 98865 | ** Previous versions of SQLite performed only the second iteration - |
| 98866 | ** the next outermost loop was always that with the lowest overall |
| 98867 | ** cost. However, this meant that SQLite could select the wrong plan |
| 98868 | ** for scripts such as the following: |
| @@ -98925,11 +98878,11 @@ | |
| 98878 | ** algorithm may choose to use t2 for the outer loop, which is a much |
| 98879 | ** costlier approach. |
| 98880 | */ |
| 98881 | nUnconstrained = 0; |
| 98882 | notIndexed = 0; |
| 98883 | for(isOptimal=(iFrom<nTabList-1); isOptimal>=0 && bestJ<0; isOptimal--){ |
| 98884 | Bitmask mask; /* Mask of tables not yet ready */ |
| 98885 | for(j=iFrom, pTabItem=&pTabList->a[j]; j<nTabList; j++, pTabItem++){ |
| 98886 | int doNotReorder; /* True if this table should not be reordered */ |
| 98887 | WhereCost sCost; /* Cost information from best[Virtual]Index() */ |
| 98888 | ExprList *pOrderBy; /* ORDER BY clause for index to optimize */ |
| @@ -98947,15 +98900,17 @@ | |
| 98900 | |
| 98901 | assert( pTabItem->pTab ); |
| 98902 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 98903 | if( IsVirtual(pTabItem->pTab) ){ |
| 98904 | sqlite3_index_info **pp = &pWInfo->a[j].pIdxInfo; |
| 98905 | bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, |
| 98906 | &sCost, pp); |
| 98907 | }else |
| 98908 | #endif |
| 98909 | { |
| 98910 | bestBtreeIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, |
| 98911 | &sCost); |
| 98912 | } |
| 98913 | assert( isOptimal || (sCost.used¬Ready)==0 ); |
| 98914 | |
| 98915 | /* If an INDEXED BY clause is present, then the plan must use that |
| 98916 | ** index if it uses any index at all */ |
| 98917 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.3" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007003 |
| 112 | -#define SQLITE_SOURCE_ID "2010-09-29 23:09:23 1ef0dc9328f47506cb2dcd142150e96cb4755216" | |
| 112 | +#define SQLITE_SOURCE_ID "2010-10-04 23:55:51 ece641eb8951c6314cedbdb3243f91cb199c3239" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.3" |
| 111 | #define SQLITE_VERSION_NUMBER 3007003 |
| 112 | #define SQLITE_SOURCE_ID "2010-09-29 23:09:23 1ef0dc9328f47506cb2dcd142150e96cb4755216" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.3" |
| 111 | #define SQLITE_VERSION_NUMBER 3007003 |
| 112 | #define SQLITE_SOURCE_ID "2010-10-04 23:55:51 ece641eb8951c6314cedbdb3243f91cb199c3239" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |