aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c
index 04dbd2879..0eb7af7f4 100644
--- a/src/expr.c
+++ b/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;