1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-22 20:22:44 +03:00

Fix an integer overflow bug in the automatic index logic. The bug was

detected by the testcase() macros added in the previous check-in.  Also
add some more testcase() macros, since this issue points up their importance.

FossilOrigin-Name: af97b4881a8f010055cde672634141d7ed6898fc
This commit is contained in:
drh
2010-04-08 14:38:51 +00:00
parent 52ff8ea605
commit 67ae0cb231
3 changed files with 15 additions and 12 deletions

View File

@@ -1798,7 +1798,7 @@ static void constructAutomaticIndex(
testcase( pTable->nCol==BMS-1 );
testcase( pTable->nCol==BMS-2 );
for(i=0; i<mxBitCol; i++){
if( extraCols & (1<<i) ) nColumn++;
if( extraCols & (((Bitmask)1)<<i) ) nColumn++;
}
if( pSrc->colUsed & (((Bitmask)1)<<(BMS-1)) ){
nColumn += pTable->nCol - BMS + 1;
@@ -1840,7 +1840,7 @@ static void constructAutomaticIndex(
/* Add additional columns needed to make the automatic index into
** a covering index */
for(i=0; i<mxBitCol; i++){
if( extraCols & (1<<i) ){
if( extraCols & (((Bitmask)1)<<i) ){
pIdx->aiColumn[n] = i;
pIdx->azColl[n] = "BINARY";
n++;
@@ -3841,6 +3841,7 @@ WhereInfo *sqlite3WhereBegin(
/* The number of tables in the FROM clause is limited by the number of
** bits in a Bitmask
*/
testcase( pTabList->nSrc==BMS );
if( pTabList->nSrc>BMS ){
sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
return 0;
@@ -4168,6 +4169,8 @@ WhereInfo *sqlite3WhereBegin(
&& (wctrlFlags & WHERE_OMIT_OPEN)==0 ){
int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead;
sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);
testcase( pTab->nCol==BMS-1 );
testcase( pTab->nCol==BMS );
if( !pWInfo->okOnePass && pTab->nCol<BMS ){
Bitmask b = pTabItem->colUsed;
int n = 0;