diff options
author | drh <drh@noemail.net> | 2019-10-22 21:01:34 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-10-22 21:01:34 +0000 |
commit | e70fa7feba0b07eb1b5fe4f5373182875e709b32 (patch) | |
tree | 8fdb5f25be29883e784f2bf13bc2deeabdf0ca04 /src/expr.c | |
parent | 7b8ab230dce94ccbca56a204589066bca1201d28 (diff) | |
download | sqlite-e70fa7feba0b07eb1b5fe4f5373182875e709b32.tar.gz sqlite-e70fa7feba0b07eb1b5fe4f5373182875e709b32.zip |
Take the declared column time into account when computing the values for
generated columns, and apply appropriate affinity.
FossilOrigin-Name: 9e04ba22dfce3998e61331ac229ff543ecccc590284c9dd5def21efbe594fba0
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 22 |
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; |