Changeset: 748161abcf1d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=748161abcf1d
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        sql/backends/monet5/sql.c
Branch: default
Log Message:

Merge with Jul2017 branch.


diffs (93 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1145,6 +1145,8 @@ BUNinplace(BAT *b, BUN p, const void *t,
        HASHdestroy(b);
        PROPdestroy(b->tprops);
        b->tprops = NULL;
+       OIDXdestroy(b);
+       IMPSdestroy(b);
        Treplacevalue(b, BUNtloc(bi, p), t);
 
        tt = b->ttype;
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1437,7 +1437,7 @@ BATsort(BAT **sorted, BAT **order, BAT *
        } else {
                pb = b;
        }
-       if (g == NULL && groups == NULL && o == NULL && !reverse &&
+       if (g == NULL && o == NULL && !reverse &&
            pb != NULL && BATcheckorderidx(pb) &&
            /* if we want a stable sort, the order index must be
             * stable, if we don't want stable, we don't care */
@@ -1453,12 +1453,28 @@ BATsort(BAT **sorted, BAT **order, BAT *
                on->tnonil = 1;
                on->tsorted = on->trevsorted = 0;
                on->tdense = 0;
-               if (sorted) {
+               if (sorted || groups) {
                        bn = BATproject(on, b);
                        if (bn == NULL)
                                goto error;
                        bn->tsorted = 1;
-                       *sorted = bn;
+                       if (groups) {
+                               if (BATgroup_internal(groups, NULL, NULL, bn, 
NULL, g, NULL, NULL, 1) != GDK_SUCCEED)
+                                       goto error;
+                               if (sorted &&
+                                   (*groups)->tkey &&
+                                   g == NULL) {
+                                       /* if new groups bat is key
+                                        * and since there is no input
+                                        * groups bat, we know the
+                                        * result bat is key */
+                                       bn->tkey = 1;
+                               }
+                       }
+                       if (sorted)
+                               *sorted = bn;
+                       else
+                               BBPunfix(bn->batCacheid);
                }
                if (order)
                        *order = on;
@@ -1475,6 +1491,7 @@ BATsort(BAT **sorted, BAT **order, BAT *
                        BBPunfix(bn->batCacheid);
                        bn = b;
                }
+               pb = NULL;
        } else {
                bn = COLcopy(b, b->ttype, TRUE, TRANSIENT);
        }
@@ -1615,8 +1632,13 @@ BATsort(BAT **sorted, BAT **order, BAT *
                             ords,
                             bn->tvheap ? bn->tvheap->base : NULL,
                             BATcount(bn), Tsize(bn), ords ? sizeof(oid) : 0,
-                            bn->ttype, reverse, stable) != GDK_SUCCEED))
+                            bn->ttype, reverse, stable) != GDK_SUCCEED)) {
+                       if (m != NULL) {
+                               HEAPfree(m, 1);
+                               GDKfree(m);
+                       }
                        goto error;
+               }
                bn->tsorted = !reverse;
                bn->trevsorted = reverse;
                if (m != NULL) {
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -66,9 +66,9 @@ rel_no_mitosis(sql_rel *rel)
 {
        int is_point = 0;
 
-       if (!rel)
+       if (!rel || is_basetable(rel->op))
                return 1;
-       if (is_project(rel->op))
+       if (is_topn(rel->op) || is_project(rel->op))
                return rel_no_mitosis(rel->l);
        if (is_modify(rel->op) && rel->card <= CARD_AGGR)
                return rel_no_mitosis(rel->r);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to