diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 6 | ||||
-rw-r--r-- | src/expr.c | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/build.c b/src/build.c index 5026b89e4..46bf3677e 100644 --- a/src/build.c +++ b/src/build.c @@ -947,13 +947,15 @@ i16 sqlite3StorageColumnToTable(Table *pTab, i16 iCol){ ** the end. ** ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and -** this routine is a no-op macro. +** this routine is a no-op macro. If the pTab does not have any virtual +** columns, then this routine is no-op that always return iCol. If iCol +** is negative (indicating the ROWID column) then this routine return iCol. */ i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){ int i; i16 n; assert( iCol<pTab->nCol ); - if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol; + if( (pTab->tabFlags & TF_HasVirtual)==0 || iCol<0 ) return iCol; for(i=0, n=0; i<iCol; i++){ if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++; } diff --git a/src/expr.c b/src/expr.c index 52b68b7c7..3b2b513b6 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4136,7 +4136,7 @@ expr_code_doover: Table *pTab = pExpr->y.pTab; int iCol = pExpr->iColumn; int p1 = pExpr->iTable * (pTab->nCol+1) + 1 - + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1); + + sqlite3TableColumnToStorage(pTab, iCol); assert( pExpr->iTable==0 || pExpr->iTable==1 ); assert( iCol>=-1 && iCol<pTab->nCol ); |