diff options
author | drh <drh@noemail.net> | 2009-12-08 02:06:08 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2009-12-08 02:06:08 +0000 |
commit | 2ba3cccf226e38d4fcaf293ce09c9b5f121aa6a3 (patch) | |
tree | 8730ea4af8fc006462814e002077934d1a51c1dd /src/func.c | |
parent | 9286c07daaaabdc8ea72c69b9a54107950f6df59 (diff) | |
download | sqlite-2ba3cccf226e38d4fcaf293ce09c9b5f121aa6a3.tar.gz sqlite-2ba3cccf226e38d4fcaf293ce09c9b5f121aa6a3.zip |
Add evidence marks for the abs() and soundex() SQL functions.
FossilOrigin-Name: 003f3ed10cdb64b73d6df00e28260dd3491e1f16
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/func.c b/src/func.c index 8cb7a037c..3227dca3f 100644 --- a/src/func.c +++ b/src/func.c @@ -117,7 +117,10 @@ static void lengthFunc( } /* -** Implementation of the abs() function +** Implementation of the abs() function. +** +** IMP: R-23979-26855 The abs(X) function returns the absolute value of +** the numeric argument X. */ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ assert( argc==1 ); @@ -127,6 +130,9 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ i64 iVal = sqlite3_value_int64(argv[0]); if( iVal<0 ){ if( (iVal<<1)==0 ){ + /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then + ** abs(X) throws an integer overflow error since there is no + ** equivalent positive 64-bit two complement value. */ sqlite3_result_error(context, "integer overflow", -1); return; } @@ -136,10 +142,16 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ break; } case SQLITE_NULL: { + /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */ sqlite3_result_null(context); break; } default: { + /* Because sqlite3_value_double() returns 0.0 if the argument is not + ** something that can be converted into a number, we have: + ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that + ** cannot be converted to a numeric value. + */ double rVal = sqlite3_value_double(argv[0]); if( rVal<0 ) rVal = -rVal; sqlite3_result_double(context, rVal); @@ -1041,9 +1053,16 @@ static void trimFunc( } +/* IMP: R-25361-16150 This function is omitted from SQLite by default. It +** is only available if the SQLITE_SOUNDEX compile-time option is used +** when SQLite is built. +*/ #ifdef SQLITE_SOUNDEX /* ** Compute the soundex encoding of a word. +** +** IMP: R-59782-00072 The soundex(X) function returns a string that is the +** soundex encoding of the string X. */ static void soundexFunc( sqlite3_context *context, @@ -1087,10 +1106,12 @@ static void soundexFunc( zResult[j] = 0; sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT); }else{ + /* IMP: R-64894-50321 The string "?000" is returned if the argument + ** is NULL or contains no ASCII alphabetic characters. */ sqlite3_result_text(context, "?000", 4, SQLITE_STATIC); } } -#endif +#endif /* SQLITE_SOUNDEX */ #ifndef SQLITE_OMIT_LOAD_EXTENSION /* |