mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Take the declared column time into account when computing the values for
generated columns, and apply appropriate affinity. FossilOrigin-Name: 9e04ba22dfce3998e61331ac229ff543ecccc590284c9dd5def21efbe594fba0
This commit is contained in:
22
src/expr.c
22
src/expr.c
@@ -3395,6 +3395,24 @@ void sqlite3ExprCodeLoadIndexColumn(
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
/*
|
||||
** Generate code that will compute the value of generated column pCol
|
||||
** and store the result in register regOut
|
||||
*/
|
||||
void sqlite3ExprCodeGeneratedColumn(
|
||||
Parse *pParse,
|
||||
Column *pCol,
|
||||
int regOut
|
||||
){
|
||||
sqlite3ExprCode(pParse, pCol->pDflt, regOut);
|
||||
if( pCol->affinity>=SQLITE_AFF_TEXT ){
|
||||
sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0,
|
||||
&pCol->affinity, 1);
|
||||
}
|
||||
}
|
||||
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
|
||||
|
||||
/*
|
||||
** Generate code to extract the value of the iCol-th column of a table.
|
||||
*/
|
||||
@@ -3428,7 +3446,7 @@ void sqlite3ExprCodeGetColumnOfTable(
|
||||
int savedSelfTab = pParse->iSelfTab;
|
||||
pCol->colFlags |= COLFLAG_BUSY;
|
||||
pParse->iSelfTab = iTabCur+1;
|
||||
sqlite3ExprCode(pParse, pTab->aCol[iCol].pDflt, regOut);
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pCol, regOut);
|
||||
pParse->iSelfTab = savedSelfTab;
|
||||
pCol->colFlags &= ~COLFLAG_BUSY;
|
||||
}
|
||||
@@ -3630,7 +3648,7 @@ expr_code_doover:
|
||||
}
|
||||
pCol->colFlags |= COLFLAG_BUSY;
|
||||
if( pCol->colFlags & COLFLAG_NOTAVAIL ){
|
||||
sqlite3ExprCode(pParse, pCol->pDflt, iSrc);
|
||||
sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
|
||||
}
|
||||
pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
|
||||
return iSrc;
|
||||
|
||||
Reference in New Issue
Block a user