From 5f33f375806d0856bb12002dc07d9f2766eaac35 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 4 Oct 2013 00:00:12 +0000 Subject: [PATCH] Make sure the count(*) optimization works correctly even when partial indices are present. Ticket [a5c8ed66cae]. FossilOrigin-Name: 9f2f4c0a50808910ad01c8c4352367f25747be08 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 7 ++++++- test/index6.test | 7 +++++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 69357054f1..5afa0d39ec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sFTS\stake\sadvantage\sof\s"docidpIndex; pIdx; pIdx=pIdx->pNext){ - if( pIdx->bUnordered==0 && (!pBest || pIdx->nColumnnColumn) ){ + if( pIdx->bUnordered==0 + && pIdx->pPartIdxWhere==0 + && (!pBest || pIdx->nColumnnColumn) + ){ pBest = pIdx; } } diff --git a/test/index6.test b/test/index6.test index 0b440451c1..c427dc3df3 100644 --- a/test/index6.test +++ b/test/index6.test @@ -37,6 +37,13 @@ do_test index6-1.1 { } } {14 20 ok} +# Make sure the count(*) optimization works correctly with +# partial indices. Ticket [a5c8ed66cae16243be6] 2013-10-03. +# +do_execsql_test index6-1.1.1 { + SELECT count(*) FROM t1; +} {20} + # Error conditions during parsing... # do_test index6-1.2 { -- 2.47.2