mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix byte-code register allocation in ANALYZE for STAT4 when there multiple
indexes with differing numbers of columns. [forum:/forumpost/bc39e531e5|forum post bc39e531e5]. FossilOrigin-Name: 2bf5413dc2c19d5feb32e5b01aa9b990ec2f74f45f5ca0dca15215f8c9dbc9b9
This commit is contained in:
@@ -994,8 +994,11 @@ static void analyzeOneTable(
|
||||
int regIdxname = iMem++; /* Register containing index name */
|
||||
int regStat1 = iMem++; /* Value for the stat column of sqlite_stat1 */
|
||||
int regPrev = iMem; /* MUST BE LAST (see below) */
|
||||
#ifdef SQLITE_ENABLE_STAT4
|
||||
int doOnce = 1; /* Flag for a one-time computation */
|
||||
#endif
|
||||
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
Table *pStat1 = 0;
|
||||
Table *pStat1 = 0;
|
||||
#endif
|
||||
|
||||
pParse->nMem = MAX(pParse->nMem, iMem);
|
||||
@@ -1276,7 +1279,25 @@ static void analyzeOneTable(
|
||||
int addrIsNull;
|
||||
u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
|
||||
|
||||
pParse->nMem = MAX(pParse->nMem, regCol+nCol);
|
||||
if( doOnce ){
|
||||
int mxCol = nCol;
|
||||
Index *pX;
|
||||
|
||||
/* Compute the maximum number of columns in any index */
|
||||
for(pX=pTab->pIndex; pX; pX=pX->pNext){
|
||||
int nColX; /* Number of columns in pX */
|
||||
if( !HasRowid(pTab) && IsPrimaryKeyIndex(pX) ){
|
||||
nColX = pX->nKeyCol;
|
||||
}else{
|
||||
nColX = pX->nColumn;
|
||||
}
|
||||
if( nColX>mxCol ) mxCol = nColX;
|
||||
}
|
||||
|
||||
/* Allocate space to compute results for the largest index */
|
||||
pParse->nMem = MAX(pParse->nMem, regCol+mxCol);
|
||||
doOnce = 0;
|
||||
}
|
||||
|
||||
addrNext = sqlite3VdbeCurrentAddr(v);
|
||||
callStatGet(pParse, regStat, STAT_GET_ROWID, regSampleRowid);
|
||||
|
Reference in New Issue
Block a user