aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-10-31 13:16:26 +0000
committerdrh <drh@noemail.net>2019-10-31 13:16:26 +0000
commit04307c8a3f457760348fd56f474cedc940fd7dc3 (patch)
tree79e011897fa37dd87dcd4e0a39b05ecf74c48d87 /src/expr.c
parentd493353e9991159a69540f9732df8ff6be2aa2d6 (diff)
downloadsqlite-04307c8a3f457760348fd56f474cedc940fd7dc3.tar.gz
sqlite-04307c8a3f457760348fd56f474cedc940fd7dc3.zip
Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it
does matter. Ticket [1d2a8efc6c3a595a]. FossilOrigin-Name: 329820673a12ff6a6c8759f40989d4ccf272441064b0366a5f491695b55ad0e9
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c
index b0c61f00f..a4407f4a8 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -5028,7 +5028,21 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
&& (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;
}