diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 14 | ||||
-rw-r--r-- | src/func.c | 1 | ||||
-rw-r--r-- | src/sqliteInt.h | 1 |
3 files changed, 16 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 ); diff --git a/src/func.c b/src/func.c index 5b8ed6dd2..ec50d97af 100644 --- a/src/func.c +++ b/src/func.c @@ -1772,6 +1772,7 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION2(unlikely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), FUNCTION2(likely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), + FUNCTION2(affinity, 1, 0, 0, noopFunc, SQLITE_FUNC_AFFINITY), FUNCTION(ltrim, 1, 1, 0, trimFunc ), FUNCTION(ltrim, 2, 1, 0, trimFunc ), FUNCTION(rtrim, 1, 2, 0, trimFunc ), diff --git a/src/sqliteInt.h b/src/sqliteInt.h index d78d2072d..c4aaf3924 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1561,6 +1561,7 @@ struct FuncDestructor { #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a ** single query - might change over time */ +#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */ /* ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |