1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

When computing an expression value for an index-on-expression or a CHECK

constraint and the expressions uses a REAL table column, but the value of
that column is an integer (in other words, when it is using the 
store-real-as-integer optimization) be sure to promote the value to real
before evaluating the expression.  Ticket [57af00b6642ecd68].

FossilOrigin-Name: 0658c16e311393c8a347b1bd41fa5dbfd2e184aa75d84c011aa8dbac79b632e9
This commit is contained in:
drh
2019-09-02 00:58:44 +00:00
parent cc80db69e9
commit bffdd63633
5 changed files with 60 additions and 10 deletions

View File

@@ -3532,7 +3532,19 @@ expr_code_doover:
if( iTab<0 ){
if( pParse->iSelfTab<0 ){
/* Generating CHECK constraints or inserting into partial index */
return pExpr->iColumn - pParse->iSelfTab;
assert( pExpr->y.pTab!=0 );
assert( pExpr->iColumn>=XN_ROWID );
assert( pExpr->iColumn<pExpr->y.pTab->nCol );
if( pExpr->iColumn>=0
&& pExpr->y.pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
){
sqlite3VdbeAddOp2(v, OP_SCopy, pExpr->iColumn - pParse->iSelfTab,
target);
sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
return target;
}else{
return pExpr->iColumn - pParse->iSelfTab;
}
}else{
/* Coding an expression that is part of an index where column names
** in the index refer to the table to which the index belongs */