diff options
author | drh <drh@noemail.net> | 2019-08-17 17:07:15 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-08-17 17:07:15 +0000 |
commit | 9e9a67adb059733e05e0791f2ec519985eaa333c (patch) | |
tree | 6c09b82af50a2ec508da883093f738d20bf472c5 /src/expr.c | |
parent | cc3f3d1f055e5bce28d7c7fa122ac5f922a7706b (diff) | |
download | sqlite-9e9a67adb059733e05e0791f2ec519985eaa333c.tar.gz sqlite-9e9a67adb059733e05e0791f2ec519985eaa333c.zip |
Ensure the functions that appear to be constant are not factored out of
expression that originate on the right-hand side of a LEFT JOIN.
Ticket [6710d2f7a13a2997]
FossilOrigin-Name: 500c9152daaf11cf69d778aa8592175f6088337c6667c59af6df3a24cd81eb0e
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c index 8f02ae569..ef4221ff8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3994,10 +3994,23 @@ expr_code_doover: break; } + /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions + ** that derive from the right-hand table of a LEFT JOIN. The + ** Expr.iTable value is the table number for the right-hand table. + ** The expression is only evaluated if that table is not currently + ** on a LEFT JOIN NULL row. + */ case TK_IF_NULL_ROW: { int addrINR; + u8 okConstFactor = pParse->okConstFactor; addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable); + /* Temporarily disable factoring of constant expressions, since + ** even though expressions may appear to be constant, they are not + ** really constant because they originate from the right-hand side + ** of a LEFT JOIN. */ + pParse->okConstFactor = 0; inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); + pParse->okConstFactor = okConstFactor; sqlite3VdbeJumpHere(v, addrINR); sqlite3VdbeChangeP3(v, addrINR, inReg); break; |