diff options
author | drh <drh@noemail.net> | 2005-09-08 20:37:43 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2005-09-08 20:37:43 +0000 |
commit | c2bd913a408e919441a3987c7b0b4b0e54d2057d (patch) | |
tree | 237227489802832daf50f948f48c1c66eb787054 /src/func.c | |
parent | 3f219f46fc370746c600b7b862f35d75dad236cd (diff) | |
download | sqlite-c2bd913a408e919441a3987c7b0b4b0e54d2057d.tar.gz sqlite-c2bd913a408e919441a3987c7b0b4b0e54d2057d.zip |
SUM returns NULL when it has no inputs. Ticket #1413. (CVS 2678)
FossilOrigin-Name: 6281859425d39c11d82875301fefafad1f08416d
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/func.c b/src/func.c index 7d0a73c15..ed9133c35 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.109 2005/09/08 19:45:58 drh Exp $ +** $Id: func.c,v 1.110 2005/09/08 20:37:43 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -842,12 +842,12 @@ static void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){ static void sumFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); - if( p==0 ){ - sqlite3_result_int(context, 0); - }else if( p->seenFloat ){ - sqlite3_result_double(context, p->sum); - }else if( p->cnt>0 ){ - sqlite3_result_int64(context, (i64)p->sum); + if( p && p->cnt>0 ){ + if( p->seenFloat ){ + sqlite3_result_double(context, p->sum); + }else{ + sqlite3_result_int64(context, (i64)p->sum); + } } } static void avgFinalize(sqlite3_context *context){ |