1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-24 09:53:10 +03:00

min() ignores NULL values. Ticket #800. (CVS 1802)

FossilOrigin-Name: 166234a2b61e1d6a501e48dde1caec0a02bec90b
This commit is contained in:
drh
2004-07-18 20:52:32 +00:00
parent e29b1a05a7
commit 9eb516c0eb
9 changed files with 97 additions and 34 deletions

View File

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.77 2004/06/28 13:09:11 danielk1977 Exp $
** $Id: func.c,v 1.78 2004/07/18 20:52:32 drh Exp $
*/
#include <ctype.h>
#include <math.h>
@@ -979,13 +979,16 @@ struct MinMaxCtx {
** Routines to implement min() and max() aggregate functions.
*/
static void minmaxStep(sqlite3_context *context, int argc, sqlite3_value **argv){
int max = 0;
int cmp = 0;
Mem *pArg = (Mem *)argv[0];
Mem *pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
Mem *pBest;
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
if( !pBest ) return;
if( pBest->flags ){
int max;
int cmp;
CollSeq *pColl = sqlite3GetFuncCollSeq(context);
/* This step function is used for both the min() and max() aggregates,
** the only difference between the two being that the sense of the