From: drh Date: Thu, 17 Mar 2011 01:53:00 +0000 (+0000) Subject: Backport the "x IS NULL" query planner enhancement of [2353176811f] to X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=510eca1d25a3c0289cfcd4a5e96d1c69f0627d3e;p=thirdparty%2Fsqlite.git Backport the "x IS NULL" query planner enhancement of [2353176811f] to the 3.7.2 branch. FossilOrigin-Name: 68daf20d019a0a84764d635a91eaa9faeeabbab4 --- diff --git a/manifest b/manifest index 1c8cf637d8..6054817eb3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Backport\sthe\sSQLITE_OMIT_UNIQUE_ENFORCEMENT\schange\sfrom\scheckin\sb86999436e\son\sthe\strunk. -D 2011-03-12T05:55:38.900 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Backport\sthe\s"x\sIS\sNULL"\squery\splanner\senhancement\sof\s[2353176811f]\sto\nthe\s3.7.2\sbranch. +D 2011-03-17T01:53:00.823 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 543f91f24cd7fee774ecc0a61c19704c0c3e78fd F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -230,7 +233,7 @@ F src/vtab.c 0e8e0cb30dffb078367e843e84e37ef99236c7e4 F src/wal.c 5ac2119e23ee4424599d4275b66dc88d612a0543 F src/wal.h 96669b645e27cd5a111ba59f0cae7743a207bc3c F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 124e56fc30ffc1d8284bcd60151829afb5d55a2f +F src/where.c deee5203073e0f63d79fd104b15dbebb6083dc03 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 6745008c144bd2956d58864d21f7b304689c1cce @@ -847,7 +850,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 2d55234ea3b8a8d6f18683d51f05945394e97275 -R 1db94dc3291fba1026c28b4049abf650 -U shaneh -Z 84dd2ae494c40f1290217661561c5409 +P 668b91dbff036c6b76a5611cc3ebe455d277ed59 +R 3deac5f89493711dcb01d153d7e3d240 +U drh +Z c3047dd905fb57f35c3045f1bdcf4daf +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNgWmAoxKgR168RlERAkI3AJ46nXurlFqON8jJkpUsMsyM4a2EqwCeJzde +XXyg86cVMugwqsg1J9KaC2s= +=slbW +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index ec6b70c56b..e04ff4770d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -668b91dbff036c6b76a5611cc3ebe455d277ed59 \ No newline at end of file +68daf20d019a0a84764d635a91eaa9faeeabbab4 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 89f3f33b06..4f69258a2d 100644 --- a/src/where.c +++ b/src/where.c @@ -2546,8 +2546,12 @@ int whereEqualScanEst( assert( p->aSample!=0 ); aff = p->pTable->aCol[p->aiColumn[0]].affinity; - rc = valueFromExpr(pParse, pExpr, aff, &pRhs); - if( rc ) goto whereEqualScanEst_cancel; + if( pExpr ){ + rc = valueFromExpr(pParse, pExpr, aff, &pRhs); + if( rc ) goto whereEqualScanEst_cancel; + }else{ + pRhs = sqlite3ValueNew(pParse->db); + } if( pRhs==0 ) return SQLITE_NOTFOUND; rc = whereRangeRegion(pParse, p, pRhs, 0, &iLower); if( rc ) goto whereEqualScanEst_cancel; @@ -2936,7 +2940,9 @@ static void bestBtreeIndex( ** VALUE and how common that value is according to the histogram. */ if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 ){ - if( pFirstTerm->eOperator==WO_EQ ){ + if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){ + testcase( pFirstTerm->eOperator==WO_EQ ); + testcase( pFirstTerm->pOperator==WO_ISNULL ); whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow); }else if( pFirstTerm->eOperator==WO_IN && bInEst==0 ){ whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow);