diff options
Diffstat (limited to 'src/where.c')
-rw-r--r-- | src/where.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/where.c b/src/where.c index 7dd8c339a..da89853ca 100644 --- a/src/where.c +++ b/src/where.c @@ -6191,7 +6191,13 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ for(; k<last; k++, pOp++){ if( pOp->p1!=pLevel->iTabCur ) continue; if( pOp->opcode==OP_Column ){ - i16 x = sqlite3ColumnOfIndex(pIdx, pOp->p2); + int x = pOp->p2; + Table *pTab = pIdx->pTable; + if( !HasRowid(pTab) ){ + Index *pPk = sqlite3PrimaryKeyIndex(pTab); + x = pPk->aiColumn[x]; + } + x = sqlite3ColumnOfIndex(pIdx, x); if( x>=0 ){ pOp->p2 = x; pOp->p1 = pLevel->iIdxCur; |