]> git.pld-linux.org Git - packages/sqlite3.git/blame - sqlite3-sign-function.patch
- updated to 3.30.0
[packages/sqlite3.git] / sqlite3-sign-function.patch
CommitLineData
92da2924 1diff -uNr sqlite-3.4.1/src/func.c.orig sqlite-3.4.1/src/func.c
2--- sqlite-3.4.1/src/func.c.orig 2007-06-28 12:46:19.000000000 +0000
3+++ sqlite-3.4.1/src/func.c 2007-07-23 11:39:52.000000000 +0000
4@@ -150,6 +150,31 @@
b3a6c129
5 }
6
7 /*
8+** Implementation of the sign() function
9+*/
10+static void signFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
11+ assert( argc==1 );
12+ switch( sqlite3_value_type(argv[0]) ){
13+ case SQLITE_INTEGER: {
14+ i64 iVal = sqlite3_value_int64(argv[0]);
15+ iVal = (iVal > 0)? 1 : (iVal < 0)? -1 : 0;
16+ sqlite3_result_int64(context, iVal);
17+ break;
18+ }
19+ case SQLITE_NULL: {
20+ sqlite3_result_null(context);
21+ break;
22+ }
23+ default: {
24+ double rVal = sqlite3_value_double(argv[0]);
25+ rVal = (rVal > 0)? 1.0 : (rVal < 0)? -1.0 : 0;
26+ sqlite3_result_double(context, rVal);
27+ break;
28+ }
29+ }
30+}
31+
32+/*
92da2924 33 ** Implementation of the substr() function.
34 **
35 ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1.
36@@ -1315,6 +1340,7 @@
2eb1953b
AG
37 FUNCTION(substr, 2, 0, 0, substrFunc ),
38 FUNCTION(substr, 3, 0, 0, substrFunc ),
39 FUNCTION(abs, 1, 0, 0, absFunc ),
40+ FUNCTION(sign, 1, 0, 0, signFunc ),
41ecedce 41 #ifndef SQLITE_OMIT_FLOATING_POINT
2eb1953b
AG
42 FUNCTION(round, 1, 0, 0, roundFunc ),
43 FUNCTION(round, 2, 0, 0, roundFunc ),
This page took 0.072172 seconds and 4 git commands to generate.