diff options
Diffstat (limited to 'src/build.c')
-rw-r--r-- | src/build.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/build.c b/src/build.c index 29a798e6c..415eeae70 100644 --- a/src/build.c +++ b/src/build.c @@ -2004,6 +2004,13 @@ void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){ if( pCol->colFlags & COLFLAG_PRIMKEY ){ makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */ } + if( ALWAYS(pExpr) && pExpr->op==TK_ID ){ + /* The value of a generated column needs to be a real expression, not + ** just a reference to another column, in order for covering index + ** optimizations to work correctly. So if the value is not an expression, + ** turn it into one by adding a unary "+" operator. */ + pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0); + } sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr); pExpr = 0; goto generated_done; |