aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c
index ef7c54d28..8bc85fcb5 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.412 2009/02/19 14:39:25 danielk1977 Exp $
+** $Id: expr.c,v 1.413 2009/02/20 03:55:05 drh Exp $
*/
#include "sqliteInt.h"
@@ -2002,9 +2002,26 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
}
#endif
case TK_VARIABLE: {
- sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iTable, target);
- if( pExpr->token.n>1 ){
- sqlite3VdbeChangeP4(v, -1, (char*)pExpr->token.z, pExpr->token.n);
+ int iPrior;
+ VdbeOp *pOp;
+ if( pExpr->token.n<=1
+ && (iPrior = sqlite3VdbeCurrentAddr(v)-1)>=0
+ && (pOp = sqlite3VdbeGetOp(v, iPrior))->opcode==OP_Variable
+ && pOp->p1+pOp->p3==pExpr->iTable
+ && pOp->p2+pOp->p3==target
+ && pOp->p4.z==0
+ ){
+ /* If the previous instruction was a copy of the previous unnamed
+ ** parameter into the previous register, then simply increment the
+ ** repeat count on the prior instruction rather than making a new
+ ** instruction.
+ */
+ pOp->p3++;
+ }else{
+ sqlite3VdbeAddOp3(v, OP_Variable, pExpr->iTable, target, 1);
+ if( pExpr->token.n>1 ){
+ sqlite3VdbeChangeP4(v, -1, (char*)pExpr->token.z, pExpr->token.n);
+ }
}
break;
}