aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c22
-rw-r--r--src/insert.c8
-rw-r--r--src/sqliteInt.h3
3 files changed, 27 insertions, 6 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;
diff --git a/src/insert.c b/src/insert.c
index 1995f9634..be5f49c9e 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -240,14 +240,14 @@ void sqlite3ComputeGeneratedColumns(
if( colFlags & COLFLAG_VIRTUAL ){
/* Virtual columns go at the end */
assert( pTab->nNVCol+nv == sqlite3TableColumnToStorage(pTab,i) );
- sqlite3ExprCode(pParse, pTab->aCol[i].pDflt,
- iRegStore+pTab->nNVCol+nv);
+ sqlite3ExprCodeGeneratedColumn(pParse, &pTab->aCol[i],
+ iRegStore+pTab->nNVCol+nv);
}else{
/* Stored columns go in column order */
assert( i-nv == sqlite3TableColumnToStorage(pTab,i) );
- sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, iRegStore+i-nv);
+ sqlite3ExprCodeGeneratedColumn(pParse, &pTab->aCol[i], iRegStore+i-nv);
}
- colFlags &= ~COLFLAG_NOTAVAIL;
+ pTab->aCol[i].colFlags &= ~COLFLAG_NOTAVAIL;
}
if( (colFlags & COLFLAG_VIRTUAL)!=0 ) nv++;
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 06464acb5..e2002810f 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -4096,6 +4096,9 @@ int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
void sqlite3ExprCodeMove(Parse*, int, int, int);
void sqlite3ExprCode(Parse*, Expr*, int);
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
+void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int);
+#endif
void sqlite3ExprCodeCopy(Parse*, Expr*, int);
void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
int sqlite3ExprCodeAtInit(Parse*, Expr*, int);