diff options
author | dan <dan@noemail.net> | 2013-09-02 18:58:11 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2013-09-02 18:58:11 +0000 |
commit | b49d1047c6efccc83d5986ed5f07b1372ab0e88c (patch) | |
tree | 3d57cd237361f71563d52b4000d868893dc58d41 /src/analyze.c | |
parent | 84f48296faace4671b517664c486560194f64eca (diff) | |
download | sqlite-b49d1047c6efccc83d5986ed5f07b1372ab0e88c.tar.gz sqlite-b49d1047c6efccc83d5986ed5f07b1372ab0e88c.zip |
Further stat4 related tests.
FossilOrigin-Name: 0a702c4b4c35fdbcb62e3ab88b9e57d7ea0052a8
Diffstat (limited to 'src/analyze.c')
-rw-r--r-- | src/analyze.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/analyze.c b/src/analyze.c index d70f77e77..89dc84f2c 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -468,14 +468,25 @@ static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){ p->nSample = p->mxSample-1; } - /* Figure out where in the a[] array the new sample should be inserted. */ + /* The "rows less-than" for the rowid column must be greater than that + ** for the last sample in the p->a[] array. Otherwise, the samples would + ** be out of order. */ +#ifdef SQLITE_ENABLE_STAT4 + assert( p->nSample==0 + || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] ); +#endif + + /* Insert the new sample */ + pSample = &p->a[p->nSample]; + sampleCopy(p, pSample, pNew); + p->nSample++; + +#if 0 iSeq = pNew->anLt[p->nCol-1]; for(iPos=p->nSample; iPos>0; iPos--){ if( iSeq>p->a[iPos-1].anLt[p->nCol-1] ) break; } - /* Insert the new sample */ - pSample = &p->a[iPos]; if( iPos!=p->nSample ){ Stat4Sample *pEnd = &p->a[p->nSample]; tRowcnt *anEq = pEnd->anEq; @@ -486,8 +497,8 @@ static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){ pSample->anDLt = anDLt; pSample->anLt = anLt; } - p->nSample++; - sampleCopy(p, pSample, pNew); +#endif + /* Zero the first nEqZero entries in the anEq[] array. */ memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero); @@ -584,8 +595,7 @@ static void statPush( assert( iChng<p->nCol ); if( p->nRow==0 ){ - /* anEq[0] is only zero for the very first call to this function. Do - ** appropriate initialization */ + /* This is the first call to this function. Do initialization. */ for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1; }else{ /* Second and subsequent calls get processed here */ |