diff options
author | dan <dan@noemail.net> | 2016-11-10 20:14:06 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2016-11-10 20:14:06 +0000 |
commit | 257c13fa008b2033960e60927d180f2ebbe1fdca (patch) | |
tree | e5c0f947ddb9c5633ffe88013f35aa249ad948d5 /src/expr.c | |
parent | 58282f68d88e6c9ff907988a99ff67d8c473f137 (diff) | |
download | sqlite-257c13fa008b2033960e60927d180f2ebbe1fdca.tar.gz sqlite-257c13fa008b2033960e60927d180f2ebbe1fdca.zip |
Avoid storing redundant fields in sorter records when the sort-key and data have
fields in common (as in "SELECT a FROM t1 ORDER BY 1").
FossilOrigin-Name: 0af62fdbd8e2aab14718ff8bcb5934f05463c176
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c index c2b9c8fe4..165bb30f7 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4086,8 +4086,13 @@ int sqlite3ExprCodeExprList( if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR; for(pItem=pList->a, i=0; i<n; i++, pItem++){ Expr *pExpr = pItem->pExpr; - if( (flags & SQLITE_ECEL_REF)!=0 && (j = pList->a[i].u.x.iOrderByCol)>0 ){ - sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i); + if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){ + if( flags & SQLITE_ECEL_OMITREF ){ + i--; + n--; + }else{ + sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i); + } }else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){ sqlite3ExprCodeAtInit(pParse, pExpr, target+i, 0); }else{ |