From: drh Date: Tue, 10 Sep 2013 01:41:25 +0000 (+0000) Subject: Deterministically initialize the PRNG used as a tie-breaker in the ANALYZE X-Git-Tag: version-3.8.1~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d2b3c1f8a5499c3ccb26938d8ffa856ac10aa51;p=thirdparty%2Fsqlite.git Deterministically initialize the PRNG used as a tie-breaker in the ANALYZE command, so that the analysis is always the same given the same database. This simplifies testing. FossilOrigin-Name: 48ed8b565b84c8fa7898c2f9817c01f7e9c9182e --- diff --git a/manifest b/manifest index ed617d0854..11dfa9b55b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthat\sthe\stransitive\sconstraint\soptimization\sdoes\snot\scause\nWHERE\sclause\sterms\sto\sbe\sdisabled\sprematurely.\s\sWe\sare\sunable\sto\sfind\sa\stest\ncase\sthat\sfails\sbecause\sof\sthis,\sbut\sit\sseems\sprudent\sto\smake\sthis\npreventative\schange\snevertheless. -D 2013-09-09T19:37:46.167 +C Deterministically\sinitialize\sthe\sPRNG\sused\sas\sa\stie-breaker\sin\sthe\sANALYZE\ncommand,\sso\sthat\sthe\sanalysis\sis\salways\sthe\ssame\sgiven\sthe\ssame\sdatabase.\nThis\ssimplifies\stesting. +D 2013-09-10T01:41:25.676 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -157,7 +157,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083 -F src/analyze.c 7da9d6a0d04a3662d110a28f4a7e7b73a6171e75 +F src/analyze.c d322972af09e3f8debb45f420dfe3ded142b108b F src/attach.c eeb8d9d2c791caa0a54a835170ea898e96c2802d F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 @@ -308,7 +308,7 @@ F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test 19151da2c4e918905d2081b74ac5c4d47fc850ab F test/analyze7.test bb1409afc9e8629e414387ef048b8e0e3e0bdc4f F test/analyze8.test 093d15c1c888eed5034304a98c992f7360130b88 -F test/analyze9.test 4a48461d71a7b4a958570c580495a97e842e2700 +F test/analyze9.test ed70f0c10502f6bcd6e1ec347edc3c0e114f4b53 F test/analyzeA.test 1a5c40079894847976d983ca39c707aaa44b6944 F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b @@ -1111,7 +1111,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 97b10e66e98e84755aa577f8da017bf1aea2056c -R 73b0244a1b138f6550e626804843b7d8 +P d6e361d7fb8013d616af91ef2c10038c97d1be5f +R f0dc49c77588220f9d25d9d712edfe4a U drh -Z 85372a45ca54a00c15dc226dffaae301 +Z e68c71d629e67be96bb05aa541d1ef71 diff --git a/manifest.uuid b/manifest.uuid index 0e91f78a00..b31980649d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d6e361d7fb8013d616af91ef2c10038c97d1be5f \ No newline at end of file +48ed8b565b84c8fa7898c2f9817c01f7e9c9182e \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 42c81fd659..474d80d1b8 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -347,7 +347,7 @@ static void statInit( p->mxSample = mxSample; p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1); p->current.anLt = &p->current.anEq[nColUp]; - sqlite3_randomness(sizeof(p->iPrn), &p->iPrn); + p->iPrn = nCol*0x689e962d ^ sqlite3_value_int(argv[1])*0xd0944565; /* Set up the Stat4Accum.a[] and aBest[] arrays */ p->a = (struct Stat4Sample*)&p->current.anLt[nColUp]; diff --git a/test/analyze9.test b/test/analyze9.test index 604f340bf5..250de200b7 100644 --- a/test/analyze9.test +++ b/test/analyze9.test @@ -244,8 +244,8 @@ do_execsql_test 4.3 { FROM sqlite_stat4 ORDER BY rowid DESC LIMIT 2; } { - {2 1 1 1} {295 295 295} {120 121 124} {201 3} - {5 3 1 1} {290 290 292} {119 119 121} {200 1} + {2 1 1 1} {295 296 296} {120 122 125} {201 4} + {5 3 1 1} {290 290 290} {119 119 119} {200 1} } do_execsql_test 4.4 { SELECT count(DISTINCT c) FROM t1 WHERE c<201 } 120 @@ -806,7 +806,7 @@ do_test 16.1 { } set nByte2 [lindex [sqlite3_db_status db SCHEMA_USED 0] 1] - expr {$nByte2 > $nByte+950 && $nByte2 < $nByte+1050} + expr {$nByte2 > $nByte+900 && $nByte2 < $nByte+1050} } {1} #------------------------------------------------------------------------- @@ -950,4 +950,3 @@ for {set i 0} {$i<16} {incr i} { } finish_test -