diff options
author | drh <drh@noemail.net> | 2012-02-02 18:42:09 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-02-02 18:42:09 +0000 |
commit | 94a6d998f6ce481f7d0a2ef2e1619cdef5ebb10e (patch) | |
tree | 5d037d2fdd13624db414897e18adb9db85c93057 /src/func.c | |
parent | 7a95789c0c21a39e8bd9972b92262c63a2ae820a (diff) | |
download | sqlite-94a6d998f6ce481f7d0a2ef2e1619cdef5ebb10e.tar.gz sqlite-94a6d998f6ce481f7d0a2ef2e1619cdef5ebb10e.zip |
Fix a problem with NULL handling in aggregate min/max when returning
values from the row containing the min or max.
FossilOrigin-Name: f27c7b4fb193126548e6a620ac89664d1efa3856
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/func.c b/src/func.c index deddd5375..b7d081068 100644 --- a/src/func.c +++ b/src/func.c @@ -1342,11 +1342,12 @@ static void minmaxStep( Mem *pBest; UNUSED_PARAMETER(NotUsed); - if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest)); if( !pBest ) return; - if( pBest->flags ){ + if( sqlite3_value_type(argv[0])==SQLITE_NULL ){ + if( pBest->flags ) sqlite3SkipAccumulatorLoad(context); + }else if( pBest->flags ){ int max; int cmp; CollSeq *pColl = sqlite3GetFuncCollSeq(context); @@ -1373,7 +1374,7 @@ static void minMaxFinalize(sqlite3_context *context){ sqlite3_value *pRes; pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0); if( pRes ){ - if( ALWAYS(pRes->flags) ){ + if( pRes->flags ){ sqlite3_result_value(context, pRes); } sqlite3VdbeMemRelease(pRes); |