Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it
does matter. Ticket [1d2a8efc6c3a595a].
FossilOrigin-Name: 329820673a12ff6a6c8759f40989d4ccf272441064b0366a5f491695b55ad0e9
diff --git a/src/expr.c b/src/expr.c
index b0c61f0..a4407f4 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -5028,7 +5028,21 @@
&& (combinedFlags & EP_Reduced)==0
){
if( pA->iColumn!=pB->iColumn ) return 2;
- if( pA->op2!=pB->op2 && (pA->op!=TK_FUNCTION || iTab<0) ) return 2;
+ if( pA->op2!=pB->op2 ){
+ if( pA->op==TK_TRUTH ) return 2;
+ if( pA->op==TK_FUNCTION && iTab<0 ){
+ /* Ex: CREATE TABLE t1(a CHECK( a<julianday('now') ));
+ ** INSERT INTO t1(a) VALUES(julianday('now')+10);
+ ** Without this test, sqlite3ExprCodeAtInit() will run on the
+ ** the julianday() of INSERT first, and remember that expression.
+ ** Then sqlite3ExprCodeInit() will see the julianday() in the CHECK
+ ** constraint as redundant, reusing the one from the INSERT, even
+ ** though the julianday() in INSERT lacks the critical NC_IsCheck
+ ** flag. See ticket [830277d9db6c3ba1] (2019-10-30)
+ */
+ return 2;
+ }
+ }
if( pA->op!=TK_IN && pA->iTable!=pB->iTable && pA->iTable!=iTab ){
return 2;
}