Fossil SCM
Update the built-in SQLite to the latest 3.7.16 beta from upstream.
Commit
f803d534d0f236a970338647797f85e334c5b754
Parent
7dee90383907ee4…
2 files changed
+29
-12
+2
-2
+29
-12
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -678,11 +678,11 @@ | ||
| 678 | 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | 680 | */ |
| 681 | 681 | #define SQLITE_VERSION "3.7.16" |
| 682 | 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | -#define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" | |
| 683 | +#define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" | |
| 684 | 684 | |
| 685 | 685 | /* |
| 686 | 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | 688 | ** |
| @@ -857,11 +857,11 @@ | ||
| 857 | 857 | ** |
| 858 | 858 | ** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
| 859 | 859 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 860 | 860 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 861 | 861 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 862 | -** sqlite3_close() is called on a [database connection] that still has | |
| 862 | +** sqlite3_close_v2() is called on a [database connection] that still has | |
| 863 | 863 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 864 | 864 | ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation |
| 865 | 865 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 866 | 866 | ** and [sqlite3_backup] objects are also destroyed. |
| 867 | 867 | ** |
| @@ -12342,11 +12342,12 @@ | ||
| 12342 | 12342 | #define sqlite3EndBenignMalloc() |
| 12343 | 12343 | #endif |
| 12344 | 12344 | |
| 12345 | 12345 | #define IN_INDEX_ROWID 1 |
| 12346 | 12346 | #define IN_INDEX_EPH 2 |
| 12347 | -#define IN_INDEX_INDEX 3 | |
| 12347 | +#define IN_INDEX_INDEX_ASC 3 | |
| 12348 | +#define IN_INDEX_INDEX_DESC 4 | |
| 12348 | 12349 | SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, int*); |
| 12349 | 12350 | |
| 12350 | 12351 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 12351 | 12352 | SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int); |
| 12352 | 12353 | SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *); |
| @@ -75426,14 +75427,15 @@ | ||
| 75426 | 75427 | ** A cursor is opened on the b-tree object that the RHS of the IN operator |
| 75427 | 75428 | ** and pX->iTable is set to the index of that cursor. |
| 75428 | 75429 | ** |
| 75429 | 75430 | ** The returned value of this function indicates the b-tree type, as follows: |
| 75430 | 75431 | ** |
| 75431 | -** IN_INDEX_ROWID - The cursor was opened on a database table. | |
| 75432 | -** IN_INDEX_INDEX - The cursor was opened on a database index. | |
| 75433 | -** IN_INDEX_EPH - The cursor was opened on a specially created and | |
| 75434 | -** populated epheremal table. | |
| 75432 | +** IN_INDEX_ROWID - The cursor was opened on a database table. | |
| 75433 | +** IN_INDEX_INDEX_ASC - The cursor was opened on an ascending index. | |
| 75434 | +** IN_INDEX_INDEX_DESC - The cursor was opened on a descending index. | |
| 75435 | +** IN_INDEX_EPH - The cursor was opened on a specially created and | |
| 75436 | +** populated epheremal table. | |
| 75435 | 75437 | ** |
| 75436 | 75438 | ** An existing b-tree might be used if the RHS expression pX is a simple |
| 75437 | 75439 | ** subquery such as: |
| 75438 | 75440 | ** |
| 75439 | 75441 | ** SELECT <column> FROM <table> |
| @@ -75552,11 +75554,12 @@ | ||
| 75552 | 75554 | iAddr = sqlite3CodeOnce(pParse); |
| 75553 | 75555 | |
| 75554 | 75556 | sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb, |
| 75555 | 75557 | pKey,P4_KEYINFO_HANDOFF); |
| 75556 | 75558 | VdbeComment((v, "%s", pIdx->zName)); |
| 75557 | - eType = IN_INDEX_INDEX; | |
| 75559 | + assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 ); | |
| 75560 | + eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0]; | |
| 75558 | 75561 | |
| 75559 | 75562 | sqlite3VdbeJumpHere(v, iAddr); |
| 75560 | 75563 | if( prNotFound && !pTab->aCol[iCol].notNull ){ |
| 75561 | 75564 | *prNotFound = ++pParse->nMem; |
| 75562 | 75565 | sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound); |
| @@ -106747,11 +106750,12 @@ | ||
| 106747 | 106750 | ** this routine sets up a loop that will iterate over all values of X. |
| 106748 | 106751 | */ |
| 106749 | 106752 | static int codeEqualityTerm( |
| 106750 | 106753 | Parse *pParse, /* The parsing context */ |
| 106751 | 106754 | WhereTerm *pTerm, /* The term of the WHERE clause to be coded */ |
| 106752 | - WhereLevel *pLevel, /* When level of the FROM clause we are working on */ | |
| 106755 | + WhereLevel *pLevel, /* The level of the FROM clause we are working on */ | |
| 106756 | + int iEq, /* Index of the equality term within this level */ | |
| 106753 | 106757 | int iTarget /* Attempt to leave results in this register */ |
| 106754 | 106758 | ){ |
| 106755 | 106759 | Expr *pX = pTerm->pExpr; |
| 106756 | 106760 | Vdbe *v = pParse->pVdbe; |
| 106757 | 106761 | int iReg; /* Register holding results */ |
| @@ -106767,13 +106771,26 @@ | ||
| 106767 | 106771 | int eType; |
| 106768 | 106772 | int iTab; |
| 106769 | 106773 | struct InLoop *pIn; |
| 106770 | 106774 | u8 bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0; |
| 106771 | 106775 | |
| 106776 | + if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 | |
| 106777 | + && pLevel->plan.u.pIdx->aSortOrder[iEq] | |
| 106778 | + ){ | |
| 106779 | + testcase( iEq==0 ); | |
| 106780 | + testcase( iEq==pLevel->plan.u.pIdx->nColumn-1 ); | |
| 106781 | + testcase( iEq>0 && iEq+1<pLevel->plan.u.pIdx->nColumn ); | |
| 106782 | + testcase( bRev ); | |
| 106783 | + bRev = !bRev; | |
| 106784 | + } | |
| 106772 | 106785 | assert( pX->op==TK_IN ); |
| 106773 | 106786 | iReg = iTarget; |
| 106774 | 106787 | eType = sqlite3FindInIndex(pParse, pX, 0); |
| 106788 | + if( eType==IN_INDEX_INDEX_DESC ){ | |
| 106789 | + testcase( bRev ); | |
| 106790 | + bRev = !bRev; | |
| 106791 | + } | |
| 106775 | 106792 | iTab = pX->iTable; |
| 106776 | 106793 | sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); |
| 106777 | 106794 | assert( pLevel->plan.wsFlags & WHERE_IN_ABLE ); |
| 106778 | 106795 | if( pLevel->u.in.nIn==0 ){ |
| 106779 | 106796 | pLevel->addrNxt = sqlite3VdbeMakeLabel(v); |
| @@ -106884,11 +106901,11 @@ | ||
| 106884 | 106901 | if( pTerm==0 ) break; |
| 106885 | 106902 | /* The following true for indices with redundant columns. |
| 106886 | 106903 | ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ |
| 106887 | 106904 | testcase( (pTerm->wtFlags & TERM_CODED)!=0 ); |
| 106888 | 106905 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 106889 | - r1 = codeEqualityTerm(pParse, pTerm, pLevel, regBase+j); | |
| 106906 | + r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, regBase+j); | |
| 106890 | 106907 | if( r1!=regBase+j ){ |
| 106891 | 106908 | if( nReg==1 ){ |
| 106892 | 106909 | sqlite3ReleaseTempReg(pParse, regBase); |
| 106893 | 106910 | regBase = r1; |
| 106894 | 106911 | }else{ |
| @@ -107161,11 +107178,11 @@ | ||
| 107161 | 107178 | for(k=0; k<nConstraint; k++){ |
| 107162 | 107179 | if( aUsage[k].argvIndex==j ){ |
| 107163 | 107180 | int iTarget = iReg+j+1; |
| 107164 | 107181 | pTerm = &pWC->a[aConstraint[k].iTermOffset]; |
| 107165 | 107182 | if( pTerm->eOperator & WO_IN ){ |
| 107166 | - codeEqualityTerm(pParse, pTerm, pLevel, iTarget); | |
| 107183 | + codeEqualityTerm(pParse, pTerm, pLevel, k, iTarget); | |
| 107167 | 107184 | addrNotFound = pLevel->addrNxt; |
| 107168 | 107185 | }else{ |
| 107169 | 107186 | sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget); |
| 107170 | 107187 | } |
| 107171 | 107188 | break; |
| @@ -107202,11 +107219,11 @@ | ||
| 107202 | 107219 | pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0); |
| 107203 | 107220 | assert( pTerm!=0 ); |
| 107204 | 107221 | assert( pTerm->pExpr!=0 ); |
| 107205 | 107222 | assert( omitTable==0 ); |
| 107206 | 107223 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 107207 | - iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, iReleaseReg); | |
| 107224 | + iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, iReleaseReg); | |
| 107208 | 107225 | addrNxt = pLevel->addrNxt; |
| 107209 | 107226 | sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); |
| 107210 | 107227 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); |
| 107211 | 107228 | sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); |
| 107212 | 107229 | sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); |
| 107213 | 107230 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -678,11 +678,11 @@ | |
| 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | */ |
| 681 | #define SQLITE_VERSION "3.7.16" |
| 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | #define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" |
| 684 | |
| 685 | /* |
| 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | ** |
| @@ -857,11 +857,11 @@ | |
| 857 | ** |
| 858 | ** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
| 859 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 860 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 861 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 862 | ** sqlite3_close() is called on a [database connection] that still has |
| 863 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 864 | ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation |
| 865 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 866 | ** and [sqlite3_backup] objects are also destroyed. |
| 867 | ** |
| @@ -12342,11 +12342,12 @@ | |
| 12342 | #define sqlite3EndBenignMalloc() |
| 12343 | #endif |
| 12344 | |
| 12345 | #define IN_INDEX_ROWID 1 |
| 12346 | #define IN_INDEX_EPH 2 |
| 12347 | #define IN_INDEX_INDEX 3 |
| 12348 | SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, int*); |
| 12349 | |
| 12350 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 12351 | SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int); |
| 12352 | SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *); |
| @@ -75426,14 +75427,15 @@ | |
| 75426 | ** A cursor is opened on the b-tree object that the RHS of the IN operator |
| 75427 | ** and pX->iTable is set to the index of that cursor. |
| 75428 | ** |
| 75429 | ** The returned value of this function indicates the b-tree type, as follows: |
| 75430 | ** |
| 75431 | ** IN_INDEX_ROWID - The cursor was opened on a database table. |
| 75432 | ** IN_INDEX_INDEX - The cursor was opened on a database index. |
| 75433 | ** IN_INDEX_EPH - The cursor was opened on a specially created and |
| 75434 | ** populated epheremal table. |
| 75435 | ** |
| 75436 | ** An existing b-tree might be used if the RHS expression pX is a simple |
| 75437 | ** subquery such as: |
| 75438 | ** |
| 75439 | ** SELECT <column> FROM <table> |
| @@ -75552,11 +75554,12 @@ | |
| 75552 | iAddr = sqlite3CodeOnce(pParse); |
| 75553 | |
| 75554 | sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb, |
| 75555 | pKey,P4_KEYINFO_HANDOFF); |
| 75556 | VdbeComment((v, "%s", pIdx->zName)); |
| 75557 | eType = IN_INDEX_INDEX; |
| 75558 | |
| 75559 | sqlite3VdbeJumpHere(v, iAddr); |
| 75560 | if( prNotFound && !pTab->aCol[iCol].notNull ){ |
| 75561 | *prNotFound = ++pParse->nMem; |
| 75562 | sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound); |
| @@ -106747,11 +106750,12 @@ | |
| 106747 | ** this routine sets up a loop that will iterate over all values of X. |
| 106748 | */ |
| 106749 | static int codeEqualityTerm( |
| 106750 | Parse *pParse, /* The parsing context */ |
| 106751 | WhereTerm *pTerm, /* The term of the WHERE clause to be coded */ |
| 106752 | WhereLevel *pLevel, /* When level of the FROM clause we are working on */ |
| 106753 | int iTarget /* Attempt to leave results in this register */ |
| 106754 | ){ |
| 106755 | Expr *pX = pTerm->pExpr; |
| 106756 | Vdbe *v = pParse->pVdbe; |
| 106757 | int iReg; /* Register holding results */ |
| @@ -106767,13 +106771,26 @@ | |
| 106767 | int eType; |
| 106768 | int iTab; |
| 106769 | struct InLoop *pIn; |
| 106770 | u8 bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0; |
| 106771 | |
| 106772 | assert( pX->op==TK_IN ); |
| 106773 | iReg = iTarget; |
| 106774 | eType = sqlite3FindInIndex(pParse, pX, 0); |
| 106775 | iTab = pX->iTable; |
| 106776 | sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); |
| 106777 | assert( pLevel->plan.wsFlags & WHERE_IN_ABLE ); |
| 106778 | if( pLevel->u.in.nIn==0 ){ |
| 106779 | pLevel->addrNxt = sqlite3VdbeMakeLabel(v); |
| @@ -106884,11 +106901,11 @@ | |
| 106884 | if( pTerm==0 ) break; |
| 106885 | /* The following true for indices with redundant columns. |
| 106886 | ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ |
| 106887 | testcase( (pTerm->wtFlags & TERM_CODED)!=0 ); |
| 106888 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 106889 | r1 = codeEqualityTerm(pParse, pTerm, pLevel, regBase+j); |
| 106890 | if( r1!=regBase+j ){ |
| 106891 | if( nReg==1 ){ |
| 106892 | sqlite3ReleaseTempReg(pParse, regBase); |
| 106893 | regBase = r1; |
| 106894 | }else{ |
| @@ -107161,11 +107178,11 @@ | |
| 107161 | for(k=0; k<nConstraint; k++){ |
| 107162 | if( aUsage[k].argvIndex==j ){ |
| 107163 | int iTarget = iReg+j+1; |
| 107164 | pTerm = &pWC->a[aConstraint[k].iTermOffset]; |
| 107165 | if( pTerm->eOperator & WO_IN ){ |
| 107166 | codeEqualityTerm(pParse, pTerm, pLevel, iTarget); |
| 107167 | addrNotFound = pLevel->addrNxt; |
| 107168 | }else{ |
| 107169 | sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget); |
| 107170 | } |
| 107171 | break; |
| @@ -107202,11 +107219,11 @@ | |
| 107202 | pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0); |
| 107203 | assert( pTerm!=0 ); |
| 107204 | assert( pTerm->pExpr!=0 ); |
| 107205 | assert( omitTable==0 ); |
| 107206 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 107207 | iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, iReleaseReg); |
| 107208 | addrNxt = pLevel->addrNxt; |
| 107209 | sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); |
| 107210 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); |
| 107211 | sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); |
| 107212 | sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); |
| 107213 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -678,11 +678,11 @@ | |
| 678 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 679 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 680 | */ |
| 681 | #define SQLITE_VERSION "3.7.16" |
| 682 | #define SQLITE_VERSION_NUMBER 3007016 |
| 683 | #define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" |
| 684 | |
| 685 | /* |
| 686 | ** CAPI3REF: Run-Time Library Version Numbers |
| 687 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 688 | ** |
| @@ -857,11 +857,11 @@ | |
| 857 | ** |
| 858 | ** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
| 859 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 860 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 861 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 862 | ** sqlite3_close_v2() is called on a [database connection] that still has |
| 863 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 864 | ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation |
| 865 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 866 | ** and [sqlite3_backup] objects are also destroyed. |
| 867 | ** |
| @@ -12342,11 +12342,12 @@ | |
| 12342 | #define sqlite3EndBenignMalloc() |
| 12343 | #endif |
| 12344 | |
| 12345 | #define IN_INDEX_ROWID 1 |
| 12346 | #define IN_INDEX_EPH 2 |
| 12347 | #define IN_INDEX_INDEX_ASC 3 |
| 12348 | #define IN_INDEX_INDEX_DESC 4 |
| 12349 | SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, int*); |
| 12350 | |
| 12351 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 12352 | SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int); |
| 12353 | SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *); |
| @@ -75426,14 +75427,15 @@ | |
| 75427 | ** A cursor is opened on the b-tree object that the RHS of the IN operator |
| 75428 | ** and pX->iTable is set to the index of that cursor. |
| 75429 | ** |
| 75430 | ** The returned value of this function indicates the b-tree type, as follows: |
| 75431 | ** |
| 75432 | ** IN_INDEX_ROWID - The cursor was opened on a database table. |
| 75433 | ** IN_INDEX_INDEX_ASC - The cursor was opened on an ascending index. |
| 75434 | ** IN_INDEX_INDEX_DESC - The cursor was opened on a descending index. |
| 75435 | ** IN_INDEX_EPH - The cursor was opened on a specially created and |
| 75436 | ** populated epheremal table. |
| 75437 | ** |
| 75438 | ** An existing b-tree might be used if the RHS expression pX is a simple |
| 75439 | ** subquery such as: |
| 75440 | ** |
| 75441 | ** SELECT <column> FROM <table> |
| @@ -75552,11 +75554,12 @@ | |
| 75554 | iAddr = sqlite3CodeOnce(pParse); |
| 75555 | |
| 75556 | sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb, |
| 75557 | pKey,P4_KEYINFO_HANDOFF); |
| 75558 | VdbeComment((v, "%s", pIdx->zName)); |
| 75559 | assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 ); |
| 75560 | eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0]; |
| 75561 | |
| 75562 | sqlite3VdbeJumpHere(v, iAddr); |
| 75563 | if( prNotFound && !pTab->aCol[iCol].notNull ){ |
| 75564 | *prNotFound = ++pParse->nMem; |
| 75565 | sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound); |
| @@ -106747,11 +106750,12 @@ | |
| 106750 | ** this routine sets up a loop that will iterate over all values of X. |
| 106751 | */ |
| 106752 | static int codeEqualityTerm( |
| 106753 | Parse *pParse, /* The parsing context */ |
| 106754 | WhereTerm *pTerm, /* The term of the WHERE clause to be coded */ |
| 106755 | WhereLevel *pLevel, /* The level of the FROM clause we are working on */ |
| 106756 | int iEq, /* Index of the equality term within this level */ |
| 106757 | int iTarget /* Attempt to leave results in this register */ |
| 106758 | ){ |
| 106759 | Expr *pX = pTerm->pExpr; |
| 106760 | Vdbe *v = pParse->pVdbe; |
| 106761 | int iReg; /* Register holding results */ |
| @@ -106767,13 +106771,26 @@ | |
| 106771 | int eType; |
| 106772 | int iTab; |
| 106773 | struct InLoop *pIn; |
| 106774 | u8 bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0; |
| 106775 | |
| 106776 | if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 |
| 106777 | && pLevel->plan.u.pIdx->aSortOrder[iEq] |
| 106778 | ){ |
| 106779 | testcase( iEq==0 ); |
| 106780 | testcase( iEq==pLevel->plan.u.pIdx->nColumn-1 ); |
| 106781 | testcase( iEq>0 && iEq+1<pLevel->plan.u.pIdx->nColumn ); |
| 106782 | testcase( bRev ); |
| 106783 | bRev = !bRev; |
| 106784 | } |
| 106785 | assert( pX->op==TK_IN ); |
| 106786 | iReg = iTarget; |
| 106787 | eType = sqlite3FindInIndex(pParse, pX, 0); |
| 106788 | if( eType==IN_INDEX_INDEX_DESC ){ |
| 106789 | testcase( bRev ); |
| 106790 | bRev = !bRev; |
| 106791 | } |
| 106792 | iTab = pX->iTable; |
| 106793 | sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); |
| 106794 | assert( pLevel->plan.wsFlags & WHERE_IN_ABLE ); |
| 106795 | if( pLevel->u.in.nIn==0 ){ |
| 106796 | pLevel->addrNxt = sqlite3VdbeMakeLabel(v); |
| @@ -106884,11 +106901,11 @@ | |
| 106901 | if( pTerm==0 ) break; |
| 106902 | /* The following true for indices with redundant columns. |
| 106903 | ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ |
| 106904 | testcase( (pTerm->wtFlags & TERM_CODED)!=0 ); |
| 106905 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 106906 | r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, regBase+j); |
| 106907 | if( r1!=regBase+j ){ |
| 106908 | if( nReg==1 ){ |
| 106909 | sqlite3ReleaseTempReg(pParse, regBase); |
| 106910 | regBase = r1; |
| 106911 | }else{ |
| @@ -107161,11 +107178,11 @@ | |
| 107178 | for(k=0; k<nConstraint; k++){ |
| 107179 | if( aUsage[k].argvIndex==j ){ |
| 107180 | int iTarget = iReg+j+1; |
| 107181 | pTerm = &pWC->a[aConstraint[k].iTermOffset]; |
| 107182 | if( pTerm->eOperator & WO_IN ){ |
| 107183 | codeEqualityTerm(pParse, pTerm, pLevel, k, iTarget); |
| 107184 | addrNotFound = pLevel->addrNxt; |
| 107185 | }else{ |
| 107186 | sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget); |
| 107187 | } |
| 107188 | break; |
| @@ -107202,11 +107219,11 @@ | |
| 107219 | pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0); |
| 107220 | assert( pTerm!=0 ); |
| 107221 | assert( pTerm->pExpr!=0 ); |
| 107222 | assert( omitTable==0 ); |
| 107223 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 107224 | iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, iReleaseReg); |
| 107225 | addrNxt = pLevel->addrNxt; |
| 107226 | sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); |
| 107227 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); |
| 107228 | sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); |
| 107229 | sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); |
| 107230 |
+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.7.16" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | -#define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" | |
| 112 | +#define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -286,11 +286,11 @@ | ||
| 286 | 286 | ** |
| 287 | 287 | ** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
| 288 | 288 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 289 | 289 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 290 | 290 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 291 | -** sqlite3_close() is called on a [database connection] that still has | |
| 291 | +** sqlite3_close_v2() is called on a [database connection] that still has | |
| 292 | 292 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 293 | 293 | ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation |
| 294 | 294 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 295 | 295 | ** and [sqlite3_backup] objects are also destroyed. |
| 296 | 296 | ** |
| 297 | 297 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2013-03-11 13:37:52 f9027cb47bdec8dcebf1f038921b28d9e9928c18" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -286,11 +286,11 @@ | |
| 286 | ** |
| 287 | ** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
| 288 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 289 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 290 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 291 | ** sqlite3_close() is called on a [database connection] that still has |
| 292 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 293 | ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation |
| 294 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 295 | ** and [sqlite3_backup] objects are also destroyed. |
| 296 | ** |
| 297 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -286,11 +286,11 @@ | |
| 286 | ** |
| 287 | ** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
| 288 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 289 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 290 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 291 | ** sqlite3_close_v2() is called on a [database connection] that still has |
| 292 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 293 | ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation |
| 294 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 295 | ** and [sqlite3_backup] objects are also destroyed. |
| 296 | ** |
| 297 |