aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2016-12-26 00:18:36 +0000
committerdrh <drh@noemail.net>2016-12-26 00:18:36 +0000
commita1a523a5bb3628a833065d43d8035cfa8249fc16 (patch)
tree3cfb1bbb766a3aad2a1727a87b0cf823b0805ea3 /src/expr.c
parentbeaf514e2300cfdaa2d606fc9f3b9cbe89afaefc (diff)
downloadsqlite-a1a523a5bb3628a833065d43d8035cfa8249fc16.tar.gz
sqlite-a1a523a5bb3628a833065d43d8035cfa8249fc16.zip
Add the built-in affinity() SQL function.
FossilOrigin-Name: 57e40e1cb1bcd3dd8473d2fdeecc9c7ff3d6192b
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c
index ecc6c7928..883273b3b 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3621,6 +3621,20 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);
}
+ /* The AFFINITY() function evaluates to a string that describes
+ ** the type affinity of the argument. This is used for testing of
+ ** the SQLite type logic.
+ */
+ if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){
+ const char *azAff[] = { "blob", "text", "numeric", "integer", "real" };
+ char aff;
+ assert( nFarg==1 );
+ aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
+ sqlite3VdbeLoadString(v, target,
+ aff ? azAff[aff-SQLITE_AFF_BLOB] : "none");
+ return target;
+ }
+
for(i=0; i<nFarg; i++){
if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
testcase( i==31 );