Fossil SCM
Update the built-in SQLite to the latest 3.8.0 beta with the ORDER BY and GROUP BY name resolution fixes, in order to test SQLite.
Commit
b67b42fea8afe1c8c95a84261aa748ca510c1c7d
Parent
4e9522abafa116d…
2 files changed
+71
-56
+2
-2
+71
-56
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -656,11 +656,11 @@ | ||
| 656 | 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | 658 | */ |
| 659 | 659 | #define SQLITE_VERSION "3.8.0" |
| 660 | 660 | #define SQLITE_VERSION_NUMBER 3008000 |
| 661 | -#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084" | |
| 661 | +#define SQLITE_SOURCE_ID "2013-08-15 22:40:21 f2d175f975cd0be63425424ec322a98fb650019e" | |
| 662 | 662 | |
| 663 | 663 | /* |
| 664 | 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | 666 | ** |
| @@ -7780,11 +7780,11 @@ | ||
| 7780 | 7780 | #endif |
| 7781 | 7781 | |
| 7782 | 7782 | #if 0 |
| 7783 | 7783 | } /* End of the 'extern "C"' block */ |
| 7784 | 7784 | #endif |
| 7785 | -#endif | |
| 7785 | +#endif /* _SQLITE3_H_ */ | |
| 7786 | 7786 | |
| 7787 | 7787 | /* |
| 7788 | 7788 | ** 2010 August 30 |
| 7789 | 7789 | ** |
| 7790 | 7790 | ** The author disclaims copyright to this source code. In place of |
| @@ -11214,11 +11214,11 @@ | ||
| 11214 | 11214 | ** subqueries looking for a match. |
| 11215 | 11215 | */ |
| 11216 | 11216 | struct NameContext { |
| 11217 | 11217 | Parse *pParse; /* The parser */ |
| 11218 | 11218 | SrcList *pSrcList; /* One or more tables used to resolve names */ |
| 11219 | - ExprList *pEList; /* Optional list of named expressions */ | |
| 11219 | + ExprList *pEList; /* Optional list of result-set columns */ | |
| 11220 | 11220 | AggInfo *pAggInfo; /* Information about aggregates at this level */ |
| 11221 | 11221 | NameContext *pNext; /* Next outer name context. NULL for outermost */ |
| 11222 | 11222 | int nRef; /* Number of names resolved by this context */ |
| 11223 | 11223 | int nErr; /* Number of errors encountered while resolving names */ |
| 11224 | 11224 | u8 ncFlags; /* Zero or more NC_* flags defined below */ |
| @@ -11229,13 +11229,11 @@ | ||
| 11229 | 11229 | */ |
| 11230 | 11230 | #define NC_AllowAgg 0x01 /* Aggregate functions are allowed here */ |
| 11231 | 11231 | #define NC_HasAgg 0x02 /* One or more aggregate functions seen */ |
| 11232 | 11232 | #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ |
| 11233 | 11233 | #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ |
| 11234 | -#define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only | |
| 11235 | - ** if no other resolution is available */ | |
| 11236 | -#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */ | |
| 11234 | +#define NC_PartIdx 0x10 /* True if resolving a partial index WHERE */ | |
| 11237 | 11235 | |
| 11238 | 11236 | /* |
| 11239 | 11237 | ** An instance of the following structure contains all information |
| 11240 | 11238 | ** needed to generate code for a single SELECT statement. |
| 11241 | 11239 | ** |
| @@ -17231,17 +17229,17 @@ | ||
| 17231 | 17229 | u8 *aCtrl; |
| 17232 | 17230 | |
| 17233 | 17231 | } mem5; |
| 17234 | 17232 | |
| 17235 | 17233 | /* |
| 17236 | -** Access the static variable through a macro for SQLITE_OMIT_WSD | |
| 17234 | +** Access the static variable through a macro for SQLITE_OMIT_WSD. | |
| 17237 | 17235 | */ |
| 17238 | 17236 | #define mem5 GLOBAL(struct Mem5Global, mem5) |
| 17239 | 17237 | |
| 17240 | 17238 | /* |
| 17241 | 17239 | ** Assuming mem5.zPool is divided up into an array of Mem5Link |
| 17242 | -** structures, return a pointer to the idx-th such lik. | |
| 17240 | +** structures, return a pointer to the idx-th such link. | |
| 17243 | 17241 | */ |
| 17244 | 17242 | #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom])) |
| 17245 | 17243 | |
| 17246 | 17244 | /* |
| 17247 | 17245 | ** Unlink the chunk at mem5.aPool[i] from list it is currently |
| @@ -17333,11 +17331,11 @@ | ||
| 17333 | 17331 | |
| 17334 | 17332 | /* |
| 17335 | 17333 | ** Return a block of memory of at least nBytes in size. |
| 17336 | 17334 | ** Return NULL if unable. Return NULL if nBytes==0. |
| 17337 | 17335 | ** |
| 17338 | -** The caller guarantees that nByte positive. | |
| 17336 | +** The caller guarantees that nByte is positive. | |
| 17339 | 17337 | ** |
| 17340 | 17338 | ** The caller has obtained a mutex prior to invoking this |
| 17341 | 17339 | ** routine so there is never any chance that two or more |
| 17342 | 17340 | ** threads can be in this routine at the same time. |
| 17343 | 17341 | */ |
| @@ -17455,11 +17453,11 @@ | ||
| 17455 | 17453 | } |
| 17456 | 17454 | memsys5Link(iBlock, iLogsize); |
| 17457 | 17455 | } |
| 17458 | 17456 | |
| 17459 | 17457 | /* |
| 17460 | -** Allocate nBytes of memory | |
| 17458 | +** Allocate nBytes of memory. | |
| 17461 | 17459 | */ |
| 17462 | 17460 | static void *memsys5Malloc(int nBytes){ |
| 17463 | 17461 | sqlite3_int64 *p = 0; |
| 17464 | 17462 | if( nBytes>0 ){ |
| 17465 | 17463 | memsys5Enter(); |
| @@ -74041,22 +74039,23 @@ | ||
| 74041 | 74039 | ** |
| 74042 | 74040 | ** The reason for suppressing the TK_AS term when the expression is a simple |
| 74043 | 74041 | ** column reference is so that the column reference will be recognized as |
| 74044 | 74042 | ** usable by indices within the WHERE clause processing logic. |
| 74045 | 74043 | ** |
| 74046 | -** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means | |
| 74044 | +** The TK_AS operator is inhibited if zType[0]=='G'. This means | |
| 74047 | 74045 | ** that in a GROUP BY clause, the expression is evaluated twice. Hence: |
| 74048 | 74046 | ** |
| 74049 | 74047 | ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x |
| 74050 | 74048 | ** |
| 74051 | 74049 | ** Is equivalent to: |
| 74052 | 74050 | ** |
| 74053 | 74051 | ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 |
| 74054 | 74052 | ** |
| 74055 | 74053 | ** The result of random()%5 in the GROUP BY clause is probably different |
| 74056 | -** from the result in the result-set. We might fix this someday. Or | |
| 74057 | -** then again, we might not... | |
| 74054 | +** from the result in the result-set. On the other hand Standard SQL does | |
| 74055 | +** not allow the GROUP BY clause to contain references to result-set columns. | |
| 74056 | +** So this should never come up in well-formed queries. | |
| 74058 | 74057 | ** |
| 74059 | 74058 | ** If the reference is followed by a COLLATE operator, then make sure |
| 74060 | 74059 | ** the COLLATE operator is preserved. For example: |
| 74061 | 74060 | ** |
| 74062 | 74061 | ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase; |
| @@ -74382,14 +74381,20 @@ | ||
| 74382 | 74381 | ** |
| 74383 | 74382 | ** In cases like this, replace pExpr with a copy of the expression that |
| 74384 | 74383 | ** forms the result set entry ("a+b" in the example) and return immediately. |
| 74385 | 74384 | ** Note that the expression in the result set should have already been |
| 74386 | 74385 | ** resolved by the time the WHERE clause is resolved. |
| 74386 | + ** | |
| 74387 | + ** The ability to use an output result-set column in the WHERE, GROUP BY, | |
| 74388 | + ** or HAVING clauses, or as part of a larger expression in the ORDRE BY | |
| 74389 | + ** clause is not standard SQL. This is a (goofy) SQLite extension, that | |
| 74390 | + ** is supported for backwards compatibility only. TO DO: Issue a warning | |
| 74391 | + ** on sqlite3_log() whenever the capability is used. | |
| 74387 | 74392 | */ |
| 74388 | 74393 | if( (pEList = pNC->pEList)!=0 |
| 74389 | 74394 | && zTab==0 |
| 74390 | - && ((pNC->ncFlags & NC_AsMaybe)==0 || cnt==0) | |
| 74395 | + && cnt==0 | |
| 74391 | 74396 | ){ |
| 74392 | 74397 | for(j=0; j<pEList->nExpr; j++){ |
| 74393 | 74398 | char *zAs = pEList->a[j].zName; |
| 74394 | 74399 | if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 74395 | 74400 | Expr *pOrig; |
| @@ -74947,11 +74952,11 @@ | ||
| 74947 | 74952 | } |
| 74948 | 74953 | |
| 74949 | 74954 | /* |
| 74950 | 74955 | ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of |
| 74951 | 74956 | ** the SELECT statement pSelect. If any term is reference to a |
| 74952 | -** result set expression (as determined by the ExprList.a.iCol field) | |
| 74957 | +** result set expression (as determined by the ExprList.a.iOrderByCol field) | |
| 74953 | 74958 | ** then convert that term into a copy of the corresponding result set |
| 74954 | 74959 | ** column. |
| 74955 | 74960 | ** |
| 74956 | 74961 | ** If any errors are detected, add an error message to pParse and |
| 74957 | 74962 | ** return non-zero. Return zero if no errors are seen. |
| @@ -74995,11 +75000,11 @@ | ||
| 74995 | 75000 | ** |
| 74996 | 75001 | ** This routine resolves each term of the clause into an expression. |
| 74997 | 75002 | ** If the order-by term is an integer I between 1 and N (where N is the |
| 74998 | 75003 | ** number of columns in the result set of the SELECT) then the expression |
| 74999 | 75004 | ** in the resolution is a copy of the I-th result-set expression. If |
| 75000 | -** the order-by term is an identify that corresponds to the AS-name of | |
| 75005 | +** the order-by term is an identifier that corresponds to the AS-name of | |
| 75001 | 75006 | ** a result-set expression, then the term resolves to a copy of the |
| 75002 | 75007 | ** result-set expression. Otherwise, the expression is resolved in |
| 75003 | 75008 | ** the usual way - using sqlite3ResolveExprNames(). |
| 75004 | 75009 | ** |
| 75005 | 75010 | ** This routine returns the number of errors. If errors occur, then |
| @@ -75021,20 +75026,23 @@ | ||
| 75021 | 75026 | if( pOrderBy==0 ) return 0; |
| 75022 | 75027 | nResult = pSelect->pEList->nExpr; |
| 75023 | 75028 | pParse = pNC->pParse; |
| 75024 | 75029 | for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ |
| 75025 | 75030 | Expr *pE = pItem->pExpr; |
| 75026 | - iCol = resolveAsName(pParse, pSelect->pEList, pE); | |
| 75027 | - if( iCol>0 ){ | |
| 75028 | - /* If an AS-name match is found, mark this ORDER BY column as being | |
| 75029 | - ** a copy of the iCol-th result-set column. The subsequent call to | |
| 75030 | - ** sqlite3ResolveOrderGroupBy() will convert the expression to a | |
| 75031 | - ** copy of the iCol-th result-set expression. */ | |
| 75032 | - pItem->iOrderByCol = (u16)iCol; | |
| 75033 | - continue; | |
| 75034 | - } | |
| 75035 | - if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){ | |
| 75031 | + Expr *pE2 = sqlite3ExprSkipCollate(pE); | |
| 75032 | + if( zType[0]!='G' ){ | |
| 75033 | + iCol = resolveAsName(pParse, pSelect->pEList, pE2); | |
| 75034 | + if( iCol>0 ){ | |
| 75035 | + /* If an AS-name match is found, mark this ORDER BY column as being | |
| 75036 | + ** a copy of the iCol-th result-set column. The subsequent call to | |
| 75037 | + ** sqlite3ResolveOrderGroupBy() will convert the expression to a | |
| 75038 | + ** copy of the iCol-th result-set expression. */ | |
| 75039 | + pItem->iOrderByCol = (u16)iCol; | |
| 75040 | + continue; | |
| 75041 | + } | |
| 75042 | + } | |
| 75043 | + if( sqlite3ExprIsInteger(pE2, &iCol) ){ | |
| 75036 | 75044 | /* The ORDER BY term is an integer constant. Again, set the column |
| 75037 | 75045 | ** number so that sqlite3ResolveOrderGroupBy() will convert the |
| 75038 | 75046 | ** order-by term to a copy of the result-set expression */ |
| 75039 | 75047 | if( iCol<1 || iCol>0xffff ){ |
| 75040 | 75048 | resolveOutOfRangeError(pParse, zType, i+1, nResult); |
| @@ -75173,23 +75181,21 @@ | ||
| 75173 | 75181 | if( p->pHaving && !pGroupBy ){ |
| 75174 | 75182 | sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); |
| 75175 | 75183 | return WRC_Abort; |
| 75176 | 75184 | } |
| 75177 | 75185 | |
| 75178 | - /* Add the expression list to the name-context before parsing the | |
| 75186 | + /* Add the output column list to the name-context before parsing the | |
| 75179 | 75187 | ** other expressions in the SELECT statement. This is so that |
| 75180 | 75188 | ** expressions in the WHERE clause (etc.) can refer to expressions by |
| 75181 | 75189 | ** aliases in the result set. |
| 75182 | 75190 | ** |
| 75183 | 75191 | ** Minor point: If this is the case, then the expression will be |
| 75184 | 75192 | ** re-evaluated for each reference to it. |
| 75185 | 75193 | */ |
| 75186 | 75194 | sNC.pEList = p->pEList; |
| 75187 | - sNC.ncFlags |= NC_AsMaybe; | |
| 75188 | 75195 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 75189 | 75196 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| 75190 | - sNC.ncFlags &= ~NC_AsMaybe; | |
| 75191 | 75197 | |
| 75192 | 75198 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 75193 | 75199 | ** outer queries |
| 75194 | 75200 | */ |
| 75195 | 75201 | sNC.pNext = 0; |
| @@ -77134,19 +77140,21 @@ | ||
| 77134 | 77140 | assert( !isRowid ); |
| 77135 | 77141 | sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); |
| 77136 | 77142 | dest.affSdst = (u8)affinity; |
| 77137 | 77143 | assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); |
| 77138 | 77144 | pExpr->x.pSelect->iLimit = 0; |
| 77145 | + testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ | |
| 77139 | 77146 | if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ |
| 77140 | 77147 | sqlite3DbFree(pParse->db, pKeyInfo); |
| 77141 | 77148 | return 0; |
| 77142 | 77149 | } |
| 77143 | 77150 | pEList = pExpr->x.pSelect->pEList; |
| 77144 | - if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){ | |
| 77145 | - pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, | |
| 77146 | - pEList->a[0].pExpr); | |
| 77147 | - } | |
| 77151 | + assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ | |
| 77152 | + assert( pEList!=0 ); | |
| 77153 | + assert( pEList->nExpr>0 ); | |
| 77154 | + pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, | |
| 77155 | + pEList->a[0].pExpr); | |
| 77148 | 77156 | }else if( ALWAYS(pExpr->x.pList!=0) ){ |
| 77149 | 77157 | /* Case 2: expr IN (exprlist) |
| 77150 | 77158 | ** |
| 77151 | 77159 | ** For each expression, build an index key from the evaluation and |
| 77152 | 77160 | ** store it in the temporary table. If <expr> is a column, then use |
| @@ -104711,11 +104719,11 @@ | ||
| 104711 | 104719 | # define WHERETRACE_ENABLED 1 |
| 104712 | 104720 | #else |
| 104713 | 104721 | # define WHERETRACE(K,X) |
| 104714 | 104722 | #endif |
| 104715 | 104723 | |
| 104716 | -/* Forward reference | |
| 104724 | +/* Forward references | |
| 104717 | 104725 | */ |
| 104718 | 104726 | typedef struct WhereClause WhereClause; |
| 104719 | 104727 | typedef struct WhereMaskSet WhereMaskSet; |
| 104720 | 104728 | typedef struct WhereOrInfo WhereOrInfo; |
| 104721 | 104729 | typedef struct WhereAndInfo WhereAndInfo; |
| @@ -104733,18 +104741,19 @@ | ||
| 104733 | 104741 | ** maximum cost for ordinary tables is 64*(2**63) which becomes 6900. |
| 104734 | 104742 | ** (Virtual tables can return a larger cost, but let's assume they do not.) |
| 104735 | 104743 | ** So all costs can be stored in a 16-bit unsigned integer without risk |
| 104736 | 104744 | ** of overflow. |
| 104737 | 104745 | ** |
| 104738 | -** Costs are estimates, so don't go to the computational trouble to compute | |
| 104739 | -** 10*log2(X) exactly. Instead, a close estimate is used. Any value of | |
| 104740 | -** X<=1 is stored as 0. X=2 is 10. X=3 is 16. X=1000 is 99. etc. | |
| 104746 | +** Costs are estimates, so no effort is made to compute 10*log2(X) exactly. | |
| 104747 | +** Instead, a close estimate is used. Any value of X<=1 is stored as 0. | |
| 104748 | +** X=2 is 10. X=3 is 16. X=1000 is 99. etc. | |
| 104741 | 104749 | ** |
| 104742 | 104750 | ** The tool/wherecosttest.c source file implements a command-line program |
| 104743 | -** that will convert between WhereCost to integers and do addition and | |
| 104744 | -** multiplication on WhereCost values. That command-line program is a | |
| 104745 | -** useful utility to have around when working with this module. | |
| 104751 | +** that will convert WhereCosts to integers, convert integers to WhereCosts | |
| 104752 | +** and do addition and multiplication on WhereCost values. The wherecosttest | |
| 104753 | +** command-line program is a useful utility to have around when working with | |
| 104754 | +** this module. | |
| 104746 | 104755 | */ |
| 104747 | 104756 | typedef unsigned short int WhereCost; |
| 104748 | 104757 | |
| 104749 | 104758 | /* |
| 104750 | 104759 | ** This object contains information needed to implement a single nested |
| @@ -104843,12 +104852,12 @@ | ||
| 104843 | 104852 | WhereCost rRun; /* Cost of running this subquery */ |
| 104844 | 104853 | WhereCost nOut; /* Number of outputs for this subquery */ |
| 104845 | 104854 | }; |
| 104846 | 104855 | |
| 104847 | 104856 | /* The WhereOrSet object holds a set of possible WhereOrCosts that |
| 104848 | -** correspond to the subquery(s) of OR-clause processing. At most | |
| 104849 | -** favorable N_OR_COST elements are retained. | |
| 104857 | +** correspond to the subquery(s) of OR-clause processing. Only the | |
| 104858 | +** best N_OR_COST elements are retained. | |
| 104850 | 104859 | */ |
| 104851 | 104860 | #define N_OR_COST 3 |
| 104852 | 104861 | struct WhereOrSet { |
| 104853 | 104862 | u16 n; /* Number of valid a[] entries */ |
| 104854 | 104863 | WhereOrCost a[N_OR_COST]; /* Set of best costs */ |
| @@ -104910,13 +104919,13 @@ | ||
| 104910 | 104919 | ** |
| 104911 | 104920 | ** A WhereTerm might also be two or more subterms connected by OR: |
| 104912 | 104921 | ** |
| 104913 | 104922 | ** (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR .... |
| 104914 | 104923 | ** |
| 104915 | -** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR | |
| 104924 | +** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR | |
| 104916 | 104925 | ** and the WhereTerm.u.pOrInfo field points to auxiliary information that |
| 104917 | -** is collected about the | |
| 104926 | +** is collected about the OR clause. | |
| 104918 | 104927 | ** |
| 104919 | 104928 | ** If a term in the WHERE clause does not match either of the two previous |
| 104920 | 104929 | ** categories, then eOperator==0. The WhereTerm.pExpr field is still set |
| 104921 | 104930 | ** to the original subexpression content and wtFlags is set up appropriately |
| 104922 | 104931 | ** but no other fields in the WhereTerm object are meaningful. |
| @@ -105424,11 +105433,11 @@ | ||
| 105424 | 105433 | assert( pMaskSet->n < ArraySize(pMaskSet->ix) ); |
| 105425 | 105434 | pMaskSet->ix[pMaskSet->n++] = iCursor; |
| 105426 | 105435 | } |
| 105427 | 105436 | |
| 105428 | 105437 | /* |
| 105429 | -** These routine walk (recursively) an expression tree and generates | |
| 105438 | +** These routines walk (recursively) an expression tree and generate | |
| 105430 | 105439 | ** a bitmask indicating which tables are used in that expression |
| 105431 | 105440 | ** tree. |
| 105432 | 105441 | */ |
| 105433 | 105442 | static Bitmask exprListTableUsage(WhereMaskSet*, ExprList*); |
| 105434 | 105443 | static Bitmask exprSelectTableUsage(WhereMaskSet*, Select*); |
| @@ -105941,14 +105950,14 @@ | ||
| 105941 | 105950 | ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. |
| 105942 | 105951 | ** |
| 105943 | 105952 | ** From another point of view, "indexable" means that the subterm could |
| 105944 | 105953 | ** potentially be used with an index if an appropriate index exists. |
| 105945 | 105954 | ** This analysis does not consider whether or not the index exists; that |
| 105946 | -** is something the bestIndex() routine will determine. This analysis | |
| 105947 | -** only looks at whether subterms appropriate for indexing exist. | |
| 105955 | +** is decided elsewhere. This analysis only looks at whether subterms | |
| 105956 | +** appropriate for indexing exist. | |
| 105948 | 105957 | ** |
| 105949 | -** All examples A through E above all satisfy case 2. But if a term | |
| 105958 | +** All examples A through E above satisfy case 2. But if a term | |
| 105950 | 105959 | ** also statisfies case 1 (such as B) we know that the optimizer will |
| 105951 | 105960 | ** always prefer case 1, so in that case we pretend that case 2 is not |
| 105952 | 105961 | ** satisfied. |
| 105953 | 105962 | ** |
| 105954 | 105963 | ** It might be the case that multiple tables are indexable. For example, |
| @@ -106611,11 +106620,11 @@ | ||
| 106611 | 106620 | |
| 106612 | 106621 | return 0; |
| 106613 | 106622 | } |
| 106614 | 106623 | |
| 106615 | 106624 | /* |
| 106616 | -** The (an approximate) sum of two WhereCosts. This computation is | |
| 106625 | +** Find (an approximate) sum of two WhereCosts. This computation is | |
| 106617 | 106626 | ** not a simple "+" operator because WhereCost is stored as a logarithmic |
| 106618 | 106627 | ** value. |
| 106619 | 106628 | ** |
| 106620 | 106629 | */ |
| 106621 | 106630 | static WhereCost whereCostAdd(WhereCost a, WhereCost b){ |
| @@ -115614,10 +115623,13 @@ | ||
| 115614 | 115623 | ** without blocking. |
| 115615 | 115624 | */ |
| 115616 | 115625 | SQLITE_API int sqlite3_initialize(void){ |
| 115617 | 115626 | MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ |
| 115618 | 115627 | int rc; /* Result code */ |
| 115628 | +#ifdef SQLITE_EXTRA_INIT | |
| 115629 | + int bRunExtraInit = 0; /* Extra initialization needed */ | |
| 115630 | +#endif | |
| 115619 | 115631 | |
| 115620 | 115632 | #ifdef SQLITE_OMIT_WSD |
| 115621 | 115633 | rc = sqlite3_wsd_init(4096, 24); |
| 115622 | 115634 | if( rc!=SQLITE_OK ){ |
| 115623 | 115635 | return rc; |
| @@ -115711,10 +115723,13 @@ | ||
| 115711 | 115723 | } |
| 115712 | 115724 | if( rc==SQLITE_OK ){ |
| 115713 | 115725 | sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, |
| 115714 | 115726 | sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage); |
| 115715 | 115727 | sqlite3GlobalConfig.isInit = 1; |
| 115728 | +#ifdef SQLITE_EXTRA_INIT | |
| 115729 | + bRunExtraInit = 1; | |
| 115730 | +#endif | |
| 115716 | 115731 | } |
| 115717 | 115732 | sqlite3GlobalConfig.inProgress = 0; |
| 115718 | 115733 | } |
| 115719 | 115734 | sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex); |
| 115720 | 115735 | |
| @@ -115751,11 +115766,11 @@ | ||
| 115751 | 115766 | |
| 115752 | 115767 | /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT |
| 115753 | 115768 | ** compile-time option. |
| 115754 | 115769 | */ |
| 115755 | 115770 | #ifdef SQLITE_EXTRA_INIT |
| 115756 | - if( rc==SQLITE_OK && sqlite3GlobalConfig.isInit ){ | |
| 115771 | + if( bRunExtraInit ){ | |
| 115757 | 115772 | int SQLITE_EXTRA_INIT(const char*); |
| 115758 | 115773 | rc = SQLITE_EXTRA_INIT(0); |
| 115759 | 115774 | } |
| 115760 | 115775 | #endif |
| 115761 | 115776 | |
| @@ -115939,12 +115954,12 @@ | ||
| 115939 | 115954 | ** run. |
| 115940 | 115955 | */ |
| 115941 | 115956 | memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m)); |
| 115942 | 115957 | }else{ |
| 115943 | 115958 | /* The heap pointer is not NULL, then install one of the |
| 115944 | - ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor | |
| 115945 | - ** ENABLE_MEMSYS5 is defined, return an error. | |
| 115959 | + ** mem5.c/mem3.c methods. The enclosing #if guarantees at | |
| 115960 | + ** least one of these methods is currently enabled. | |
| 115946 | 115961 | */ |
| 115947 | 115962 | #ifdef SQLITE_ENABLE_MEMSYS3 |
| 115948 | 115963 | sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3(); |
| 115949 | 115964 | #endif |
| 115950 | 115965 | #ifdef SQLITE_ENABLE_MEMSYS5 |
| @@ -115959,11 +115974,11 @@ | ||
| 115959 | 115974 | sqlite3GlobalConfig.szLookaside = va_arg(ap, int); |
| 115960 | 115975 | sqlite3GlobalConfig.nLookaside = va_arg(ap, int); |
| 115961 | 115976 | break; |
| 115962 | 115977 | } |
| 115963 | 115978 | |
| 115964 | - /* Record a pointer to the logger funcction and its first argument. | |
| 115979 | + /* Record a pointer to the logger function and its first argument. | |
| 115965 | 115980 | ** The default is NULL. Logging is disabled if the function pointer is |
| 115966 | 115981 | ** NULL. |
| 115967 | 115982 | */ |
| 115968 | 115983 | case SQLITE_CONFIG_LOG: { |
| 115969 | 115984 | /* MSVC is picky about pulling func ptrs from va lists. |
| @@ -117675,24 +117690,24 @@ | ||
| 117675 | 117690 | |
| 117676 | 117691 | for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&'); |
| 117677 | 117692 | zFile = sqlite3_malloc(nByte); |
| 117678 | 117693 | if( !zFile ) return SQLITE_NOMEM; |
| 117679 | 117694 | |
| 117695 | + iIn = 5; | |
| 117696 | +#ifndef SQLITE_ALLOW_URI_AUTHORITY | |
| 117680 | 117697 | /* Discard the scheme and authority segments of the URI. */ |
| 117681 | 117698 | if( zUri[5]=='/' && zUri[6]=='/' ){ |
| 117682 | 117699 | iIn = 7; |
| 117683 | 117700 | while( zUri[iIn] && zUri[iIn]!='/' ) iIn++; |
| 117684 | - | |
| 117685 | 117701 | if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){ |
| 117686 | 117702 | *pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", |
| 117687 | 117703 | iIn-7, &zUri[7]); |
| 117688 | 117704 | rc = SQLITE_ERROR; |
| 117689 | 117705 | goto parse_uri_out; |
| 117690 | 117706 | } |
| 117691 | - }else{ | |
| 117692 | - iIn = 5; | |
| 117693 | 117707 | } |
| 117708 | +#endif | |
| 117694 | 117709 | |
| 117695 | 117710 | /* Copy the filename and any query parameters into the zFile buffer. |
| 117696 | 117711 | ** Decode %HH escape codes along the way. |
| 117697 | 117712 | ** |
| 117698 | 117713 | ** Within this loop, variable eState may be set to 0, 1 or 2, depending |
| 117699 | 117714 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -656,11 +656,11 @@ | |
| 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | */ |
| 659 | #define SQLITE_VERSION "3.8.0" |
| 660 | #define SQLITE_VERSION_NUMBER 3008000 |
| 661 | #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084" |
| 662 | |
| 663 | /* |
| 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | ** |
| @@ -7780,11 +7780,11 @@ | |
| 7780 | #endif |
| 7781 | |
| 7782 | #if 0 |
| 7783 | } /* End of the 'extern "C"' block */ |
| 7784 | #endif |
| 7785 | #endif |
| 7786 | |
| 7787 | /* |
| 7788 | ** 2010 August 30 |
| 7789 | ** |
| 7790 | ** The author disclaims copyright to this source code. In place of |
| @@ -11214,11 +11214,11 @@ | |
| 11214 | ** subqueries looking for a match. |
| 11215 | */ |
| 11216 | struct NameContext { |
| 11217 | Parse *pParse; /* The parser */ |
| 11218 | SrcList *pSrcList; /* One or more tables used to resolve names */ |
| 11219 | ExprList *pEList; /* Optional list of named expressions */ |
| 11220 | AggInfo *pAggInfo; /* Information about aggregates at this level */ |
| 11221 | NameContext *pNext; /* Next outer name context. NULL for outermost */ |
| 11222 | int nRef; /* Number of names resolved by this context */ |
| 11223 | int nErr; /* Number of errors encountered while resolving names */ |
| 11224 | u8 ncFlags; /* Zero or more NC_* flags defined below */ |
| @@ -11229,13 +11229,11 @@ | |
| 11229 | */ |
| 11230 | #define NC_AllowAgg 0x01 /* Aggregate functions are allowed here */ |
| 11231 | #define NC_HasAgg 0x02 /* One or more aggregate functions seen */ |
| 11232 | #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ |
| 11233 | #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ |
| 11234 | #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only |
| 11235 | ** if no other resolution is available */ |
| 11236 | #define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */ |
| 11237 | |
| 11238 | /* |
| 11239 | ** An instance of the following structure contains all information |
| 11240 | ** needed to generate code for a single SELECT statement. |
| 11241 | ** |
| @@ -17231,17 +17229,17 @@ | |
| 17231 | u8 *aCtrl; |
| 17232 | |
| 17233 | } mem5; |
| 17234 | |
| 17235 | /* |
| 17236 | ** Access the static variable through a macro for SQLITE_OMIT_WSD |
| 17237 | */ |
| 17238 | #define mem5 GLOBAL(struct Mem5Global, mem5) |
| 17239 | |
| 17240 | /* |
| 17241 | ** Assuming mem5.zPool is divided up into an array of Mem5Link |
| 17242 | ** structures, return a pointer to the idx-th such lik. |
| 17243 | */ |
| 17244 | #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom])) |
| 17245 | |
| 17246 | /* |
| 17247 | ** Unlink the chunk at mem5.aPool[i] from list it is currently |
| @@ -17333,11 +17331,11 @@ | |
| 17333 | |
| 17334 | /* |
| 17335 | ** Return a block of memory of at least nBytes in size. |
| 17336 | ** Return NULL if unable. Return NULL if nBytes==0. |
| 17337 | ** |
| 17338 | ** The caller guarantees that nByte positive. |
| 17339 | ** |
| 17340 | ** The caller has obtained a mutex prior to invoking this |
| 17341 | ** routine so there is never any chance that two or more |
| 17342 | ** threads can be in this routine at the same time. |
| 17343 | */ |
| @@ -17455,11 +17453,11 @@ | |
| 17455 | } |
| 17456 | memsys5Link(iBlock, iLogsize); |
| 17457 | } |
| 17458 | |
| 17459 | /* |
| 17460 | ** Allocate nBytes of memory |
| 17461 | */ |
| 17462 | static void *memsys5Malloc(int nBytes){ |
| 17463 | sqlite3_int64 *p = 0; |
| 17464 | if( nBytes>0 ){ |
| 17465 | memsys5Enter(); |
| @@ -74041,22 +74039,23 @@ | |
| 74041 | ** |
| 74042 | ** The reason for suppressing the TK_AS term when the expression is a simple |
| 74043 | ** column reference is so that the column reference will be recognized as |
| 74044 | ** usable by indices within the WHERE clause processing logic. |
| 74045 | ** |
| 74046 | ** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means |
| 74047 | ** that in a GROUP BY clause, the expression is evaluated twice. Hence: |
| 74048 | ** |
| 74049 | ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x |
| 74050 | ** |
| 74051 | ** Is equivalent to: |
| 74052 | ** |
| 74053 | ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 |
| 74054 | ** |
| 74055 | ** The result of random()%5 in the GROUP BY clause is probably different |
| 74056 | ** from the result in the result-set. We might fix this someday. Or |
| 74057 | ** then again, we might not... |
| 74058 | ** |
| 74059 | ** If the reference is followed by a COLLATE operator, then make sure |
| 74060 | ** the COLLATE operator is preserved. For example: |
| 74061 | ** |
| 74062 | ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase; |
| @@ -74382,14 +74381,20 @@ | |
| 74382 | ** |
| 74383 | ** In cases like this, replace pExpr with a copy of the expression that |
| 74384 | ** forms the result set entry ("a+b" in the example) and return immediately. |
| 74385 | ** Note that the expression in the result set should have already been |
| 74386 | ** resolved by the time the WHERE clause is resolved. |
| 74387 | */ |
| 74388 | if( (pEList = pNC->pEList)!=0 |
| 74389 | && zTab==0 |
| 74390 | && ((pNC->ncFlags & NC_AsMaybe)==0 || cnt==0) |
| 74391 | ){ |
| 74392 | for(j=0; j<pEList->nExpr; j++){ |
| 74393 | char *zAs = pEList->a[j].zName; |
| 74394 | if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 74395 | Expr *pOrig; |
| @@ -74947,11 +74952,11 @@ | |
| 74947 | } |
| 74948 | |
| 74949 | /* |
| 74950 | ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of |
| 74951 | ** the SELECT statement pSelect. If any term is reference to a |
| 74952 | ** result set expression (as determined by the ExprList.a.iCol field) |
| 74953 | ** then convert that term into a copy of the corresponding result set |
| 74954 | ** column. |
| 74955 | ** |
| 74956 | ** If any errors are detected, add an error message to pParse and |
| 74957 | ** return non-zero. Return zero if no errors are seen. |
| @@ -74995,11 +75000,11 @@ | |
| 74995 | ** |
| 74996 | ** This routine resolves each term of the clause into an expression. |
| 74997 | ** If the order-by term is an integer I between 1 and N (where N is the |
| 74998 | ** number of columns in the result set of the SELECT) then the expression |
| 74999 | ** in the resolution is a copy of the I-th result-set expression. If |
| 75000 | ** the order-by term is an identify that corresponds to the AS-name of |
| 75001 | ** a result-set expression, then the term resolves to a copy of the |
| 75002 | ** result-set expression. Otherwise, the expression is resolved in |
| 75003 | ** the usual way - using sqlite3ResolveExprNames(). |
| 75004 | ** |
| 75005 | ** This routine returns the number of errors. If errors occur, then |
| @@ -75021,20 +75026,23 @@ | |
| 75021 | if( pOrderBy==0 ) return 0; |
| 75022 | nResult = pSelect->pEList->nExpr; |
| 75023 | pParse = pNC->pParse; |
| 75024 | for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ |
| 75025 | Expr *pE = pItem->pExpr; |
| 75026 | iCol = resolveAsName(pParse, pSelect->pEList, pE); |
| 75027 | if( iCol>0 ){ |
| 75028 | /* If an AS-name match is found, mark this ORDER BY column as being |
| 75029 | ** a copy of the iCol-th result-set column. The subsequent call to |
| 75030 | ** sqlite3ResolveOrderGroupBy() will convert the expression to a |
| 75031 | ** copy of the iCol-th result-set expression. */ |
| 75032 | pItem->iOrderByCol = (u16)iCol; |
| 75033 | continue; |
| 75034 | } |
| 75035 | if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){ |
| 75036 | /* The ORDER BY term is an integer constant. Again, set the column |
| 75037 | ** number so that sqlite3ResolveOrderGroupBy() will convert the |
| 75038 | ** order-by term to a copy of the result-set expression */ |
| 75039 | if( iCol<1 || iCol>0xffff ){ |
| 75040 | resolveOutOfRangeError(pParse, zType, i+1, nResult); |
| @@ -75173,23 +75181,21 @@ | |
| 75173 | if( p->pHaving && !pGroupBy ){ |
| 75174 | sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); |
| 75175 | return WRC_Abort; |
| 75176 | } |
| 75177 | |
| 75178 | /* Add the expression list to the name-context before parsing the |
| 75179 | ** other expressions in the SELECT statement. This is so that |
| 75180 | ** expressions in the WHERE clause (etc.) can refer to expressions by |
| 75181 | ** aliases in the result set. |
| 75182 | ** |
| 75183 | ** Minor point: If this is the case, then the expression will be |
| 75184 | ** re-evaluated for each reference to it. |
| 75185 | */ |
| 75186 | sNC.pEList = p->pEList; |
| 75187 | sNC.ncFlags |= NC_AsMaybe; |
| 75188 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 75189 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| 75190 | sNC.ncFlags &= ~NC_AsMaybe; |
| 75191 | |
| 75192 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 75193 | ** outer queries |
| 75194 | */ |
| 75195 | sNC.pNext = 0; |
| @@ -77134,19 +77140,21 @@ | |
| 77134 | assert( !isRowid ); |
| 77135 | sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); |
| 77136 | dest.affSdst = (u8)affinity; |
| 77137 | assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); |
| 77138 | pExpr->x.pSelect->iLimit = 0; |
| 77139 | if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ |
| 77140 | sqlite3DbFree(pParse->db, pKeyInfo); |
| 77141 | return 0; |
| 77142 | } |
| 77143 | pEList = pExpr->x.pSelect->pEList; |
| 77144 | if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){ |
| 77145 | pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, |
| 77146 | pEList->a[0].pExpr); |
| 77147 | } |
| 77148 | }else if( ALWAYS(pExpr->x.pList!=0) ){ |
| 77149 | /* Case 2: expr IN (exprlist) |
| 77150 | ** |
| 77151 | ** For each expression, build an index key from the evaluation and |
| 77152 | ** store it in the temporary table. If <expr> is a column, then use |
| @@ -104711,11 +104719,11 @@ | |
| 104711 | # define WHERETRACE_ENABLED 1 |
| 104712 | #else |
| 104713 | # define WHERETRACE(K,X) |
| 104714 | #endif |
| 104715 | |
| 104716 | /* Forward reference |
| 104717 | */ |
| 104718 | typedef struct WhereClause WhereClause; |
| 104719 | typedef struct WhereMaskSet WhereMaskSet; |
| 104720 | typedef struct WhereOrInfo WhereOrInfo; |
| 104721 | typedef struct WhereAndInfo WhereAndInfo; |
| @@ -104733,18 +104741,19 @@ | |
| 104733 | ** maximum cost for ordinary tables is 64*(2**63) which becomes 6900. |
| 104734 | ** (Virtual tables can return a larger cost, but let's assume they do not.) |
| 104735 | ** So all costs can be stored in a 16-bit unsigned integer without risk |
| 104736 | ** of overflow. |
| 104737 | ** |
| 104738 | ** Costs are estimates, so don't go to the computational trouble to compute |
| 104739 | ** 10*log2(X) exactly. Instead, a close estimate is used. Any value of |
| 104740 | ** X<=1 is stored as 0. X=2 is 10. X=3 is 16. X=1000 is 99. etc. |
| 104741 | ** |
| 104742 | ** The tool/wherecosttest.c source file implements a command-line program |
| 104743 | ** that will convert between WhereCost to integers and do addition and |
| 104744 | ** multiplication on WhereCost values. That command-line program is a |
| 104745 | ** useful utility to have around when working with this module. |
| 104746 | */ |
| 104747 | typedef unsigned short int WhereCost; |
| 104748 | |
| 104749 | /* |
| 104750 | ** This object contains information needed to implement a single nested |
| @@ -104843,12 +104852,12 @@ | |
| 104843 | WhereCost rRun; /* Cost of running this subquery */ |
| 104844 | WhereCost nOut; /* Number of outputs for this subquery */ |
| 104845 | }; |
| 104846 | |
| 104847 | /* The WhereOrSet object holds a set of possible WhereOrCosts that |
| 104848 | ** correspond to the subquery(s) of OR-clause processing. At most |
| 104849 | ** favorable N_OR_COST elements are retained. |
| 104850 | */ |
| 104851 | #define N_OR_COST 3 |
| 104852 | struct WhereOrSet { |
| 104853 | u16 n; /* Number of valid a[] entries */ |
| 104854 | WhereOrCost a[N_OR_COST]; /* Set of best costs */ |
| @@ -104910,13 +104919,13 @@ | |
| 104910 | ** |
| 104911 | ** A WhereTerm might also be two or more subterms connected by OR: |
| 104912 | ** |
| 104913 | ** (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR .... |
| 104914 | ** |
| 104915 | ** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR |
| 104916 | ** and the WhereTerm.u.pOrInfo field points to auxiliary information that |
| 104917 | ** is collected about the |
| 104918 | ** |
| 104919 | ** If a term in the WHERE clause does not match either of the two previous |
| 104920 | ** categories, then eOperator==0. The WhereTerm.pExpr field is still set |
| 104921 | ** to the original subexpression content and wtFlags is set up appropriately |
| 104922 | ** but no other fields in the WhereTerm object are meaningful. |
| @@ -105424,11 +105433,11 @@ | |
| 105424 | assert( pMaskSet->n < ArraySize(pMaskSet->ix) ); |
| 105425 | pMaskSet->ix[pMaskSet->n++] = iCursor; |
| 105426 | } |
| 105427 | |
| 105428 | /* |
| 105429 | ** These routine walk (recursively) an expression tree and generates |
| 105430 | ** a bitmask indicating which tables are used in that expression |
| 105431 | ** tree. |
| 105432 | */ |
| 105433 | static Bitmask exprListTableUsage(WhereMaskSet*, ExprList*); |
| 105434 | static Bitmask exprSelectTableUsage(WhereMaskSet*, Select*); |
| @@ -105941,14 +105950,14 @@ | |
| 105941 | ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. |
| 105942 | ** |
| 105943 | ** From another point of view, "indexable" means that the subterm could |
| 105944 | ** potentially be used with an index if an appropriate index exists. |
| 105945 | ** This analysis does not consider whether or not the index exists; that |
| 105946 | ** is something the bestIndex() routine will determine. This analysis |
| 105947 | ** only looks at whether subterms appropriate for indexing exist. |
| 105948 | ** |
| 105949 | ** All examples A through E above all satisfy case 2. But if a term |
| 105950 | ** also statisfies case 1 (such as B) we know that the optimizer will |
| 105951 | ** always prefer case 1, so in that case we pretend that case 2 is not |
| 105952 | ** satisfied. |
| 105953 | ** |
| 105954 | ** It might be the case that multiple tables are indexable. For example, |
| @@ -106611,11 +106620,11 @@ | |
| 106611 | |
| 106612 | return 0; |
| 106613 | } |
| 106614 | |
| 106615 | /* |
| 106616 | ** The (an approximate) sum of two WhereCosts. This computation is |
| 106617 | ** not a simple "+" operator because WhereCost is stored as a logarithmic |
| 106618 | ** value. |
| 106619 | ** |
| 106620 | */ |
| 106621 | static WhereCost whereCostAdd(WhereCost a, WhereCost b){ |
| @@ -115614,10 +115623,13 @@ | |
| 115614 | ** without blocking. |
| 115615 | */ |
| 115616 | SQLITE_API int sqlite3_initialize(void){ |
| 115617 | MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ |
| 115618 | int rc; /* Result code */ |
| 115619 | |
| 115620 | #ifdef SQLITE_OMIT_WSD |
| 115621 | rc = sqlite3_wsd_init(4096, 24); |
| 115622 | if( rc!=SQLITE_OK ){ |
| 115623 | return rc; |
| @@ -115711,10 +115723,13 @@ | |
| 115711 | } |
| 115712 | if( rc==SQLITE_OK ){ |
| 115713 | sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, |
| 115714 | sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage); |
| 115715 | sqlite3GlobalConfig.isInit = 1; |
| 115716 | } |
| 115717 | sqlite3GlobalConfig.inProgress = 0; |
| 115718 | } |
| 115719 | sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex); |
| 115720 | |
| @@ -115751,11 +115766,11 @@ | |
| 115751 | |
| 115752 | /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT |
| 115753 | ** compile-time option. |
| 115754 | */ |
| 115755 | #ifdef SQLITE_EXTRA_INIT |
| 115756 | if( rc==SQLITE_OK && sqlite3GlobalConfig.isInit ){ |
| 115757 | int SQLITE_EXTRA_INIT(const char*); |
| 115758 | rc = SQLITE_EXTRA_INIT(0); |
| 115759 | } |
| 115760 | #endif |
| 115761 | |
| @@ -115939,12 +115954,12 @@ | |
| 115939 | ** run. |
| 115940 | */ |
| 115941 | memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m)); |
| 115942 | }else{ |
| 115943 | /* The heap pointer is not NULL, then install one of the |
| 115944 | ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor |
| 115945 | ** ENABLE_MEMSYS5 is defined, return an error. |
| 115946 | */ |
| 115947 | #ifdef SQLITE_ENABLE_MEMSYS3 |
| 115948 | sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3(); |
| 115949 | #endif |
| 115950 | #ifdef SQLITE_ENABLE_MEMSYS5 |
| @@ -115959,11 +115974,11 @@ | |
| 115959 | sqlite3GlobalConfig.szLookaside = va_arg(ap, int); |
| 115960 | sqlite3GlobalConfig.nLookaside = va_arg(ap, int); |
| 115961 | break; |
| 115962 | } |
| 115963 | |
| 115964 | /* Record a pointer to the logger funcction and its first argument. |
| 115965 | ** The default is NULL. Logging is disabled if the function pointer is |
| 115966 | ** NULL. |
| 115967 | */ |
| 115968 | case SQLITE_CONFIG_LOG: { |
| 115969 | /* MSVC is picky about pulling func ptrs from va lists. |
| @@ -117675,24 +117690,24 @@ | |
| 117675 | |
| 117676 | for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&'); |
| 117677 | zFile = sqlite3_malloc(nByte); |
| 117678 | if( !zFile ) return SQLITE_NOMEM; |
| 117679 | |
| 117680 | /* Discard the scheme and authority segments of the URI. */ |
| 117681 | if( zUri[5]=='/' && zUri[6]=='/' ){ |
| 117682 | iIn = 7; |
| 117683 | while( zUri[iIn] && zUri[iIn]!='/' ) iIn++; |
| 117684 | |
| 117685 | if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){ |
| 117686 | *pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", |
| 117687 | iIn-7, &zUri[7]); |
| 117688 | rc = SQLITE_ERROR; |
| 117689 | goto parse_uri_out; |
| 117690 | } |
| 117691 | }else{ |
| 117692 | iIn = 5; |
| 117693 | } |
| 117694 | |
| 117695 | /* Copy the filename and any query parameters into the zFile buffer. |
| 117696 | ** Decode %HH escape codes along the way. |
| 117697 | ** |
| 117698 | ** Within this loop, variable eState may be set to 0, 1 or 2, depending |
| 117699 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -656,11 +656,11 @@ | |
| 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | */ |
| 659 | #define SQLITE_VERSION "3.8.0" |
| 660 | #define SQLITE_VERSION_NUMBER 3008000 |
| 661 | #define SQLITE_SOURCE_ID "2013-08-15 22:40:21 f2d175f975cd0be63425424ec322a98fb650019e" |
| 662 | |
| 663 | /* |
| 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | ** |
| @@ -7780,11 +7780,11 @@ | |
| 7780 | #endif |
| 7781 | |
| 7782 | #if 0 |
| 7783 | } /* End of the 'extern "C"' block */ |
| 7784 | #endif |
| 7785 | #endif /* _SQLITE3_H_ */ |
| 7786 | |
| 7787 | /* |
| 7788 | ** 2010 August 30 |
| 7789 | ** |
| 7790 | ** The author disclaims copyright to this source code. In place of |
| @@ -11214,11 +11214,11 @@ | |
| 11214 | ** subqueries looking for a match. |
| 11215 | */ |
| 11216 | struct NameContext { |
| 11217 | Parse *pParse; /* The parser */ |
| 11218 | SrcList *pSrcList; /* One or more tables used to resolve names */ |
| 11219 | ExprList *pEList; /* Optional list of result-set columns */ |
| 11220 | AggInfo *pAggInfo; /* Information about aggregates at this level */ |
| 11221 | NameContext *pNext; /* Next outer name context. NULL for outermost */ |
| 11222 | int nRef; /* Number of names resolved by this context */ |
| 11223 | int nErr; /* Number of errors encountered while resolving names */ |
| 11224 | u8 ncFlags; /* Zero or more NC_* flags defined below */ |
| @@ -11229,13 +11229,11 @@ | |
| 11229 | */ |
| 11230 | #define NC_AllowAgg 0x01 /* Aggregate functions are allowed here */ |
| 11231 | #define NC_HasAgg 0x02 /* One or more aggregate functions seen */ |
| 11232 | #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ |
| 11233 | #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ |
| 11234 | #define NC_PartIdx 0x10 /* True if resolving a partial index WHERE */ |
| 11235 | |
| 11236 | /* |
| 11237 | ** An instance of the following structure contains all information |
| 11238 | ** needed to generate code for a single SELECT statement. |
| 11239 | ** |
| @@ -17231,17 +17229,17 @@ | |
| 17229 | u8 *aCtrl; |
| 17230 | |
| 17231 | } mem5; |
| 17232 | |
| 17233 | /* |
| 17234 | ** Access the static variable through a macro for SQLITE_OMIT_WSD. |
| 17235 | */ |
| 17236 | #define mem5 GLOBAL(struct Mem5Global, mem5) |
| 17237 | |
| 17238 | /* |
| 17239 | ** Assuming mem5.zPool is divided up into an array of Mem5Link |
| 17240 | ** structures, return a pointer to the idx-th such link. |
| 17241 | */ |
| 17242 | #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom])) |
| 17243 | |
| 17244 | /* |
| 17245 | ** Unlink the chunk at mem5.aPool[i] from list it is currently |
| @@ -17333,11 +17331,11 @@ | |
| 17331 | |
| 17332 | /* |
| 17333 | ** Return a block of memory of at least nBytes in size. |
| 17334 | ** Return NULL if unable. Return NULL if nBytes==0. |
| 17335 | ** |
| 17336 | ** The caller guarantees that nByte is positive. |
| 17337 | ** |
| 17338 | ** The caller has obtained a mutex prior to invoking this |
| 17339 | ** routine so there is never any chance that two or more |
| 17340 | ** threads can be in this routine at the same time. |
| 17341 | */ |
| @@ -17455,11 +17453,11 @@ | |
| 17453 | } |
| 17454 | memsys5Link(iBlock, iLogsize); |
| 17455 | } |
| 17456 | |
| 17457 | /* |
| 17458 | ** Allocate nBytes of memory. |
| 17459 | */ |
| 17460 | static void *memsys5Malloc(int nBytes){ |
| 17461 | sqlite3_int64 *p = 0; |
| 17462 | if( nBytes>0 ){ |
| 17463 | memsys5Enter(); |
| @@ -74041,22 +74039,23 @@ | |
| 74039 | ** |
| 74040 | ** The reason for suppressing the TK_AS term when the expression is a simple |
| 74041 | ** column reference is so that the column reference will be recognized as |
| 74042 | ** usable by indices within the WHERE clause processing logic. |
| 74043 | ** |
| 74044 | ** The TK_AS operator is inhibited if zType[0]=='G'. This means |
| 74045 | ** that in a GROUP BY clause, the expression is evaluated twice. Hence: |
| 74046 | ** |
| 74047 | ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x |
| 74048 | ** |
| 74049 | ** Is equivalent to: |
| 74050 | ** |
| 74051 | ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 |
| 74052 | ** |
| 74053 | ** The result of random()%5 in the GROUP BY clause is probably different |
| 74054 | ** from the result in the result-set. On the other hand Standard SQL does |
| 74055 | ** not allow the GROUP BY clause to contain references to result-set columns. |
| 74056 | ** So this should never come up in well-formed queries. |
| 74057 | ** |
| 74058 | ** If the reference is followed by a COLLATE operator, then make sure |
| 74059 | ** the COLLATE operator is preserved. For example: |
| 74060 | ** |
| 74061 | ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase; |
| @@ -74382,14 +74381,20 @@ | |
| 74381 | ** |
| 74382 | ** In cases like this, replace pExpr with a copy of the expression that |
| 74383 | ** forms the result set entry ("a+b" in the example) and return immediately. |
| 74384 | ** Note that the expression in the result set should have already been |
| 74385 | ** resolved by the time the WHERE clause is resolved. |
| 74386 | ** |
| 74387 | ** The ability to use an output result-set column in the WHERE, GROUP BY, |
| 74388 | ** or HAVING clauses, or as part of a larger expression in the ORDRE BY |
| 74389 | ** clause is not standard SQL. This is a (goofy) SQLite extension, that |
| 74390 | ** is supported for backwards compatibility only. TO DO: Issue a warning |
| 74391 | ** on sqlite3_log() whenever the capability is used. |
| 74392 | */ |
| 74393 | if( (pEList = pNC->pEList)!=0 |
| 74394 | && zTab==0 |
| 74395 | && cnt==0 |
| 74396 | ){ |
| 74397 | for(j=0; j<pEList->nExpr; j++){ |
| 74398 | char *zAs = pEList->a[j].zName; |
| 74399 | if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 74400 | Expr *pOrig; |
| @@ -74947,11 +74952,11 @@ | |
| 74952 | } |
| 74953 | |
| 74954 | /* |
| 74955 | ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of |
| 74956 | ** the SELECT statement pSelect. If any term is reference to a |
| 74957 | ** result set expression (as determined by the ExprList.a.iOrderByCol field) |
| 74958 | ** then convert that term into a copy of the corresponding result set |
| 74959 | ** column. |
| 74960 | ** |
| 74961 | ** If any errors are detected, add an error message to pParse and |
| 74962 | ** return non-zero. Return zero if no errors are seen. |
| @@ -74995,11 +75000,11 @@ | |
| 75000 | ** |
| 75001 | ** This routine resolves each term of the clause into an expression. |
| 75002 | ** If the order-by term is an integer I between 1 and N (where N is the |
| 75003 | ** number of columns in the result set of the SELECT) then the expression |
| 75004 | ** in the resolution is a copy of the I-th result-set expression. If |
| 75005 | ** the order-by term is an identifier that corresponds to the AS-name of |
| 75006 | ** a result-set expression, then the term resolves to a copy of the |
| 75007 | ** result-set expression. Otherwise, the expression is resolved in |
| 75008 | ** the usual way - using sqlite3ResolveExprNames(). |
| 75009 | ** |
| 75010 | ** This routine returns the number of errors. If errors occur, then |
| @@ -75021,20 +75026,23 @@ | |
| 75026 | if( pOrderBy==0 ) return 0; |
| 75027 | nResult = pSelect->pEList->nExpr; |
| 75028 | pParse = pNC->pParse; |
| 75029 | for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ |
| 75030 | Expr *pE = pItem->pExpr; |
| 75031 | Expr *pE2 = sqlite3ExprSkipCollate(pE); |
| 75032 | if( zType[0]!='G' ){ |
| 75033 | iCol = resolveAsName(pParse, pSelect->pEList, pE2); |
| 75034 | if( iCol>0 ){ |
| 75035 | /* If an AS-name match is found, mark this ORDER BY column as being |
| 75036 | ** a copy of the iCol-th result-set column. The subsequent call to |
| 75037 | ** sqlite3ResolveOrderGroupBy() will convert the expression to a |
| 75038 | ** copy of the iCol-th result-set expression. */ |
| 75039 | pItem->iOrderByCol = (u16)iCol; |
| 75040 | continue; |
| 75041 | } |
| 75042 | } |
| 75043 | if( sqlite3ExprIsInteger(pE2, &iCol) ){ |
| 75044 | /* The ORDER BY term is an integer constant. Again, set the column |
| 75045 | ** number so that sqlite3ResolveOrderGroupBy() will convert the |
| 75046 | ** order-by term to a copy of the result-set expression */ |
| 75047 | if( iCol<1 || iCol>0xffff ){ |
| 75048 | resolveOutOfRangeError(pParse, zType, i+1, nResult); |
| @@ -75173,23 +75181,21 @@ | |
| 75181 | if( p->pHaving && !pGroupBy ){ |
| 75182 | sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING"); |
| 75183 | return WRC_Abort; |
| 75184 | } |
| 75185 | |
| 75186 | /* Add the output column list to the name-context before parsing the |
| 75187 | ** other expressions in the SELECT statement. This is so that |
| 75188 | ** expressions in the WHERE clause (etc.) can refer to expressions by |
| 75189 | ** aliases in the result set. |
| 75190 | ** |
| 75191 | ** Minor point: If this is the case, then the expression will be |
| 75192 | ** re-evaluated for each reference to it. |
| 75193 | */ |
| 75194 | sNC.pEList = p->pEList; |
| 75195 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 75196 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| 75197 | |
| 75198 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 75199 | ** outer queries |
| 75200 | */ |
| 75201 | sNC.pNext = 0; |
| @@ -77134,19 +77140,21 @@ | |
| 77140 | assert( !isRowid ); |
| 77141 | sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); |
| 77142 | dest.affSdst = (u8)affinity; |
| 77143 | assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); |
| 77144 | pExpr->x.pSelect->iLimit = 0; |
| 77145 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ |
| 77146 | if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ |
| 77147 | sqlite3DbFree(pParse->db, pKeyInfo); |
| 77148 | return 0; |
| 77149 | } |
| 77150 | pEList = pExpr->x.pSelect->pEList; |
| 77151 | assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ |
| 77152 | assert( pEList!=0 ); |
| 77153 | assert( pEList->nExpr>0 ); |
| 77154 | pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, |
| 77155 | pEList->a[0].pExpr); |
| 77156 | }else if( ALWAYS(pExpr->x.pList!=0) ){ |
| 77157 | /* Case 2: expr IN (exprlist) |
| 77158 | ** |
| 77159 | ** For each expression, build an index key from the evaluation and |
| 77160 | ** store it in the temporary table. If <expr> is a column, then use |
| @@ -104711,11 +104719,11 @@ | |
| 104719 | # define WHERETRACE_ENABLED 1 |
| 104720 | #else |
| 104721 | # define WHERETRACE(K,X) |
| 104722 | #endif |
| 104723 | |
| 104724 | /* Forward references |
| 104725 | */ |
| 104726 | typedef struct WhereClause WhereClause; |
| 104727 | typedef struct WhereMaskSet WhereMaskSet; |
| 104728 | typedef struct WhereOrInfo WhereOrInfo; |
| 104729 | typedef struct WhereAndInfo WhereAndInfo; |
| @@ -104733,18 +104741,19 @@ | |
| 104741 | ** maximum cost for ordinary tables is 64*(2**63) which becomes 6900. |
| 104742 | ** (Virtual tables can return a larger cost, but let's assume they do not.) |
| 104743 | ** So all costs can be stored in a 16-bit unsigned integer without risk |
| 104744 | ** of overflow. |
| 104745 | ** |
| 104746 | ** Costs are estimates, so no effort is made to compute 10*log2(X) exactly. |
| 104747 | ** Instead, a close estimate is used. Any value of X<=1 is stored as 0. |
| 104748 | ** X=2 is 10. X=3 is 16. X=1000 is 99. etc. |
| 104749 | ** |
| 104750 | ** The tool/wherecosttest.c source file implements a command-line program |
| 104751 | ** that will convert WhereCosts to integers, convert integers to WhereCosts |
| 104752 | ** and do addition and multiplication on WhereCost values. The wherecosttest |
| 104753 | ** command-line program is a useful utility to have around when working with |
| 104754 | ** this module. |
| 104755 | */ |
| 104756 | typedef unsigned short int WhereCost; |
| 104757 | |
| 104758 | /* |
| 104759 | ** This object contains information needed to implement a single nested |
| @@ -104843,12 +104852,12 @@ | |
| 104852 | WhereCost rRun; /* Cost of running this subquery */ |
| 104853 | WhereCost nOut; /* Number of outputs for this subquery */ |
| 104854 | }; |
| 104855 | |
| 104856 | /* The WhereOrSet object holds a set of possible WhereOrCosts that |
| 104857 | ** correspond to the subquery(s) of OR-clause processing. Only the |
| 104858 | ** best N_OR_COST elements are retained. |
| 104859 | */ |
| 104860 | #define N_OR_COST 3 |
| 104861 | struct WhereOrSet { |
| 104862 | u16 n; /* Number of valid a[] entries */ |
| 104863 | WhereOrCost a[N_OR_COST]; /* Set of best costs */ |
| @@ -104910,13 +104919,13 @@ | |
| 104919 | ** |
| 104920 | ** A WhereTerm might also be two or more subterms connected by OR: |
| 104921 | ** |
| 104922 | ** (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR .... |
| 104923 | ** |
| 104924 | ** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR |
| 104925 | ** and the WhereTerm.u.pOrInfo field points to auxiliary information that |
| 104926 | ** is collected about the OR clause. |
| 104927 | ** |
| 104928 | ** If a term in the WHERE clause does not match either of the two previous |
| 104929 | ** categories, then eOperator==0. The WhereTerm.pExpr field is still set |
| 104930 | ** to the original subexpression content and wtFlags is set up appropriately |
| 104931 | ** but no other fields in the WhereTerm object are meaningful. |
| @@ -105424,11 +105433,11 @@ | |
| 105433 | assert( pMaskSet->n < ArraySize(pMaskSet->ix) ); |
| 105434 | pMaskSet->ix[pMaskSet->n++] = iCursor; |
| 105435 | } |
| 105436 | |
| 105437 | /* |
| 105438 | ** These routines walk (recursively) an expression tree and generate |
| 105439 | ** a bitmask indicating which tables are used in that expression |
| 105440 | ** tree. |
| 105441 | */ |
| 105442 | static Bitmask exprListTableUsage(WhereMaskSet*, ExprList*); |
| 105443 | static Bitmask exprSelectTableUsage(WhereMaskSet*, Select*); |
| @@ -105941,14 +105950,14 @@ | |
| 105950 | ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. |
| 105951 | ** |
| 105952 | ** From another point of view, "indexable" means that the subterm could |
| 105953 | ** potentially be used with an index if an appropriate index exists. |
| 105954 | ** This analysis does not consider whether or not the index exists; that |
| 105955 | ** is decided elsewhere. This analysis only looks at whether subterms |
| 105956 | ** appropriate for indexing exist. |
| 105957 | ** |
| 105958 | ** All examples A through E above satisfy case 2. But if a term |
| 105959 | ** also statisfies case 1 (such as B) we know that the optimizer will |
| 105960 | ** always prefer case 1, so in that case we pretend that case 2 is not |
| 105961 | ** satisfied. |
| 105962 | ** |
| 105963 | ** It might be the case that multiple tables are indexable. For example, |
| @@ -106611,11 +106620,11 @@ | |
| 106620 | |
| 106621 | return 0; |
| 106622 | } |
| 106623 | |
| 106624 | /* |
| 106625 | ** Find (an approximate) sum of two WhereCosts. This computation is |
| 106626 | ** not a simple "+" operator because WhereCost is stored as a logarithmic |
| 106627 | ** value. |
| 106628 | ** |
| 106629 | */ |
| 106630 | static WhereCost whereCostAdd(WhereCost a, WhereCost b){ |
| @@ -115614,10 +115623,13 @@ | |
| 115623 | ** without blocking. |
| 115624 | */ |
| 115625 | SQLITE_API int sqlite3_initialize(void){ |
| 115626 | MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ |
| 115627 | int rc; /* Result code */ |
| 115628 | #ifdef SQLITE_EXTRA_INIT |
| 115629 | int bRunExtraInit = 0; /* Extra initialization needed */ |
| 115630 | #endif |
| 115631 | |
| 115632 | #ifdef SQLITE_OMIT_WSD |
| 115633 | rc = sqlite3_wsd_init(4096, 24); |
| 115634 | if( rc!=SQLITE_OK ){ |
| 115635 | return rc; |
| @@ -115711,10 +115723,13 @@ | |
| 115723 | } |
| 115724 | if( rc==SQLITE_OK ){ |
| 115725 | sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, |
| 115726 | sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage); |
| 115727 | sqlite3GlobalConfig.isInit = 1; |
| 115728 | #ifdef SQLITE_EXTRA_INIT |
| 115729 | bRunExtraInit = 1; |
| 115730 | #endif |
| 115731 | } |
| 115732 | sqlite3GlobalConfig.inProgress = 0; |
| 115733 | } |
| 115734 | sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex); |
| 115735 | |
| @@ -115751,11 +115766,11 @@ | |
| 115766 | |
| 115767 | /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT |
| 115768 | ** compile-time option. |
| 115769 | */ |
| 115770 | #ifdef SQLITE_EXTRA_INIT |
| 115771 | if( bRunExtraInit ){ |
| 115772 | int SQLITE_EXTRA_INIT(const char*); |
| 115773 | rc = SQLITE_EXTRA_INIT(0); |
| 115774 | } |
| 115775 | #endif |
| 115776 | |
| @@ -115939,12 +115954,12 @@ | |
| 115954 | ** run. |
| 115955 | */ |
| 115956 | memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m)); |
| 115957 | }else{ |
| 115958 | /* The heap pointer is not NULL, then install one of the |
| 115959 | ** mem5.c/mem3.c methods. The enclosing #if guarantees at |
| 115960 | ** least one of these methods is currently enabled. |
| 115961 | */ |
| 115962 | #ifdef SQLITE_ENABLE_MEMSYS3 |
| 115963 | sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3(); |
| 115964 | #endif |
| 115965 | #ifdef SQLITE_ENABLE_MEMSYS5 |
| @@ -115959,11 +115974,11 @@ | |
| 115974 | sqlite3GlobalConfig.szLookaside = va_arg(ap, int); |
| 115975 | sqlite3GlobalConfig.nLookaside = va_arg(ap, int); |
| 115976 | break; |
| 115977 | } |
| 115978 | |
| 115979 | /* Record a pointer to the logger function and its first argument. |
| 115980 | ** The default is NULL. Logging is disabled if the function pointer is |
| 115981 | ** NULL. |
| 115982 | */ |
| 115983 | case SQLITE_CONFIG_LOG: { |
| 115984 | /* MSVC is picky about pulling func ptrs from va lists. |
| @@ -117675,24 +117690,24 @@ | |
| 117690 | |
| 117691 | for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&'); |
| 117692 | zFile = sqlite3_malloc(nByte); |
| 117693 | if( !zFile ) return SQLITE_NOMEM; |
| 117694 | |
| 117695 | iIn = 5; |
| 117696 | #ifndef SQLITE_ALLOW_URI_AUTHORITY |
| 117697 | /* Discard the scheme and authority segments of the URI. */ |
| 117698 | if( zUri[5]=='/' && zUri[6]=='/' ){ |
| 117699 | iIn = 7; |
| 117700 | while( zUri[iIn] && zUri[iIn]!='/' ) iIn++; |
| 117701 | if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){ |
| 117702 | *pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", |
| 117703 | iIn-7, &zUri[7]); |
| 117704 | rc = SQLITE_ERROR; |
| 117705 | goto parse_uri_out; |
| 117706 | } |
| 117707 | } |
| 117708 | #endif |
| 117709 | |
| 117710 | /* Copy the filename and any query parameters into the zFile buffer. |
| 117711 | ** Decode %HH escape codes along the way. |
| 117712 | ** |
| 117713 | ** Within this loop, variable eState may be set to 0, 1 or 2, depending |
| 117714 |
+2
-2
| --- 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.8.0" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3008000 |
| 112 | -#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-08-15 22:40:21 f2d175f975cd0be63425424ec322a98fb650019e" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -7231,11 +7231,11 @@ | ||
| 7231 | 7231 | #endif |
| 7232 | 7232 | |
| 7233 | 7233 | #ifdef __cplusplus |
| 7234 | 7234 | } /* End of the 'extern "C"' block */ |
| 7235 | 7235 | #endif |
| 7236 | -#endif | |
| 7236 | +#endif /* _SQLITE3_H_ */ | |
| 7237 | 7237 | |
| 7238 | 7238 | /* |
| 7239 | 7239 | ** 2010 August 30 |
| 7240 | 7240 | ** |
| 7241 | 7241 | ** The author disclaims copyright to this source code. In place of |
| 7242 | 7242 |
| --- 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.8.0" |
| 111 | #define SQLITE_VERSION_NUMBER 3008000 |
| 112 | #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -7231,11 +7231,11 @@ | |
| 7231 | #endif |
| 7232 | |
| 7233 | #ifdef __cplusplus |
| 7234 | } /* End of the 'extern "C"' block */ |
| 7235 | #endif |
| 7236 | #endif |
| 7237 | |
| 7238 | /* |
| 7239 | ** 2010 August 30 |
| 7240 | ** |
| 7241 | ** The author disclaims copyright to this source code. In place of |
| 7242 |
| --- 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.8.0" |
| 111 | #define SQLITE_VERSION_NUMBER 3008000 |
| 112 | #define SQLITE_SOURCE_ID "2013-08-15 22:40:21 f2d175f975cd0be63425424ec322a98fb650019e" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -7231,11 +7231,11 @@ | |
| 7231 | #endif |
| 7232 | |
| 7233 | #ifdef __cplusplus |
| 7234 | } /* End of the 'extern "C"' block */ |
| 7235 | #endif |
| 7236 | #endif /* _SQLITE3_H_ */ |
| 7237 | |
| 7238 | /* |
| 7239 | ** 2010 August 30 |
| 7240 | ** |
| 7241 | ** The author disclaims copyright to this source code. In place of |
| 7242 |