Always make sure the left-hand side of the IS NOT NULL operator is a

smiple column, not a general expression, before applying the IS NOT NULL
query optimization.

FossilOrigin-Name: 543f75a6abe3aa4f49df43e71a462702d40b3251
This commit is contained in:
drh 2011-04-08 21:35:26 +00:00
parent 1c152101ca
commit ea6dc4458b
4 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Add\ssome\srtree\stests\sto\sthe\sbackcompat.test\sscript.
D 2011-04-08T18:47:24.227
C Always\smake\ssure\sthe\sleft-hand\sside\sof\sthe\sIS\sNOT\sNULL\soperator\sis\sa\nsmiple\scolumn,\snot\sa\sgeneral\sexpression,\sbefore\sapplying\sthe\sIS\sNOT\sNULL\nquery\soptimization.
D 2011-04-08T21:35:26.364
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -247,7 +247,7 @@ F src/vtab.c b0abc931f95af94c9ffdf9f747eb191cda953123
F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794
F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 9af3810842aa57c7de99dcb209e6a8b25acd5bb7
F src/where.c 494d106959a492838ab3723e284de46ddd520da1
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125
@ -260,7 +260,7 @@ F test/analyze.test c8cb89e8736336f1f0646c8123e6028a14c7b55e
F test/analyze2.test 8f2b1534d43f5547ce9a6b736c021d4192c75be3
F test/analyze3.test d61f55d8b472fc6e713160b1e577f7a68e63f38b
F test/analyze4.test 757b37875cf9bb528d46f74497bc789c88365045
F test/analyze5.test adc89b92fc9fee5ca1cb0bc8512f3206ad0fe5aa
F test/analyze5.test 1de8d66b11aae5a1453aa042d62e834a476bac9c
F test/analyze6.test c125622a813325bba1b4999040ddc213773c2290
F test/analyze7.test 5508e7828164ea0b518ed219bed7320a481863d4
F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3
@ -927,7 +927,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 7b8e176143bb8b55e34fd70cbfa639b1097b2c34
R 721738e1b7737b5721b6d7302a3c4ca3
U dan
Z 88b5a8ea4fcbb765bca47e95e089b60f
P 8ea3601cd11088ae4d62bd4a05d1675301b26ace
R 7e699a3cf12fb4b90da6a0d2b765dc1b
U drh
Z b346c2d4f65ea7f3ece8de7fdcc289fd

View File

@ -1 +1 @@
8ea3601cd11088ae4d62bd4a05d1675301b26ace
543f75a6abe3aa4f49df43e71a462702d40b3251

View File

@ -1342,7 +1342,10 @@ static void exprAnalyze(
** of the loop. Without the TERM_VNULL flag, the not-null check at
** the start of the loop will prevent any results from being returned.
*/
if( pExpr->op==TK_NOTNULL && pExpr->pLeft->iColumn>=0 ){
if( pExpr->op==TK_NOTNULL
&& pExpr->pLeft->op==TK_COLUMN
&& pExpr->pLeft->iColumn>=0
){
Expr *pNewExpr;
Expr *pLeft = pExpr->pLeft;
int idxNew;

View File

@ -209,6 +209,8 @@ foreach {testid where index rows} {
502 {x IS NULL} {} 100
503 {x=1} t1x 50
504 {x IS NOT NULL} t1x 25
505 {+x IS NOT NULL} {} 500
506 {upper(x) IS NOT NULL} {} 500
} {
# Verify that the expected index is used with the expected row count