aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-08-25 20:11:52 +0000
committerdrh <drh@noemail.net>2014-08-25 20:11:52 +0000
commit4169e430a2343b76c6e8373ca59c393a9719e5d7 (patch)
tree053d624c25caa71bcebe374567e3851ba2f9dc54 /src/expr.c
parentf741e0491e0a1ac499983f5d709c08c334c18783 (diff)
downloadsqlite-4169e430a2343b76c6e8373ca59c393a9719e5d7.tar.gz
sqlite-4169e430a2343b76c6e8373ca59c393a9719e5d7.zip
Allow CAST expressions and unary "+" operators to be used in the DEFAULT
argument of an ALTER TABLE ADD COLUMN and to be understand on the RHS of range constraints interpreted by STAT3/4. This involves a rewrite of the implementation of the CAST operator. FossilOrigin-Name: 91d8a8d0b792ea5c4fe68fd9caaf3345eddea486
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/expr.c b/src/expr.c
index 0d2292e94..fabdae2fc 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2595,26 +2595,13 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
#ifndef SQLITE_OMIT_CAST
case TK_CAST: {
/* Expressions of the form: CAST(pLeft AS token) */
- int aff, to_op;
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
- assert( !ExprHasProperty(pExpr, EP_IntValue) );
- aff = sqlite3AffinityType(pExpr->u.zToken, 0);
- to_op = aff - SQLITE_AFF_TEXT + OP_ToText;
- assert( to_op==OP_ToText || aff!=SQLITE_AFF_TEXT );
- assert( to_op==OP_ToBlob || aff!=SQLITE_AFF_NONE );
- assert( to_op==OP_ToNumeric || aff!=SQLITE_AFF_NUMERIC );
- assert( to_op==OP_ToInt || aff!=SQLITE_AFF_INTEGER );
- assert( to_op==OP_ToReal || aff!=SQLITE_AFF_REAL );
- testcase( to_op==OP_ToText );
- testcase( to_op==OP_ToBlob );
- testcase( to_op==OP_ToNumeric );
- testcase( to_op==OP_ToInt );
- testcase( to_op==OP_ToReal );
if( inReg!=target ){
sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
inReg = target;
}
- sqlite3VdbeAddOp1(v, to_op, inReg);
+ sqlite3VdbeAddOp2(v, OP_Cast, target,
+ sqlite3AffinityType(pExpr->u.zToken, 0));
testcase( usedAsColumnCache(pParse, inReg, inReg) );
sqlite3ExprCacheAffinityChange(pParse, inReg, 1);
break;