mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-22 20:22:44 +03:00
Ensure that the expression of a virtual column really is an expression and
not just a reference to another column, as a real expression is necessary for the indexed expression coverage optimization to work properly. [forum:/forumpost/07b36e3899a9ae21|Forum thread 07b36e3899a9ae21]. FossilOrigin-Name: 40549bacb3923e439627b0103bedd7da30258b69a46960040f7176e060f51f2f
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user