0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-12-01 17:23:42 +01:00

Fix the sqlite3ExprImpliesNonNullRow() routine so that it correctly

handles a numeric comparison of two AND subexpressions.

FossilOrigin-Name: 07e504d5174a1a8b1aa05ec5b44ac81ab3ea706c5a098caa88deb3d489cec8fb
This commit is contained in:
drh 2020-01-01 16:43:41 +00:00
parent 171c50ec38
commit aef8167421
4 changed files with 34 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C New\stest-only\sSQL\sfunctions:\simplies_nonnull_row(),\sexpr_compare(),\sand\nexpr_implies_expr().\s\sThe\sSQLITE_TESTCTRL_INTERNAL_FUNCTIONS\stest-control\nis\smodified\sto\stoggle\sinternal\sfunction\saccess\son\sand\soff\sfor\sa\ssingle\ndatabase\sconnection.
D 2020-01-01T15:43:30.603
C Fix\sthe\ssqlite3ExprImpliesNonNullRow()\sroutine\sso\sthat\sit\scorrectly\nhandles\sa\snumeric\scomparison\sof\stwo\sAND\ssubexpressions.
D 2020-01-01T16:43:41.805
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -480,7 +480,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c 6c407e549406c10fde9ac3987f6d734459205239ad370369bc5fcd683084a4fa
F src/delete.c a5c59b9c0251cf7682bc52af0d64f09b1aefc6781a63592c8f1136f7b73c66e4
F src/expr.c 971e442fd52c493826a23e993de94e504adb10e5979d69169786af594687911b
F src/expr.c e76660a57fa2bbe4103686dc8add1a8c5ca40ae139076956dc8c670f5af34e93
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 92a248ec0fa4ed8ab60c98d9b188ce173aaf218f32e7737ba77deb2a684f9847
F src/func.c 259496e4856bd0a3215d16804992f3339f3e8db29f129a5a7285c341488bbe9c
@ -855,7 +855,7 @@ F test/exclusive.test d6ccc6acc5d660544f8e0cacaec2c620f8ebb42a764d783ab53430e260
F test/exclusive2.test 984090e8e9d1b331d2e8111daf6e5d61dda0bef7
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac
F test/expr.test 7cb55e80aeb41d65fec968c08212505123063fea60bdc355d764d747670e9eea
F test/expr.test 26cd01e8485bc48c8aa6a1add598e9ce1e706b4eb4f3f554e0b0223022e8c2cf
F test/expr2.test c27327ae9c017a7ff6280123f67aff496f912da74d78c888926d68b46ec75fd8
F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9
F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79
@ -1853,7 +1853,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 586a65a28fc6cac77309612abc32a2e1017c65e0387f9f438f5d8ac8406da8eb
R 3b4f115c4445c4450469f73abe883b1d
P 473892a8eceacf24d57fd0c72ff2a0b8be4e0d75e0af7a30bdb24fbc3b453601
R 2d8f123f2e4a8a472445b72603dcb7b0
U drh
Z 13c9af33d91ecf550a075017a4801480
Z d39001e583054b62fec0d63ed0de45b7

View File

@ -1 +1 @@
473892a8eceacf24d57fd0c72ff2a0b8be4e0d75e0af7a30bdb24fbc3b453601
07e504d5174a1a8b1aa05ec5b44ac81ab3ea706c5a098caa88deb3d489cec8fb

View File

@ -5359,12 +5359,13 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
return WRC_Prune;
case TK_AND:
assert( pWalker->eCode==0 );
if( pWalker->eCode==0 ){
sqlite3WalkExpr(pWalker, pExpr->pLeft);
if( pWalker->eCode ){
pWalker->eCode = 0;
sqlite3WalkExpr(pWalker, pExpr->pRight);
}
}
return WRC_Prune;
case TK_BETWEEN:

View File

@ -1036,4 +1036,24 @@ foreach {tn val} [list 1 NaN 2 -NaN 3 NaN0 4 -NaN0 5 Inf 6 -Inf] {
} {0}
}
reset_db
sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS db
do_execsql_test expr-16.1 {
CREATE TABLE t1(a,b,c);
CREATE TABLE dual(dummy);
INSERT INTO dual VALUES('X');
} {}
do_execsql_test expr-16.100 {
SELECT implies_nonnull_row( (b=1 AND 0)>(b=3 AND 0),a)
FROM dual LEFT JOIN t1;
} {0}
do_execsql_test expr-16.101 {
SELECT implies_nonnull_row( (b=1 AND 0)>(b=3 AND a=4),a)
FROM dual LEFT JOIN t1;
} {1}
do_execsql_test expr-16.102 {
SELECT implies_nonnull_row( (b=1 AND a=2)>(b=3 AND a=4),a)
FROM dual LEFT JOIN t1;
} {1}
finish_test