diff -uNr sqlite-3.4.1/src/func.c.orig sqlite-3.4.1/src/func.c --- sqlite-3.4.1/src/func.c.orig 2007-06-28 12:46:19.000000000 +0000 +++ sqlite-3.4.1/src/func.c 2007-07-23 11:39:52.000000000 +0000 @@ -150,6 +150,31 @@ } /* +** Implementation of the sign() function +*/ +static void signFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ + assert( argc==1 ); + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_INTEGER: { + i64 iVal = sqlite3_value_int64(argv[0]); + iVal = (iVal > 0)? 1 : (iVal < 0)? -1 : 0; + sqlite3_result_int64(context, iVal); + break; + } + case SQLITE_NULL: { + sqlite3_result_null(context); + break; + } + default: { + double rVal = sqlite3_value_double(argv[0]); + rVal = (rVal > 0)? 1.0 : (rVal < 0)? -1.0 : 0; + sqlite3_result_double(context, rVal); + break; + } + } +} + +/* ** Implementation of the substr() function. ** ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. @@ -1315,6 +1340,7 @@ FUNCTION(substr, 2, 0, 0, substrFunc ), FUNCTION(substr, 3, 0, 0, substrFunc ), FUNCTION(abs, 1, 0, 0, absFunc ), + FUNCTION(sign, 1, 0, 0, signFunc ), #ifndef SQLITE_OMIT_FLOATING_POINT FUNCTION(round, 1, 0, 0, roundFunc ), FUNCTION(round, 2, 0, 0, roundFunc ),