-C Bump\sthe\sversion\snumber\sto\s3.8.6.
-D 2014-06-30T19:28:57.595
+C Ensure\sthat\sall\sfields\sare\sloaded\sfrom\sthe\sstat4\stable\sfor\srecords\sthat\scorrespond\sto\sindexes\son\sWITHOUT\sROWID\stables\swith\scomposite\sprimary\skeys.
+D 2014-07-01T11:54:02.938
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F sqlite3.1 3d8b83c91651f53472ca17599dae3457b8b89494
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c b00900877f766f116f9e16116f1ccacdc21d82f1
-F src/analyze.c ec6e0691a6a23e0239dc733109b906ee04b89cc3
+F src/analyze.c 61bc3467bd7803158d460dd92f5ba5205371bdce
F src/attach.c 3801129015ef59d76bf23c95ef9b0069d18a0c52
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53
F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45
-F src/where.c 6ff6f7e3b272fad66eea601af489777adea3cc1f
+F src/where.c 3a451b00516b59f414c59f817508edce51c732f1
F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/analyze6.test d31defa011a561b938b4608d3538c1b4e0b5e92c
F test/analyze7.test bb1409afc9e8629e414387ef048b8e0e3e0bdc4f
F test/analyze8.test 093d15c1c888eed5034304a98c992f7360130b88
-F test/analyze9.test 93619368fff2db833747a6dfa9b1146a82e5d4d2
+F test/analyze9.test 3129cc8a82c3d6c5dfd340143b18499219faebac
F test/analyzeA.test 1a5c40079894847976d983ca39c707aaa44b6944
F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d
F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P d09ca6d5efad3e4cfa93a4dc711e6ba6079d4b4b
-R 0b9fd011a99704759c36a48aebd29593
-U drh
-Z 99f7c1257c18120424d63d4c4b9a073c
+P f925e9baafea625f63105f8013abb3807b418379
+R b0479b264ee66056e956ca8c9e5bfcd6
+U dan
+Z 2688039829f2bbaff9c051901e2506da
-f925e9baafea625f63105f8013abb3807b418379
\ No newline at end of file
+21981e35062cc6b30e9576786cbf55265a7a4d41
\ No newline at end of file
IndexSample *aSample = pIdx->aSample;
IndexSample *pFinal = &aSample[pIdx->nSample-1];
int iCol;
- for(iCol=0; iCol<pIdx->nKeyCol; iCol++){
+ int nCol = 1;
+ if( pIdx->nSampleCol>1 ){
+ /* If this is stat4 data, then calculate aAvgEq[] values for all
+ ** sample columns except the last. The last is always set to 1, as
+ ** once the trailing PK fields are considered all index keys are
+ ** unique. */
+ nCol = pIdx->nSampleCol-1;
+ pIdx->aAvgEq[nCol] = 1;
+ }
+ for(iCol=0; iCol<nCol; iCol++){
int i; /* Used to iterate through samples */
tRowcnt sumEq = 0; /* Sum of the nEq values */
tRowcnt nSum = 0; /* Number of terms contributing to sumEq */
}
if( avgEq==0 ) avgEq = 1;
pIdx->aAvgEq[iCol] = avgEq;
- if( pIdx->nSampleCol==1 ) break;
}
}
}
while( sqlite3_step(pStmt)==SQLITE_ROW ){
int nIdxCol = 1; /* Number of columns in stat4 records */
- int nAvgCol = 1; /* Number of entries in Index.aAvgEq */
char *zIndex; /* Index name */
Index *pIdx; /* Pointer to the index object */
** loaded from the stat4 table. In this case ignore stat3 data. */
if( pIdx==0 || pIdx->nSample ) continue;
if( bStat3==0 ){
- nIdxCol = pIdx->nKeyCol+1;
- nAvgCol = pIdx->nKeyCol;
+ assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
+ if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
+ nIdxCol = pIdx->nKeyCol;
+ }else{
+ nIdxCol = pIdx->nColumn;
+ }
}
pIdx->nSampleCol = nIdxCol;
nByte = sizeof(IndexSample) * nSample;
nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;
- nByte += nAvgCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */
+ nByte += nIdxCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */
pIdx->aSample = sqlite3DbMallocZero(db, nByte);
if( pIdx->aSample==0 ){
return SQLITE_NOMEM;
}
pSpace = (tRowcnt*)&pIdx->aSample[nSample];
- pIdx->aAvgEq = pSpace; pSpace += nAvgCol;
+ pIdx->aAvgEq = pSpace; pSpace += nIdxCol;
for(i=0; i<nSample; i++){
pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;
pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;
iUpper = i>=pIdx->nSample ? nRow0 : aSample[i].anLt[iCol];
iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol];
}
- aStat[1] = (pIdx->nKeyCol>iCol ? pIdx->aAvgEq[iCol] : 1);
+ aStat[1] = pIdx->aAvgEq[iCol];
if( iLower>=iUpper ){
iGap = 0;
}else{
do_eqp_test 22.2.$tn "SELECT * FROM t3 WHERE $where" $res
}
+proc int_to_char {i} {
+ set ret ""
+ set char [list a b c d e f g h i j]
+ foreach {div} {1000 100 10 1} {
+ append ret [lindex $char [expr ($i / $div) % 10]]
+ }
+ set ret
+}
+db func int_to_char int_to_char
+
+do_execsql_test 23.0 {
+ CREATE TABLE t4(
+ a COLLATE nocase, b, c,
+ d, e, f,
+ PRIMARY KEY(c, b, a)
+ ) WITHOUT ROWID;
+ CREATE INDEX i41 ON t4(e);
+ CREATE INDEX i42 ON t4(f);
+
+ WITH data(a, b, c, d, e, f) AS (
+ SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0
+ UNION ALL
+ SELECT
+ int_to_char(f+1), b, c, d, (e+1) % 2, f+1
+ FROM data WHERE f<1024
+ )
+ INSERT INTO t4 SELECT a, b, c, d, e, f FROM data;
+ ANALYZE;
+} {}
+
+do_eqp_test 23.1 {
+ SELECT * FROM t4 WHERE
+ (e=1 AND b='xyz' AND c='zyx' AND a<'AEA') AND f<300
+} {
+ 0 0 0 {SEARCH TABLE t4 USING INDEX i41 (e=? AND c=? AND b=? AND a<?)}
+}
+
+do_eqp_test 23.2 {
+ SELECT * FROM t4 WHERE
+ (e=1 AND b='xyz' AND c='zyx' AND a<'JJJ') AND f<300
+} {
+ 0 0 0 {SEARCH TABLE t4 USING INDEX i42 (f<?)}
+}
+
finish_test