1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

When reading an sqlite_stat1 table with missing entries for some indexes,

set the default for the missing indexes after all other indexes are set
so that the default values are more in line with indexes that are actually
in the stat1 table.

FossilOrigin-Name: a62340dc0507e36f6dec05b1fda68d8399ec62ec
This commit is contained in:
drh
2016-04-01 12:35:22 +00:00
parent 2779989110
commit f6661a8896
3 changed files with 24 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
C Update\sthe\sclean\starget\sin\sthe\sMSVC\smakefile. C When\sreading\san\ssqlite_stat1\stable\swith\smissing\sentries\sfor\ssome\sindexes,\nset\sthe\sdefault\sfor\sthe\smissing\sindexes\safter\sall\sother\sindexes\sare\sset\nso\sthat\sthe\sdefault\svalues\sare\smore\sin\sline\swith\sindexes\sthat\sare\sactually\nin\sthe\sstat1\stable.
D 2016-03-31T22:53:37.345 D 2016-04-01T12:35:22.357
F Makefile.in e812bb732d7af01baa09f1278bd4f4a2e3a09449 F Makefile.in e812bb732d7af01baa09f1278bd4f4a2e3a09449
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc fe57d7e3e74fa383fd01ced796c0ffd966fc094a F Makefile.msc fe57d7e3e74fa383fd01ced796c0ffd966fc094a
@@ -311,7 +311,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c 1bb0709b3048e24217b80ec6bd78a3e99a47c01b F src/alter.c 1bb0709b3048e24217b80ec6bd78a3e99a47c01b
F src/analyze.c ab57b6763dd4c6170a20673d14882c033affd188 F src/analyze.c 39b21e4d9ad8a647e9834aa5ba99a74fb6c98879
F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22 F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22
F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
F src/backup.c f60f0aa55d25d853ffde53d0b0370a7bb7ee41ce F src/backup.c f60f0aa55d25d853ffde53d0b0370a7bb7ee41ce
@@ -1480,7 +1480,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P c648539b52ca28c0b2cb61208e2c32b1d29626a1 P 69f4d83210f6425b2c0d699b397ef4fa4422d438
R 6ae456c611a2dfae066ef8a6f11a421b R 7562b4ce09688850a9cd06c483af68bc
U mistachkin U drh
Z 730dfc7c7e8862f73161aa001e93b9d4 Z f4c65a7a3ea821b7d157bc63d7456b83

View File

@@ -1 +1 @@
69f4d83210f6425b2c0d699b397ef4fa4422d438 a62340dc0507e36f6dec05b1fda68d8399ec62ec

View File

@@ -1835,31 +1835,34 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
Index *pIdx = sqliteHashData(i); Index *pIdx = sqliteHashData(i);
sqlite3DefaultRowEst(pIdx); pIdx->aiRowLogEst[0] = 0;
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
sqlite3DeleteIndexSamples(db, pIdx); sqlite3DeleteIndexSamples(db, pIdx);
pIdx->aSample = 0; pIdx->aSample = 0;
#endif #endif
} }
/* Check to make sure the sqlite_stat1 table exists */ /* Load new statistics out of the sqlite_stat1 table */
sInfo.db = db; sInfo.db = db;
sInfo.zDatabase = db->aDb[iDb].zName; sInfo.zDatabase = db->aDb[iDb].zName;
if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){ if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)!=0 ){
return SQLITE_ERROR; zSql = sqlite3MPrintf(db,
"SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
if( zSql==0 ){
rc = SQLITE_NOMEM_BKPT;
}else{
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
sqlite3DbFree(db, zSql);
}
} }
/* Load new statistics out of the sqlite_stat1 table */ /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
zSql = sqlite3MPrintf(db, assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
"SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase); for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
if( zSql==0 ){ Index *pIdx = sqliteHashData(i);
rc = SQLITE_NOMEM_BKPT; if( pIdx->aiRowLogEst[0]==0 ) sqlite3DefaultRowEst(pIdx);
}else{
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
sqlite3DbFree(db, zSql);
} }
/* Load the statistics from the sqlite_stat4 table. */ /* Load the statistics from the sqlite_stat4 table. */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){ if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){