| | @@ -1167,11 +1167,11 @@ |
| 1167 | 1167 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1168 | 1168 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1169 | 1169 | */ |
| 1170 | 1170 | #define SQLITE_VERSION "3.29.0" |
| 1171 | 1171 | #define SQLITE_VERSION_NUMBER 3029000 |
| 1172 | | -#define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c" |
| 1172 | +#define SQLITE_SOURCE_ID "2019-06-13 14:07:41 f8696b60eec0dcacfe92d9a31cbf1436d674140e5447de0cd1c2f52bff6c2be4" |
| 1173 | 1173 | |
| 1174 | 1174 | /* |
| 1175 | 1175 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1176 | 1176 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1177 | 1177 | ** |
| | @@ -2338,12 +2338,18 @@ |
| 2338 | 2338 | ** |
| 2339 | 2339 | ** [[sqlite3_vfs.xAccess]] |
| 2340 | 2340 | ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] |
| 2341 | 2341 | ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to |
| 2342 | 2342 | ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] |
| 2343 | | -** to test whether a file is at least readable. The file can be a |
| 2344 | | -** directory. |
| 2343 | +** to test whether a file is at least readable. The SQLITE_ACCESS_READ |
| 2344 | +** flag is never actually used and is not implemented in the built-in |
| 2345 | +** VFSes of SQLite. The file is named by the second argument and can be a |
| 2346 | +** directory. The xAccess method returns [SQLITE_OK] on success or some |
| 2347 | +** non-zero error code if there is an I/O error or if the name of |
| 2348 | +** the file given in the second argument is illegal. If SQLITE_OK |
| 2349 | +** is returned, then non-zero or zero is written into *pResOut to indicate |
| 2350 | +** whether or not the file is accessible. |
| 2345 | 2351 | ** |
| 2346 | 2352 | ** ^SQLite will always allocate at least mxPathname+1 bytes for the |
| 2347 | 2353 | ** output buffer xFullPathname. The exact size of the output buffer |
| 2348 | 2354 | ** is also passed as a parameter to both methods. If the output buffer |
| 2349 | 2355 | ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is |
| | @@ -17444,11 +17450,11 @@ |
| 17444 | 17450 | #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */ |
| 17445 | 17451 | #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */ |
| 17446 | 17452 | #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */ |
| 17447 | 17453 | #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */ |
| 17448 | 17454 | #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */ |
| 17449 | | -#define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */ |
| 17455 | +#define EP_Skip 0x001000 /* Operator does not contribute to affinity */ |
| 17450 | 17456 | #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ |
| 17451 | 17457 | #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| 17452 | 17458 | #define EP_Win 0x008000 /* Contains window functions */ |
| 17453 | 17459 | #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */ |
| 17454 | 17460 | #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */ |
| | @@ -18799,10 +18805,11 @@ |
| 18799 | 18805 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 18800 | 18806 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 18801 | 18807 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int); |
| 18802 | 18808 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 18803 | 18809 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 18810 | +SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| 18804 | 18811 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 18805 | 18812 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 18806 | 18813 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int); |
| 18807 | 18814 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
| 18808 | 18815 | SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*); |
| | @@ -21327,11 +21334,11 @@ |
| 21327 | 21334 | return 0; |
| 21328 | 21335 | }else if( parseHhMmSs(zDate, p)==0 ){ |
| 21329 | 21336 | return 0; |
| 21330 | 21337 | }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){ |
| 21331 | 21338 | return setDateTimeToCurrent(context, p); |
| 21332 | | - }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){ |
| 21339 | + }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){ |
| 21333 | 21340 | setRawDateNumber(p, r); |
| 21334 | 21341 | return 0; |
| 21335 | 21342 | } |
| 21336 | 21343 | return 1; |
| 21337 | 21344 | } |
| | @@ -21661,11 +21668,11 @@ |
| 21661 | 21668 | ** Move the date to the same time on the next occurrence of |
| 21662 | 21669 | ** weekday N where 0==Sunday, 1==Monday, and so forth. If the |
| 21663 | 21670 | ** date is already on the appropriate weekday, this is a no-op. |
| 21664 | 21671 | */ |
| 21665 | 21672 | if( sqlite3_strnicmp(z, "weekday ", 8)==0 |
| 21666 | | - && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8) |
| 21673 | + && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)>0 |
| 21667 | 21674 | && (n=(int)r)==r && n>=0 && r<7 ){ |
| 21668 | 21675 | sqlite3_int64 Z; |
| 21669 | 21676 | computeYMD_HMS(p); |
| 21670 | 21677 | p->validTZ = 0; |
| 21671 | 21678 | p->validJD = 0; |
| | @@ -21720,11 +21727,11 @@ |
| 21720 | 21727 | case '8': |
| 21721 | 21728 | case '9': { |
| 21722 | 21729 | double rRounder; |
| 21723 | 21730 | int i; |
| 21724 | 21731 | for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){} |
| 21725 | | - if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){ |
| 21732 | + if( sqlite3AtoF(z, &r, n, SQLITE_UTF8)<=0 ){ |
| 21726 | 21733 | rc = 1; |
| 21727 | 21734 | break; |
| 21728 | 21735 | } |
| 21729 | 21736 | if( z[n]==':' ){ |
| 21730 | 21737 | /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the |
| | @@ -29068,11 +29075,11 @@ |
| 29068 | 29075 | const char *azOp[] = { |
| 29069 | 29076 | "IS-FALSE", "IS-TRUE", "IS-NOT-FALSE", "IS-NOT-TRUE" |
| 29070 | 29077 | }; |
| 29071 | 29078 | assert( pExpr->op2==TK_IS || pExpr->op2==TK_ISNOT ); |
| 29072 | 29079 | assert( pExpr->pRight ); |
| 29073 | | - assert( pExpr->pRight->op==TK_TRUEFALSE ); |
| 29080 | + assert( sqlite3ExprSkipCollate(pExpr->pRight)->op==TK_TRUEFALSE ); |
| 29074 | 29081 | x = (pExpr->op2==TK_ISNOT)*2 + sqlite3ExprTruthValue(pExpr->pRight); |
| 29075 | 29082 | zUniOp = azOp[x]; |
| 29076 | 29083 | break; |
| 29077 | 29084 | } |
| 29078 | 29085 | |
| | @@ -30598,11 +30605,13 @@ |
| 30598 | 30605 | ** Return TRUE if the result is a valid real number (or integer) and FALSE |
| 30599 | 30606 | ** if the string is empty or contains extraneous text. More specifically |
| 30600 | 30607 | ** return |
| 30601 | 30608 | ** 1 => The input string is a pure integer |
| 30602 | 30609 | ** 2 or more => The input has a decimal point or eNNN clause |
| 30603 | | -** 0 => The input string is not a valid number |
| 30610 | +** 0 or less => The input string is not a valid number |
| 30611 | +** -1 => Not a valid number, but has a valid prefix which |
| 30612 | +** includes a decimal point and/or an eNNN clause |
| 30604 | 30613 | ** |
| 30605 | 30614 | ** Valid numbers are in one of these formats: |
| 30606 | 30615 | ** |
| 30607 | 30616 | ** [+-]digits[E[+-]digits] |
| 30608 | 30617 | ** [+-]digits.[digits][E[+-]digits] |
| | @@ -30789,11 +30798,17 @@ |
| 30789 | 30798 | |
| 30790 | 30799 | /* store the result */ |
| 30791 | 30800 | *pResult = result; |
| 30792 | 30801 | |
| 30793 | 30802 | /* return true if number and no extra non-whitespace chracters after */ |
| 30794 | | - return z==zEnd && nDigit>0 && eValid && eType>0 ? eType : 0; |
| 30803 | + if( z==zEnd && nDigit>0 && eValid && eType>0 ){ |
| 30804 | + return eType; |
| 30805 | + }else if( eType>=2 && (eType==3 || eValid) && nDigit>0 ){ |
| 30806 | + return -1; |
| 30807 | + }else{ |
| 30808 | + return 0; |
| 30809 | + } |
| 30795 | 30810 | #else |
| 30796 | 30811 | return !sqlite3Atoi64(z, pResult, length, enc); |
| 30797 | 30812 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 30798 | 30813 | } |
| 30799 | 30814 | |
| | @@ -30832,10 +30847,11 @@ |
| 30832 | 30847 | ** Convert zNum to a 64-bit signed integer. zNum must be decimal. This |
| 30833 | 30848 | ** routine does *not* accept hexadecimal notation. |
| 30834 | 30849 | ** |
| 30835 | 30850 | ** Returns: |
| 30836 | 30851 | ** |
| 30852 | +** -1 Not even a prefix of the input text looks like an integer |
| 30837 | 30853 | ** 0 Successful transformation. Fits in a 64-bit signed integer. |
| 30838 | 30854 | ** 1 Excess non-space text after the integer value |
| 30839 | 30855 | ** 2 Integer too large for a 64-bit signed integer or is malformed |
| 30840 | 30856 | ** 3 Special case of 9223372036854775808 |
| 30841 | 30857 | ** |
| | @@ -30891,13 +30907,13 @@ |
| 30891 | 30907 | *pNum = -(i64)u; |
| 30892 | 30908 | }else{ |
| 30893 | 30909 | *pNum = (i64)u; |
| 30894 | 30910 | } |
| 30895 | 30911 | rc = 0; |
| 30896 | | - if( (i==0 && zStart==zNum) /* No digits */ |
| 30897 | | - || nonNum /* UTF16 with high-order bytes non-zero */ |
| 30898 | | - ){ |
| 30912 | + if( i==0 && zStart==zNum ){ /* No digits */ |
| 30913 | + rc = -1; |
| 30914 | + }else if( nonNum ){ /* UTF16 with high-order bytes non-zero */ |
| 30899 | 30915 | rc = 1; |
| 30900 | 30916 | }else if( &zNum[i]<zEnd ){ /* Extra bytes at the end */ |
| 30901 | 30917 | int jj = i; |
| 30902 | 30918 | do{ |
| 30903 | 30919 | if( !sqlite3Isspace(zNum[jj]) ){ |
| | @@ -48009,13 +48025,14 @@ |
| 48009 | 48025 | if( p->szCache>=0 ){ |
| 48010 | 48026 | /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the |
| 48011 | 48027 | ** suggested cache size is set to N. */ |
| 48012 | 48028 | return p->szCache; |
| 48013 | 48029 | }else{ |
| 48014 | | - /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then |
| 48015 | | - ** the number of cache pages is adjusted to use approximately abs(N*1024) |
| 48016 | | - ** bytes of memory. */ |
| 48030 | + /* IMPLEMANTATION-OF: R-59858-46238 If the argument N is negative, then the |
| 48031 | + ** number of cache pages is adjusted to be a number of pages that would |
| 48032 | + ** use approximately abs(N*1024) bytes of memory based on the current |
| 48033 | + ** page size. */ |
| 48017 | 48034 | return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); |
| 48018 | 48035 | } |
| 48019 | 48036 | } |
| 48020 | 48037 | |
| 48021 | 48038 | /*************************************************** General Interfaces ****** |
| | @@ -75137,18 +75154,22 @@ |
| 75137 | 75154 | return SQLITE_OK; |
| 75138 | 75155 | } |
| 75139 | 75156 | |
| 75140 | 75157 | /* Compare a floating point value to an integer. Return true if the two |
| 75141 | 75158 | ** values are the same within the precision of the floating point value. |
| 75159 | +** |
| 75160 | +** This function assumes that i was obtained by assignment from r1. |
| 75142 | 75161 | ** |
| 75143 | 75162 | ** For some versions of GCC on 32-bit machines, if you do the more obvious |
| 75144 | 75163 | ** comparison of "r1==(double)i" you sometimes get an answer of false even |
| 75145 | 75164 | ** though the r1 and (double)i values are bit-for-bit the same. |
| 75146 | 75165 | */ |
| 75147 | 75166 | SQLITE_PRIVATE int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){ |
| 75148 | 75167 | double r2 = (double)i; |
| 75149 | | - return memcmp(&r1, &r2, sizeof(r1))==0; |
| 75168 | + return r1==0.0 |
| 75169 | + || (memcmp(&r1, &r2, sizeof(r1))==0 |
| 75170 | + && i >= -2251799813685248 && i < 2251799813685248); |
| 75150 | 75171 | } |
| 75151 | 75172 | |
| 75152 | 75173 | /* |
| 75153 | 75174 | ** Convert pMem so that it has type MEM_Real or MEM_Int. |
| 75154 | 75175 | ** Invalidate any prior representations. |
| | @@ -75162,24 +75183,21 @@ |
| 75162 | 75183 | testcase( pMem->flags & MEM_Real ); |
| 75163 | 75184 | testcase( pMem->flags & MEM_IntReal ); |
| 75164 | 75185 | testcase( pMem->flags & MEM_Null ); |
| 75165 | 75186 | if( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))==0 ){ |
| 75166 | 75187 | int rc; |
| 75188 | + sqlite3_int64 ix; |
| 75167 | 75189 | assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); |
| 75168 | 75190 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 75169 | | - rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc); |
| 75170 | | - if( rc==0 ){ |
| 75191 | + rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); |
| 75192 | + if( ((rc==0 || rc==1) && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1) |
| 75193 | + || sqlite3RealSameAsInt(pMem->u.r, (ix = (i64)pMem->u.r)) |
| 75194 | + ){ |
| 75195 | + pMem->u.i = ix; |
| 75171 | 75196 | MemSetTypeFlag(pMem, MEM_Int); |
| 75172 | 75197 | }else{ |
| 75173 | | - i64 i = pMem->u.i; |
| 75174 | | - sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); |
| 75175 | | - if( rc==1 && sqlite3RealSameAsInt(pMem->u.r, i) ){ |
| 75176 | | - pMem->u.i = i; |
| 75177 | | - MemSetTypeFlag(pMem, MEM_Int); |
| 75178 | | - }else{ |
| 75179 | | - MemSetTypeFlag(pMem, MEM_Real); |
| 75180 | | - } |
| 75198 | + MemSetTypeFlag(pMem, MEM_Real); |
| 75181 | 75199 | } |
| 75182 | 75200 | } |
| 75183 | 75201 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal|MEM_Null))!=0 ); |
| 75184 | 75202 | pMem->flags &= ~(MEM_Str|MEM_Blob|MEM_Zero); |
| 75185 | 75203 | return SQLITE_OK; |
| | @@ -83936,21 +83954,12 @@ |
| 83936 | 83954 | ** return false. |
| 83937 | 83955 | */ |
| 83938 | 83956 | static int alsoAnInt(Mem *pRec, double rValue, i64 *piValue){ |
| 83939 | 83957 | i64 iValue = (double)rValue; |
| 83940 | 83958 | if( sqlite3RealSameAsInt(rValue,iValue) ){ |
| 83941 | | - testcase( iValue<-2251799813685248 ); |
| 83942 | | - testcase( iValue==-2251799813685248 ); |
| 83943 | | - testcase( iValue==-2251799813685247 ); |
| 83944 | | - testcase( iValue>-2251799813685247 && iValue<+2251799813685247 ); |
| 83945 | | - testcase( iValue==+2251799813685247 ); |
| 83946 | | - testcase( iValue==+2251799813685248 ); |
| 83947 | | - testcase( iValue>+2251799813685248 ); |
| 83948 | | - if( iValue > -2251799813685248 && iValue < 2251799813685248 ){ |
| 83949 | | - *piValue = iValue; |
| 83950 | | - return 1; |
| 83951 | | - } |
| 83959 | + *piValue = iValue; |
| 83960 | + return 1; |
| 83952 | 83961 | } |
| 83953 | 83962 | return 0==sqlite3Atoi64(pRec->z, piValue, pRec->n, pRec->enc); |
| 83954 | 83963 | } |
| 83955 | 83964 | |
| 83956 | 83965 | /* |
| | @@ -83972,11 +83981,11 @@ |
| 83972 | 83981 | double rValue; |
| 83973 | 83982 | u8 enc = pRec->enc; |
| 83974 | 83983 | int rc; |
| 83975 | 83984 | assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str ); |
| 83976 | 83985 | rc = sqlite3AtoF(pRec->z, &rValue, pRec->n, enc); |
| 83977 | | - if( rc==0 ) return; |
| 83986 | + if( rc<=0 ) return; |
| 83978 | 83987 | if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){ |
| 83979 | 83988 | pRec->flags |= MEM_Int; |
| 83980 | 83989 | }else{ |
| 83981 | 83990 | pRec->u.r = rValue; |
| 83982 | 83991 | pRec->flags |= MEM_Real; |
| | @@ -84073,17 +84082,25 @@ |
| 84073 | 84082 | ** interpret as a string if we want to). Compute its corresponding |
| 84074 | 84083 | ** numeric type, if has one. Set the pMem->u.r and pMem->u.i fields |
| 84075 | 84084 | ** accordingly. |
| 84076 | 84085 | */ |
| 84077 | 84086 | static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){ |
| 84087 | + int rc; |
| 84088 | + sqlite3_int64 ix; |
| 84078 | 84089 | assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ); |
| 84079 | 84090 | assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ); |
| 84080 | 84091 | ExpandBlob(pMem); |
| 84081 | | - if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){ |
| 84082 | | - return 0; |
| 84083 | | - } |
| 84084 | | - if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){ |
| 84092 | + rc = sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); |
| 84093 | + if( rc<=0 ){ |
| 84094 | + if( rc==0 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)<=1 ){ |
| 84095 | + pMem->u.i = ix; |
| 84096 | + return MEM_Int; |
| 84097 | + }else{ |
| 84098 | + return MEM_Real; |
| 84099 | + } |
| 84100 | + }else if( rc==1 && sqlite3Atoi64(pMem->z, &ix, pMem->n, pMem->enc)==0 ){ |
| 84101 | + pMem->u.i = ix; |
| 84085 | 84102 | return MEM_Int; |
| 84086 | 84103 | } |
| 84087 | 84104 | return MEM_Real; |
| 84088 | 84105 | } |
| 84089 | 84106 | |
| | @@ -85330,11 +85347,10 @@ |
| 85330 | 85347 | case OP_Add: /* same as TK_PLUS, in1, in2, out3 */ |
| 85331 | 85348 | case OP_Subtract: /* same as TK_MINUS, in1, in2, out3 */ |
| 85332 | 85349 | case OP_Multiply: /* same as TK_STAR, in1, in2, out3 */ |
| 85333 | 85350 | case OP_Divide: /* same as TK_SLASH, in1, in2, out3 */ |
| 85334 | 85351 | case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ |
| 85335 | | - char bIntint; /* Started out as two integer operands */ |
| 85336 | 85352 | u16 flags; /* Combined MEM_* flags from both inputs */ |
| 85337 | 85353 | u16 type1; /* Numeric type of left operand */ |
| 85338 | 85354 | u16 type2; /* Numeric type of right operand */ |
| 85339 | 85355 | i64 iA; /* Integer value of left operand */ |
| 85340 | 85356 | i64 iB; /* Integer value of right operand */ |
| | @@ -85348,11 +85364,10 @@ |
| 85348 | 85364 | pOut = &aMem[pOp->p3]; |
| 85349 | 85365 | flags = pIn1->flags | pIn2->flags; |
| 85350 | 85366 | if( (type1 & type2 & MEM_Int)!=0 ){ |
| 85351 | 85367 | iA = pIn1->u.i; |
| 85352 | 85368 | iB = pIn2->u.i; |
| 85353 | | - bIntint = 1; |
| 85354 | 85369 | switch( pOp->opcode ){ |
| 85355 | 85370 | case OP_Add: if( sqlite3AddInt64(&iB,iA) ) goto fp_math; break; |
| 85356 | 85371 | case OP_Subtract: if( sqlite3SubInt64(&iB,iA) ) goto fp_math; break; |
| 85357 | 85372 | case OP_Multiply: if( sqlite3MulInt64(&iB,iA) ) goto fp_math; break; |
| 85358 | 85373 | case OP_Divide: { |
| | @@ -85371,11 +85386,10 @@ |
| 85371 | 85386 | pOut->u.i = iB; |
| 85372 | 85387 | MemSetTypeFlag(pOut, MEM_Int); |
| 85373 | 85388 | }else if( (flags & MEM_Null)!=0 ){ |
| 85374 | 85389 | goto arithmetic_result_is_null; |
| 85375 | 85390 | }else{ |
| 85376 | | - bIntint = 0; |
| 85377 | 85391 | fp_math: |
| 85378 | 85392 | rA = sqlite3VdbeRealValue(pIn1); |
| 85379 | 85393 | rB = sqlite3VdbeRealValue(pIn2); |
| 85380 | 85394 | switch( pOp->opcode ){ |
| 85381 | 85395 | case OP_Add: rB += rA; break; |
| | @@ -85403,13 +85417,10 @@ |
| 85403 | 85417 | if( sqlite3IsNaN(rB) ){ |
| 85404 | 85418 | goto arithmetic_result_is_null; |
| 85405 | 85419 | } |
| 85406 | 85420 | pOut->u.r = rB; |
| 85407 | 85421 | MemSetTypeFlag(pOut, MEM_Real); |
| 85408 | | - if( ((type1|type2)&(MEM_Real|MEM_IntReal))==0 && !bIntint ){ |
| 85409 | | - sqlite3VdbeIntegerAffinity(pOut); |
| 85410 | | - } |
| 85411 | 85422 | #endif |
| 85412 | 85423 | } |
| 85413 | 85424 | break; |
| 85414 | 85425 | |
| 85415 | 85426 | arithmetic_result_is_null: |
| | @@ -96110,11 +96121,11 @@ |
| 96110 | 96121 | wrong_num_args = 1; |
| 96111 | 96122 | } |
| 96112 | 96123 | }else{ |
| 96113 | 96124 | is_agg = pDef->xFinalize!=0; |
| 96114 | 96125 | if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){ |
| 96115 | | - ExprSetProperty(pExpr, EP_Unlikely|EP_Skip); |
| 96126 | + ExprSetProperty(pExpr, EP_Unlikely); |
| 96116 | 96127 | if( n==2 ){ |
| 96117 | 96128 | pExpr->iTable = exprProbability(pList->a[1].pExpr); |
| 96118 | 96129 | if( pExpr->iTable<0 ){ |
| 96119 | 96130 | sqlite3ErrorMsg(pParse, |
| 96120 | 96131 | "second argument to likelihood() must be a " |
| | @@ -96293,15 +96304,15 @@ |
| 96293 | 96304 | notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr); |
| 96294 | 96305 | break; |
| 96295 | 96306 | } |
| 96296 | 96307 | case TK_IS: |
| 96297 | 96308 | case TK_ISNOT: { |
| 96298 | | - Expr *pRight; |
| 96309 | + Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight); |
| 96299 | 96310 | assert( !ExprHasProperty(pExpr, EP_Reduced) ); |
| 96300 | 96311 | /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", |
| 96301 | 96312 | ** and "x IS NOT FALSE". */ |
| 96302 | | - if( (pRight = pExpr->pRight)->op==TK_ID ){ |
| 96313 | + if( pRight->op==TK_ID ){ |
| 96303 | 96314 | int rc = resolveExprStep(pWalker, pRight); |
| 96304 | 96315 | if( rc==WRC_Abort ) return WRC_Abort; |
| 96305 | 96316 | if( pRight->op==TK_TRUEFALSE ){ |
| 96306 | 96317 | pExpr->op2 = pExpr->op; |
| 96307 | 96318 | pExpr->op = TK_TRUTH; |
| | @@ -97190,12 +97201,16 @@ |
| 97190 | 97201 | ** SELECT a AS b FROM t1 WHERE b; |
| 97191 | 97202 | ** SELECT * FROM t1 WHERE (select a from t1); |
| 97192 | 97203 | */ |
| 97193 | 97204 | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){ |
| 97194 | 97205 | int op; |
| 97195 | | - pExpr = sqlite3ExprSkipCollate(pExpr); |
| 97196 | 97206 | if( pExpr->flags & EP_Generic ) return 0; |
| 97207 | + while( ExprHasProperty(pExpr, EP_Skip) ){ |
| 97208 | + assert( pExpr->op==TK_COLLATE ); |
| 97209 | + pExpr = pExpr->pLeft; |
| 97210 | + assert( pExpr!=0 ); |
| 97211 | + } |
| 97197 | 97212 | op = pExpr->op; |
| 97198 | 97213 | if( op==TK_SELECT ){ |
| 97199 | 97214 | assert( pExpr->flags&EP_xIsSelect ); |
| 97200 | 97215 | return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr); |
| 97201 | 97216 | } |
| | @@ -97252,11 +97267,11 @@ |
| 97252 | 97267 | /* |
| 97253 | 97268 | ** Skip over any TK_COLLATE operators and any unlikely() |
| 97254 | 97269 | ** or likelihood() function at the root of an expression. |
| 97255 | 97270 | */ |
| 97256 | 97271 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){ |
| 97257 | | - while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){ |
| 97272 | + while( pExpr && ExprHasProperty(pExpr, EP_Skip|EP_Unlikely) ){ |
| 97258 | 97273 | if( ExprHasProperty(pExpr, EP_Unlikely) ){ |
| 97259 | 97274 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 97260 | 97275 | assert( pExpr->x.pList->nExpr>0 ); |
| 97261 | 97276 | assert( pExpr->op==TK_FUNCTION ); |
| 97262 | 97277 | pExpr = pExpr->x.pList->a[0].pExpr; |
| | @@ -98040,15 +98055,13 @@ |
| 98040 | 98055 | sqlite3 *db = pParse->db; |
| 98041 | 98056 | if( pLeft==0 ){ |
| 98042 | 98057 | return pRight; |
| 98043 | 98058 | }else if( pRight==0 ){ |
| 98044 | 98059 | return pLeft; |
| 98045 | | - }else if( pParse->nErr || IN_RENAME_OBJECT ){ |
| 98046 | | - return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); |
| 98047 | 98060 | }else if( ExprAlwaysFalse(pLeft) || ExprAlwaysFalse(pRight) ){ |
| 98048 | | - sqlite3ExprDelete(db, pLeft); |
| 98049 | | - sqlite3ExprDelete(db, pRight); |
| 98061 | + sqlite3ExprUnmapAndDelete(pParse, pLeft); |
| 98062 | + sqlite3ExprUnmapAndDelete(pParse, pRight); |
| 98050 | 98063 | return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0); |
| 98051 | 98064 | }else{ |
| 98052 | 98065 | return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); |
| 98053 | 98066 | } |
| 98054 | 98067 | } |
| | @@ -98203,10 +98216,22 @@ |
| 98203 | 98216 | } |
| 98204 | 98217 | } |
| 98205 | 98218 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ |
| 98206 | 98219 | if( p ) sqlite3ExprDeleteNN(db, p); |
| 98207 | 98220 | } |
| 98221 | + |
| 98222 | +/* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the |
| 98223 | +** expression. |
| 98224 | +*/ |
| 98225 | +SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse *pParse, Expr *p){ |
| 98226 | + if( p ){ |
| 98227 | + if( IN_RENAME_OBJECT ){ |
| 98228 | + sqlite3RenameExprUnmap(pParse, p); |
| 98229 | + } |
| 98230 | + sqlite3ExprDeleteNN(pParse->db, p); |
| 98231 | + } |
| 98232 | +} |
| 98208 | 98233 | |
| 98209 | 98234 | /* |
| 98210 | 98235 | ** Return the number of bytes allocated for the expression structure |
| 98211 | 98236 | ** passed as the first argument. This is always one of EXPR_FULLSIZE, |
| 98212 | 98237 | ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. |
| | @@ -98786,14 +98811,11 @@ |
| 98786 | 98811 | ** the RHS and LHS sizes match during code generation. */ |
| 98787 | 98812 | pFirst->iTable = pColumns->nId; |
| 98788 | 98813 | } |
| 98789 | 98814 | |
| 98790 | 98815 | vector_append_error: |
| 98791 | | - if( IN_RENAME_OBJECT ){ |
| 98792 | | - sqlite3RenameExprUnmap(pParse, pExpr); |
| 98793 | | - } |
| 98794 | | - sqlite3ExprDelete(db, pExpr); |
| 98816 | + sqlite3ExprUnmapAndDelete(pParse, pExpr); |
| 98795 | 98817 | sqlite3IdListDelete(db, pColumns); |
| 98796 | 98818 | return pList; |
| 98797 | 98819 | } |
| 98798 | 98820 | |
| 98799 | 98821 | /* |
| | @@ -98948,10 +98970,11 @@ |
| 98948 | 98970 | /* |
| 98949 | 98971 | ** The argument must be a TK_TRUEFALSE Expr node. Return 1 if it is TRUE |
| 98950 | 98972 | ** and 0 if it is FALSE. |
| 98951 | 98973 | */ |
| 98952 | 98974 | SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr *pExpr){ |
| 98975 | + pExpr = sqlite3ExprSkipCollate((Expr*)pExpr); |
| 98953 | 98976 | assert( pExpr->op==TK_TRUEFALSE ); |
| 98954 | 98977 | assert( sqlite3StrICmp(pExpr->u.zToken,"true")==0 |
| 98955 | 98978 | || sqlite3StrICmp(pExpr->u.zToken,"false")==0 ); |
| 98956 | 98979 | return pExpr->u.zToken[4]==0; |
| 98957 | 98980 | } |
| | @@ -103410,19 +103433,34 @@ |
| 103410 | 103433 | static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ |
| 103411 | 103434 | Parse *pParse = pWalker->pParse; |
| 103412 | 103435 | sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr); |
| 103413 | 103436 | return WRC_Continue; |
| 103414 | 103437 | } |
| 103438 | + |
| 103439 | +/* |
| 103440 | +** Walker callback used by sqlite3RenameExprUnmap(). |
| 103441 | +*/ |
| 103442 | +static int renameUnmapSelectCb(Walker *pWalker, Select *p){ |
| 103443 | + if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */ |
| 103444 | + Parse *pParse = pWalker->pParse; |
| 103445 | + int i; |
| 103446 | + for(i=0; i<p->pSrc->nSrc; i++){ |
| 103447 | + sqlite3RenameTokenRemap(pParse, 0, (void*)p->pSrc->a[0].zName); |
| 103448 | + } |
| 103449 | + } |
| 103450 | + return WRC_Continue; |
| 103451 | +} |
| 103415 | 103452 | |
| 103416 | 103453 | /* |
| 103417 | 103454 | ** Remove all nodes that are part of expression pExpr from the rename list. |
| 103418 | 103455 | */ |
| 103419 | 103456 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){ |
| 103420 | 103457 | Walker sWalker; |
| 103421 | 103458 | memset(&sWalker, 0, sizeof(Walker)); |
| 103422 | 103459 | sWalker.pParse = pParse; |
| 103423 | 103460 | sWalker.xExprCallback = renameUnmapExprCb; |
| 103461 | + sWalker.xSelectCallback = renameUnmapSelectCb; |
| 103424 | 103462 | sqlite3WalkExpr(&sWalker, pExpr); |
| 103425 | 103463 | } |
| 103426 | 103464 | |
| 103427 | 103465 | /* |
| 103428 | 103466 | ** Remove all nodes that are part of expression-list pEList from the |
| | @@ -113797,14 +113835,11 @@ |
| 113797 | 113835 | zBuf = sqlite3_mprintf("%.*f",n,r); |
| 113798 | 113836 | if( zBuf==0 ){ |
| 113799 | 113837 | sqlite3_result_error_nomem(context); |
| 113800 | 113838 | return; |
| 113801 | 113839 | } |
| 113802 | | - if( !sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8) ){ |
| 113803 | | - assert( sqlite3_strglob("*Inf", zBuf)==0 ); |
| 113804 | | - r = zBuf[0]=='-' ? -HUGE_VAL : +HUGE_VAL; |
| 113805 | | - } |
| 113840 | + sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8); |
| 113806 | 113841 | sqlite3_free(zBuf); |
| 113807 | 113842 | } |
| 113808 | 113843 | sqlite3_result_double(context, r); |
| 113809 | 113844 | } |
| 113810 | 113845 | #endif |
| | @@ -118275,11 +118310,11 @@ |
| 118275 | 118310 | if( onError==OE_Ignore ){ |
| 118276 | 118311 | sqlite3VdbeGoto(v, ignoreDest); |
| 118277 | 118312 | }else{ |
| 118278 | 118313 | char *zName = pCheck->a[i].zName; |
| 118279 | 118314 | if( zName==0 ) zName = pTab->zName; |
| 118280 | | - if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ |
| 118315 | + if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-26383-51744 */ |
| 118281 | 118316 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK, |
| 118282 | 118317 | onError, zName, P4_TRANSIENT, |
| 118283 | 118318 | P5_ConstraintCheck); |
| 118284 | 118319 | } |
| 118285 | 118320 | sqlite3VdbeResolveLabel(v, allOk); |
| | @@ -139140,23 +139175,24 @@ |
| 139140 | 139175 | zNew[iTo++] = zNew[iFrom]; |
| 139141 | 139176 | } |
| 139142 | 139177 | zNew[iTo] = 0; |
| 139143 | 139178 | assert( iTo>0 ); |
| 139144 | 139179 | |
| 139145 | | - /* If the RHS begins with a digit or a +/- sign, then the LHS must be |
| 139146 | | - ** an ordinary column (not a virtual table column) with TEXT affinity. |
| 139147 | | - ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false |
| 139148 | | - ** even though "lhs LIKE rhs" is true. But if the RHS does not start |
| 139149 | | - ** with a digit or +/-, then "lhs LIKE rhs" will always be false if |
| 139150 | | - ** the LHS is numeric and so the optimization still works. |
| 139180 | + /* If the RHS begins with a digit, a +/- sign or whitespace, then the |
| 139181 | + ** LHS must be an ordinary column (not a virtual table column) with |
| 139182 | + ** TEXT affinity. Otherwise the LHS might be numeric and "lhs >= rhs" |
| 139183 | + ** would be false even though "lhs LIKE rhs" is true. But if the RHS |
| 139184 | + ** does not start with a digit or +/-, then "lhs LIKE rhs" will always |
| 139185 | + ** be false if the LHS is numeric and so the optimization still works. |
| 139151 | 139186 | ** |
| 139152 | 139187 | ** 2018-09-10 ticket c94369cae9b561b1f996d0054bfab11389f9d033 |
| 139153 | 139188 | ** The RHS pattern must not be '/%' because the termination condition |
| 139154 | 139189 | ** will then become "x<'0'" and if the affinity is numeric, will then |
| 139155 | 139190 | ** be converted into "x<0", which is incorrect. |
| 139156 | 139191 | */ |
| 139157 | 139192 | if( sqlite3Isdigit(zNew[0]) |
| 139193 | + || sqlite3Isspace(zNew[0]) |
| 139158 | 139194 | || zNew[0]=='-' |
| 139159 | 139195 | || zNew[0]=='+' |
| 139160 | 139196 | || zNew[iTo-1]=='0'-1 |
| 139161 | 139197 | ){ |
| 139162 | 139198 | if( pLeft->op!=TK_COLUMN |
| | @@ -152641,14 +152677,12 @@ |
| 152641 | 152677 | ** expr1 NOT IN () |
| 152642 | 152678 | ** |
| 152643 | 152679 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 152644 | 152680 | ** regardless of the value of expr1. |
| 152645 | 152681 | */ |
| 152646 | | - if( IN_RENAME_OBJECT==0 ){ |
| 152647 | | - sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy102); |
| 152648 | | - yymsp[-4].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy100],1); |
| 152649 | | - } |
| 152682 | + sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy102); |
| 152683 | + yymsp[-4].minor.yy102 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy100],1); |
| 152650 | 152684 | }else if( yymsp[-1].minor.yy94->nExpr==1 ){ |
| 152651 | 152685 | /* Expressions of the form: |
| 152652 | 152686 | ** |
| 152653 | 152687 | ** expr1 IN (?1) |
| 152654 | 152688 | ** expr1 NOT IN (?2) |
| | @@ -218857,11 +218891,11 @@ |
| 218857 | 218891 | int nArg, /* Number of args */ |
| 218858 | 218892 | sqlite3_value **apUnused /* Function arguments */ |
| 218859 | 218893 | ){ |
| 218860 | 218894 | assert( nArg==0 ); |
| 218861 | 218895 | UNUSED_PARAM2(nArg, apUnused); |
| 218862 | | - sqlite3_result_text(pCtx, "fts5: 2019-06-04 18:21:59 4979f138e8c8bef7dd6b5921fb9ca9fea86bbf7ec1419934bb2d1a0d74e77183", -1, SQLITE_TRANSIENT); |
| 218896 | + sqlite3_result_text(pCtx, "fts5: 2019-06-13 14:07:41 f8696b60eec0dcacfe92d9a31cbf1436d674140e5447de0cd1c2f52bff6c2be4", -1, SQLITE_TRANSIENT); |
| 218863 | 218897 | } |
| 218864 | 218898 | |
| 218865 | 218899 | /* |
| 218866 | 218900 | ** Return true if zName is the extension on one of the shadow tables used |
| 218867 | 218901 | ** by this module. |
| | @@ -223623,12 +223657,12 @@ |
| 223623 | 223657 | } |
| 223624 | 223658 | #endif /* SQLITE_CORE */ |
| 223625 | 223659 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 223626 | 223660 | |
| 223627 | 223661 | /************** End of stmt.c ************************************************/ |
| 223628 | | -#if __LINE__!=223628 |
| 223662 | +#if __LINE__!=223662 |
| 223629 | 223663 | #undef SQLITE_SOURCE_ID |
| 223630 | | -#define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872alt2" |
| 223664 | +#define SQLITE_SOURCE_ID "2019-06-13 14:07:41 f8696b60eec0dcacfe92d9a31cbf1436d674140e5447de0cd1c2f52bff6calt2" |
| 223631 | 223665 | #endif |
| 223632 | 223666 | /* Return the source-id for this library */ |
| 223633 | 223667 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 223634 | 223668 | /************************** End of sqlite3.c ******************************/ |
| 223635 | 223669 | |