mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Ensure that sqlite_stat1 and sqlite_stat4 are ordinary tables (not views or
virtual tables) before trying to load them (dbsqlfuzz bc02a0cde82dee801a8d6f653d2831680f87dca1). This prevents sqlite3_declare_vtab() from running with db->init.busy turned on. Even so, enhance sqlite3_declare_vtab() to be able to deal with db->init.busy being on, in case there are undiscovered paths to that state. Each of these two changes are independently sufficient to prevent the problem fixed by the previous check-in [c7560c1329965ab5] but there is no harm in keeping that third layer of protection in place. FossilOrigin-Name: eb94f4a8174436b1f0deed0a43618a20018387bb815be658314ca6b454c446fb
This commit is contained in:
@@ -1840,9 +1840,12 @@ static int loadStatTbl(
|
||||
*/
|
||||
static int loadStat4(sqlite3 *db, const char *zDb){
|
||||
int rc = SQLITE_OK; /* Result codes from subroutines */
|
||||
const Table *pStat4;
|
||||
|
||||
assert( db->lookaside.bDisable );
|
||||
if( sqlite3FindTable(db, "sqlite_stat4", zDb) ){
|
||||
if( (pStat4 = sqlite3FindTable(db, "sqlite_stat4", zDb))!=0
|
||||
&& IsOrdinaryTable(pStat4)
|
||||
){
|
||||
rc = loadStatTbl(db,
|
||||
"SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx",
|
||||
"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4",
|
||||
@@ -1879,6 +1882,7 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
|
||||
char *zSql;
|
||||
int rc = SQLITE_OK;
|
||||
Schema *pSchema = db->aDb[iDb].pSchema;
|
||||
const Table *pStat1;
|
||||
|
||||
assert( iDb>=0 && iDb<db->nDb );
|
||||
assert( db->aDb[iDb].pBt!=0 );
|
||||
@@ -1901,7 +1905,9 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
|
||||
/* Load new statistics out of the sqlite_stat1 table */
|
||||
sInfo.db = db;
|
||||
sInfo.zDatabase = db->aDb[iDb].zDbSName;
|
||||
if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)!=0 ){
|
||||
if( (pStat1 = sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase))
|
||||
&& IsOrdinaryTable(pStat1)
|
||||
){
|
||||
zSql = sqlite3MPrintf(db,
|
||||
"SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
|
||||
if( zSql==0 ){
|
||||
|
Reference in New Issue
Block a user