For queries of the form "SELECT p, max(q) FROM t1", the value of column p
returned is the one on the same row that holds the maximum value of q. FossilOrigin-Name: adb29232b659c5332b6841776372407fcc350b08
This commit is contained in:
+10
@@ -28,6 +28,14 @@ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
|
||||
return context->pColl;
|
||||
}
|
||||
|
||||
/*
|
||||
** Indicate that the accumulator load should be skipped on this
|
||||
** iteration of the aggregate loop.
|
||||
*/
|
||||
static void sqlite3SkipAccumulatorLoad(sqlite3_context *context){
|
||||
context->skipFlag = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the non-aggregate min() and max() functions
|
||||
*/
|
||||
@@ -1354,6 +1362,8 @@ static void minmaxStep(
|
||||
cmp = sqlite3MemCompare(pBest, pArg, pColl);
|
||||
if( (max && cmp<0) || (!max && cmp>0) ){
|
||||
sqlite3VdbeMemCopy(pBest, pArg);
|
||||
}else{
|
||||
sqlite3SkipAccumulatorLoad(context);
|
||||
}
|
||||
}else{
|
||||
sqlite3VdbeMemCopy(pBest, pArg);
|
||||
|
||||
Reference in New Issue
Block a user