From: drh Date: Wed, 16 Mar 2016 18:26:54 +0000 (+0000) Subject: Fix the query planner so that it is able to use the integer primary key X-Git-Tag: version-3.12.0~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=892ffcc7fc5b0a6d20c20c64b56096ee8ecbd207;p=thirdparty%2Fsqlite.git Fix the query planner so that it is able to use the integer primary key from an index as part of a multi-column constraint. FossilOrigin-Name: 96ea9909429f0b3b4a67002e8340ae3f7dc0b73f --- diff --git a/manifest b/manifest index bf413d574c..9530ffa5fc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_OMIT_CODEC_FROM_TCL\scompile-time\soption. -D 2016-03-16T01:03:10.251 +C Fix\sthe\squery\splanner\sso\sthat\sit\sis\sable\sto\suse\sthe\sinteger\sprimary\skey\nfrom\san\sindex\sas\spart\sof\sa\smulti-column\sconstraint. +D 2016-03-16T18:26:54.117 F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66 @@ -430,7 +430,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 10deb6b43887662691e5f53d10b3c171c401169b F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 5533002ddf4fbc256f450cb629668a200b06a3ce +F src/where.c fe7925faafbe9a458972035c0bb4753d672f04ed F src/whereInt.h 93297d56edd137b7ea004490690fb6e2ce028a34 F src/wherecode.c 863aedf086131743763c1960637fde904eadc442 F src/whereexpr.c fb87944b1254234e5bba671aaf6dee476241506a @@ -820,7 +820,7 @@ F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc -F test/intpkey.test 7506090fc08e028712a8bf47e5f54111947e3844 +F test/intpkey.test 70aab09756b9bd3bcb6b0358f971d7bbace46522 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 @@ -1456,7 +1456,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 e0b116edd64a55c971c368685aa343cb6beed0f1 -R 1b0c52bbc749be5b9a732d29d3d099e5 +P 45f7f0c80bd91a0c7ff859c27fd9e82e551bd83e +R 48d902683e4b6144f631d91ce9dec30e U drh -Z 5dddb7cbfc6ef15baab9797e73067d60 +Z 4770e56ece3387d541183edf6806d70a diff --git a/manifest.uuid b/manifest.uuid index 3aa4fcd861..11ed7df765 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45f7f0c80bd91a0c7ff859c27fd9e82e551bd83e \ No newline at end of file +96ea9909429f0b3b4a67002e8340ae3f7dc0b73f \ No newline at end of file diff --git a/src/where.c b/src/where.c index 83d72ee397..cf23aa62a4 100644 --- a/src/where.c +++ b/src/where.c @@ -289,6 +289,7 @@ static WhereTerm *whereScanInit( j = iColumn; iColumn = pIdx->aiColumn[j]; if( iColumn==XN_EXPR ) pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr; + if( iColumn==pIdx->pTable->iPKey ) iColumn = XN_ROWID; } if( pIdx && iColumn>=0 ){ pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; @@ -3929,7 +3930,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ int j; Table *pTab; Index *pIdx; - + pWInfo = pBuilder->pWInfo; if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0; assert( pWInfo->pTabList->nSrc>=1 ); diff --git a/test/intpkey.test b/test/intpkey.test index 41858e5d46..a149f43fb2 100644 --- a/test/intpkey.test +++ b/test/intpkey.test @@ -296,7 +296,7 @@ do_test intpkey-3.8 { count { SELECT * FROM t1 WHERE c=='world' AND a>7; } -} {11 hello world 4} +} {11 hello world 3} do_test intpkey-3.9 { count { SELECT * FROM t1 WHERE 7