aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-01-03 14:16:43 +0000
committerdrh <drh@noemail.net>2020-01-03 14:16:43 +0000
commit90996885fcad330e5773ae77b2f0276e9233bb47 (patch)
tree6e822d6130ea6c740ffc323832bf4155fca059cf /src/expr.c
parentaa328b6ab13d97f092bced55f8faeb13b4c42237 (diff)
downloadsqlite-90996885fcad330e5773ae77b2f0276e9233bb47.tar.gz
sqlite-90996885fcad330e5773ae77b2f0276e9233bb47.zip
Fix the OP_Copy-coalesce optimization so that if the previous row happens
to end with OP_Copy but is not a candidate for the optimization due to jumps, then the optimization is correctly bypassed. FossilOrigin-Name: b36126c1889e323c9a8f04b4f4884576993c845e7d393e5e73aaa6ab5158c1f9
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c
index cc795c09f..0c4a61175 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3620,6 +3620,9 @@ static int exprCodeInlineFunction(
VdbeCoverage(v);
sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
}
+ if( sqlite3VdbeGetOp(v, -1)->opcode==OP_Copy ){
+ sqlite3VdbeChangeP5(v, 1); /* Tag trailing OP_Copy as not mergable */
+ }
sqlite3VdbeResolveLabel(v, endCoalesce);
break;
}
@@ -4607,6 +4610,7 @@ int sqlite3ExprCodeExprList(
&& (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy
&& pOp->p1+pOp->p3+1==inReg
&& pOp->p2+pOp->p3+1==target+i
+ && pOp->p5==0 /* The do-not-merge flag must be clear */
){
pOp->p3++;
}else{