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
diff --git a/src/expr.c b/src/expr.c
index cc795c0..0c4a611 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3620,6 +3620,9 @@
         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 @@
          && (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{