From: drh Date: Tue, 12 Nov 2013 14:55:40 +0000 (+0000) Subject: Make sure the count(*) optimization works correctly on WITHOUT ROWID tables. X-Git-Tag: version-3.8.2~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abcc1941db3481c8ca05b4cde66df083329087a8;p=thirdparty%2Fsqlite.git Make sure the count(*) optimization works correctly on WITHOUT ROWID tables. FossilOrigin-Name: 91174779786be07d63f3c4a5277602ddc5f0ba26 --- diff --git a/manifest b/manifest index 74fe80d785..b28477fad1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stest\scommand\s[explain_i]\sto\shandle\sthe\sopcodes\sused\sby\svirtual\stables\s(VNext,\sVFilter\setc.). -D 2013-11-12T12:30:09.040 +C Make\ssure\sthe\scount(*)\soptimization\sworks\scorrectly\son\sWITHOUT\sROWID\stables. +D 2013-11-12T14:55:40.075 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -219,7 +219,7 @@ F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 F src/resolve.c fc4673cc49b116e51e7f12de074c0acf8f2388f9 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c a040df82c4ac90b27114e1c21a05d77cc6dc6f80 +F src/select.c 98855336b4499d731363c08ba26dfc1bbf8b731d F src/shell.c 03d8d9b4052430343ff30d646334621f980f1202 F src/sqlite.h.in 4dedcab5b32358bf7a596badffe7363be1f1a82d F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e @@ -405,7 +405,7 @@ F test/corruptD.test 3b09903a2e2fe07ecafe775fea94177f8a4bb34f F test/corruptE.test d3a3d7e864a95978195741744dda4abfd8286018 F test/corruptF.test 1c7b6f77cf3f237fb7fbb5b61d6c921fd4c7b993 F test/corruptG.test c67fd860e9e3943bc90b856a3049c9a28827167e -F test/count.test 454e1ce985c94d13efeac405ce54439f49336163 +F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f F test/crash2.test 5b14d4eb58b880e231361d3b609b216acda86651 @@ -1136,7 +1136,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P e2684ece455f53563ae6da7cbb5505d9a4a3076a -R 689a8dc8aa01a2c309250dfed05151c5 -U dan -Z f07d22c7597ab468bfc7a55252cdaa8e +P 1b215ee3219750d3beda8f3628c8673efd517061 +R 697ad63209879b2cc9b3d0ee859ef9f2 +U drh +Z 7d51e8fe49c496b0ea3c1c3661447e30 diff --git a/manifest.uuid b/manifest.uuid index dfcc3f429f..86c9e3ea9b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b215ee3219750d3beda8f3628c8673efd517061 \ No newline at end of file +91174779786be07d63f3c4a5277602ddc5f0ba26 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 02730ac123..3c7501376f 100644 --- a/src/select.c +++ b/src/select.c @@ -4670,7 +4670,7 @@ int sqlite3Select( ** ** (2011-04-15) Do not do a full scan of an unordered index. ** - ** (2013-10-03) Do not count the entires in a partial index. + ** (2013-10-03) Do not count the entries in a partial index. ** ** In practice the KeyInfo structure will not be used. It is only ** passed to keep OP_OpenRead happy. @@ -4682,6 +4682,8 @@ int sqlite3Select( && (!pBest || pIdx->szIdxRowszIdxRow) ){ pBest = pIdx; + }else if( pIdx->autoIndex==2 && pBest==0 && !HasRowid(pTab) ){ + pBest = pIdx; } } if( pBest ){ diff --git a/test/count.test b/test/count.test index fbdd13b6ba..3461e49c1d 100644 --- a/test/count.test +++ b/test/count.test @@ -1,4 +1,4 @@ -# 2009 February 24 +# 2009-02-24 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -11,7 +11,6 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing "SELECT count(*)" statements. # -# $Id: count.test,v 1.6 2009/06/05 17:09:12 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -24,8 +23,6 @@ source $testdir/tester.tcl # tables and indexes. Test both when they contain 0 entries, # when all entries are on the root page, and when the b-tree # forms a structure 2 and 3 levels deep. -# -# count-2.*: Test that # # @@ -188,5 +185,10 @@ do_test count-4.3 { } } {1} +do_execsql_test count-5.1 { + CREATE TABLE t5(a TEXT PRIMARY KEY, b VARCHAR(50)) WITHOUT ROWID; + INSERT INTO t5 VALUES('bison','jazz'); + SELECT count(*) FROM t5; +} {1} finish_test