1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

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
This commit is contained in:
drh
2020-01-03 14:16:43 +00:00
parent aa328b6ab1
commit 90996885fc
4 changed files with 16 additions and 9 deletions

View File

@@ -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{