diff options
author | drh <drh@noemail.net> | 2016-02-02 02:22:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-02-02 02:22:30 +0000 |
commit | 33c1eb64772caf48a33d92e1a3c5a577c9ba1aa9 (patch) | |
tree | e820c4a4276381c4c71f8cf891e75dc67302fa8b /src/select.c | |
parent | e1ed0bb6077cc223fa54f58ae835f133d1c4aa59 (diff) | |
parent | b8db549832d2acc2fc30327e6fb5c0474820f122 (diff) | |
download | sqlite-33c1eb64772caf48a33d92e1a3c5a577c9ba1aa9.tar.gz sqlite-33c1eb64772caf48a33d92e1a3c5a577c9ba1aa9.zip |
Merge all recent enhancements from trunk.
FossilOrigin-Name: f3f9200115caf4b356f90ec97c351d1afbcb9bf6
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/select.c b/src/select.c index 9eb6279c1..891b12354 100644 --- a/src/select.c +++ b/src/select.c @@ -1860,10 +1860,8 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){ sqlite3ExprCode(pParse, p->pOffset, iOffset); sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); VdbeCoverage(v); VdbeComment((v, "OFFSET counter")); - sqlite3VdbeAddOp3(v, OP_SetIfNotPos, iOffset, iOffset, 0); - sqlite3VdbeAddOp3(v, OP_Add, iLimit, iOffset, iOffset+1); + sqlite3VdbeAddOp3(v, OP_OffsetLimit, iLimit, iOffset+1, iOffset); VdbeComment((v, "LIMIT+OFFSET")); - sqlite3VdbeAddOp3(v, OP_SetIfNotPos, iLimit, iOffset+1, -1); } } } @@ -2280,9 +2278,8 @@ static int multiSelect( addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v); VdbeComment((v, "Jump ahead if LIMIT reached")); if( p->iOffset ){ - sqlite3VdbeAddOp3(v, OP_SetIfNotPos, p->iOffset, p->iOffset, 0); - sqlite3VdbeAddOp3(v, OP_Add, p->iLimit, p->iOffset, p->iOffset+1); - sqlite3VdbeAddOp3(v, OP_SetIfNotPos, p->iLimit, p->iOffset+1, -1); + sqlite3VdbeAddOp3(v, OP_OffsetLimit, + p->iLimit, p->iOffset+1, p->iOffset); } } explainSetInteger(iSub2, pParse->iNextSelectId); @@ -2873,10 +2870,11 @@ static int multiSelectOrderBy( ** to the right and the left are evaluated, they use the correct ** collation. */ - aPermute = sqlite3DbMallocRaw(db, sizeof(int)*nOrderBy); + aPermute = sqlite3DbMallocRaw(db, sizeof(int)*(nOrderBy + 1)); if( aPermute ){ struct ExprList_item *pItem; - for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ + aPermute[0] = nOrderBy; + for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){ assert( pItem->u.x.iOrderByCol>0 ); assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ); aPermute[i] = pItem->u.x.iOrderByCol - 1; @@ -4438,8 +4436,7 @@ static int selectExpander(Walker *pWalker, Select *p){ pExpr = pRight; } pNew = sqlite3ExprListAppend(pParse, pNew, pExpr); - sColname.z = zColname; - sColname.n = sqlite3Strlen30(zColname); + sqlite3TokenInit(&sColname, zColname); sqlite3ExprListSetName(pParse, pNew, &sColname, 0); if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){ struct ExprList_item *pX = &pNew->a[pNew->nExpr-1]; |