Fix the ANALYZE command so that it takes collating sequences into account
when gathering index statistics. FossilOrigin-Name: a5867cfc4c9b9155fa345247dec29e38fffa8002
This commit is contained in:
parent
8e93b10a4e
commit
4856698fa5
20
manifest
20
manifest
@ -1,8 +1,8 @@
|
|||||||
-----BEGIN PGP SIGNED MESSAGE-----
|
-----BEGIN PGP SIGNED MESSAGE-----
|
||||||
Hash: SHA1
|
Hash: SHA1
|
||||||
|
|
||||||
C The\sANALYZE\scommand\snow\scounts\sat\sall\srows\sof\san\sindex,\seven\sthose\scontaining\nNULL\svalues.\s\sA\svalid\ssqlite_stat1\sentry\sis\screated\seven\sif\sthe\sindex\scontains\nnothing\sbut\sNULLs.
|
C Fix\sthe\sANALYZE\scommand\sso\sthat\sit\stakes\scollating\ssequences\sinto\saccount\nwhen\sgathering\sindex\sstatistics.
|
||||||
D 2011-01-04T17:57:54
|
D 2011-01-04T19:01:27
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c
|
F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -116,7 +116,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
|||||||
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
|
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
|
||||||
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
|
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
|
||||||
F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3
|
F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3
|
||||||
F src/analyze.c 62ccd3a44e5c303bfa27987c596bfd1136741d81
|
F src/analyze.c a2257126f629615fee6381526d928487b44d628f
|
||||||
F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3
|
F src/attach.c 252c4f7e36cc219349451ed63e278c60e80b26f3
|
||||||
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
||||||
F src/backup.c d5b0137bc20327af08c14772227cc35134839c30
|
F src/backup.c d5b0137bc20327af08c14772227cc35134839c30
|
||||||
@ -255,7 +255,7 @@ F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
|
|||||||
F test/analyze.test c1eb87067fc16ece7c07e823d6395fd831b270c5
|
F test/analyze.test c1eb87067fc16ece7c07e823d6395fd831b270c5
|
||||||
F test/analyze2.test 3bde8f0879d9c1f2df3af21fcf42e706d8ee1e43
|
F test/analyze2.test 3bde8f0879d9c1f2df3af21fcf42e706d8ee1e43
|
||||||
F test/analyze3.test 820ddfb7591b49607fbaf77240c7955ac3cabb04
|
F test/analyze3.test 820ddfb7591b49607fbaf77240c7955ac3cabb04
|
||||||
F test/analyze4.test ce844952931beea75dcd3bd416f3d10444fbcfde
|
F test/analyze4.test 757b37875cf9bb528d46f74497bc789c88365045
|
||||||
F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3
|
F test/async.test ad4ba51b77cd118911a3fe1356b0809da9c108c3
|
||||||
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
|
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
|
||||||
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
|
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
|
||||||
@ -898,14 +898,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P 430635dacfa818e8266a88214aaf60c77862de1c
|
P 824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3
|
||||||
R ec45ba633f0c4f96e6a484b9eb344d5c
|
R d21b60403fa8454869264e5a7d85a460
|
||||||
U drh
|
U drh
|
||||||
Z cde307ce45c85e17f986af467042bf4f
|
Z 85dcf9c1c5d1988281920e678e21e010
|
||||||
-----BEGIN PGP SIGNATURE-----
|
-----BEGIN PGP SIGNATURE-----
|
||||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||||
|
|
||||||
iD8DBQFNI1+moxKgR168RlERAjnJAJ4o8v4Qvkj2Lt5p/tc7Gw/iz0iScACeJQd8
|
iD8DBQFNI26OoxKgR168RlERAjyZAJ0cxp7jjQMaSBHHPEQ/Ng2xxCrQ6QCeJqqw
|
||||||
a939JIEB/46ZOm5/OzfvI/M=
|
pD4g20IkcXJp5ot9VEJNDSI=
|
||||||
=dmuf
|
=6TbT
|
||||||
-----END PGP SIGNATURE-----
|
-----END PGP SIGNATURE-----
|
||||||
|
@ -1 +1 @@
|
|||||||
824c8dd3015bbd5c8a1dd661cfe09fe5bf7a80d3
|
a5867cfc4c9b9155fa345247dec29e38fffa8002
|
@ -233,6 +233,7 @@ static void analyzeOneTable(
|
|||||||
sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1);
|
sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1);
|
||||||
|
|
||||||
for(i=0; i<nCol; i++){
|
for(i=0; i<nCol; i++){
|
||||||
|
CollSeq *pColl;
|
||||||
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol);
|
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol);
|
||||||
if( i==0 ){
|
if( i==0 ){
|
||||||
#ifdef SQLITE_ENABLE_STAT2
|
#ifdef SQLITE_ENABLE_STAT2
|
||||||
@ -269,8 +270,11 @@ static void analyzeOneTable(
|
|||||||
/* Always record the very first row */
|
/* Always record the very first row */
|
||||||
sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1);
|
sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1);
|
||||||
}
|
}
|
||||||
sqlite3VdbeAddOp3(v, OP_Ne, regCol, 0, iMem+nCol+i+1);
|
assert( pIdx->azColl!=0 );
|
||||||
/**** TODO: add collating sequence *****/
|
assert( pIdx->azColl[i]!=0 );
|
||||||
|
pColl = sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);
|
||||||
|
sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1,
|
||||||
|
(char*)pColl, P4_COLLSEQ);
|
||||||
sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
|
sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
|
||||||
}
|
}
|
||||||
if( db->mallocFailed ){
|
if( db->mallocFailed ){
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# a NULL value count as distinct rows for the purposes of analyze
|
# a NULL value count as distinct rows for the purposes of analyze
|
||||||
# statistics.
|
# statistics.
|
||||||
#
|
#
|
||||||
|
# Also include test cases for collating sequences on indices.
|
||||||
|
#
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -77,4 +79,33 @@ do_test analyze4-1.3 {
|
|||||||
}
|
}
|
||||||
} {t1a {128 1} t1b {128 128} t1bcd {128 128 4 2} t1cbd {128 4 4 2} t1cdb {128 4 2 2}}
|
} {t1a {128 1} t1b {128 128} t1bcd {128 128 4 2} t1cbd {128 4 4 2} t1cdb {128 4 2 2}}
|
||||||
|
|
||||||
|
# Verify that collating sequences are taken into account when computing
|
||||||
|
# ANALYZE statistics.
|
||||||
|
#
|
||||||
|
do_test analyze4-2.0 {
|
||||||
|
db eval {
|
||||||
|
CREATE TABLE t2(
|
||||||
|
x INTEGER PRIMARY KEY,
|
||||||
|
a TEXT COLLATE nocase,
|
||||||
|
b TEXT COLLATE rtrim,
|
||||||
|
c TEXT COLLATE binary
|
||||||
|
);
|
||||||
|
CREATE INDEX t2a ON t2(a);
|
||||||
|
CREATE INDEX t2b ON t2(b);
|
||||||
|
CREATE INDEX t2c ON t2(c);
|
||||||
|
CREATE INDEX t2c2 ON t2(c COLLATE nocase);
|
||||||
|
CREATE INDEX t2c3 ON t2(c COLLATE rtrim);
|
||||||
|
INSERT INTO t2 VALUES(1, 'abc', 'abc', 'abc');
|
||||||
|
INSERT INTO t2 VALUES(2, 'abC', 'abC', 'abC');
|
||||||
|
INSERT INTO t2 VALUES(3, 'abc ', 'abc ', 'abc ');
|
||||||
|
INSERT INTO t2 VALUES(4, 'abC ', 'abC ', 'abC ');
|
||||||
|
INSERT INTO t2 VALUES(5, 'aBc', 'aBc', 'aBc');
|
||||||
|
INSERT INTO t2 VALUES(6, 'aBC', 'aBC', 'aBC');
|
||||||
|
INSERT INTO t2 VALUES(7, 'aBc ', 'aBc ', 'aBc ');
|
||||||
|
INSERT INTO t2 VALUES(8, 'aBC ', 'aBC ', 'aBC ');
|
||||||
|
ANALYZE;
|
||||||
|
SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t2' ORDER BY idx;
|
||||||
|
}
|
||||||
|
} {t2a {8 4} t2b {8 2} t2c {8 1} t2c2 {8 4} t2c3 {8 2}}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Loading…
Reference in New Issue
Block a user