The expression "(X IS FALSE) BETWEEN FALSE AND TRUE" does not implie that

X is not NULL.  Ticket [fba33c8b1df6a915]

FossilOrigin-Name: 057fb8b1809b8b9c8fff0fd0804153b9644f0545c23c6ddc4758bda3381094b9
This commit is contained in:
drh 2019-08-30 15:11:08 +00:00
parent 38cefc83c8
commit 7a231b4973
4 changed files with 25 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C The\sexpression\s"(x\sIS\sFALSE)\sIS\sFALSE"\sdoes\snot\simply\sthat\sX\sis\snot\sNULL.\nTicket\s[a6408d42b9f44462]
D 2019-08-30T13:07:06.147
C The\sexpression\s"(X\sIS\sFALSE)\sBETWEEN\sFALSE\sAND\sTRUE"\sdoes\snot\simplie\sthat\nX\sis\snot\sNULL.\s\sTicket\s[fba33c8b1df6a915]
D 2019-08-30T15:11:08.913
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -475,7 +475,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c c12833de69cb655751487d2c5a59607e36be1c58ba1f4bd536609909ad47b319
F src/delete.c d08c9e01a2664afd12edcfa3a9c6578517e8ff8735f35509582693adbe0edeaf
F src/expr.c 5f9d677be65dd8f636eedb598e3c68c9a72bc39fa753d952df2adea96ade17be
F src/expr.c e1d261e3d2ddd29d49d645bf2b919f37b842fa5fc41a936b2dcc3e5a309d58c0
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 6b79f4c2447691aa9ac86e2a6a774b65f3b3dd053d4220a4893051a0de20f82e
F src/func.c 4ee36219698d50d672a28eca4adb0fd6b92e607a1883d318315e0d2fd5044467
@ -1047,7 +1047,7 @@ F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407
F test/index3.test 51685f39345462b84fcf77eb8537af847fdf438cc96b05c45d6aaca4e473ade0
F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6
F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7
F test/index6.test 4286a391c34586bc4d6cc0f68c6505c7b0f5b9afe8cb98fe415eefffb2384cb4
F test/index6.test 5b016266f0e823b2a27724da25c18fe38feb474006f9604d9d5f996bfef75b68
F test/index7.test 1d764c0cca45f5a76150b08e127ccc8d52492cfa788b5fafed4be784a351b020
F test/index8.test bc2e3db70e8e62459aaa1bd7e4a9b39664f8f9d7
F test/index9.test 0aa3e509dddf81f93380396e40e9bb386904c1054924ba8fa9bcdfe85a8e7721
@ -1837,7 +1837,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 80124ae55246b79023d23d3f55487ac3c0b40e8ff301c5daf4dd0631de8ddb29
R cd2bfff061492eccfe83623c7f6b6353
P 45ff2b1f2693bb0231a864a511bb82cf2a5945ab3d806a5bbaf1517ecb287883
R 9c64b300fe2525056b87d63bc987465b
U drh
Z 295dda45dc991784101709d0169e56ad
Z 75ee72b9565e384807e78e8394c68f11

View File

@ -1 +1 @@
45ff2b1f2693bb0231a864a511bb82cf2a5945ab3d806a5bbaf1517ecb287883
057fb8b1809b8b9c8fff0fd0804153b9644f0545c23c6ddc4758bda3381094b9

View File

@ -4974,13 +4974,16 @@ int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
/*
** Return non-zero if Expr p can only be true if pNN is not NULL.
**
** Or if seenNot is true, return non-zero if Expr p can only be
** non-NULL if pNN is not NULL
*/
static int exprImpliesNotNull(
Parse *pParse, /* Parsing context */
Expr *p, /* The expression to be checked */
Expr *pNN, /* The expression that is NOT NULL */
int iTab, /* Table being evaluated */
int seenNot /* True if p is an operand of NOT */
int seenNot /* Return true only if p can be any non-NULL value */
){
assert( p );
assert( pNN );
@ -4999,12 +5002,12 @@ static int exprImpliesNotNull(
assert( pList!=0 );
assert( pList->nExpr==2 );
if( seenNot ) return 0;
if( exprImpliesNotNull(pParse, pList->a[0].pExpr, pNN, iTab, seenNot)
|| exprImpliesNotNull(pParse, pList->a[1].pExpr, pNN, iTab, seenNot)
if( exprImpliesNotNull(pParse, pList->a[0].pExpr, pNN, iTab, 1)
|| exprImpliesNotNull(pParse, pList->a[1].pExpr, pNN, iTab, 1)
){
return 1;
}
return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
}
case TK_EQ:
case TK_NE:

View File

@ -439,6 +439,7 @@ do_execsql_test index6-14.2 {
# 2019-08-30
# Ticket https://www.sqlite.org/src/info/a6408d42b9f44462
# Ticket https://www.sqlite.org/src/info/fba33c8b1df6a915
#
do_execsql_test index6-15.1 {
DROP TABLE t0;
@ -447,5 +448,14 @@ do_execsql_test index6-15.1 {
CREATE INDEX i0 ON t0(1) WHERE c0 NOT NULL;
SELECT 1 FROM t0 WHERE (t0.c0 IS FALSE) IS FALSE;
} {1}
do_execsql_test index6-15.2 {
SELECT 1 FROM t0 WHERE (t0.c0 IS FALSE) BETWEEN FALSE AND TRUE;
} {1}
do_execsql_test index6-15.3 {
SELECT 1 FROM t0 WHERE TRUE BETWEEN (t0.c0 IS FALSE) AND TRUE;
} {1}
do_execsql_test index6-15.4 {
SELECT 1 FROM t0 WHERE FALSE BETWEEN FALSE AND (t0.c0 IS FALSE);
} {1}
finish_test