Fix a problem with queries of the form "SELECT min(<expr>) ... WHERE <expr>=?" where there is an index on <expr>. Fix for [71e183ca].
FossilOrigin-Name: d465c3eef458c851d97eea6e4117247d9c69386b276168080dbff7bb64070c93
This commit is contained in:
parent
55b4c827fa
commit
192418bd49
20
manifest
20
manifest
@ -1,5 +1,5 @@
|
||||
C In\sthe\s".wheretrace\s0x100"\sdebugging\smode,\sshow\sthe\sstructure\sof\sthe\nmain\sparameters\sto\ssqlite3WhereBegin()\scalls.
|
||||
D 2019-08-03T16:17:46.598
|
||||
C Fix\sa\sproblem\swith\squeries\sof\sthe\sform\s"SELECT\smin(<expr>)\s...\sWHERE\s<expr>=?"\swhere\sthere\sis\san\sindex\son\s<expr>.\sFix\sfor\s[71e183ca].
|
||||
D 2019-08-03T16:37:40.150
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -609,9 +609,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c bbd6838bd79c0a32144d482fb0b6a9d2d1a252fb3b16d5005ec30f2f80413b0d
|
||||
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
|
||||
F src/walker.c d5a94907dcac990e31976be9dc769d17f6a806782593d6aec9d760ee01ec22cd
|
||||
F src/where.c 57a9b7b393878e4ab276e1028a392926ab10fd21057980291a30fdb19b4e6d1f
|
||||
F src/whereInt.h 6fab4b6f7e4ae716f112ee09cd1343fc6dde3d4a1831feabc6b3ed3b54b8eef3
|
||||
F src/wherecode.c 52451ce3673e1d737b2d9f0a05ff336038e9dd2dcfba221d43e06b51c1fe514e
|
||||
F src/where.c dee31d6842a8f6acd54bc7a7c2505050cd0fa52228634187195bc0b64eb9c240
|
||||
F src/whereInt.h 2bb9632f90a1a32952d43a52587209cdd536c3548715d7859bf0c1f9a65a2efd
|
||||
F src/wherecode.c b45c98f260a9fa84787b0673d7053d55d60cb55900236376cac935f2ab6ce3ec
|
||||
F src/whereexpr.c 5e559bdd24b06e3bc2e68f258bf751302954dc1e432daf71fdd8098a71462326
|
||||
F src/window.c 7728ba7a3d44084a44eefb60464a88fb2ff035eb20cdeb1160ae65ac3c0be6b9
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
@ -1151,7 +1151,7 @@ F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08
|
||||
F test/minmax.test 6751e87b409fe11b02e70a306d846fa544e25a41
|
||||
F test/minmax2.test dae92964ac87c1d2ef978c582e81a95e11c00f1cbef68980bfb2abaf10315063
|
||||
F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
|
||||
F test/minmax4.test be0b227f574a20871bdd4258d4a26620f263e4cd231d2eec0259b8980e7408b4
|
||||
F test/minmax4.test 325f0fccb12f3d36049105817a0152a3e9bbf7f194b2610744de899e636c7d69
|
||||
F test/misc1.test 7ce84b25df9872e7d7878613a96815d2ba5bc974ac4e15a50118dde8f3917599
|
||||
F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d
|
||||
F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d
|
||||
@ -1838,7 +1838,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 2660e9292ae2c229eb7c57a6a79bb19f0c970072f86750fbe9cca3113d44ffe4
|
||||
R a7169e6245912e88f71e7cf76fa1ca23
|
||||
U drh
|
||||
Z cd555f66c82162cedea0a54c10ae02a4
|
||||
P fd598e475d353363e19adc27a671170f11ae9f6d8cad58cb2303fb2ad8ac6bec
|
||||
R cc89bfbc259b9b7136163b32cac7f905
|
||||
U dan
|
||||
Z 99d6ce70f917d34037e260832ba76b7f
|
||||
|
@ -1 +1 @@
|
||||
fd598e475d353363e19adc27a671170f11ae9f6d8cad58cb2303fb2ad8ac6bec
|
||||
d465c3eef458c851d97eea6e4117247d9c69386b276168080dbff7bb64070c93
|
@ -3862,6 +3862,9 @@ static i8 wherePathSatisfiesOrderBy(
|
||||
distinctColumns = 1;
|
||||
}
|
||||
obSat |= MASKBIT(i);
|
||||
if( (wctrlFlags & WHERE_ORDERBY_MIN) && j==pLoop->u.btree.nEq ){
|
||||
pLoop->wsFlags |= WHERE_MIN_ORDERED;
|
||||
}
|
||||
}else{
|
||||
/* No match found */
|
||||
if( j==0 || j<nKeyCol ){
|
||||
|
@ -586,5 +586,6 @@ void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);
|
||||
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
|
||||
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
|
||||
#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
|
||||
#define WHERE_MIN_ORDERED 0x00080000 /* Column nEq of index is min() expr */
|
||||
|
||||
#endif /* !defined(SQLITE_WHEREINT_H) */
|
||||
|
@ -1562,13 +1562,12 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
** the first one after the nEq equality constraints in the index,
|
||||
** this requires some special handling.
|
||||
*/
|
||||
assert( pWInfo->pOrderBy==0
|
||||
|| pWInfo->pOrderBy->nExpr==1
|
||||
assert( (pWInfo->pOrderBy!=0 && pWInfo->pOrderBy->nExpr==1)
|
||||
|| (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 );
|
||||
if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0
|
||||
&& pWInfo->nOBSat>0
|
||||
&& (pIdx->nKeyCol>nEq)
|
||||
){
|
||||
if( pLoop->wsFlags & WHERE_MIN_ORDERED ){
|
||||
assert( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN) );
|
||||
assert( pWInfo->nOBSat );
|
||||
assert( pIdx->nColumn>nEq );
|
||||
assert( pLoop->nSkip==0 );
|
||||
bSeekPastNull = 1;
|
||||
nExtraReg = 1;
|
||||
|
@ -178,4 +178,27 @@ foreach {tn sql} {
|
||||
} {2 2}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
do_execsql_test 4.0 {
|
||||
CREATE TABLE t0 (c0, c1);
|
||||
CREATE INDEX i0 ON t0(c1, c1 + 1 DESC);
|
||||
INSERT INTO t0(c0) VALUES (1);
|
||||
}
|
||||
do_execsql_test 4.1 {
|
||||
SELECT MIN(t0.c1), t0.c0 FROM t0 WHERE t0.c1 ISNULL;
|
||||
} {{} 1}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
do_execsql_test 5.0 {
|
||||
CREATE TABLE t1 (a, b);
|
||||
INSERT INTO t1 VALUES(123, NULL);
|
||||
CREATE INDEX i1 ON t1(a, b DESC);
|
||||
}
|
||||
do_execsql_test 5.1 {
|
||||
SELECT MIN(a) FROM t1 WHERE a=123;
|
||||
} {123}
|
||||
|
||||
finish_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user