aboutsummaryrefslogtreecommitdiff
path: root/src/where.c
diff options
context:
space:
mode:
authordrh <>2025-02-21 20:35:37 +0000
committerdrh <>2025-02-21 20:35:37 +0000
commitcc803b209f2ffa9dcaad43c37eb8ccafaed199bd (patch)
treed58455eecf8e403f2ecf00a75fb28a22f8d23a2d /src/where.c
parentd9959bf48b13bffda4c073de17eb13752b9cb5c9 (diff)
downloadsqlite-cc803b209f2ffa9dcaad43c37eb8ccafaed199bd.tar.gz
sqlite-cc803b209f2ffa9dcaad43c37eb8ccafaed199bd.zip
The number of declared columns in an index is limited to SQLITE_LIMIT_COLUMN.
But the actual number of columns in the implementation might need to be twice as much to account for the primary key at the end. Ensure that the code is able to deal with this. This is a correction to check-in [d7729dbbf231d57c]. FossilOrigin-Name: 5822feec43be9352fd87bf9968c39c0218e01ab5fe3ba50431ae21cba79e6c89
Diffstat (limited to 'src/where.c')
-rw-r--r--src/where.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/where.c b/src/where.c
index 5cb52b8ad..127525006 100644
--- a/src/where.c
+++ b/src/where.c
@@ -1104,6 +1104,8 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
}
/* Construct the Index object to describe this index */
+ assert( nKeyCol <= pTable->nCol + MAX(0, pTable->nCol - BMS + 1) );
+ /* ^-- This guarantees that the number of index columns will fit in the u16 */
pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+HasRowid(pTable),
0, &zNotUsed);
if( pIdx==0 ) goto end_auto_index_create;