------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Incremental\scode\sand\scomment\scleanup\sin\swhere.c.\s\sThere\sis\smore\sto\sbe\sdone.
-D 2009-08-20T13:45:08
+C Change\sthe\scode\sthat\scollects\ssamples\sfor\ssqlite_stat2\sso\sthat\sthe\sfirst\ssample\staken\sis\sthe\s(nRow/(2*SQLITE_INDEX_SAMPLES))th\sentry\sin\sthe\sindex,\swhere\snRow\sis\sthe\stotal\snumber\sof\sindex\sentries.
+D 2009-08-20T09:11:06
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 0f7761c5d1c62ae7a841e3393ffaff1fa0f5c00a
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
F src/alter.c 8b42cace4f8e312de596807ba2685179da64fec4
-F src/analyze.c b62fc66fce1f7ac0336f10189ce8a7b809c65b2d
+F src/analyze.c e3ad83c1462c68cba458e3bdf21f00bc2069bf31
F src/attach.c 13995348fc5a26cdd136a50806faf292aabc173f
F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025
F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
F test/alter4.test 9386ffd1e9c7245f43eca412b2058d747509cc1f
F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
F test/analyze.test ad5329098fe4de4a96852231d53e3e9e6283ad4b
-F test/analyze2.test f3c0944b854fb33987dbadd1e95913365c33deb7
+F test/analyze2.test 297d3d63f2f50976c606227040fe36605745d9dd
F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 167644f33c949b532655c2297aedf13f93876396
-R fb372557659e26b35bbe68ecf447e1ca
-U drh
-Z 24339a8c1ef1b0f0335c1d9d08b33691
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFKjVNnoxKgR168RlERAlJzAJwNEG76YvhUi3RkLEp7KwaZArgnPQCghw3J
-pSL+ypKyYegD2N/rATGSaX4=
-=lyU7
------END PGP SIGNATURE-----
+P 4a5d9550bdc08633535a7869d7748f56ac3e9a36
+R a06a46e0e6092a62dbfee6601412e863
+U dan
+Z 2c479b2a4ff638923d236b4fdc91cdb8
int regRec = iMem++; /* Register holding completed record */
int regTemp = iMem++; /* Temporary use register */
int regRowid = iMem++; /* Rowid for the inserted record */
+
#ifdef SQLITE_ENABLE_STAT2
int regTemp2 = iMem++; /* Temporary use register */
- int regSamplerecno = iMem++; /* Next sample index record number */
- int regRecno = iMem++; /* Register next index record number */
- int regCount = iMem++; /* Total number of records in table */
+ int regSamplerecno = iMem++; /* Index of next sample to record */
+ int regRecno = iMem++; /* Current sample index */
+ int regLast = iMem++; /* Index of last sample to record */
+ int regFirst = iMem++; /* Index of first sample to record */
#endif
v = sqlite3GetVdbe(pParse);
sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0);
#ifdef SQLITE_ENABLE_STAT2
+
/* If this iteration of the loop is generating code to analyze the
- ** first index in the pTab->pIndex list, then register regCount has
+ ** first index in the pTab->pIndex list, then register regLast has
** not been populated. In this case populate it now. */
if( pTab->pIndex==pIdx ){
- sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regCount);
+ sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regSamplerecno);
+ sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2-1, regTemp);
+ sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2, regTemp2);
+
+ sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regLast);
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regFirst);
+ addr = sqlite3VdbeAddOp3(v, OP_Lt, regSamplerecno, 0, regLast);
+ sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regFirst);
+ sqlite3VdbeAddOp3(v, OP_Multiply, regLast, regTemp, regLast);
+ sqlite3VdbeAddOp2(v, OP_AddImm, regLast, SQLITE_INDEX_SAMPLES*2-2);
+ sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regLast);
+ sqlite3VdbeJumpHere(v, addr);
}
/* Zero the regSampleno and regRecno registers. */
sqlite3VdbeAddOp2(v, OP_Integer, 0, regSampleno);
sqlite3VdbeAddOp2(v, OP_Integer, 0, regRecno);
-
- /* If there are less than INDEX_SAMPLES records in the index, then
- ** set the contents of regSampleRecno to integer value INDEX_SAMPLES.
- ** Otherwise, set it to zero. This is to ensure that if there are
- ** less than the said number of entries in the index, no samples at
- ** all are collected. */
- sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regSamplerecno);
- sqlite3VdbeAddOp3(v, OP_Lt, regSamplerecno, sqlite3VdbeCurrentAddr(v)+2,
- regCount);
- sqlite3VdbeAddOp2(v, OP_Integer, 0, regSamplerecno);
+ sqlite3VdbeAddOp2(v, OP_Copy, regFirst, regSamplerecno);
#endif
/* The block of memory cells initialized here is used as follows.
&& regTabname+2==regSampleno
&& regTabname+3==regCol
);
+ sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);
sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 4, regRec, "aaab", 0);
sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regRowid);
sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regRec, regRowid);
** samplerecno = samplerecno+(remaining records)/(remaining samples)
*/
sqlite3VdbeAddOp2(v, OP_AddImm, regSampleno, 1);
- sqlite3VdbeAddOp3(v, OP_Subtract, regRecno, regCount, regTemp);
+ sqlite3VdbeAddOp3(v, OP_Subtract, regRecno, regLast, regTemp);
sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regTemp2);
sqlite3VdbeAddOp3(v, OP_Subtract, regSampleno, regTemp2, regTemp2);
ANALYZE;
SELECT * FROM sqlite_stat2;
}
-} [list t1 sqlite_autoindex_t1_1 0 0 \
- t1 sqlite_autoindex_t1_1 1 111 \
- t1 sqlite_autoindex_t1_1 2 222 \
- t1 sqlite_autoindex_t1_1 3 333 \
- t1 sqlite_autoindex_t1_1 4 444 \
- t1 sqlite_autoindex_t1_1 5 555 \
- t1 sqlite_autoindex_t1_1 6 666 \
- t1 sqlite_autoindex_t1_1 7 777 \
- t1 sqlite_autoindex_t1_1 8 888 \
- t1 sqlite_autoindex_t1_1 9 999 \
+} [list t1 sqlite_autoindex_t1_1 0 50 \
+ t1 sqlite_autoindex_t1_1 1 149 \
+ t1 sqlite_autoindex_t1_1 2 249 \
+ t1 sqlite_autoindex_t1_1 3 349 \
+ t1 sqlite_autoindex_t1_1 4 449 \
+ t1 sqlite_autoindex_t1_1 5 549 \
+ t1 sqlite_autoindex_t1_1 6 649 \
+ t1 sqlite_autoindex_t1_1 7 749 \
+ t1 sqlite_autoindex_t1_1 8 849 \
+ t1 sqlite_autoindex_t1_1 9 949 \
]
+
do_test analyze2-1.2 {
execsql {
DELETE FROM t1 WHERe x>9;
} {t1 sqlite_autoindex_t1_1 {0 1 2 3 4 5 6 7 8 9}}
do_test analyze2-1.3 {
execsql {
- DELETE FROM t1 WHERE x>5;
+ DELETE FROM t1 WHERE x>8;
ANALYZE;
SELECT * FROM sqlite_stat2;
}
}
} {}
-
do_test analyze2-2.1 {
execsql {
BEGIN;
WHERE idx = 't1_x'
GROUP BY tbl,idx
}
-} {t1 t1_x {0 222 444 666 888 bba ddc ffe hhg jjj}}
+} {t1 t1_x {100 299 499 699 899 ajj cjj ejj gjj ijj}}
do_test analyze2-3.2 {
execsql {
SELECT tbl,idx,group_concat(sample,' ')
WHERE idx = 't1_y'
GROUP BY tbl,idx
}
-} {t1 t1_y {0 222 444 666 888 bba ddc ffe hhg jjj}}
+} {t1 t1_y {100 299 499 699 899 ajj cjj ejj gjj ijj}}
do_test analyze2-3.3 {
eqp "SELECT * FROM t1 WHERE x BETWEEN 100 AND 500 AND y BETWEEN 'a' AND 'b'"
eqp "SELECT * FROM t1 WHERE x<444 AND y>'h'"
} {0 0 {TABLE t1 WITH INDEX t1_y}}
do_test analyze2-3.7 {
- eqp "SELECT * FROM t1 WHERE x<221 AND y>'h'"
+ eqp "SELECT * FROM t1 WHERE x<221 AND y>'g'"
} {0 0 {TABLE t1 WITH INDEX t1_x}}
do_test analyze2-4.1 {
WHERE idx = 't3a'
GROUP BY tbl,idx
}
-} {t3 t3a {AAA bbb CCC ddd EEE fff GGG hhh III jjj}}
+} {t3 t3a {AfA bEj CEj dEj EEj fEj GEj hEj IEj jEj}}
do_test analyze2-4.3 {
execsql {
SELECT tbl,idx,group_concat(sample,' ')
WHERE idx = 't3b'
GROUP BY tbl,idx
}
-} {t3 t3b {AAA CCC EEE GGG III bbb ddd fff hhh jjj}}
+} {t3 t3b {AbA CIj EIj GIj IIj bIj dIj fIj hIj jIj}}
do_test analyze2-4.4 {
eqp "SELECT * FROM t3 WHERE a > 'A' AND a < 'C' AND b > 'A' AND b < 'C'"
WHERE tbl = 't4'
GROUP BY tbl,idx
}
-} {t4 t4x {aaa bbb ccc ddd eee fff ggg hhh iii jjj}}
+} {t4 t4x {afa bej cej dej eej fej gej hej iej jej}}
do_test analyze2-5.3 {
eqp "SELECT * FROM t4 WHERE x>'ccc'"
} {0 0 {TABLE t4 WITH INDEX t4x}}