Changeset: b75fdf8fd164 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b75fdf8fd164
Modified Files:
        gdk/gdk_select.c
Branch: Oct2014
Log Message:

Extra protection in virtualizing subselect results.


diffs (28 lines):

diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -54,15 +54,20 @@ virtualize(BAT *bn)
        /* since bn has unique and strictly ascending tail values, we
         * can easily check whether the tail is dense */
        if (bn && !BATtdense(bn) &&
-           * (const oid *) Tloc(bn, BUNfirst(bn)) + BATcount(bn) - 1 ==
-           * (const oid *) Tloc(bn, BUNlast(bn) - 1)) {
+           (BATcount(bn) == 0 ||
+            * (const oid *) Tloc(bn, BUNfirst(bn)) + BATcount(bn) - 1 ==
+            * (const oid *) Tloc(bn, BUNlast(bn) - 1))) {
                /* tail is dense, replace by virtual oid */
                ALGODEBUG fprintf(stderr, 
"#virtualize(bn=%s#"BUNFMT",seq="OIDFMT")\n",
                                  BATgetId(bn), BATcount(bn),
                                  * (const oid *) Tloc(bn, BUNfirst(bn)));
-               bn->tseqbase = * (const oid *) Tloc(bn, BUNfirst(bn));
+               if (BATcount(bn) == 0)
+                       bn->tseqbase = 0;
+               else
+                       bn->tseqbase = * (const oid *) Tloc(bn, BUNfirst(bn));
                bn->tdense = 1;
-               HEAPfree(&bn->T->heap);
+               if (bn->ttype == TYPE_oid)
+                       HEAPfree(&bn->T->heap);
                bn->ttype = TYPE_void;
                bn->tvarsized = 1;
                bn->T->width = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to