Changeset: b9c401194700 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b9c401194700
Modified Files:
        sql/backends/monet5/dict.c
Branch: default
Log Message:

Missing bat descriptor checks and look for gdk errors


diffs (84 lines):

diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c
--- a/sql/backends/monet5/dict.c
+++ b/sql/backends/monet5/dict.c
@@ -563,17 +563,20 @@ DICTjoin(Client cntxt, MalBlkPtr mb, Mal
        BAT *ro = BATdescriptor(RO);
        BAT *rv = BATdescriptor(RV);
 
-       if (!lo || !lv || !ro || !rv) {
+       if (!is_bat_nil(LC))
+               lc = BATdescriptor(LC);
+       if (!is_bat_nil(RC))
+               rc = BATdescriptor(RC);
+       if (!lo || !lv || !ro || !rv || (!is_bat_nil(LC) && !lc) || 
(!is_bat_nil(RC) && !rc)) {
                bat_destroy(lo);
                bat_destroy(lv);
                bat_destroy(ro);
                bat_destroy(rv);
+               bat_destroy(lc);
+               bat_destroy(rc);
                throw(SQL, "dict.join", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       if (!is_bat_nil(LC))
-               lc = BATdescriptor(LC);
-       if (!is_bat_nil(RC))
-               rc = BATdescriptor(RC);
+
        /* if both are the same, continue with join on indices */
        if (lv->batCacheid != rv->batCacheid) {
                /* first join values of the dicts */
@@ -636,13 +639,15 @@ DICTthetaselect(Client cntxt, MalBlkPtr 
        BAT *lo = BATdescriptor(LO);
        BAT *lv = BATdescriptor(LV);
 
-       if (!lo || !lv) {
+       if (!is_bat_nil(LC))
+               lc = BATdescriptor(LC);
+       if (!lo || !lv || (!is_bat_nil(LC) && !lc)) {
                bat_destroy(lo);
                bat_destroy(lv);
+               bat_destroy(lc);
                throw(SQL, "dict.thetaselect", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       if (!is_bat_nil(LC))
-               lc = BATdescriptor(LC);
+
        BUN max_cnt = lv->ttype == TYPE_bte?256:(64*1024);
        if ((lv->tkey && (op[0] == '=' || op[0] == '!')) || ((op[0] == '<' || 
op[0] == '>') && lv->tsorted && BATcount(lv) < (max_cnt/2))) {
                BUN p = BUN_NONE;
@@ -687,7 +692,7 @@ DICTthetaselect(Client cntxt, MalBlkPtr 
        bat_destroy(lv);
        bat_destroy(lc);
        if (!bn)
-               throw(SQL, "dict.thetaselect", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               throw(SQL, "dict.thetaselect", GDK_EXCEPTION);
        BBPkeepref(*R0 = bn->batCacheid);
        return MAL_SUCCEED;
 }
@@ -719,13 +724,14 @@ DICTselect(Client cntxt, MalBlkPtr mb, M
        BAT *lo = BATdescriptor(LO);
        BAT *lv = BATdescriptor(LV);
 
-       if (!lo || !lv) {
+       if (!is_bat_nil(LC))
+               lc = BATdescriptor(LC);
+       if (!lo || !lv || (!is_bat_nil(LC) && !lc)) {
                bat_destroy(lo);
                bat_destroy(lv);
+               bat_destroy(lc);
                throw(SQL, "dict.select", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       if (!is_bat_nil(LC))
-               lc = BATdescriptor(LC);
 
        if (ATOMvarsized(lv->ttype)) {
                l = *(ptr*)l;
@@ -789,7 +795,7 @@ DICTselect(Client cntxt, MalBlkPtr mb, M
        bat_destroy(lv);
        bat_destroy(lc);
        if (!bn)
-               throw(SQL, "dict.select", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               throw(SQL, "dict.select", GDK_EXCEPTION);
        BBPkeepref(*R0 = bn->batCacheid);
        return MAL_SUCCEED;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to