aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-02-04 01:41:44 +0000
committerdrh <drh@noemail.net>2020-02-04 01:41:44 +0000
commit92a27f7bf2866cf2b99713559b39e1e725b489bd (patch)
treef4c6a1357abcf8460577cce78443578032333e74 /src/expr.c
parent40d1db8d20ed664abd7303f9ed1cd15f437ddd54 (diff)
downloadsqlite-92a27f7bf2866cf2b99713559b39e1e725b489bd.tar.gz
sqlite-92a27f7bf2866cf2b99713559b39e1e725b489bd.zip
Extend the OP_Copy-coalesce optimization fix of check-in [b36126c1889e323c]
so that it is also correctly disabled by the CASE operator. Ticket [9d3666754ac37d5a]. FossilOrigin-Name: 29a969d6b1709b80d9cb88b60971e4eb021f7f5f8ee9a619be74b833a78a35ef
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/expr.c b/src/expr.c
index d82ef8b8c..46a3f9f57 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3638,6 +3638,16 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){
}
/*
+** If the last opcode is a OP_Copy, then set the do-not-merge flag (p5)
+** so that a subsequent copy will not be merged into this one.
+*/
+static void setDoNotMergeFlagOnCopy(Vdbe *v){
+ if( sqlite3VdbeGetOp(v, -1)->opcode==OP_Copy ){
+ sqlite3VdbeChangeP5(v, 1); /* Tag trailing OP_Copy as not mergable */
+ }
+}
+
+/*
** Generate code to implement special SQL functions that are implemented
** in-line rather than by using the usual callbacks.
*/
@@ -3668,9 +3678,7 @@ 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 */
- }
+ setDoNotMergeFlagOnCopy(v);
sqlite3VdbeResolveLabel(v, endCoalesce);
break;
}
@@ -4441,6 +4449,7 @@ expr_code_doover:
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
sqlite3ExprDelete(db, pDel);
+ setDoNotMergeFlagOnCopy(v);
sqlite3VdbeResolveLabel(v, endLabel);
break;
}