diff options
author | drh <drh@noemail.net> | 2019-12-07 00:22:18 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-12-07 00:22:18 +0000 |
commit | 7fe2fc0dcb0bb214fe83a8a8fcdeb553fb20b97d (patch) | |
tree | fb8d2c02e8b00130bf86326fdc6b899b0b8e70fa /src | |
parent | 5102cf8df5147aa9f230334d4d0d5b4555957943 (diff) | |
download | sqlite-7fe2fc0dcb0bb214fe83a8a8fcdeb553fb20b97d.tar.gz sqlite-7fe2fc0dcb0bb214fe83a8a8fcdeb553fb20b97d.zip |
Fix a problem with foreign keys and generated columns discovered by
Manuel Rigger.
FossilOrigin-Name: 27c0fdab1ba4d4993b164eb4b777c63e82aa247c3fa406121dc8ed94970a0b35
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 ); |