]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Added IFNULL and NVL functions. (CVS 401)
authordrh <drh@noemail.net>
Thu, 28 Feb 2002 00:46:26 +0000 (00:46 +0000)
committerdrh <drh@noemail.net>
Thu, 28 Feb 2002 00:46:26 +0000 (00:46 +0000)
FossilOrigin-Name: c6a85c8ee3d653a294bcc033ac6cab2b6de06f96

manifest
manifest.uuid
src/func.c

index 08cd03cf2eff5cee0cd0c714fee6ec4c4cf23505..cff3de8ab870ddbdf1fd83490b17b14cfbe1008a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Completely\sremove\sthe\sold\sSQL\sfunction\ssystem\sand\sreplace\sit\swith\sthe\nnew\suser\sfunctions.\s\sThe\scode\scurrently\scompiles\sbut\sit\scoredumps\son\sthe\ntest\ssuite.\s\sDo\snot\suse\sin\sits\spresent\sstate.\s(CVS\s400)
-D 2002-02-28T00:41:10
+C Added\sIFNULL\sand\sNVL\sfunctions.\s(CVS\s401)
+D 2002-02-28T00:46:26
 F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
 F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@@ -24,7 +24,7 @@ F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
 F src/build.c 7ada2426caba70cb1072ba268bedb694b5018065
 F src/delete.c 950d8f9097361419f1963875f9943344b469cf02
 F src/expr.c 32a2b5826b892a61e153df0ff5778e01d1ba9ad9
-F src/func.c 709784ce09c6156c52cbf860f6bcc7c2349d0b65
+F src/func.c 7bfb8a2068cc5e8bed64a3eaf8521448e05371cc
 F src/hash.c cc259475e358baaf299b00a2c7370f2b03dda892
 F src/hash.h dca065dda89d4575f3176e75e9a3dc0f4b4fb8b9
 F src/insert.c 164d2d5e943268a8ff0594e1947599e04df0ce11
@@ -127,7 +127,7 @@ F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5
 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
 F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P c4f9e017b449d4036fa8d2bf77b931d4c31d74f7
-R 8c438145064b7ce85d82d8ac4ca5e8e8
+P 50797fee5066ec9ea23b720e5ab7e8fc8ccc1988
+R ce3267187f04fb6cf19d5ce1ab432374
 U drh
-Z 324db426e1592b4f7c305e457c298b2e
+Z b311912d740a382c290a6410e1cb599f
index df3abacc50a974e19e9463a758726ab618e6a52c..09592c194d0608391e59af9d30dc648d56ab5be3 100644 (file)
@@ -1 +1 @@
-50797fee5066ec9ea23b720e5ab7e8fc8ccc1988
\ No newline at end of file
+c6a85c8ee3d653a294bcc033ac6cab2b6de06f96
\ No newline at end of file
index 0f49b549d8653723b2347d66e4133579158c0e2c..0916e480fc788ed3f5d51a34cc2921ccf239d650 100644 (file)
@@ -16,7 +16,7 @@
 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: func.c,v 1.6 2002/02/28 00:41:10 drh Exp $
+** $Id: func.c,v 1.7 2002/02/28 00:46:26 drh Exp $
 */
 #include <ctype.h>
 #include <math.h>
@@ -165,6 +165,18 @@ static void lowerFunc(sqlite_func *context, int argc, const char **argv){
   }
 }
 
+/*
+** Implementation of the IFNULL() and NVL() functions.  (both do the
+** same thing.  They return their first argument if it is not NULL or
+** their second argument if the first is NULL.
+*/
+static void ifnullFunc(sqlite_func *context, int argc, const char **argv){
+  const char *z;
+  assert( argc==2 );
+  z = argv[0] ? argv[0] : argv[1];
+  sqlite_set_result_string(context, z, -1);
+}
+
 /*
 ** An instance of the following structure holds the context of a
 ** sum() or avg() aggregate computation.
@@ -350,6 +362,8 @@ void sqliteRegisterBuildinFunctions(sqlite *db){
     { "round",  2, roundFunc  },
     { "upper",  1, upperFunc  },
     { "lower",  1, lowerFunc  },
+    { "ifnull", 2, ifnullFunc },
+    { "nvl",    2, ifnullFunc },
   };
   static struct {
     char *zName;