Changeset: 5a2c6a344a0c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5a2c6a344a0c
Modified Files:
        gdk/gdk_firstn.c
        monetdb5/modules/kernel/algebra.c
Branch: default
Log Message:

If N(comes from limit) >= cnt, lastp is setted to BUN cnt - 1 and not 0.


diffs (27 lines):

diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c
--- a/gdk/gdk_firstn.c
+++ b/gdk/gdk_firstn.c
@@ -227,9 +227,9 @@ BATfirstn_unique(BATiter *bi, BAT *s, BU
 
        if (n >= cnt) {
                /* trivial: return all candidates */
-               if (lastp)
-                       *lastp = 0;
                bn = canditer_slice(&ci, 0, ci.ncand);
+               if (bn && lastp)
+                       *lastp = BUNtoid(bn, cnt - 1);
                TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
                          ",n=" BUNFMT " -> " ALGOOPTBATFMT
                          " (trivial -- " LLFMT " usec)\n",
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -683,7 +683,7 @@ ALGfirstn(Client cntxt, MalBlkPtr mb, Ma
        bat *ret1, *ret2 = NULL;
        bat bid, sid, gid;
        BAT *b, *s = NULL, *g = NULL;
-       BAT *bn, *gn;
+       BAT *bn = NULL, *gn = NULL;
        lng n;
        bit asc, nilslast, distinct;
        gdk_return rc;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to